Muse writer: add support for left-align and right-align classes
Address issue #4542
This commit is contained in:
parent
621e864023
commit
5879923422
2 changed files with 14 additions and 2 deletions
|
@ -511,7 +511,7 @@ inlineToMuse (Link _ txt (src, _)) =
|
||||||
isImageUrl = (`elem` imageExtensions) . takeExtension
|
isImageUrl = (`elem` imageExtensions) . takeExtension
|
||||||
inlineToMuse (Image attr alt (source,'f':'i':'g':':':title)) =
|
inlineToMuse (Image attr alt (source,'f':'i':'g':':':title)) =
|
||||||
inlineToMuse (Image attr alt (source,title))
|
inlineToMuse (Image attr alt (source,title))
|
||||||
inlineToMuse (Image attr inlines (source, title)) = do
|
inlineToMuse (Image attr@(_, classes, _) inlines (source, title)) = do
|
||||||
opts <- asks envOptions
|
opts <- asks envOptions
|
||||||
alt <- local (\env -> env { envInsideLinkDescription = True }) $ inlineListToMuse inlines
|
alt <- local (\env -> env { envInsideLinkDescription = True }) $ inlineListToMuse inlines
|
||||||
let title' = if null title
|
let title' = if null title
|
||||||
|
@ -522,7 +522,13 @@ inlineToMuse (Image attr inlines (source, title)) = do
|
||||||
let width = case dimension Width attr of
|
let width = case dimension Width attr of
|
||||||
Just (Percent x) | isEnabled Ext_amuse opts -> " " ++ show (round x :: Integer)
|
Just (Percent x) | isEnabled Ext_amuse opts -> " " ++ show (round x :: Integer)
|
||||||
_ -> ""
|
_ -> ""
|
||||||
return $ "[[" <> text (urlEscapeBrackets source ++ width) <> "]" <> title' <> "]"
|
let leftalign = if "align-left" `elem` classes
|
||||||
|
then " l"
|
||||||
|
else ""
|
||||||
|
let rightalign = if "align-right" `elem` classes
|
||||||
|
then " r"
|
||||||
|
else ""
|
||||||
|
return $ "[[" <> text (urlEscapeBrackets source ++ width ++ leftalign ++ rightalign) <> "]" <> title' <> "]"
|
||||||
inlineToMuse (Note contents) = do
|
inlineToMuse (Note contents) = do
|
||||||
-- add to notes in state
|
-- add to notes in state
|
||||||
notes <- gets stNotes
|
notes <- gets stNotes
|
||||||
|
|
|
@ -425,6 +425,12 @@ tests = [ testGroup "block elements"
|
||||||
, "image with width" =:
|
, "image with width" =:
|
||||||
imageWith ("", [], [("width", "60%")]) "image.png" "Image" (str "") =?>
|
imageWith ("", [], [("width", "60%")]) "image.png" "Image" (str "") =?>
|
||||||
"[[image.png 60][Image]]"
|
"[[image.png 60][Image]]"
|
||||||
|
, "left-aligned image with width" =:
|
||||||
|
imageWith ("", ["align-left"], [("width", "60%")]) "image.png" "Image" (str "") =?>
|
||||||
|
"[[image.png 60 l][Image]]"
|
||||||
|
, "right-aligned image with width" =:
|
||||||
|
imageWith ("", ["align-right"], [("width", "60%")]) "image.png" "Image" (str "") =?>
|
||||||
|
"[[image.png 60 r][Image]]"
|
||||||
, "escape brackets in image title" =: image "image.png" "Foo]bar" (str "") =?> "[[image.png][<verbatim>Foo]bar</verbatim>]]"
|
, "escape brackets in image title" =: image "image.png" "Foo]bar" (str "") =?> "[[image.png][<verbatim>Foo]bar</verbatim>]]"
|
||||||
, "note" =: note (plain (text "Foo"))
|
, "note" =: note (plain (text "Foo"))
|
||||||
=?> unlines [ "[1]"
|
=?> unlines [ "[1]"
|
||||||
|
|
Loading…
Add table
Reference in a new issue