@@ -345,6 +345,11 @@ fixNotes (Space : n@Note{} : rest) = Str " " : n : fixNotes rest
345fixNotes (SoftBreak : n@Note{} : rest) = Str " " : n : fixNotes rest
345fixNotes (SoftBreak : n@Note{} : rest) = Str " " : n : fixNotes rest
346fixNotes (x:xs) = x : fixNotes xs
346fixNotes (x:xs) = x : fixNotes xs
348+urlEscapeBrackets :: String -> String
349+urlEscapeBrackets (']':xs) = '%':'5':'D':urlEscapeBrackets xs
350+urlEscapeBrackets (x:xs) = x:urlEscapeBrackets xs
351+urlEscapeBrackets [] = []
348-- | Convert list of Pandoc inline elements to Muse.
353-- | Convert list of Pandoc inline elements to Muse.
349inlineListToMuse :: PandocMonad m
354inlineListToMuse :: PandocMonad m
350 => [Inline]
355 => [Inline]
@@ -402,7 +407,7 @@ inlineToMuse (Link _ txt (src, _)) =
402 return $ "[[" <> text (escapeLink x) <> "]]"
407 return $ "[[" <> text (escapeLink x) <> "]]"
403 _ -> do contents <- inlineListToMuse txt
408 _ -> do contents <- inlineListToMuse txt
404 return $ "[[" <> text (escapeLink src) <> "][" <> contents <> "]]"
409 return $ "[[" <> text (escapeLink src) <> "][" <> contents <> "]]"
405− where escapeLink lnk = if isImageUrl lnk then "URL:" ++ lnk else lnk
410+ where escapeLink lnk = if isImageUrl lnk then "URL:" ++ urlEscapeBrackets lnk else urlEscapeBrackets lnk
406 -- Taken from muse-image-regexp defined in Emacs Muse file lisp/muse-regexps.el
411 -- Taken from muse-image-regexp defined in Emacs Muse file lisp/muse-regexps.el
407 imageExtensions = [".eps", ".gif", ".jpg", ".jpeg", ".pbm", ".png", ".tiff", ".xbm", ".xpm"]
412 imageExtensions = [".eps", ".gif", ".jpg", ".jpeg", ".pbm", ".png", ".tiff", ".xbm", ".xpm"]
408 isImageUrl = (`elem` imageExtensions) . takeExtension
413 isImageUrl = (`elem` imageExtensions) . takeExtension
@@ -419,7 +424,7 @@ inlineToMuse (Image attr inlines (source, title)) = do
419 let width = case dimension Width attr of
424 let width = case dimension Width attr of
420 Just (Percent x) | isEnabled Ext_amuse opts -> " " ++ show (round x :: Integer)
425 Just (Percent x) | isEnabled Ext_amuse opts -> " " ++ show (round x :: Integer)
422− return $ "[[" <> text (source ++ width) <> "]" <> title' <> "]"
427+ return $ "[[" <> text (urlEscapeBrackets source ++ width) <> "]" <> title' <> "]"
423inlineToMuse (Note contents) = do
428inlineToMuse (Note contents) = do
424 -- add to notes in state
429 -- add to notes in state
425 notes <- gets stNotes
430 notes <- gets stNotes