Texinfo writer: use @sup and @sub instead of custom macros

Fixes #4728
This commit is contained in:
Alexander Krotov 2018-06-25 03:14:04 +03:00
parent dda3882348
commit ebf4ed8944
3 changed files with 5 additions and 54 deletions

View file

@ -9,28 +9,6 @@ $if(strikeout)$
~~\text\~~
@end macro
$endif$
$if(subscript)$
@macro textsubscript{text}
@iftex
@textsubscript{\text\}
@end iftex
@ifnottex
_@{\text\@}
@end ifnottex
@end macro
$endif$
$if(superscript)$
@macro textsuperscript{text}
@iftex
@textsuperscript{\text\}
@end iftex
@ifnottex
^@{\text\@}
@end ifnottex
@end macro
$endif$
@ifnottex
@paragraphindent 0

View file

@ -56,8 +56,6 @@ import Text.Printf (printf)
data WriterState =
WriterState { stStrikeout :: Bool -- document contains strikeout
, stSuperscript :: Bool -- document contains superscript
, stSubscript :: Bool -- document contains subscript
, stEscapeComma :: Bool -- in a context where we need @comma
, stIdentifiers :: Set.Set String -- header ids used already
, stOptions :: WriterOptions -- writer options
@ -74,8 +72,7 @@ type TI m = StateT WriterState m
writeTexinfo :: PandocMonad m => WriterOptions -> Pandoc -> m Text
writeTexinfo options document =
evalStateT (pandocToTexinfo options $ wrapTop document)
WriterState { stStrikeout = False, stSuperscript = False,
stEscapeComma = False, stSubscript = False,
WriterState { stStrikeout = False, stEscapeComma = False,
stIdentifiers = Set.empty, stOptions = options}
-- | Add a "Top" node around the document, needed by Texinfo.
@ -102,8 +99,6 @@ pandocToTexinfo options (Pandoc meta blocks) = do
let context = defField "body" body
$ defField "toc" (writerTableOfContents options)
$ defField "titlepage" titlePage
$ defField "subscript" (stSubscript st)
$ defField "superscript" (stSuperscript st)
$
defField "strikeout" (stStrikeout st) metadata
case writerTemplate options of
@ -427,14 +422,12 @@ inlineToTexinfo (Strikeout lst) = do
return $ text "@textstrikeout{" <> contents <> text "}"
inlineToTexinfo (Superscript lst) = do
modify $ \st -> st{ stSuperscript = True }
contents <- inlineListToTexinfo lst
return $ text "@textsuperscript{" <> contents <> char '}'
return $ text "@sup{" <> contents <> char '}'
inlineToTexinfo (Subscript lst) = do
modify $ \st -> st{ stSubscript = True }
contents <- inlineListToTexinfo lst
return $ text "@textsubscript{" <> contents <> char '}'
return $ text "@sub{" <> contents <> char '}'
inlineToTexinfo (SmallCaps lst) =
inlineListToTexinfo lst >>= return . inCmd "sc"

View file

@ -5,24 +5,6 @@
~~\text\~~
@end macro
@macro textsubscript{text}
@iftex
@textsubscript{\text\}
@end iftex
@ifnottex
_@{\text\@}
@end ifnottex
@end macro
@macro textsuperscript{text}
@iftex
@textsuperscript{\text\}
@end iftex
@ifnottex
^@{\text\@}
@end ifnottex
@end macro
@ifnottex
@paragraphindent 0
@end ifnottex
@ -738,11 +720,9 @@ This is code: @code{>}, @code{$}, @code{\}, @code{\$}, @code{<html>}.
@textstrikeout{This is @emph{strikeout}.}
Superscripts: a@textsuperscript{bc}d a@textsuperscript{@emph{hello}}
a@textsuperscript{hello@ there}.
Superscripts: a@sup{bc}d a@sup{@emph{hello}} a@sup{hello@ there}.
Subscripts: H@textsubscript{2}O, H@textsubscript{23}O,
H@textsubscript{many@ of@ them}O.
Subscripts: H@sub{2}O, H@sub{23}O, H@sub{many@ of@ them}O.
These should not be superscripts or subscripts, because of the unescaped
spaces: a^b c^d, a~b c~d.