mirror of
https://github.com/jgm/pandoc.git
synced 2026-09-24 15:44:59 +08:00
Muse writer: escape "]" in image title
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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]"
|
||||
, ""
|
||||
|
||||
Reference in New Issue
Block a user