@@ -45,7 +45,7 @@ import Network.HTTP (urlEncode)
4545import Text.Pandoc.Class (PandocMonad)
4646import Text.Pandoc.Definition
4747import Text.Pandoc.Options
48−import Text.Pandoc.Shared (isTightList, linesToPara, substitute)
48+import Text.Pandoc.Shared (isTightList, linesToPara, substitute, capitalize)
4949import Text.Pandoc.Templates (renderTemplate')
5050import Text.Pandoc.Walk (query, walk, walkM)
5151import Text.Pandoc.Writers.HTML (writeHtml5String, tagWithAttributes)
@@ -253,18 +253,34 @@ inlineToNodes opts (Strong xs) = (node STRONG (inlinesToNodes opts xs) :)
253253inlineToNodes opts (Strikeout xs) =
254254 if isEnabled Ext_strikeout opts
255255 then (node (CUSTOM_INLINE "~~" "~~") (inlinesToNodes opts xs) :)
256− else ((node (HTML_INLINE (T.pack "<s>")) [] : inlinesToNodes opts xs ++
257− [node (HTML_INLINE (T.pack "</s>")) []]) ++ )
256+ else if isEnabled Ext_raw_html opts
257+ then ((node (HTML_INLINE (T.pack "<s>")) [] : inlinesToNodes opts xs ++
258+ [node (HTML_INLINE (T.pack "</s>")) []]) ++ )
259+ else (inlinesToNodes opts xs ++)
258260inlineToNodes opts (Superscript xs) =
259− ((node (HTML_INLINE (T.pack "<sup>")) [] : inlinesToNodes opts xs ++
260− [node (HTML_INLINE (T.pack "</sup>")) []]) ++ )
261+ if isEnabled Ext_raw_html opts
262+ then ((node (HTML_INLINE (T.pack "<sup>")) [] : inlinesToNodes opts xs ++
263+ [node (HTML_INLINE (T.pack "</sup>")) []]) ++ )
264+ else case traverse toSuperscriptInline xs of
265+ Nothing ->
266+ ((node (TEXT (T.pack "^(")) [] : inlinesToNodes opts xs ++
267+ [node (TEXT (T.pack ")")) []]) ++ )
268+ Just xs' -> (inlinesToNodes opts xs' ++)
261269inlineToNodes opts (Subscript xs) =
262− ((node (HTML_INLINE (T.pack "<sub>")) [] : inlinesToNodes opts xs ++
263− [node (HTML_INLINE (T.pack "</sub>")) []]) ++ )
270+ if isEnabled Ext_raw_html opts
271+ then ((node (HTML_INLINE (T.pack "<sub>")) [] : inlinesToNodes opts xs ++
272+ [node (HTML_INLINE (T.pack "</sub>")) []]) ++ )
273+ else case traverse toSubscriptInline xs of
274+ Nothing ->
275+ ((node (TEXT (T.pack "_(")) [] : inlinesToNodes opts xs ++
276+ [node (TEXT (T.pack ")")) []]) ++ )
277+ Just xs' -> (inlinesToNodes opts xs' ++)
264278inlineToNodes opts (SmallCaps xs) =
265− ((node (HTML_INLINE (T.pack "<span class=\"smallcaps\">")) []
266− : inlinesToNodes opts xs ++
267− [node (HTML_INLINE (T.pack "</span>")) []]) ++ )
279+ if isEnabled Ext_raw_html opts
280+ then ((node (HTML_INLINE (T.pack "<span class=\"smallcaps\">")) []
281+ : inlinesToNodes opts xs ++
282+ [node (HTML_INLINE (T.pack "</span>")) []]) ++ )
283+ else (inlinesToNodes opts (capitalize xs) ++)
268284inlineToNodes opts (Link _ ils (url,tit)) =
269285 (node (LINK (T.pack url) (T.pack tit)) (inlinesToNodes opts ils) :)
270286-- title beginning with fig: indicates implicit figure
@@ -319,3 +335,19 @@ inlineToNodes opts (Span attr ils) =
319335inlineToNodes opts (Cite _ ils) = (inlinesToNodes opts ils ++)
320336inlineToNodes _ (Note _) = id -- should not occur
321337-- we remove Note elements in preprocessing
338+
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
346+
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