Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Support multiline values
  • Loading branch information
pmwmedia committed Sep 3, 2022
commit d260c5826fd19b17c72d9d5f9ac560cfc426e679
6 changes: 3 additions & 3 deletions lexers/embedded/properties.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<token type="CommentSingle"/>
</bygroups>
</rule>
<rule pattern="^([ \t\f]*)(\S+?)([ \t\f]*)([=:])([ \t\f]*)(.*)">
<rule pattern="^([ \t\f]*)(\S+?)([ \t\f]*)([=:])([ \t\f]*)(.*(?:(?&lt;=\\)\n.*)*)">
<bygroups>
<token type="Text"/>
<token type="NameAttribute"/>
Expand All @@ -23,7 +23,7 @@
<token type="LiteralString"/>
</bygroups>
</rule>
<rule pattern="^([ \t\f]*)(\S+)([ \t\f]+)(.*)">
<rule pattern="^([ \t\f]*)(\S+)([ \t\f]+)(.*(?:(?&lt;=\\)\n.*)*)">
<bygroups>
<token type="Text"/>
<token type="NameAttribute"/>
Expand All @@ -37,7 +37,7 @@
<token type="NameAttribute"/>
</bygroups>
</rule>
<rule pattern="[\n\r]*">
<rule pattern="\n">
<token type="Text"/>
</rule>
</state>
Expand Down
6 changes: 6 additions & 0 deletions lexers/testdata/properties.actual
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ empty
# For example the final value for "duplicateKey" will be "second".
duplicateKey = first
duplicateKey = second
# Adding a \ at the end of a line means that the value continues to the next line.
towLines = This line \
continues
threeLines: This value \
has even \
three lines
# If you need to add newlines and carriage returns, they need to be escaped using \n and \r respectively.
# You can also optionally escape tabs with \t for readability purposes.
valueWithEscapes = This is a newline\n and a carriage return\r and a tab\t.
Expand Down
13 changes: 13 additions & 0 deletions lexers/testdata/properties.expected
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,19 @@
{"type":"Text","value":" "},
{"type":"LiteralString","value":"second"},
{"type":"Text","value":"\n"},
{"type":"CommentSingle","value":"# Adding a \\ at the end of a line means that the value continues to the next line."},
{"type":"Text","value":"\n"},
{"type":"NameAttribute","value":"towLines"},
{"type":"Text","value":" "},
{"type":"Operator","value":"="},
{"type":"Text","value":" "},
{"type":"LiteralString","value":"This line \\\n continues"},
{"type":"Text","value":"\n"},
{"type":"NameAttribute","value":"threeLines"},
{"type":"Operator","value":":"},
{"type":"Text","value":" "},
{"type":"LiteralString","value":"This value \\\n has even \\\n three lines"},
{"type":"Text","value":"\n"},
{"type":"CommentSingle","value":"# If you need to add newlines and carriage returns, they need to be escaped using \\n and \\r respectively."},
{"type":"Text","value":"\n"},
{"type":"CommentSingle","value":"# You can also optionally escape tabs with \\t for readability purposes."},
Expand Down