git.iko.soy/typeable/pandoc
on master help sign in
Merge pull request #3911 from labdsf/muse-reader-braces
ddecd72John MacFarlane
src/Text/Pandoc/Readers/Muse.hs+8−1
@@ -30,7 +30,6 @@ Conversion of Muse text to 'Pandoc' document.
30-}
30-}
31{-
31{-
32TODO:
32TODO:
33−- {{{ }}} syntax for <example>
34- Page breaks (five "*")
33- Page breaks (five "*")
35- Headings with anchors (make it round trip with Muse writer)
34- Headings with anchors (make it round trip with Muse writer)
36- Org tables
35- Org tables
@@ -178,6 +177,7 @@ blockElements :: PandocMonad m => MuseParser m (F Blocks)
178blockElements = choice [ comment
177blockElements = choice [ comment
179 , separator
178 , separator
180 , header
179 , header
180+ , example
181 , exampleTag
181 , exampleTag
182 , literal
182 , literal
183 , centerTag
183 , centerTag
@@ -222,6 +222,13 @@ header = try $ do
222 attr <- registerHeader ("", [], []) (runF content defaultParserState)
222 attr <- registerHeader ("", [], []) (runF content defaultParserState)
223 return $ B.headerWith attr level <$> content
223 return $ B.headerWith attr level <$> content
224
224
225+example :: PandocMonad m => MuseParser m (F Blocks)
226+example = try $ do
227+ string "{{{"
228+ optionMaybe blankline
229+ contents <- manyTill anyChar $ try (optionMaybe blankline >> string "}}}")
230+ return $ return $ B.codeBlock contents
231+
225exampleTag :: PandocMonad m => MuseParser m (F Blocks)
232exampleTag :: PandocMonad m => MuseParser m (F Blocks)
226exampleTag = do
233exampleTag = do
227 (attr, contents) <- htmlElement "example"
234 (attr, contents) <- htmlElement "example"
test/Tests/Readers/Muse.hs+33
@@ -248,6 +248,39 @@ tests =
248 lineBlock [ "Foo bar" ] <>
248 lineBlock [ "Foo bar" ] <>
249 lineBlock [ "Foo bar" ] <>
249 lineBlock [ "Foo bar" ] <>
250 lineBlock [ "\160\160\160Foo" ]
250 lineBlock [ "\160\160\160Foo" ]
251+ , testGroup "Example"
252+ [ "Braces on separate lines" =:
253+ T.unlines [ "{{{"
254+ , "Example line"
255+ , "}}}"
256+ ] =?>
257+ codeBlock "Example line"
258+ , "Spaces after opening braces" =:
259+ T.unlines [ "{{{ "
260+ , "Example line"
261+ , "}}}"
262+ ] =?>
263+ codeBlock "Example line"
264+ , "One blank line in the beginning" =:
265+ T.unlines [ "{{{"
266+ , ""
267+ , "Example line"
268+ , "}}}"
269+ ] =?>
270+ codeBlock "\nExample line"
271+ , "One blank line in the end" =:
272+ T.unlines [ "{{{"
273+ , "Example line"
274+ , ""
275+ , "}}}"
276+ ] =?>
277+ codeBlock "Example line\n"
278+ -- Amusewiki requires braces to be on separate line,
279+ -- this is an extension.
280+ , "One line" =:
281+ "{{{Example line}}}" =?>
282+ codeBlock "Example line"
283+ ]
251 , testGroup "Example tag"
284 , testGroup "Example tag"
252 [ "Tags on separate lines" =:
285 [ "Tags on separate lines" =:
253 T.unlines [ "<example>"
286 T.unlines [ "<example>"