junit5 icon indicating copy to clipboard operation
junit5 copied to clipboard

User guide highlights Java and Kotlin code wrong

Open rillig opened this issue 2 years ago • 10 comments

Steps to reproduce

Look at the rendered user guide (either the HTML or the PDF version):

  • In the Kotlin test name exception absence testing, the middle word has a different color than the outer words, even though the words are part of the same identifier.
  • In the Java tests, import static org.junit is highlighted inconsistently. The word static is highlighed like other class names, the words org and junit are colored differently.

On a related note, the highlighting colors in the HTML and PDF versions differ unnecessarily.

rillig avatar May 06 '23 15:05 rillig

We just merged #3267 to improve the accessibility of the web version of the User Guide. To which version of the User Guide are you referring?

marcphilipp avatar May 06 '23 15:05 marcphilipp

That's in current: https://junit.org/junit5/docs/current/user-guide/#writing-tests-assertions-kotlin

It's due to the syntax highlighter which doesn't know how to parse Kotlin's backtick method names.

The same issue can be seen in snapshot: https://junit.org/junit5/docs/snapshot/user-guide/#writing-tests-assertions-kotlin

sbrannen avatar May 06 '23 15:05 sbrannen

As far as I understand it, this is out of our control.

Rather, it's an issue with Asciidoc (or perhaps more specifically with the Rouge syntax highlighting feature).

sbrannen avatar May 06 '23 15:05 sbrannen

  • In the Java tests, import static org.junit is highlighted inconsistently. The word static is highlighed like other class names, the words org and junit are colored differently.

Similar to what I stated above about Kotlin backtick quoted method names, the syntax highlighter does not know how to properly parse static imports in Java source code.

sbrannen avatar May 06 '23 15:05 sbrannen

Another one: double quotes in Java text blocks. For example, "lemon lime" is highlighted in the wrong color.

rillig avatar May 06 '23 18:05 rillig

All of the issues you have reported are due to deficiencies in the Java lexer in the Rouge project.

Thus, the JUnit team cannot address them.

However, the JUnit team could consider switching to the CodeRay or Pygments syntax highlighters which are also supported by Asciidoc.

But if we switch the syntax highlighter, that would revert the accessibility changes made in conjunction with #3071.

In light of that, I think the best course of action is to raise issue's with the Rouge project.

@junit-team/junit-5, thoughts?

sbrannen avatar May 07 '23 13:05 sbrannen

In the Kotlin test name exception absence testing, the middle word has a different color than the outer words, even though the words are part of the same identifier.

This has already been reported in https://github.com/rouge-ruby/rouge/issues/1921.

sbrannen avatar May 07 '23 13:05 sbrannen

@rillig, I have reported your findings to the Rouge team here:

  • https://github.com/rouge-ruby/rouge/issues/1956
  • https://github.com/rouge-ruby/rouge/issues/1957

sbrannen avatar May 07 '23 14:05 sbrannen

I also raised the following issue which should address support for several missing keywords.

  • https://github.com/rouge-ruby/rouge/issues/1958

sbrannen avatar May 07 '23 14:05 sbrannen

Let's see if anybody from the Twittersphere can help...

https://twitter.com/sam_brannen/status/1655216258604838916

sbrannen avatar May 07 '23 14:05 sbrannen