diff --git a/lexers/embedded/properties.xml b/lexers/embedded/properties.xml index 0bb4c4605..d5ae0a283 100644 --- a/lexers/embedded/properties.xml +++ b/lexers/embedded/properties.xml @@ -7,14 +7,15 @@ - - - - - + + + + + - + + @@ -22,6 +23,23 @@ + + + + + + + + + + + + + + + + + - \ No newline at end of file + diff --git a/lexers/testdata/properties.actual b/lexers/testdata/properties.actual index 823a6bc8d..9b5f36dc9 100644 --- a/lexers/testdata/properties.actual +++ b/lexers/testdata/properties.actual @@ -8,10 +8,19 @@ language : English # This means that the following are equivalent (other than for readability). hello=hello hello = hello +topic .properties files +# A word on a line will just create a key with no value. +empty # Keys with the same name will be overwritten by the key that is the furthest in a file. # 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. @@ -20,3 +29,7 @@ valueWithEscapes = This is a newline\n and a carriage return\r and a tab\t. encodedHelloInJapanese = \u3053\u3093\u306b\u3061\u306f # But with more modern file encodings like UTF-8, you can directly use supported characters. helloInJapanese = こんにちは + # Comments and keys can have leading whitespace + foo = I have leading whitespace +# Comments and keys can have trailing whitespace as part of the comment +bar = I have trailing whitespace as part of the value diff --git a/lexers/testdata/properties.expected b/lexers/testdata/properties.expected index c5081c110..79c26d7e5 100644 --- a/lexers/testdata/properties.expected +++ b/lexers/testdata/properties.expected @@ -33,6 +33,14 @@ {"type":"Text","value":" "}, {"type":"LiteralString","value":"hello"}, {"type":"Text","value":"\n"}, + {"type":"NameAttribute","value":"topic"}, + {"type":"Text","value":" "}, + {"type":"LiteralString","value":".properties files"}, + {"type":"Text","value":"\n"}, + {"type":"CommentSingle","value":"# A word on a line will just create a key with no value."}, + {"type":"Text","value":"\n"}, + {"type":"NameAttribute","value":"empty"}, + {"type":"Text","value":"\n"}, {"type":"CommentSingle","value":"# Keys with the same name will be overwritten by the key that is the furthest in a file."}, {"type":"Text","value":"\n"}, {"type":"CommentSingle","value":"# For example the final value for \"duplicateKey\" will be \"second\"."}, @@ -49,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."}, @@ -76,5 +97,21 @@ {"type":"Operator","value":"="}, {"type":"Text","value":" "}, {"type":"LiteralString","value":"こんにちは"}, + {"type":"Text","value":"\n "}, + {"type":"CommentSingle","value":"# Comments and keys can have leading whitespace"}, + {"type":"Text","value":"\n "}, + {"type":"NameAttribute","value":"foo"}, + {"type":"Text","value":" "}, + {"type":"Operator","value":"="}, + {"type":"Text","value":" "}, + {"type":"LiteralString","value":"I have leading whitespace"}, + {"type":"Text","value":"\n"}, + {"type":"CommentSingle","value":"# Comments and keys can have trailing whitespace as part of the comment "}, + {"type":"Text","value":"\n"}, + {"type":"NameAttribute","value":"bar"}, + {"type":"Text","value":" "}, + {"type":"Operator","value":"="}, + {"type":"Text","value":" "}, + {"type":"LiteralString","value":"I have trailing whitespace as part of the value "}, {"type":"Text","value":"\n"} ]