From b5cc01e9765e37cb8367a00a0b1a6b8af57cc9e5 Mon Sep 17 00:00:00 2001 From: Konstantin Zudov <konstantin@anche.no> Date: Thu, 29 Jan 2015 22:09:35 +0200 Subject: [PATCH 1/2] Do not ommit missing `alt` attribute on `img` tag Fixes #1131 --- src/Text/Pandoc/Writers/HTML.hs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs index 955c1b208..113965568 100644 --- a/src/Text/Pandoc/Writers/HTML.hs +++ b/src/Text/Pandoc/Writers/HTML.hs @@ -785,14 +785,11 @@ inlineToHtml opts inline = then link' else link' ! A.title (toValue tit) (Image txt (s,tit)) | treatAsImage s -> do - let alternate' = stringify txt let attributes = [A.src $ toValue s] ++ (if null tit then [] else [A.title $ toValue tit]) ++ - if null txt - then [] - else [A.alt $ toValue alternate'] + [A.alt $ toValue $ stringify txt] let tag = if writerHtml5 opts then H5.img else H.img return $ foldl (!) tag attributes -- note: null title included, as in Markdown.pl From 92e762c2d63335639f1ddb2df901fac396db74a1 Mon Sep 17 00:00:00 2001 From: Konstantin Zudov <konstantin@anche.no> Date: Thu, 29 Jan 2015 22:36:23 +0200 Subject: [PATCH 2/2] Refactored `if x then [] else y` to `[y | not x]` --- src/Text/Pandoc/Writers/HTML.hs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs index 113965568..e38d66216 100644 --- a/src/Text/Pandoc/Writers/HTML.hs +++ b/src/Text/Pandoc/Writers/HTML.hs @@ -786,18 +786,14 @@ inlineToHtml opts inline = else link' ! A.title (toValue tit) (Image txt (s,tit)) | treatAsImage s -> do let attributes = [A.src $ toValue s] ++ - (if null tit - then [] - else [A.title $ toValue tit]) ++ + [A.title $ toValue tit | not $ null tit] ++ [A.alt $ toValue $ stringify txt] let tag = if writerHtml5 opts then H5.img else H.img return $ foldl (!) tag attributes -- note: null title included, as in Markdown.pl (Image _ (s,tit)) -> do let attributes = [A.src $ toValue s] ++ - (if null tit - then [] - else [A.title $ toValue tit]) + [A.title $ toValue tit | not $ null tit] return $ foldl (!) H5.embed attributes -- note: null title included, as in Markdown.pl (Note contents)