@@ -45,7 +45,7 @@ import Network.HTTP (urlEncode)
45import Text.Pandoc.Class (PandocMonad)
45import Text.Pandoc.Class (PandocMonad)
46import Text.Pandoc.Definition
46import Text.Pandoc.Definition
47import Text.Pandoc.Options
47import Text.Pandoc.Options
48−import Text.Pandoc.Shared (isTightList, linesToPara, substitute)
48+import Text.Pandoc.Shared (isTightList, linesToPara, substitute, capitalize)
49import Text.Pandoc.Templates (renderTemplate')
49import Text.Pandoc.Templates (renderTemplate')
50import Text.Pandoc.Walk (query, walk, walkM)
50import Text.Pandoc.Walk (query, walk, walkM)
51import Text.Pandoc.Writers.HTML (writeHtml5String, tagWithAttributes)
51import Text.Pandoc.Writers.HTML (writeHtml5String, tagWithAttributes)
@@ -253,18 +253,34 @@ inlineToNodes opts (Strong xs) = (node STRONG (inlinesToNodes opts xs) :)
253inlineToNodes opts (Strikeout xs) =
253inlineToNodes opts (Strikeout xs) =
254 if isEnabled Ext_strikeout opts
254 if isEnabled Ext_strikeout opts
255 then (node (CUSTOM_INLINE "~~" "~~") (inlinesToNodes opts xs) :)
255 then (node (CUSTOM_INLINE "~~" "~~") (inlinesToNodes opts xs) :)
256+ else if isEnabled Ext_raw_html opts
256− else ((node (HTML_INLINE (T.pack "<s>")) [] : inlinesToNodes opts xs ++
257+ then ((node (HTML_INLINE (T.pack "<s>")) [] : inlinesToNodes opts xs ++
257− [node (HTML_INLINE (T.pack "</s>")) []]) ++ )
258+ [node (HTML_INLINE (T.pack "</s>")) []]) ++ )
259+ else (inlinesToNodes opts xs ++)
258inlineToNodes opts (Superscript xs) =
260inlineToNodes opts (Superscript xs) =
261+ if isEnabled Ext_raw_html opts
259− ((node (HTML_INLINE (T.pack "<sup>")) [] : inlinesToNodes opts xs ++
262+ then ((node (HTML_INLINE (T.pack "<sup>")) [] : inlinesToNodes opts xs ++
260− [node (HTML_INLINE (T.pack "</sup>")) []]) ++ )
263+ [node (HTML_INLINE (T.pack "</sup>")) []]) ++ )
264+ else case traverse toSuperscriptInline xs of
266+ ((node (TEXT (T.pack "^(")) [] : inlinesToNodes opts xs ++
267+ [node (TEXT (T.pack ")")) []]) ++ )
268+ Just xs' -> (inlinesToNodes opts xs' ++)
261inlineToNodes opts (Subscript xs) =
269inlineToNodes opts (Subscript xs) =
270+ if isEnabled Ext_raw_html opts
262− ((node (HTML_INLINE (T.pack "<sub>")) [] : inlinesToNodes opts xs ++
271+ then ((node (HTML_INLINE (T.pack "<sub>")) [] : inlinesToNodes opts xs ++
263− [node (HTML_INLINE (T.pack "</sub>")) []]) ++ )
272+ [node (HTML_INLINE (T.pack "</sub>")) []]) ++ )
273+ else case traverse toSubscriptInline xs of
275+ ((node (TEXT (T.pack "_(")) [] : inlinesToNodes opts xs ++
276+ [node (TEXT (T.pack ")")) []]) ++ )
277+ Just xs' -> (inlinesToNodes opts xs' ++)
264inlineToNodes opts (SmallCaps xs) =
278inlineToNodes opts (SmallCaps xs) =
279+ if isEnabled Ext_raw_html opts
265− ((node (HTML_INLINE (T.pack "<span class=\"smallcaps\">")) []
280+ then ((node (HTML_INLINE (T.pack "<span class=\"smallcaps\">")) []
266− : inlinesToNodes opts xs ++
281+ : inlinesToNodes opts xs ++
267− [node (HTML_INLINE (T.pack "</span>")) []]) ++ )
282+ [node (HTML_INLINE (T.pack "</span>")) []]) ++ )
283+ else (inlinesToNodes opts (capitalize xs) ++)
268inlineToNodes opts (Link _ ils (url,tit)) =
284inlineToNodes opts (Link _ ils (url,tit)) =
269 (node (LINK (T.pack url) (T.pack tit)) (inlinesToNodes opts ils) :)
285 (node (LINK (T.pack url) (T.pack tit)) (inlinesToNodes opts ils) :)
270-- title beginning with fig: indicates implicit figure
286-- title beginning with fig: indicates implicit figure
@@ -319,3 +335,19 @@ inlineToNodes opts (Span attr ils) =
319inlineToNodes opts (Cite _ ils) = (inlinesToNodes opts ils ++)
335inlineToNodes opts (Cite _ ils) = (inlinesToNodes opts ils ++)
320inlineToNodes _ (Note _) = id -- should not occur
336inlineToNodes _ (Note _) = id -- should not occur
321-- we remove Note elements in preprocessing
337-- we remove Note elements in preprocessing
339+toSubscriptInline :: Inline -> Maybe Inline
340+toSubscriptInline Space = Just Space
341+toSubscriptInline (Span attr ils) = Span attr <$> traverse toSubscriptInline ils
342+toSubscriptInline (Str s) = Str <$> traverse toSubscript s
343+toSubscriptInline LineBreak = Just LineBreak
344+toSubscriptInline SoftBreak = Just SoftBreak
345+toSubscriptInline _ = Nothing
347+toSuperscriptInline :: Inline -> Maybe Inline
348+toSuperscriptInline Space = Just Space
349+toSuperscriptInline (Span attr ils) = Span attr <$> traverse toSuperscriptInline ils
350+toSuperscriptInline (Str s) = Str <$> traverse toSuperscript s
351+toSuperscriptInline LineBreak = Just LineBreak
352+toSuperscriptInline SoftBreak = Just SoftBreak
353+toSuperscriptInline _ = Nothing