git.iko.soy/typeable/pandoc
on master help sign in
Added support for definition lists to RST reader.
6a6b1a5fiddlosopher
src/Text/Pandoc/Readers/RST.hs+15−1
@@ -355,7 +355,21 @@ blockQuote = try (do
355-- list blocks
355-- list blocks
356--
356--
357
357
358−list = choice [ bulletList, orderedList ] <?> "list"
358+list = choice [ bulletList, orderedList, definitionList ] <?> "list"
359+
360+definitionListItem = try $ do
361+ term <- many1Till inline endline
362+ raw <- indentedBlock True
363+ -- parse the extracted block, which may contain various block elements:
364+ rest <- getInput
365+ setInput $ raw ++ "\n\n"
366+ contents <- parseBlocks
367+ setInput rest
368+ return (normalizeSpaces term, contents)
369+
370+definitionList = try $ do
371+ items <- many1 definitionListItem
372+ return (DefinitionList items)
359
373
360-- parses bullet list start and returns its length (inc. following whitespace)
374-- parses bullet list start and returns its length (inc. following whitespace)
361bulletListStart = try (do
375bulletListStart = try (do
tests/rst-reader.native+11
@@ -117,6 +117,17 @@ Pandoc (Meta [Str "Pandoc",Space,Str "Test",Space,Str "Suite",Str ":",Space,Str
117 [ [ Plain [Str "Fee"] ]
117 [ [ Plain [Str "Fee"] ]
118 , [ Plain [Str "Fie"] ]
118 , [ Plain [Str "Fie"] ]
119 , [ Plain [Str "Foe"] ] ] ] ], [ Para [Str "Third"] ] ]
119 , [ Plain [Str "Foe"] ] ] ] ], [ Para [Str "Third"] ] ]
120+, Header 2 [Str "Definition"]
121+, DefinitionList
122+ [ ([Str "term",Space,Str "1"],
123+ [ Para [Str "Definition",Space,Str "1."] ]
124+ ),
125+ ([Str "term",Space,Str "2"],
126+ [ Para [Str "Definition",Space,Str "2,",Space,Str "paragraph",Space,Str "1."]
127+ , Para [Str "Definition",Space,Str "2,",Space,Str "paragraph",Space,Str "2."] ] ),
128+ ([Str "term",Space,Str "with",Space,Emph [Str "emphasis"]],
129+ [ Para [Str "Definition",Space,Str "3."] ]
130+ ) ]
120, Header 1 [Str "HTML",Space,Str "Blocks"]
131, Header 1 [Str "HTML",Space,Str "Blocks"]
121, Para [Str "Simple",Space,Str "block",Space,Str "on",Space,Str "one",Space,Str "line",Str ":"]
132, Para [Str "Simple",Space,Str "block",Space,Str "on",Space,Str "one",Space,Str "line",Str ":"]
122, RawHtml "<div>foo</div>\n"
133, RawHtml "<div>foo</div>\n"
tests/rst-reader.rst+14
@@ -211,6 +211,20 @@ Here's another:
211
211
2123. Third
2123. Third
213
213
214+Definition
215+----------
216+
217+term 1
218+ Definition 1.
219+
220+term 2
221+ Definition 2, paragraph 1.
222+
223+ Definition 2, paragraph 2.
224+
225+term with *emphasis*
226+ Definition 3.
227+
214HTML Blocks
228HTML Blocks
215===========
229===========
216
230