git.iko.soy/typeable/pandoc
on master help sign in
Muse writer: escape "]" in image title
commit81afcdfaf808d345cc94facdcf927f87325dfa4e authorAlexander Krotov <ilabdsf@gmail.com> dateTue 20 Mar 2018, 15:01 (9 years ago) parentbc0025d
2 files changed+3−1
src/Text/Pandoc/Writers/Muse.hs+2−1 test/Tests/Writers/Muse.hs+1
src/Text/Pandoc/Writers/Muse.hs+2−1
@@ -428,11 +428,12 @@ inlineToMuse (Image attr inlines (source, title)) = do
428428 then if null inlines
429429 then ""
430430 else "[" <> alt <> "]"
431− else "[" <> text title <> "]"
431+ else "[" <> text (escape title) <> "]"
432432 let width = case dimension Width attr of
433433 Just (Percent x) | isEnabled Ext_amuse opts -> " " ++ show (round x :: Integer)
434434 _ -> ""
435435 return $ "[[" <> text (urlEscapeBrackets source ++ width) <> "]" <> title' <> "]"
436+ where escape s = if "]" `isInfixOf` s then escapeString s else conditionalEscapeString s
436437inlineToMuse (Note contents) = do
437438 -- add to notes in state
438439 notes <- gets stNotes
test/Tests/Writers/Muse.hs+1
@@ -393,6 +393,7 @@ tests = [ testGroup "block elements"
393393 , "image with width" =:
394394 imageWith ("", [], [("width", "60%")]) "image.png" "Image" (str "") =?>
395395 "[[image.png 60][Image]]"
396+ , "escape brackets in image title" =: image "image.png" "Foo]bar" (str "") =?> "[[image.png][<verbatim>Foo]bar</verbatim>]]"
396397 , "note" =: note (plain (text "Foo"))
397398 =?> unlines [ "[1]"
398399 , ""