From e5c25d045eee3e0feaad88e69eb893b4844a5260 Mon Sep 17 00:00:00 2001 From: Gusted Date: Mon, 1 Apr 2024 23:40:43 +0200 Subject: [PATCH] Org: Keep all newlines (#951) - Move the `*` operator to inside the capturing group so all characters that match `\s` is preserved and not just the first character. - Add tests. - Resolves https://github.com/alecthomas/chroma/issues/845
Input ```orgmode Generic text. /Italicized/ *strong* =Heading= ~Codeblock~ +StrikeTrough+ _Underlined_ ```
## Before ![Screen Shot 2024-04-01 at 23 26 15](https://github.com/alecthomas/chroma/assets/25481501/0ddc4b34-c434-4798-9b2a-0773b2be4f05) ## After ![Screen Shot 2024-04-01 at 23 25 52](https://github.com/alecthomas/chroma/assets/25481501/ad46591d-8d3c-421e-8564-d3d36abe6fa1) --- lexers/embedded/org_mode.xml | 12 ++++++------ lexers/testdata/org.actual | 14 ++++++++++++++ lexers/testdata/org.expected | 15 +++++++++++++-- 3 files changed, 33 insertions(+), 8 deletions(-) diff --git a/lexers/embedded/org_mode.xml b/lexers/embedded/org_mode.xml index 3f227ad8d..259e54ef5 100644 --- a/lexers/embedded/org_mode.xml +++ b/lexers/embedded/org_mode.xml @@ -228,42 +228,42 @@ - + - + - + - + - + - + diff --git a/lexers/testdata/org.actual b/lexers/testdata/org.actual index 0a1ecbd58..b8c177b16 100644 --- a/lexers/testdata/org.actual +++ b/lexers/testdata/org.actual @@ -143,3 +143,17 @@ manual/Footnotes.html][page for footnotes]]. # Local Variables: # org-link-file-path-type: relative # End: + +Generic text. + +/Italicized/ + +*strong* + +=Heading= + +~Codeblock~ + ++StrikeTrough+ + +_Underlined_ \ No newline at end of file diff --git a/lexers/testdata/org.expected b/lexers/testdata/org.expected index a7c17e03e..b3acc6d12 100644 --- a/lexers/testdata/org.expected +++ b/lexers/testdata/org.expected @@ -28,7 +28,7 @@ {"type":"NameClass","value":"=EXPORT_FILE_NAME="}, {"type":"Text","value":"\nproperty in here. But then you also lose the tag and property\ninheritance Org awesomeness.\n\nline one "}, {"type":"Operator","value":"\\\\"}, - {"type":"Text","value":"\nline two\n"}, + {"type":"Text","value":"\nline two\n\n"}, {"type":"GenericStrong","value":"*bold*"}, {"type":"Text","value":" "}, {"type":"GenericEmph","value":"/italics/"}, @@ -361,5 +361,16 @@ {"type":"Comment","value":"# org-link-file-path-type: relative"}, {"type":"Text","value":"\n"}, {"type":"Comment","value":"# End:"}, - {"type":"Text","value":"\n"} + {"type":"Text","value":"\n\nGeneric text.\n\n"}, + {"type":"GenericEmph","value":"/Italicized/"}, + {"type":"Text","value":"\n\n"}, + {"type":"GenericStrong","value":"*strong*"}, + {"type":"Text","value":"\n\n"}, + {"type":"NameClass","value":"=Heading="}, + {"type":"Text","value":"\n\n"}, + {"type":"NameClass","value":"~Codeblock~"}, + {"type":"Text","value":"\n\n"}, + {"type":"GenericDeleted","value":"+StrikeTrough+"}, + {"type":"Text","value":"\n\n"}, + {"type":"GenericUnderline","value":"_Underlined_"} ]