git.iko.soy/typeable/pandoc
on master help sign in
Muse reader: check that headers start at the first column (#3749)
commit21925284244bb88f927c287c21b48df35234b260 authorAlexander Krotov <ilabdsf@gmail.com> dateTue 20 Jun 2017, 15:48 (9 years ago) parentea1724e
2 files changed+19
src/Text/Pandoc/Readers/Muse.hs+2 test/Tests/Readers/Muse.hs+17
src/Text/Pandoc/Readers/Muse.hs+2
@@ -205,6 +205,8 @@ separator = try $ do
205205
206206header :: PandocMonad m => MuseParser m (F Blocks)
207207header = try $ do
208+ st <- stateParserContext <$> getState
209+ getPosition >>= \pos -> guard (st == NullState && sourceColumn pos == 1)
208210 level <- liftM length $ many1 $ char '*'
209211 guard $ level <= 5
210212 skipSpaces
test/Tests/Readers/Muse.hs+17
@@ -108,6 +108,12 @@ tests =
108108 , "Subsubsection" =:
109109 "***** Fifth level\n" =?>
110110 header 5 "Fifth level"
111+ , "No headers below top level" =:
112+ T.unlines [ "Foo[1]"
113+ , "[1] * Bar"
114+ ] =?>
115+ para (text "Foo" <>
116+ note (para "* Bar"))
111117 ]
112118 , testGroup "Footnotes"
113119 [ "Simple footnote" =:
@@ -273,5 +279,16 @@ tests =
273279 , para "c"
274280 ]
275281 ]
282+ -- Headers in first column of list continuation are not allowed
283+ , "No headers in list continuation" =:
284+ T.unlines
285+ [ " - Foo"
286+ , ""
287+ , " * Bar"
288+ ] =?>
289+ bulletList [ mconcat [ para "Foo"
290+ , para "* Bar"
291+ ]
292+ ]
276293 ]
277294 ]