diff options
author | Alexander Krotov <ilabdsf@gmail.com> | 2018-03-20 15:01:53 +0300 |
---|---|---|
committer | Alexander Krotov <ilabdsf@gmail.com> | 2018-03-20 15:01:53 +0300 |
commit | 81afcdfaf808d345cc94facdcf927f87325dfa4e (patch) | |
tree | 5e6d0c094a5522bfcd0ee300133c55f0bc829851 | |
parent | bc0025d944d936ab4f311e10992b7c5802424446 (diff) | |
download | pandoc-81afcdfaf808d345cc94facdcf927f87325dfa4e.tar.gz |
Muse writer: escape "]" in image title
-rw-r--r-- | src/Text/Pandoc/Writers/Muse.hs | 3 | ||||
-rw-r--r-- | test/Tests/Writers/Muse.hs | 1 |
2 files changed, 3 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Writers/Muse.hs b/src/Text/Pandoc/Writers/Muse.hs index b64756f91..8feb277c6 100644 --- a/src/Text/Pandoc/Writers/Muse.hs +++ b/src/Text/Pandoc/Writers/Muse.hs @@ -428,11 +428,12 @@ inlineToMuse (Image attr inlines (source, title)) = do then if null inlines then "" else "[" <> alt <> "]" - else "[" <> text title <> "]" + else "[" <> text (escape title) <> "]" let width = case dimension Width attr of Just (Percent x) | isEnabled Ext_amuse opts -> " " ++ show (round x :: Integer) _ -> "" return $ "[[" <> text (urlEscapeBrackets source ++ width) <> "]" <> title' <> "]" + where escape s = if "]" `isInfixOf` s then escapeString s else conditionalEscapeString s inlineToMuse (Note contents) = do -- add to notes in state notes <- gets stNotes diff --git a/test/Tests/Writers/Muse.hs b/test/Tests/Writers/Muse.hs index 04f6de449..ad7e4f1c4 100644 --- a/test/Tests/Writers/Muse.hs +++ b/test/Tests/Writers/Muse.hs @@ -393,6 +393,7 @@ tests = [ testGroup "block elements" , "image with width" =: imageWith ("", [], [("width", "60%")]) "image.png" "Image" (str "") =?> "[[image.png 60][Image]]" + , "escape brackets in image title" =: image "image.png" "Foo]bar" (str "") =?> "[[image.png][<verbatim>Foo]bar</verbatim>]]" , "note" =: note (plain (text "Foo")) =?> unlines [ "[1]" , "" |