git.iko.soy/typeable/pandoc
on master help sign in
Add jira reader (#5913)
96c80b1Albert Krewinkel
MANUAL.txt+1
@@ -240,6 +240,7 @@ header when requesting a document from a URL:
240 - `html` ([HTML])
240 - `html` ([HTML])
241 - `ipynb` ([Jupyter notebook])
241 - `ipynb` ([Jupyter notebook])
242 - `jats` ([JATS] XML)
242 - `jats` ([JATS] XML)
243+ - `jira` ([Jira] wiki markup)
243 - `json` (JSON version of native AST)
244 - `json` (JSON version of native AST)
244 - `latex` ([LaTeX])
245 - `latex` ([LaTeX])
245 - `markdown` ([Pandoc's Markdown])
246 - `markdown` ([Pandoc's Markdown])
pandoc.cabal+4
@@ -246,6 +246,7 @@ extra-source-files:
246 test/creole-reader.native
246 test/creole-reader.native
247 test/rst-reader.rst
247 test/rst-reader.rst
248 test/jats-reader.xml
248 test/jats-reader.xml
249+ test/jira-reader.jira
249 test/s5-basic.html
250 test/s5-basic.html
250 test/s5-fancy.html
251 test/s5-fancy.html
251 test/s5-fragment.html
252 test/s5-fragment.html
@@ -405,6 +406,7 @@ library
405 blaze-html >= 0.9 && < 0.10,
406 blaze-html >= 0.9 && < 0.10,
406 blaze-markup >= 0.8 && < 0.9,
407 blaze-markup >= 0.8 && < 0.9,
407 vector >= 0.10 && < 0.13,
408 vector >= 0.10 && < 0.13,
409+ jira-wiki-markup >= 1.0 && < 1.1,
408 hslua >= 1.0.1 && < 1.1,
410 hslua >= 1.0.1 && < 1.1,
409 hslua-module-system >= 0.2 && < 0.3,
411 hslua-module-system >= 0.2 && < 0.3,
410 hslua-module-text >= 0.2 && < 0.3,
412 hslua-module-text >= 0.2 && < 0.3,
@@ -487,6 +489,7 @@ library
487 Text.Pandoc.Readers.Org,
489 Text.Pandoc.Readers.Org,
488 Text.Pandoc.Readers.DocBook,
490 Text.Pandoc.Readers.DocBook,
489 Text.Pandoc.Readers.JATS,
491 Text.Pandoc.Readers.JATS,
492+ Text.Pandoc.Readers.Jira,
490 Text.Pandoc.Readers.OPML,
493 Text.Pandoc.Readers.OPML,
491 Text.Pandoc.Readers.Textile,
494 Text.Pandoc.Readers.Textile,
492 Text.Pandoc.Readers.Native,
495 Text.Pandoc.Readers.Native,
@@ -750,6 +753,7 @@ test-suite test-pandoc
750 Tests.Readers.LaTeX
753 Tests.Readers.LaTeX
751 Tests.Readers.HTML
754 Tests.Readers.HTML
752 Tests.Readers.JATS
755 Tests.Readers.JATS
756+ Tests.Readers.Jira
753 Tests.Readers.Markdown
757 Tests.Readers.Markdown
754 Tests.Readers.Org
758 Tests.Readers.Org
755 Tests.Readers.Org.Block
759 Tests.Readers.Org.Block
src/Text/Pandoc/Readers.hs+3
@@ -37,6 +37,7 @@ module Text.Pandoc.Readers
37 , readLaTeX
37 , readLaTeX
38 , readHtml
38 , readHtml
39 , readJATS
39 , readJATS
40+ , readJira
40 , readTextile
41 , readTextile
41 , readDocBook
42 , readDocBook
42 , readOPML
43 , readOPML
@@ -78,6 +79,7 @@ import Text.Pandoc.Readers.Ipynb
78import Text.Pandoc.Readers.Haddock
79import Text.Pandoc.Readers.Haddock
79import Text.Pandoc.Readers.HTML (readHtml)
80import Text.Pandoc.Readers.HTML (readHtml)
80import Text.Pandoc.Readers.JATS (readJATS)
81import Text.Pandoc.Readers.JATS (readJATS)
82+import Text.Pandoc.Readers.Jira (readJira)
81import Text.Pandoc.Readers.LaTeX
83import Text.Pandoc.Readers.LaTeX
82import Text.Pandoc.Readers.Markdown
84import Text.Pandoc.Readers.Markdown
83import Text.Pandoc.Readers.MediaWiki
85import Text.Pandoc.Readers.MediaWiki
@@ -121,6 +123,7 @@ readers = [ ("native" , TextReader readNative)
121 ,("textile" , TextReader readTextile) -- TODO : textile+lhs
123 ,("textile" , TextReader readTextile) -- TODO : textile+lhs
122 ,("html" , TextReader readHtml)
124 ,("html" , TextReader readHtml)
123 ,("jats" , TextReader readJATS)
125 ,("jats" , TextReader readJATS)
126+ ,("jira" , TextReader readJira)
124 ,("latex" , TextReader readLaTeX)
127 ,("latex" , TextReader readLaTeX)
125 ,("haddock" , TextReader readHaddock)
128 ,("haddock" , TextReader readHaddock)
126 ,("twiki" , TextReader readTWiki)
129 ,("twiki" , TextReader readTWiki)
src/Text/Pandoc/Readers/Jira.hsnew file+173
@@ -0,0 +1,173 @@
1+{-# LANGUAGE NoImplicitPrelude #-}
2+{-# LANGUAGE LambdaCase #-}
3+{-# LANGUAGE OverloadedStrings #-}
4+{- |
5+ Module : Text.Pandoc.Readers.Org
6+ Copyright : Β© 2019 Albert Krewinkel
7+ License : GNU GPL, version 2 or above
8+
9+ Maintainer : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>
10+
11+Conversion of jira wiki formatted plain text to 'Pandoc' document.
12+-}
13+module Text.Pandoc.Readers.Jira ( readJira ) where
14+
15+import Prelude
16+import Control.Monad.Except (throwError)
17+import Data.Text (Text, append, pack, singleton, unpack)
18+import Text.HTML.TagSoup.Entity (lookupEntity)
19+import Text.Jira.Parser (parse)
20+import Text.Pandoc.Class (PandocMonad (..))
21+import Text.Pandoc.Builder
22+import Text.Pandoc.Error (PandocError (PandocParseError))
23+import Text.Pandoc.Options (ReaderOptions)
24+import Text.Pandoc.Shared (stringify)
25+
26+import qualified Text.Jira.Markup as Jira
27+
28+-- | Read Jira wiki markup.
29+readJira :: PandocMonad m
30+ => ReaderOptions
31+ -> Text
32+ -> m Pandoc
33+readJira _opts s = case parse s of
34+ Right d -> return $ jiraToPandoc d
35+ Left e -> throwError . PandocParseError $
36+ "Jira parse error" `append` pack (show e)
37+
38+jiraToPandoc :: Jira.Doc -> Pandoc
39+jiraToPandoc (Jira.Doc blks) = doc $ foldMap jiraToPandocBlocks blks
40+
41+--
42+-- Blocks
43+--
44+
45+-- | Converts a Jira block to a Pandoc block.
46+jiraToPandocBlocks :: Jira.Block -> Blocks
47+jiraToPandocBlocks = \case
48+ Jira.BlockQuote blcks -> blockQuote $ foldMap jiraToPandocBlocks blcks
49+ Jira.Code lang ps txt -> toPandocCodeBlocks (Just lang) ps txt
50+ Jira.Color c blcks -> divWith (mempty, mempty, [("color", colorName c)]) $
51+ foldMap jiraToPandocBlocks blcks
52+ Jira.Header lvl inlns -> header lvl $ foldMap jiraToPandocInlines inlns
53+ Jira.HorizontalRule -> horizontalRule
54+ Jira.List style items -> toPandocList style items
55+ Jira.NoFormat ps txt -> toPandocCodeBlocks Nothing ps txt
56+ Jira.Panel ps blcks -> toPandocDiv ps blcks
57+ Jira.Para inlns -> para $ foldMap jiraToPandocInlines inlns
58+ Jira.Table rows -> toPandocTable rows
59+
60+-- | Create a pandoc list – either to a @'BulletList'@ or an @'OrderedList'@.
61+toPandocList :: Jira.ListStyle -> [[Jira.Block]] -> Blocks
62+toPandocList style items =
63+ let items' = map (foldMap jiraToPandocBlocks) items
64+ in if style == Jira.Enumeration
65+ then orderedList items'
66+ else bulletList items'
67+
68+-- | Create a pandoc @'CodeBlock'@
69+toPandocCodeBlocks :: Maybe Jira.Language -> [Jira.Parameter] -> Text -> Blocks
70+toPandocCodeBlocks langMay params txt =
71+ let classes = case langMay of
72+ Just (Jira.Language lang) -> [lang]
73+ Nothing -> []
74+ in codeBlockWith ("", classes, map paramToPair params) txt
75+
76+-- | Create a pandoc @'Div'@
77+toPandocDiv :: [Jira.Parameter] -> [Jira.Block] -> Blocks
78+toPandocDiv params =
79+ divWith ("", [], map paramToPair params) . foldMap jiraToPandocBlocks
80+
81+paramToPair :: Jira.Parameter -> (Text, Text)
82+paramToPair (Jira.Parameter key value) = (key, value)
83+
84+-- | Give textual representation of a color.
85+colorName :: Jira.ColorName -> Text
86+colorName (Jira.ColorName name) = name
87+
88+-- | Create a pandoc @'Table'@.
89+-- This relies on 'simpleTable' to sanitize the table.
90+toPandocTable :: [Jira.Row] -> Blocks
91+toPandocTable rows =
92+ let (headerRow, bodyRows) = splitIntoHeaderAndBody rows
93+ in simpleTable
94+ (rowToBlocksList headerRow)
95+ (map rowToBlocksList bodyRows)
96+
97+rowToBlocksList :: Jira.Row -> [Blocks]
98+rowToBlocksList (Jira.Row cells) =
99+ map cellContent cells
100+ where
101+ cellContent cell = let content = case cell of
102+ Jira.HeaderCell x -> x
103+ Jira.BodyCell x -> x
104+ in foldMap jiraToPandocBlocks content
105+
106+splitIntoHeaderAndBody :: [Jira.Row] -> (Jira.Row, [Jira.Row])
107+splitIntoHeaderAndBody [] = (Jira.Row [], [])
108+splitIntoHeaderAndBody rows@(first@(Jira.Row cells) : rest) =
109+ let isHeaderCell (Jira.HeaderCell{}) = True
110+ isHeaderCell (Jira.BodyCell{}) = False
111+ in if all isHeaderCell cells
112+ then (first, rest)
113+ else (Jira.Row [], rows)
114+
115+--
116+-- Inlines
117+--
118+
119+-- | Converts a Jira inline to a Pandoc block.
120+jiraToPandocInlines :: Jira.Inline -> Inlines
121+jiraToPandocInlines = \case
122+ Jira.Anchor t -> spanWith (t, [], []) mempty
123+ Jira.AutoLink url -> link (Jira.fromURL url) "" (str (Jira.fromURL url))
124+ Jira.Emoji icon -> str . iconUnicode $ icon
125+ Jira.Entity entity -> str . fromEntity $ entity
126+ Jira.Image _ url -> image (Jira.fromURL url) "" mempty
127+ Jira.Link alias url -> link (Jira.fromURL url) "" (fromInlines alias)
128+ Jira.Linebreak -> linebreak
129+ Jira.Monospaced inlns -> code . stringify . toList . fromInlines $ inlns
130+ Jira.Space -> space
131+ Jira.SpecialChar c -> str (Data.Text.singleton c)
132+ Jira.Str t -> str t
133+ Jira.Styled style inlns -> fromStyle style $ fromInlines inlns
134+ where
135+ fromInlines = foldMap jiraToPandocInlines
136+ fromEntity e = case lookupEntity (unpack e ++ ";") of
137+ Nothing -> "&" `append` e `append` ";"
138+ Just cs -> pack cs
139+
140+ fromStyle = \case
141+ Jira.Emphasis -> emph
142+ Jira.Insert -> spanWith ("", ["inserted"], [])
143+ Jira.Strikeout -> strikeout
144+ Jira.Strong -> strong
145+ Jira.Subscript -> subscript
146+ Jira.Superscript -> superscript
147+
148+-- | Get unicode representation of a Jira icon.
149+iconUnicode :: Jira.Icon -> Text
150+iconUnicode = \case
151+ Jira.IconSlightlySmiling -> "πŸ™‚"
152+ Jira.IconFrowning -> "πŸ™"
153+ Jira.IconTongue -> "πŸ˜›"
154+ Jira.IconSmiling -> "πŸ˜ƒ"
155+ Jira.IconWinking -> "πŸ˜‰"
156+ Jira.IconThumbsUp -> "πŸ‘"
157+ Jira.IconThumbsDown -> "πŸ‘Ž"
158+ Jira.IconInfo -> "β„Ή"
159+ Jira.IconCheckmark -> "βœ“"
160+ Jira.IconX -> "πŸ…‡"
161+ Jira.IconAttention -> "⚠"
162+ Jira.IconPlus -> "⊞"
163+ Jira.IconMinus -> "⊟"
164+ Jira.IconQuestionmark -> "?"
165+ Jira.IconOn -> "πŸ’‘"
166+ Jira.IconOff -> "πŸ’‘"
167+ Jira.IconStar -> "β˜…"
168+ Jira.IconStarRed -> "β˜…"
169+ Jira.IconStarGreen -> "β˜…"
170+ Jira.IconStarBlue -> "β˜…"
171+ Jira.IconStarYellow -> "β˜…"
172+ Jira.IconFlag -> "βš‘"
173+ Jira.IconFlagOff -> "⚐"
stack.yaml+1
@@ -20,6 +20,7 @@ extra-deps:
20- regex-pcre-builtin-0.95.0.8.8.35
20- regex-pcre-builtin-0.95.0.8.8.35
21- doclayout-0.2.0.1
21- doclayout-0.2.0.1
22- emojis-0.1
22- emojis-0.1
23+- jira-wiki-markup-1.0.0
23- HsYAML-0.2.0.0
24- HsYAML-0.2.0.0
24- HsYAML-aeson-0.2.0.0
25- HsYAML-aeson-0.2.0.0
25- doctemplates-0.8
26- doctemplates-0.8
test/Tests/Old.hs+2
@@ -100,6 +100,8 @@ tests pandocPath =
100 ]
100 ]
101 , testGroup "jira"
101 , testGroup "jira"
102 [ testGroup "writer" $ writerTests' "jira"
102 [ testGroup "writer" $ writerTests' "jira"
103+ , test' "reader" ["-r", "jira", "-w", "native", "-s"]
104+ "jira-reader.jira" "jira-reader.native"
103 ]
105 ]
104 , testGroup "native"
106 , testGroup "native"
105 [ testGroup "writer" $ writerTests' "native"
107 [ testGroup "writer" $ writerTests' "native"
test/Tests/Readers/Jira.hsnew file+114
@@ -0,0 +1,114 @@
1+{-# LANGUAGE NoImplicitPrelude #-}
2+{-# LANGUAGE OverloadedStrings #-}
3+{-# LANGUAGE ScopedTypeVariables #-}
4+{- |
5+ Module : Tests.Readers.Jira
6+ Copyright : Β© 2019 Albert Krewinel
7+ License : GNU GPL, version 2 or above
8+
9+ Maintainer : Albert Krewinkel <tarleb@zeitkraut.de>
10+ Stability : alpha
11+ Portability : portable
12+
13+Tests for the RST reader.
14+-}
15+module Tests.Readers.Jira (tests) where
16+
17+import Prelude
18+import Data.Text (Text)
19+import Test.Tasty (TestTree, testGroup)
20+import Tests.Helpers (ToString, purely, test, (=?>))
21+import Text.Pandoc (def)
22+import Text.Pandoc.Readers.Jira (readJira)
23+import Text.Pandoc.Builder
24+
25+jira :: Text -> Pandoc
26+jira = purely $ readJira def
27+
28+infix 4 =:
29+(=:) :: ToString c
30+ => String -> (Text, c) -> TestTree
31+(=:) = test jira
32+
33+tests :: [TestTree]
34+tests =
35+ [ testGroup "para"
36+ [ "Simple sentence" =:
37+ "Hello, World!" =?> para "Hello, World!"
38+ ]
39+
40+ , testGroup "header"
41+ [ "header" =:
42+ "h1. Main\n" =?> header 1 "Main"
43+ ]
44+
45+ , testGroup "list"
46+ [ "simple list" =:
47+ "* foo\n* bar\n" =?> bulletList [para "foo", para "bar"]
48+
49+ , "list with minus as bullets" =:
50+ "- foo\n- bar\n" =?> bulletList [para "foo", para "bar"]
51+
52+ , "ordered list / enumeration" =:
53+ "# first\n# second\n" =?> orderedList [para "first", para "second"]
54+ ]
55+
56+ , testGroup "block quote"
57+ [ "simple block quote" =:
58+ "bq. _Don't_ quote me on this." =?>
59+ blockQuote (para $ emph "Don't" <> space <> "quote me on this.")
60+ ]
61+
62+ , testGroup "table"
63+ [ "table without header" =:
64+ "| one | two |\n| three | four |\n" =?>
65+ simpleTable []
66+ [ [para "one", para "two"]
67+ , [para "three", para "four"]]
68+
69+ , "table with header" =:
70+ "|| one || two ||\n| three | four |\n| five | six |\n" =?>
71+ simpleTable [para "one", para "two"]
72+ [ [para "three", para "four"]
73+ , [para "five", para "six"]]
74+
75+ , "table with column header" =:
76+ "|| language | haskell | lua |\n|| type | static | dynamic |\n" =?>
77+ simpleTable []
78+ [ [para "language", para "haskell", para "lua"]
79+ , [para "type", para "static", para "dynamic"]]
80+ ]
81+
82+ , testGroup "inlines"
83+ [ "emphasis" =:
84+ "*quid pro quo*" =?>
85+ para (strong "quid pro quo")
86+
87+ , "deleted" =:
88+ "-old-" =?>
89+ para (strikeout "old")
90+
91+ , "monospaced" =:
92+ "{{this *is* monospace}}" =?>
93+ para (code "this is monospace")
94+
95+ , "sub- and superscript" =:
96+ "HCO ~3~^-^" =?>
97+ para ("HCO " <> subscript "3" <> superscript "-")
98+
99+ , "linebreak" =:
100+ "first\nsecond" =?>
101+ para ("first" <> linebreak <> "second")
102+
103+ , "link" =:
104+ "[Example|https://example.org]" =?>
105+ para (link "https://example.org" "" "Example")
106+
107+ , "image" =:
108+ "!https://example.com/image.jpg!" =?>
109+ para (image "https://example.com/image.jpg" "" mempty)
110+
111+ , "HTML entity" =:
112+ "me &amp; you" =?> para "me & you"
113+ ]
114+ ]
test/jira-reader.jiranew file+284
@@ -0,0 +1,284 @@
1+h1. {anchor:headers}Headers
2+h2. {anchor:level-2-with-an-embedded-link}Level 2 with an [embedded link|https://test.example/url]
3+h3. {anchor:level-3-with-emphasis}Level 3 with _emphasis_
4+h4. Level 4
5+h5. Level 5
6+h6. Level 6
7+
8+h0. this is not a header.
9+
10+----
11+h1. Paragraphs
12+Here’s a regular paragraph.
13+
14+Here’s one with a bullet. * criminey.
15+
16+There should be a hard line break
17+here.
18+
19+----
20+h1. Block Quotes
21+E-mail style:
22+
23+bq. This is a block quote. It is pretty short.
24+{quote}
25+Code in a block quote:
26+
27+{code:java}
28+sub status {
29+ print "working";
30+}
31+{code}
32+
33+An enumeration:
34+
35+# item one
36+# item two
37+{quote}
38+
39+A following paragraph.
40+
41+----
42+h1. Code Blocks
43+
44+Code:
45+
46+{code:java}
47+---- (should be four hyphens)
48+
49+sub status {
50+ print "working";
51+}
52+{code}
53+And:
54+
55+{code:java}
56+ this code block is indented by two tabs
57+
58+These should not be escaped: \$ \\ \> \[ \{
59+{code}
60+
61+----
62+h1. {anchor:lists}Lists
63+h2. {anchor:unordered}Unordered
64+Asterisks:
65+
66+* asterisk 1
67+* asterisk 2
68+* asterisk 3
69+
70+Minuses:
71+
72+- Minus 1
73+- Minus 2
74+- Minus 3
75+
76+h2. Ordered
77+
78+# First
79+# Second
80+# Third
81+
82+Linebreak in paragraph:
83+
84+# Item 1, line one.
85+Item 1. line two. The quick brown fox jumped over the lazy dog’s back.
86+# Item 2.
87+# Item 3.
88+
89+h2. Nested
90+* Tab
91+** Tab
92+*** Tab
93+
94+Here’s another:
95+
96+# First
97+# Second:
98+#* Fee
99+#* Fie
100+#* Foe
101+# Third
102+
103+Nested enumerations:
104+
105+# Essential
106+## Important
107+### Relevant
108+#### Insignificant
109+
110+----
111+h1. Linebreaks and Markup in Lists
112+
113+* *apple*
114+red fruit
115+* *orange*
116+orange fruit
117+* *banana*
118+yellow fruit
119+
120+Multiple blocks with italics:
121+
122+* *_apple_*
123+red fruit
124+contains seeds, crisp, pleasant to taste
125+* *_orange_*
126+orange fruit
127+{code:java}
128+{ orange code block }
129+{code}
130+bq. orange block quote
131+
132+----
133+h1. Colored Text Blocks
134+{color:red}
135+This is red.
136+{color}
137+
138+h2. Eiffel 65
139+
140+{color:blue}
141+da ba dee
142+{color}
143+
144+----
145+h1. Inline Markup
146+This is _emphasized_, and so _is this_.
147+
148+This is *strong*, and so *is this*.
149+
150+An _[emphasized link|https://my.example/url]_.
151+
152+*_This is strong and em._*
153+
154+So is *_this_* word.
155+
156+This is code: {{>}}, {{$}}, {{&bsol;}}, {{&bsol;$}}, {{<html>}}.
157+
158+-This is _strikeout_.-
159+
160+Superscripts: a{^}bc{^}d a{^}_hello_{^} a{^}helloΒ there{^}.
161+
162+Subscripts: H{~}2{~}O, C{~}6{~}H{~}12{~}O{~}6{~}, C{~}Β nΒ {~}H{~}_2n_{~}O{~}n{~}.
163+
164+These should not be superscripts or subscripts, because of markers used within words: a^b c^d, a~b c~d.
165+
166+----
167+h1. Dashes, and emoticons
168+
169+Some dashes: one -- two --- three.
170+
171+Sure (/)
172+Nope (x)
173+
174+Nice :D
175+
176+Capital d\:D
177+
178+----
179+h1. Math
180+
181+* 2β€…+β€…2 = 4
182+* _x_β€„βˆˆβ€„{_}y{_}
183+* _Ξ±_β€…βˆ§β€…{_}Ο‰{_}
184+* _p_-Tree
185+* Here’s one more: _Ξ±_β€…+β€…{_}Ο‰{_}β€…Γ—β€…{_}x{_}^2^.
186+
187+
188+----
189+h1. Special Characters
190+Here is some unicode:
191+
192+* I hat: Î
193+* o umlaut: ΓΆ
194+* section: Β§
195+* set membership: ∈
196+* copyright: Β©
197+
198+AT&T has an ampersand in their name.
199+
200+AT&amp;T is another way to write it.
201+
202+This & that.
203+
204+4 < 5.
205+
206+6 > 5.
207+
208+Backslash: &bsol;
209+
210+Backtick: `
211+
212+Asterisk: *
213+
214+Underscore: _
215+
216+Left brace: {
217+
218+Right brace: }
219+
220+Left bracket: [
221+
222+Right bracket: ]
223+
224+Left paren: (
225+
226+Right paren: )
227+
228+Greater-than: >
229+
230+Hash: #
231+
232+Period: .
233+
234+Bang: !
235+
236+Plus: +
237+
238+Minus: -
239+
240+----
241+h1. Links
242+h2. Explicit
243+Just a [URL|https://example.org/url].
244+
245+[File URL|file://some/file/name/].
246+
247+[IRC link|irc://example.org/pandoc].
248+
249+[Email link|mailto:nobody@nowhere.invalid]
250+
251+[Not a link|not a URL].
252+
253+h2. Reference
254+With [embedded \[brackets\]|https://example.net/url/].
255+
256+https://pandoc.org by itself should be a link.
257+
258+h2. With ampersands
259+Here’s a [link with an ampersand in the URL|http://example.com/?foo=1&bar=2].
260+
261+Here’s a link with an ampersand in the link text: [AT&T|http://att.com/].
262+
263+h2. Autolinks
264+With an ampersand: http://example.com/?foo=1&bar=2
265+
266+* In a list?
267+* http://example.com/
268+* It should.
269+
270+An e-mail address: mailto:nobody@nowhere.invalid
271+
272+bq. Blockquoted: http://example.com/
273+
274+{code:java}
275+Autolink should not occur here: <http://example.com/>
276+{code}
277+
278+----
279+h1. Images
280+From "Voyage dans la Lune" by Georges Melies (1902):
281+
282+!lalune.jpg!
283+
284+Here is a movie !movie.jpg! icon.
test/jira-reader.nativenew file+185
@@ -0,0 +1,185 @@
1+Pandoc (Meta {unMeta = fromList []})
2+[Header 1 ("",[],[]) [Span ("headers",[],[]) [],Str "Headers"]
3+,Header 2 ("",[],[]) [Span ("level-2-with-an-embedded-link",[],[]) [],Str "Level",Space,Str "2",Space,Str "with",Space,Str "an",Space,Link ("",[],[]) [Str "embedded",Space,Str "link"] ("https://test.example/url","")]
4+,Header 3 ("",[],[]) [Span ("level-3-with-emphasis",[],[]) [],Str "Level",Space,Str "3",Space,Str "with",Space,Emph [Str "emphasis"]]
5+,Header 4 ("",[],[]) [Str "Level",Space,Str "4"]
6+,Header 5 ("",[],[]) [Str "Level",Space,Str "5"]
7+,Header 6 ("",[],[]) [Str "Level",Space,Str "6"]
8+,Para [Str "h0.",Space,Str "this",Space,Str "is",Space,Str "not",Space,Str "a",Space,Str "header."]
9+,HorizontalRule
10+,Header 1 ("",[],[]) [Str "Paragraphs"]
11+,Para [Str "Here\8217s",Space,Str "a",Space,Str "regular",Space,Str "paragraph."]
12+,Para [Str "Here\8217s",Space,Str "one",Space,Str "with",Space,Str "a",Space,Str "bullet.",Space,Str "*",Space,Str "criminey."]
13+,Para [Str "There",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "hard",Space,Str "line",Space,Str "break",LineBreak,Str "here."]
14+,HorizontalRule
15+,Header 1 ("",[],[]) [Str "Block",Space,Str "Quotes"]
16+,Para [Str "E-mail",Space,Str "style:"]
17+,BlockQuote
18+ [Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "block",Space,Str "quote.",Space,Str "It",Space,Str "is",Space,Str "pretty",Space,Str "short."]]
19+,BlockQuote
20+ [Para [Str "Code",Space,Str "in",Space,Str "a",Space,Str "block",Space,Str "quote:"]
21+ ,CodeBlock ("",["java"],[]) "sub status {\n print \"working\";\n}\n"
22+ ,Para [Str "An",Space,Str "enumeration:"]
23+ ,OrderedList (1,DefaultStyle,DefaultDelim)
24+ [[Para [Str "item",Space,Str "one"]]
25+ ,[Para [Str "item",Space,Str "two"]]]]
26+,Para [Str "A",Space,Str "following",Space,Str "paragraph."]
27+,HorizontalRule
28+,Header 1 ("",[],[]) [Str "Code",Space,Str "Blocks"]
29+,Para [Str "Code:"]
30+,CodeBlock ("",["java"],[]) "---- (should be four hyphens)\n\nsub status {\n print \"working\";\n}\n"
31+,Para [Str "And:"]
32+,CodeBlock ("",["java"],[]) " this code block is indented by two tabs\n\nThese should not be escaped: \\$ \\\\ \\> \\[ \\{\n"
33+,HorizontalRule
34+,Header 1 ("",[],[]) [Span ("lists",[],[]) [],Str "Lists"]
35+,Header 2 ("",[],[]) [Span ("unordered",[],[]) [],Str "Unordered"]
36+,Para [Str "Asterisks:"]
37+,BulletList
38+ [[Para [Str "asterisk",Space,Str "1"]]
39+ ,[Para [Str "asterisk",Space,Str "2"]]
40+ ,[Para [Str "asterisk",Space,Str "3"]]]
41+,Para [Str "Minuses:"]
42+,BulletList
43+ [[Para [Str "Minus",Space,Str "1"]]
44+ ,[Para [Str "Minus",Space,Str "2"]]
45+ ,[Para [Str "Minus",Space,Str "3"]]]
46+,Header 2 ("",[],[]) [Str "Ordered"]
47+,OrderedList (1,DefaultStyle,DefaultDelim)
48+ [[Para [Str "First"]]
49+ ,[Para [Str "Second"]]
50+ ,[Para [Str "Third"]]]
51+,Para [Str "Linebreak",Space,Str "in",Space,Str "paragraph:"]
52+,OrderedList (1,DefaultStyle,DefaultDelim)
53+ [[Para [Str "Item",Space,Str "1,",Space,Str "line",Space,Str "one.",LineBreak,Str "Item",Space,Str "1.",Space,Str "line",Space,Str "two.",Space,Str "The",Space,Str "quick",Space,Str "brown",Space,Str "fox",Space,Str "jumped",Space,Str "over",Space,Str "the",Space,Str "lazy",Space,Str "dog\8217s",Space,Str "back."]]
54+ ,[Para [Str "Item",Space,Str "2."]]
55+ ,[Para [Str "Item",Space,Str "3."]]]
56+,Header 2 ("",[],[]) [Str "Nested"]
57+,BulletList
58+ [[Para [Str "Tab"]
59+ ,BulletList
60+ [[Para [Str "Tab"]
61+ ,BulletList
62+ [[Para [Str "Tab"]]]]]]]
63+,Para [Str "Here\8217s",Space,Str "another:"]
64+,OrderedList (1,DefaultStyle,DefaultDelim)
65+ [[Para [Str "First"]]
66+ ,[Para [Str "Second:"]
67+ ,BulletList
68+ [[Para [Str "Fee"]]
69+ ,[Para [Str "Fie"]]
70+ ,[Para [Str "Foe"]]]]
71+ ,[Para [Str "Third"]]]
72+,Para [Str "Nested",Space,Str "enumerations:"]
73+,OrderedList (1,DefaultStyle,DefaultDelim)
74+ [[Para [Str "Essential"]
75+ ,OrderedList (1,DefaultStyle,DefaultDelim)
76+ [[Para [Str "Important"]
77+ ,OrderedList (1,DefaultStyle,DefaultDelim)
78+ [[Para [Str "Relevant"]
79+ ,OrderedList (1,DefaultStyle,DefaultDelim)
80+ [[Para [Str "Insignificant"]]]]]]]]]
81+,HorizontalRule
82+,Header 1 ("",[],[]) [Str "Linebreaks",Space,Str "and",Space,Str "Markup",Space,Str "in",Space,Str "Lists"]
83+,BulletList
84+ [[Para [Strong [Str "apple"],LineBreak,Str "red",Space,Str "fruit"]]
85+ ,[Para [Strong [Str "orange"],LineBreak,Str "orange",Space,Str "fruit"]]
86+ ,[Para [Strong [Str "banana"],LineBreak,Str "yellow",Space,Str "fruit"]]]
87+,Para [Str "Multiple",Space,Str "blocks",Space,Str "with",Space,Str "italics:"]
88+,BulletList
89+ [[Para [Strong [Emph [Str "apple"]],LineBreak,Str "red",Space,Str "fruit",LineBreak,Str "contains",Space,Str "seeds,",Space,Str "crisp,",Space,Str "pleasant",Space,Str "to",Space,Str "taste"]]
90+ ,[Para [Strong [Emph [Str "orange"]],LineBreak,Str "orange",Space,Str "fruit"]
91+ ,CodeBlock ("",["java"],[]) "{ orange code block }\n"
92+ ,BlockQuote
93+ [Para [Str "orange",Space,Str "block",Space,Str "quote"]]]]
94+,HorizontalRule
95+,Header 1 ("",[],[]) [Str "Colored",Space,Str "Text",Space,Str "Blocks"]
96+,Div ("",[],[("color","red")])
97+ [Para [LineBreak,Str "This",Space,Str "is",Space,Str "red."]]
98+,Header 2 ("",[],[]) [Str "Eiffel",Space,Str "65"]
99+,Div ("",[],[("color","blue")])
100+ [Para [LineBreak,Str "da",Space,Str "ba",Space,Str "dee"]]
101+,HorizontalRule
102+,Header 1 ("",[],[]) [Str "Inline",Space,Str "Markup"]
103+,Para [Str "This",Space,Str "is",Space,Emph [Str "emphasized"],Str ",",Space,Str "and",Space,Str "so",Space,Emph [Str "is",Space,Str "this"],Str "."]
104+,Para [Str "This",Space,Str "is",Space,Strong [Str "strong"],Str ",",Space,Str "and",Space,Str "so",Space,Strong [Str "is",Space,Str "this"],Str "."]
105+,Para [Str "An",Space,Emph [Link ("",[],[]) [Str "emphasized",Space,Str "link"] ("https://my.example/url","")],Str "."]
106+,Para [Strong [Emph [Str "This",Space,Str "is",Space,Str "strong",Space,Str "and",Space,Str "em."]]]
107+,Para [Str "So",Space,Str "is",Space,Strong [Emph [Str "this"]],Space,Str "word."]
108+,Para [Str "This",Space,Str "is",Space,Str "code:",Space,Code ("",[],[]) ">",Str ",",Space,Code ("",[],[]) "$",Str ",",Space,Code ("",[],[]) "\\",Str ",",Space,Code ("",[],[]) "\\$",Str ",",Space,Code ("",[],[]) "<html>",Str "."]
109+,Para [Strikeout [Str "This",Space,Str "is",Space,Emph [Str "strikeout"],Str "."]]
110+,Para [Str "Superscripts:",Space,Str "a",Superscript [Str "bc"],Str "d",Space,Str "a",Superscript [Emph [Str "hello"]],Space,Str "a",Superscript [Str "hello\160there"],Str "."]
111+,Para [Str "Subscripts:",Space,Str "H",Subscript [Str "2"],Str "O,",Space,Str "C",Subscript [Str "6"],Str "H",Subscript [Str "12"],Str "O",Subscript [Str "6"],Str ",",Space,Str "C",Subscript [Str "\160n\160"],Str "H",Subscript [Emph [Str "2n"]],Str "O",Subscript [Str "n"],Str "."]
112+,Para [Str "These",Space,Str "should",Space,Str "not",Space,Str "be",Space,Str "superscripts",Space,Str "or",Space,Str "subscripts,",Space,Str "because",Space,Str "of",Space,Str "markers",Space,Str "used",Space,Str "within",Space,Str "words:",Space,Str "a^b",Space,Str "c^d,",Space,Str "a~b",Space,Str "c~d."]
113+,HorizontalRule
114+,Header 1 ("",[],[]) [Str "Dashes,",Space,Str "and",Space,Str "emoticons"]
115+,Para [Str "Some",Space,Str "dashes:",Space,Str "one",Space,Str "\8211",Space,Str "two",Space,Str "\8212",Space,Str "three."]
116+,Para [Str "Sure",Space,Str "\10003",LineBreak,Str "Nope",Space,Str "\127303"]
117+,Para [Str "Nice",Space,Str "\128515"]
118+,Para [Str "Capital",Space,Str "d:D"]
119+,HorizontalRule
120+,Header 1 ("",[],[]) [Str "Math"]
121+,BulletList
122+ [[Para [Str "2\8197+\8197\&2\8196=\8196\&4"]]
123+ ,[Para [Emph [Str "x"],Str "\8196\8712\8196",Emph [Str "y"]]]
124+ ,[Para [Emph [Str "\945"],Str "\8197\8743\8197",Emph [Str "\969"]]]
125+ ,[Para [Emph [Str "p"],Str "-Tree"]]
126+ ,[Para [Str "Here\8217s",Space,Str "one",Space,Str "more:",Space,Emph [Str "\945"],Str "\8197+\8197",Emph [Str "\969"],Str "\8197\215\8197",Emph [Str "x"],Superscript [Str "2"],Str "."]]]
127+,HorizontalRule
128+,Header 1 ("",[],[]) [Str "Special",Space,Str "Characters"]
129+,Para [Str "Here",Space,Str "is",Space,Str "some",Space,Str "unicode:"]
130+,BulletList
131+ [[Para [Str "I",Space,Str "hat:",Space,Str "\206"]]
132+ ,[Para [Str "o",Space,Str "umlaut:",Space,Str "\246"]]
133+ ,[Para [Str "section:",Space,Str "\167"]]
134+ ,[Para [Str "set",Space,Str "membership:",Space,Str "\8712"]]
135+ ,[Para [Str "copyright:",Space,Str "\169"]]]
136+,Para [Str "AT&T",Space,Str "has",Space,Str "an",Space,Str "ampersand",Space,Str "in",Space,Str "their",Space,Str "name."]
137+,Para [Str "AT&T",Space,Str "is",Space,Str "another",Space,Str "way",Space,Str "to",Space,Str "write",Space,Str "it."]
138+,Para [Str "This",Space,Str "&",Space,Str "that."]
139+,Para [Str "4",Space,Str "<",Space,Str "5."]
140+,Para [Str "6",Space,Str ">",Space,Str "5."]
141+,Para [Str "Backslash:",Space,Str "\\"]
142+,Para [Str "Backtick:",Space,Str "`"]
143+,Para [Str "Asterisk:",Space,Str "*"]
144+,Para [Str "Underscore:",Space,Str "_"]
145+,Para [Str "Left",Space,Str "brace:",Space,Str "{"]
146+,Para [Str "Right",Space,Str "brace:",Space,Str "}"]
147+,Para [Str "Left",Space,Str "bracket:",Space,Str "["]
148+,Para [Str "Right",Space,Str "bracket:",Space,Str "]"]
149+,Para [Str "Left",Space,Str "paren:",Space,Str "("]
150+,Para [Str "Right",Space,Str "paren:",Space,Str ")"]
151+,Para [Str "Greater-than:",Space,Str ">"]
152+,Para [Str "Hash:",Space,Str "#"]
153+,Para [Str "Period:",Space,Str "."]
154+,Para [Str "Bang:",Space,Str "!"]
155+,Para [Str "Plus:",Space,Str "+"]
156+,Para [Str "Minus:",Space,Str "-"]
157+,HorizontalRule
158+,Header 1 ("",[],[]) [Str "Links"]
159+,Header 2 ("",[],[]) [Str "Explicit"]
160+,Para [Str "Just",Space,Str "a",Space,Link ("",[],[]) [Str "URL"] ("https://example.org/url",""),Str "."]
161+,Para [Link ("",[],[]) [Str "File",Space,Str "URL"] ("file://some/file/name/",""),Str "."]
162+,Para [Link ("",[],[]) [Str "IRC",Space,Str "link"] ("irc://example.org/pandoc",""),Str "."]
163+,Para [Link ("",[],[]) [Str "Email",Space,Str "link"] ("mailto:nobody@nowhere.invalid","")]
164+,Para [Str "[Not",Space,Str "a",Space,Str "link|not",Space,Str "a",Space,Str "URL]."]
165+,Header 2 ("",[],[]) [Str "Reference"]
166+,Para [Str "With",Space,Link ("",[],[]) [Str "embedded",Space,Str "[brackets]"] ("https://example.net/url/",""),Str "."]
167+,Para [Link ("",[],[]) [Str "https://pandoc.org by itself should be a link."] ("https://pandoc.org by itself should be a link.","")]
168+,Header 2 ("",[],[]) [Str "With",Space,Str "ampersands"]
169+,Para [Str "Here\8217s",Space,Str "a",Space,Link ("",[],[]) [Str "link",Space,Str "with",Space,Str "an",Space,Str "ampersand",Space,Str "in",Space,Str "the",Space,Str "URL"] ("http://example.com/?foo=1&bar=2",""),Str "."]
170+,Para [Str "Here\8217s",Space,Str "a",Space,Str "link",Space,Str "with",Space,Str "an",Space,Str "ampersand",Space,Str "in",Space,Str "the",Space,Str "link",Space,Str "text:",Space,Link ("",[],[]) [Str "AT&T"] ("http://att.com/",""),Str "."]
171+,Header 2 ("",[],[]) [Str "Autolinks"]
172+,Para [Str "With",Space,Str "an",Space,Str "ampersand:",Space,Link ("",[],[]) [Str "http://example.com/?foo=1&bar=2"] ("http://example.com/?foo=1&bar=2","")]
173+,BulletList
174+ [[Para [Str "In",Space,Str "a",Space,Str "list?"]]
175+ ,[Para [Link ("",[],[]) [Str "http://example.com/"] ("http://example.com/","")]]
176+ ,[Para [Str "It",Space,Str "should."]]]
177+,Para [Str "An",Space,Str "e-mail",Space,Str "address:",Space,Link ("",[],[]) [Str "mailto:nobody@nowhere.invalid"] ("mailto:nobody@nowhere.invalid","")]
178+,BlockQuote
179+ [Para [Str "Blockquoted:",Space,Link ("",[],[]) [Str "http://example.com/"] ("http://example.com/","")]]
180+,CodeBlock ("",["java"],[]) "Autolink should not occur here: <http://example.com/>\n"
181+,HorizontalRule
182+,Header 1 ("",[],[]) [Str "Images"]
183+,Para [Str "From",Space,Str "\"Voyage",Space,Str "dans",Space,Str "la",Space,Str "Lune\"",Space,Str "by",Space,Str "Georges",Space,Str "Melies",Space,Str "(1902):"]
184+,Para [Image ("",[],[]) [] ("lalune.jpg","")]
185+,Para [Str "Here",Space,Str "is",Space,Str "a",Space,Str "movie",Space,Image ("",[],[]) [] ("movie.jpg",""),Space,Str "icon."]]
test/test-pandoc.hs+2
@@ -17,6 +17,7 @@ import qualified Tests.Readers.EPUB
17import qualified Tests.Readers.FB2
17import qualified Tests.Readers.FB2
18import qualified Tests.Readers.HTML
18import qualified Tests.Readers.HTML
19import qualified Tests.Readers.JATS
19import qualified Tests.Readers.JATS
20+import qualified Tests.Readers.Jira
20import qualified Tests.Readers.LaTeX
21import qualified Tests.Readers.LaTeX
21import qualified Tests.Readers.Markdown
22import qualified Tests.Readers.Markdown
22import qualified Tests.Readers.Muse
23import qualified Tests.Readers.Muse
@@ -73,6 +74,7 @@ tests pandocPath = testGroup "pandoc tests"
73 , testGroup "Markdown" Tests.Readers.Markdown.tests
74 , testGroup "Markdown" Tests.Readers.Markdown.tests
74 , testGroup "HTML" Tests.Readers.HTML.tests
75 , testGroup "HTML" Tests.Readers.HTML.tests
75 , testGroup "JATS" Tests.Readers.JATS.tests
76 , testGroup "JATS" Tests.Readers.JATS.tests
77+ , testGroup "Jira" Tests.Readers.Jira.tests
76 , testGroup "Org" Tests.Readers.Org.tests
78 , testGroup "Org" Tests.Readers.Org.tests
77 , testGroup "RST" Tests.Readers.RST.tests
79 , testGroup "RST" Tests.Readers.RST.tests
78 , testGroup "Docx" Tests.Readers.Docx.tests
80 , testGroup "Docx" Tests.Readers.Docx.tests