aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Krotov <ilabdsf@gmail.com>2018-06-25 03:14:04 +0300
committerAlexander Krotov <ilabdsf@gmail.com>2018-06-25 03:14:04 +0300
commitebf4ed89440d459684e2becad06a34ac3cdba7d5 (patch)
tree25e2d3d0213067593fba2e131cae66abcc124b76
parentdda38823482c1c803771c88d93e15e4fa7a65ece (diff)
downloadpandoc-ebf4ed89440d459684e2becad06a34ac3cdba7d5.tar.gz
Texinfo writer: use @sup and @sub instead of custom macros
Fixes #4728
-rw-r--r--data/templates/default.texinfo22
-rw-r--r--src/Text/Pandoc/Writers/Texinfo.hs13
-rw-r--r--test/writer.texinfo24
3 files changed, 5 insertions, 54 deletions
diff --git a/data/templates/default.texinfo b/data/templates/default.texinfo
index 458d4fdda..693827810 100644
--- a/data/templates/default.texinfo
+++ b/data/templates/default.texinfo
@@ -10,28 +10,6 @@ $if(strikeout)$
@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
@end ifnottex
diff --git a/src/Text/Pandoc/Writers/Texinfo.hs b/src/Text/Pandoc/Writers/Texinfo.hs
index 305b41206..9c73eb9ca 100644
--- a/src/Text/Pandoc/Writers/Texinfo.hs
+++ b/src/Text/Pandoc/Writers/Texinfo.hs
@@ -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"
diff --git a/test/writer.texinfo b/test/writer.texinfo
index f5727d96d..ebc0447ee 100644
--- a/test/writer.texinfo
+++ b/test/writer.texinfo
@@ -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.