Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Html highlighting of GraphQL query presents error when a value is zero. #2088

Open
raivil opened this issue Nov 25, 2024 · 0 comments
Open
Labels
bugfix-request A request for a bugfix to be developed.

Comments

@raivil
Copy link

raivil commented Nov 25, 2024

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.
Screenshot 2024-11-25 at 15 36 53

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)
@raivil raivil added the bugfix-request A request for a bugfix to be developed. label Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix-request A request for a bugfix to be developed.
Projects
None yet
Development

No branches or pull requests

1 participant