From f02fe74d53bc8428aa030db8eb0f9838c4d6302c Mon Sep 17 00:00:00 2001 From: Martin Winandy Date: Sat, 3 Sep 2022 08:21:09 +0200 Subject: [PATCH 1/5] Support entries with whitespace delimiter --- lexers/embedded/properties.xml | 13 ++++++++++--- lexers/testdata/properties.actual | 1 + lexers/testdata/properties.expected | 4 ++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/lexers/embedded/properties.xml b/lexers/embedded/properties.xml index 0bb4c4605..ba46d8d64 100644 --- a/lexers/embedded/properties.xml +++ b/lexers/embedded/properties.xml @@ -10,10 +10,10 @@ - + - + @@ -22,6 +22,13 @@ + + + + + + + - \ No newline at end of file + diff --git a/lexers/testdata/properties.actual b/lexers/testdata/properties.actual index 823a6bc8d..2ea9841c2 100644 --- a/lexers/testdata/properties.actual +++ b/lexers/testdata/properties.actual @@ -8,6 +8,7 @@ language : English # This means that the following are equivalent (other than for readability). hello=hello hello = hello +topic .properties files # 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 diff --git a/lexers/testdata/properties.expected b/lexers/testdata/properties.expected index c5081c110..34f230bab 100644 --- a/lexers/testdata/properties.expected +++ b/lexers/testdata/properties.expected @@ -33,6 +33,10 @@ {"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":"# 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\"."}, From a46ea59279d602834eb06f9e5a4da45e8e8e59b7 Mon Sep 17 00:00:00 2001 From: Martin Winandy Date: Sat, 3 Sep 2022 08:41:21 +0200 Subject: [PATCH 2/5] Support key only entries without values --- lexers/embedded/properties.xml | 7 ++++++- lexers/testdata/properties.actual | 2 ++ lexers/testdata/properties.expected | 4 ++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lexers/embedded/properties.xml b/lexers/embedded/properties.xml index ba46d8d64..215f0903d 100644 --- a/lexers/embedded/properties.xml +++ b/lexers/embedded/properties.xml @@ -10,7 +10,7 @@ - + @@ -29,6 +29,11 @@ + + + + + diff --git a/lexers/testdata/properties.actual b/lexers/testdata/properties.actual index 2ea9841c2..1cfa4a802 100644 --- a/lexers/testdata/properties.actual +++ b/lexers/testdata/properties.actual @@ -9,6 +9,8 @@ language : English 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 diff --git a/lexers/testdata/properties.expected b/lexers/testdata/properties.expected index 34f230bab..6a7f43efa 100644 --- a/lexers/testdata/properties.expected +++ b/lexers/testdata/properties.expected @@ -37,6 +37,10 @@ {"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\"."}, From 27073556fa2d7ff7eee1727ae0f8722334a07012 Mon Sep 17 00:00:00 2001 From: Martin Winandy Date: Sat, 3 Sep 2022 08:58:49 +0200 Subject: [PATCH 3/5] Support leading and trailing whitespace --- lexers/embedded/properties.xml | 22 ++++++++++++++-------- lexers/testdata/properties.actual | 4 ++++ lexers/testdata/properties.expected | 16 ++++++++++++++++ 3 files changed, 34 insertions(+), 8 deletions(-) diff --git a/lexers/embedded/properties.xml b/lexers/embedded/properties.xml index 215f0903d..d3acb2cd2 100644 --- a/lexers/embedded/properties.xml +++ b/lexers/embedded/properties.xml @@ -7,14 +7,15 @@ - - - - - + + + + + - + + @@ -22,18 +23,23 @@ - + + - + + + + + diff --git a/lexers/testdata/properties.actual b/lexers/testdata/properties.actual index 1cfa4a802..fb71257a3 100644 --- a/lexers/testdata/properties.actual +++ b/lexers/testdata/properties.actual @@ -23,3 +23,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 6a7f43efa..e947db0a4 100644 --- a/lexers/testdata/properties.expected +++ b/lexers/testdata/properties.expected @@ -84,5 +84,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"} ] From dedfca6b3597ea6d2208ad577dae6858176b26dd Mon Sep 17 00:00:00 2001 From: Martin Winandy Date: Sat, 3 Sep 2022 09:11:49 +0200 Subject: [PATCH 4/5] Keys must not contain whitespace --- lexers/embedded/properties.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lexers/embedded/properties.xml b/lexers/embedded/properties.xml index d3acb2cd2..5c84e026c 100644 --- a/lexers/embedded/properties.xml +++ b/lexers/embedded/properties.xml @@ -13,7 +13,7 @@ - + @@ -23,7 +23,7 @@ - + From d260c5826fd19b17c72d9d5f9ac560cfc426e679 Mon Sep 17 00:00:00 2001 From: Martin Winandy Date: Sat, 3 Sep 2022 11:17:52 +0200 Subject: [PATCH 5/5] Support multiline values --- lexers/embedded/properties.xml | 6 +++--- lexers/testdata/properties.actual | 6 ++++++ lexers/testdata/properties.expected | 13 +++++++++++++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/lexers/embedded/properties.xml b/lexers/embedded/properties.xml index 5c84e026c..d5ae0a283 100644 --- a/lexers/embedded/properties.xml +++ b/lexers/embedded/properties.xml @@ -13,7 +13,7 @@ - + @@ -23,7 +23,7 @@ - + @@ -37,7 +37,7 @@ - + diff --git a/lexers/testdata/properties.actual b/lexers/testdata/properties.actual index fb71257a3..9b5f36dc9 100644 --- a/lexers/testdata/properties.actual +++ b/lexers/testdata/properties.actual @@ -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. diff --git a/lexers/testdata/properties.expected b/lexers/testdata/properties.expected index e947db0a4..79c26d7e5 100644 --- a/lexers/testdata/properties.expected +++ b/lexers/testdata/properties.expected @@ -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."},