From eb184d9148e8a3e8c896a71550b1f0bee8da9a21 Mon Sep 17 00:00:00 2001 From: Albert Krewinkel Date: Mon, 8 Mar 2021 12:40:25 +0100 Subject: Jira writer: use noformat instead of code for unknown languages. Code blocks that are not marked as a language supported by Jira are rendered as preformatted text with `{noformat}` blocks. Fixes: tarleb/jira-wiki-markup#4 --- test/Tests/Writers/Jira.hs | 10 +++++++++ test/writer.jira | 55 +++++++++++++++++++--------------------------- 2 files changed, 32 insertions(+), 33 deletions(-) (limited to 'test') diff --git a/test/Tests/Writers/Jira.hs b/test/Tests/Writers/Jira.hs index aff8348d4..b618c3970 100644 --- a/test/Tests/Writers/Jira.hs +++ b/test/Tests/Writers/Jira.hs @@ -68,5 +68,15 @@ tests = spanWith ("unicorn", [], []) (str "Unicorn") =?> "{anchor:unicorn}Unicorn" ] + + , testGroup "code" + [ "code block with known language" =: + codeBlockWith ("", ["java"], []) "Book book = new Book(\"Algebra\")" =?> + "{code:java}\nBook book = new Book(\"Algebra\")\n{code}" + + , "code block without language" =: + codeBlockWith ("", [], []) "preformatted\n text.\n" =?> + "{noformat}\npreformatted\n text.\n{noformat}" + ] ] ] diff --git a/test/writer.jira b/test/writer.jira index aff0dc320..71b720d65 100644 --- a/test/writer.jira +++ b/test/writer.jira @@ -33,11 +33,10 @@ bq. This is a block quote. It is pretty short. {quote} Code in a block quote: -{code:java} +{noformat} sub status { print "working"; -} -{code} +}{noformat} A list: # item one @@ -56,22 +55,20 @@ And a following paragraph. h1. {anchor:code-blocks}Code Blocks Code: -{code:java} +{noformat} ---- (should be four hyphens) sub status { print "working"; } -this code block is indented by one tab -{code} +this code block is indented by one tab{noformat} And: -{code:java} +{noformat} this code block is indented by two tabs -These should not be escaped: \$ \\ \> \[ \{ -{code} +These should not be escaped: \$ \\ \> \[ \{{noformat} ---- h1. {anchor:lists}Lists h2. {anchor:unordered}Unordered @@ -236,9 +233,8 @@ red fruit contains seeds, crisp, pleasant to taste * *_orange_* orange fruit -{code:java} -{ orange code block } -{code} +{noformat} +{ orange code block }{noformat} bq. orange block quote Multiple definitions, tight: @@ -292,16 +288,14 @@ foo This should be a code block, though: -{code:java} +{noformat}
foo -
-{code} +{noformat} As should this: -{code:java} -
foo
-{code} +{noformat} +
foo
{noformat} Now, nested: foo @@ -312,16 +306,14 @@ Multiline: Code block: -{code:java} - -{code} +{noformat} +{noformat} Just plain comment, with trailing spaces on the line: Code: -{code:java} -
-{code} +{noformat} +
{noformat} Hr’s: ---- @@ -478,9 +470,8 @@ Indented [thrice|/url]. This should \[not\]\[\] be a link. -{code:java} -[not]: /url -{code} +{noformat} +[not]: /url{noformat} Foo [bar|/url/]. Foo [biz|/url/]. @@ -506,9 +497,8 @@ An e-mail address: [mailto:nobody@nowhere.net] bq. Blockquoted: [http://example.com/] Auto-links should not occur here: {{}} -{code:java} -or here: -{code} +{noformat} +or here: {noformat} ---- h1. {anchor:images}Images From "Voyage dans la Lune" by Georges Melies \(1902): @@ -534,9 +524,8 @@ This paragraph should not be part of the note, as it is not indented. Subsequent blocks are indented to show that they belong to the footnote \(as with list items). -{code:java} - { } -{code} +{noformat} + { }{noformat} If you want, you can indent every line, but you can also be lazy and just indent the first line of each block. -- cgit v1.2.3