@@ -345,6 +345,11 @@ fixNotes (Space : n@Note{} : rest) = Str " " : n : fixNotes rest
345345fixNotes (SoftBreak : n@Note{} : rest) = Str " " : n : fixNotes rest
346346fixNotes (x:xs) = x : fixNotes xs
347347
348+urlEscapeBrackets :: String -> String
349+urlEscapeBrackets (']':xs) = '%':'5':'D':urlEscapeBrackets xs
350+urlEscapeBrackets (x:xs) = x:urlEscapeBrackets xs
351+urlEscapeBrackets [] = []
352+
348353-- | Convert list of Pandoc inline elements to Muse.
349354inlineListToMuse :: PandocMonad m
350355 => [Inline]
@@ -402,7 +407,7 @@ inlineToMuse (Link _ txt (src, _)) =
402407 return $ "[[" <> text (escapeLink x) <> "]]"
403408 _ -> do contents <- inlineListToMuse txt
404409 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
406411 -- Taken from muse-image-regexp defined in Emacs Muse file lisp/muse-regexps.el
407412 imageExtensions = [".eps", ".gif", ".jpg", ".jpeg", ".pbm", ".png", ".tiff", ".xbm", ".xpm"]
408413 isImageUrl = (`elem` imageExtensions) . takeExtension
@@ -419,7 +424,7 @@ inlineToMuse (Image attr inlines (source, title)) = do
419424 let width = case dimension Width attr of
420425 Just (Percent x) | isEnabled Ext_amuse opts -> " " ++ show (round x :: Integer)
421426 _ -> ""
422− return $ "[[" <> text (source ++ width) <> "]" <> title' <> "]"
427+ return $ "[[" <> text (urlEscapeBrackets source ++ width) <> "]" <> title' <> "]"
423428inlineToMuse (Note contents) = do
424429 -- add to notes in state
425430 notes <- gets stNotes