Skip to content

Commit

Permalink
Support JEP 378 Text Blocks in Java [Closes #1687]
Browse files Browse the repository at this point in the history
  • Loading branch information
fprochazka committed Sep 2, 2022
1 parent 4c97072 commit 990a7d2
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/rouge/lexers/java.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class Java < RegexLexer
rule %r/(?:true|false|null)\b/, Keyword::Constant
rule %r/(?:class|interface)\b/, Keyword::Declaration, :class
rule %r/(?:import|package)\b/, Keyword::Namespace, :import
rule %r/"""\s*\n.*?(?<!\\)"""/m, Str::Heredoc
rule %r/"(\\\\|\\"|[^"])*"/, Str
rule %r/'(?:\\.|[^\\]|\\u[0-9a-f]{4})'/, Str::Char
rule %r/(\.)(#{id})/ do
Expand Down
41 changes: 41 additions & 0 deletions spec/visual/samples/java
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,47 @@ public class PlatformManagerImpl implements PlatformManager
//T: PlatformManagerCapabilities
private final HashSet capabilitySet = new HashSet();

private static final String exampleTextBlock = """
<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
<soap-env:Body>
<p>Hello, world</p>
</soap-env:Body>
</soap-env:Envelope>
""";

private static final String emptyTextBlock = """
""";

private static final String withoutFinalNewlineTextBlock = """
line 1
line 2""";

private static final String quotesEscapingTextBlock = """
String text = \"""
A text block inside a text block
\""";
""";

private static final String quotesEscaping2TextBlock = """
The empty string literal
is formed from " characters
as follows: \"\"""";

private static final String quotesEscaping3TextBlock = """
1 "
2 ""
3 ""\"
4 ""\""
5 ""\"""
6 ""\"""\"
7 ""\"""\""
8 ""\"""\"""
9 ""\"""\"""\"
10 ""\"""\"""\""
11 ""\"""\"""\"""
12 ""\"""\"""\"""\"
""";

/**
* Gets the platform manager singleton, which was already initialized
*/
Expand Down

0 comments on commit 990a7d2

Please sign in to comment.