aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Writers/HTML.hs
diff options
context:
space:
mode:
authorAmogh Rathore <amoghdroid09@gmail.com>2019-11-05 01:42:30 +0900
committerJohn MacFarlane <jgm@berkeley.edu>2019-11-04 08:42:30 -0800
commitbd2bd9b19d949f59a64358f756bf8b398a13db0f (patch)
treea266e1c6ae9a0d183695bd82e9cd5a89e12d8970 /src/Text/Pandoc/Writers/HTML.hs
parentfdc0f47519d330bcc641eeaee68486431d3c46a5 (diff)
downloadpandoc-bd2bd9b19d949f59a64358f756bf8b398a13db0f.tar.gz
HTML Reader/Writer - Add support for <var> and <samp> (#5861)
Closes #5799
Diffstat (limited to 'src/Text/Pandoc/Writers/HTML.hs')
-rw-r--r--src/Text/Pandoc/Writers/HTML.hs21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs
index 86dcb5a43..783aaa8fd 100644
--- a/src/Text/Pandoc/Writers/HTML.hs
+++ b/src/Text/Pandoc/Writers/HTML.hs
@@ -31,7 +31,7 @@ module Text.Pandoc.Writers.HTML (
) where
import Control.Monad.State.Strict
import Data.Char (ord, toLower)
-import Data.List (intercalate, intersperse, isPrefixOf, partition)
+import Data.List (intercalate, intersperse, isPrefixOf, partition, delete)
import Data.List.Split (splitWhen)
import Data.Maybe (fromMaybe, isJust, isNothing, mapMaybe)
import qualified Data.Set as Set
@@ -1023,20 +1023,29 @@ inlineToHtml opts inline = do
(Emph lst) -> inlineListToHtml opts lst >>= return . H.em
(Strong lst) -> inlineListToHtml opts lst >>= return . H.strong
- (Code attr str) -> case hlCode of
+ (Code attr@(ids,cs,kvs) str)
+ -> case hlCode of
Left msg -> do
unless (null msg) $
report $ CouldNotHighlight msg
- addAttrs opts attr $ H.code $ strToHtml str
+ addAttrs opts (ids,cs',kvs) $
+ maybe H.code id sampOrVar $
+ strToHtml str
Right h -> do
modify $ \st -> st{ stHighlighting = True }
- addAttrs opts (id',[],keyvals) h
- where (id',_,keyvals) = attr
- hlCode = if isJust (writerHighlightStyle opts)
+ addAttrs opts (ids,[],kvs) $
+ maybe id id sampOrVar $ h
+ where hlCode = if isJust (writerHighlightStyle opts)
then highlight
(writerSyntaxMap opts)
formatHtmlInline attr str
else Left ""
+ (sampOrVar,cs') =
+ if "sample" `elem` cs
+ then (Just H.samp,"sample" `delete` cs)
+ else if "variable" `elem` cs
+ then (Just H.var,"variable" `delete` cs)
+ else (Nothing,cs)
(Strikeout lst) -> inlineListToHtml opts lst >>=
return . H.del
(SmallCaps lst) -> inlineListToHtml opts lst >>=