rouge
rouge copied to clipboard
Html highlighting of GraphQL query presents error when a value is zero.
Describe the bug Not sure if this is an actual bug or if it has been reported before.
The highlight of GraphQL query will show as error when a value is zero. It will show the zero as <span class="err">0</span>
See screenshot below.
If value is quoted, the generated html is <span class="s2">"0"</span>, if value is 1(integer, no quotes), html is <span class="mi">1</span>
To Reproduce Steps to reproduce the behavior:
Generate an html output of a GraphQl query that has a parameter with value 0.
Example query (save as query.example):
mutation DoSomething__some_thing__0 {
DoSomething(
input: {
someID: "ABC1234",
someTotal: {
currencyCode: "USD",
value: 0
}
}
) {
blah {
id
partnerBlahID
token
emailContact {
emailAddress
ownerType
}
refunds {
chargeTotal {
value
currency {
isoCode
}
}
}
}
isSuccessful
failureCategory
errors {
message {
localized {
text
}
}
}
}
}
Execute the steps below:
rougify style monokai > monokai_style.css
OUTPUT_FILE="output.html"
HIGHLIGHTED_FILE="highlighted_code.html"
rougify highlight query.example --lexer graphql -t monokai -f html > "$HIGHLIGHTED_FILE"
cat <<EOF > "$OUTPUT_FILE"
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>GraphQL Syntax Highlighting</title>
<link rel="stylesheet" href="monokai_style.css" />
</head>
<body>
<h1>GraphQL Query</h1>
<pre class="highlight">
<code>
<!-- Insert the highlighted GraphQL code -->
$(cat "$HIGHLIGHTED_FILE")
</code>
</pre>
</body>
</html>
EOF
Expected behavior Same syntax highlight even if value is zero.
Screenshots Adde above.
System (please complete the following information):
- OS: Macos Sequoia 15.1.1
- ruby 3.1.6p260 (2024-05-29 revision a777087be6) [x86_64-darwin24]
- rouge (4.5.1)