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

Groovy import statement renders with red spaces on GitHub #17

Open
coder451 opened this issue Mar 26, 2018 · 4 comments
Open

Groovy import statement renders with red spaces on GitHub #17

coder451 opened this issue Mar 26, 2018 · 4 comments

Comments

@coder451
Copy link

coder451 commented Mar 26, 2018

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.

@infininight
Copy link
Member

infininight commented Mar 27, 2018

OK, some of these are very simple issues. The import rule is too strict about not allowing trailing whitespace and comments. But splitting the import rule into two lines and the trailing (1) I do not see these mentioned anywhere in the Groovy documentation at first glance. Are you aware of any proper language spec for groovy that's available? Not finding any good documentation on the syntax of the various statements, allowed characters, etc.

(And yes you are correct about the file used for the highlighting, it is a set of nested regular expression rules that match the various parts of the document.)

@coder451
Copy link
Author

The only part of this Issue that matters is being able to place a comment after an import without needing a semicolon to make it legal. After I looked in the language file and found that it had begin/end patterns, it occurred to me that forcing the formatter to use those patterns by splitting lines might provide additional clues. But the compiler says that splitting an import line is not legal, so the only issue around that for the formatter is what it complains about. The issue should be the line feed, not the spaces or dots on the second of the two lines.

I have looked for a Groovy language specification in the past, without success.

@metagn
Copy link

metagn commented Apr 14, 2018

On top of that, import as statements break too. import a.b.c.X as Y shows red spaces between X, as and Y and doesn't highlight as

@alisonatwork
Copy link

@infininight unfortunately it seems there is no formal language spec for Groovy, which is a bit annoying because there are some frequently-used features like quoted function names that aren't clearly documented (see #11 and Spock Framework examples).

I have found the following pages, which help a bit, though:

On the Style Guide page they describe "no semicolons" and "import aliasing", both of which are relevant to this ticket.

Is there any chance we can get some of the open PRs or forks that are running a bit ahead of this one merged here? This is the project GitHub is using as its syntax highlighter, so it would be nice to fix any smaller issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants