Skip to content

Groovy import statement renders with red spaces on GitHub #17

@coder451

Description

@coder451

See this repository for an example.
This shows an import statement with a following callout.
Any space between the end of the import statement is rendered as a red block.
Adding a semicolon at the end of the import statement works around the problem.
The HTML generated by Asciidoctor on my own installation is:

<pre class="highlight"><code class="language-groovy" data-lang="groovy">import x <b class="conum">(1)</b></code></pre>

The HTML generated on GitHub for the line is

<div class="highlight highlight-source-groovy"><pre><span class="pl-k">import</span> <span class="pl-smi">x<span class="pl-ii"> </span>(1)</span></pre></div>

The problem seems to be this:

<span class="pl-ii"> </span>(1)

The pl-ii is a GitHub light CSS style:

.pl-ii /* invalid.illegal */ {
  color: #fafbfc;
  background-color: #b31d28;
}

So the syntax in my example is considered incorrect.
I added some other formatting possibilities to my example as well.
For example, splitting the import across two statements.
These examples show that the problem happens with a trailing comment on an import line.
One of them suggests that splitting an import over two lines is not well handled either.

I guessed that this file was probably used to do the formatting, and some patterns that look like they would match do include some formatting for illegal characters.
But I wasn't able to pin down exactly what was going wrong.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions