git.iko.soy/typeable/pandoc
on master help sign in
Readers.RST: Parse field list name

“Inline markup is parsed in field names.” [1] [1] http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#field-lists

commit68b6b9f652125318e82819918a79f8075924d93e authorLars-Dominik Braun <lars@6xq.net> dateThu 2 Jul 2015, 19:16 (11 years ago) parent79764df
2 files changed+21−3
src/Text/Pandoc/Readers/RST.hs+1−1 tests/Tests/Readers/RST.hs+20−2
src/Text/Pandoc/Readers/RST.hs+1−1
@@ -209,7 +209,7 @@ rawFieldListItem minIndent = try $ do
209209fieldListItem :: Int -> RSTParser (Inlines, [Blocks])
210210fieldListItem minIndent = try $ do
211211 (name, raw) <- rawFieldListItem minIndent
212− let term = B.str name
212+ term <- parseFromString (trimInlines . mconcat <$> many inline) name
213213 contents <- parseFromString parseBlocks raw
214214 optional blanklines
215215 return (term, [contents])
tests/Tests/Readers/RST.hs+20−2
@@ -39,11 +39,11 @@ tests = [ "line block with blank line" =:
3939 =?> ( doc
4040 $ para "para" <>
4141 definitionList [ (str "Hostname", [para "media08"])
42− , (str "IP address", [para "10.0.0.19"])
42+ , (text "IP address", [para "10.0.0.19"])
4343 , (str "Size", [para "3ru"])
4444 , (str "Version", [para "1"])
4545 , (str "Indentation", [para "Since the field marker may be quite long, the second and subsequent lines of the field body do not have to line up with the first line, but they must be indented relative to the field name marker, and they must line up with each other."])
46− , (str "Parameter i", [para "integer"])
46+ , (text "Parameter i", [para "integer"])
4747 , (str "Final", [para "item on two lines"])
4848 ])
4949 , "initial field list" =: unlines
@@ -60,6 +60,24 @@ tests = [ "line block with blank line" =:
6060 $ setMeta "title" ("Title" :: Inlines)
6161 $ setMeta "subtitle" ("Subtitle" :: Inlines)
6262 $ doc mempty )
63+ , "field list name with inline markup" =: unlines
64+ [ "the following field list is not metadata"
65+ , ""
66+ , ":*one*: emphasis"
67+ , ":two_: reference"
68+ , ":`three`_: another one"
69+ , ":``four``: literal"
70+ , ""
71+ , ".. _two: http://example.com"
72+ , ".. _three: http://example.org"
73+ ]
74+ =?> (doc
75+ $ para "the following field list is not metadata" <>
76+ definitionList [ (emph "one", [para "emphasis"])
77+ , (link "http://example.com" "" "two", [para "reference"])
78+ , (link "http://example.org" "" "three", [para "another one"])
79+ , (code "four", [para "literal"])
80+ ])
6381 , "URLs with following punctuation" =:
6482 ("http://google.com, http://yahoo.com; http://foo.bar.baz.\n" ++
6583 "http://foo.bar/baz_(bam) (http://foo.bar)") =?>