git.iko.soy/typeable/pandoc
on master help sign in
LaTeX reader: preserve center environment (#6852)

The contents of the `center` environment are put in a `Div` with class `center`.

commit630b1bff2bba436cfba8dcb19845af394aa0dee2 authorIgor Pashev <pashev.igor@gmail.com> dateThu 26 Nov 2020, 22:04 (6 years ago) parent07919e1
3 files changed+40−14
src/Text/Pandoc/Readers/LaTeX.hs+1−1 test/command/latex-center.md+13 test/latex-reader.native+26−13
src/Text/Pandoc/Readers/LaTeX.hs+1−1
@@ -1646,7 +1646,7 @@ environments = M.fromList
16461646 skipopts *> spaces *> optional braced *> spaces *> blocks)
16471647 , ("figure", env "figure" $ skipopts *> figure)
16481648 , ("subfigure", env "subfigure" $ skipopts *> tok *> figure)
1649− , ("center", env "center" blocks)
1649+ , ("center", divWith ("", ["center"], []) <$> env "center" blocks)
16501650 , ("longtable", env "longtable" $
16511651 resetCaption *> simpTable "longtable" False >>= addTableCaption)
16521652 , ("table", env "table" $
test/command/latex-center.mdnew file+13
@@ -0,0 +1,13 @@
1+# `\begin{center}`
2+
3+```
4+% pandoc -f latex -t native
5+\begin{center}
6+Hello
7+\end{center}
8+
9+^D
10+[Div ("",["center"],[])
11+ [Para [Str "Hello"]]]
12+```
13+
test/latex-reader.native+26−13
@@ -1,7 +1,8 @@
11Pandoc (Meta {unMeta = fromList [("author",MetaList [MetaInlines [Str "John",Space,Str "MacFarlane"],MetaInlines [Str "Anonymous"]]),("date",MetaInlines [Str "July",Space,Str "17,",Space,Str "2006"]),("title",MetaInlines [Str "Pandoc",Space,Str "Test",Space,Str "Suite"])]})
22[RawBlock (Format "latex") "\\maketitle"
33,Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "set",Space,Str "of",Space,Str "tests",Space,Str "for",Space,Str "pandoc.",Space,Str "Most",Space,Str "of",Space,Str "them",Space,Str "are",Space,Str "adapted",Space,Str "from",SoftBreak,Str "John",Space,Str "Gruber\8217s",Space,Str "markdown",Space,Str "test",Space,Str "suite."]
4−,HorizontalRule
4+,Div ("",["center"],[])
5+ [HorizontalRule]
56,Header 1 ("headers",[],[]) [Str "Headers"]
67,Header 2 ("level-2-with-an-embedded-link",[],[]) [Str "Level",Space,Str "2",Space,Str "with",Space,Str "an",Space,Link ("",[],[]) [Str "embedded",Space,Str "link"] ("/url","")]
78,Header 3 ("level-3-with-emphasis",[],[]) [Str "Level",Space,Str "3",Space,Str "with",Space,Emph [Str "emphasis"]]
@@ -13,13 +14,15 @@ Pandoc (Meta {unMeta = fromList [("author",MetaList [MetaInlines [Str "John",Spa
1314,Para [Str "with",Space,Str "no",Space,Str "blank",Space,Str "line"]
1415,Header 2 ("level-2",[],[]) [Str "Level",Space,Str "2"]
1516,Para [Str "with",Space,Str "no",Space,Str "blank",Space,Str "line"]
16−,HorizontalRule
17+,Div ("",["center"],[])
18+ [HorizontalRule]
1719,Header 1 ("paragraphs",[],[]) [Str "Paragraphs"]
1820,Para [Str "Here\8217s",Space,Str "a",Space,Str "regular",Space,Str "paragraph."]
1921,Para [Str "In",Space,Str "Markdown",Space,Str "1.0.0",Space,Str "and",Space,Str "earlier.",Space,Str "Version",Space,Str "8.",Space,Str "This",Space,Str "line",Space,Str "turns",Space,Str "into",Space,Str "a",SoftBreak,Str "list",Space,Str "item.",Space,Str "Because",Space,Str "a",Space,Str "hard-wrapped",Space,Str "line",Space,Str "in",Space,Str "the",Space,Str "middle",Space,Str "of",Space,Str "a",Space,Str "paragraph",SoftBreak,Str "looked",Space,Str "like",Space,Str "a",Space,Str "list",Space,Str "item."]
2022,Para [Str "Here\8217s",Space,Str "one",Space,Str "with",Space,Str "a",Space,Str "bullet.",Space,Str "*",Space,Str "criminey."]
2123,Para [Str "There",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "hard",Space,Str "line",Space,Str "break",LineBreak,Str "here."]
22−,HorizontalRule
24+,Div ("",["center"],[])
25+ [HorizontalRule]
2326,Header 1 ("block-quotes",[],[]) [Str "Block",Space,Str "Quotes"]
2427,Para [Str "E-mail",Space,Str "style:"]
2528,BlockQuote
@@ -51,14 +54,16 @@ Pandoc (Meta {unMeta = fromList [("author",MetaList [MetaInlines [Str "John",Spa
5154 ,BlockQuote
5255 [Para [Str "Don\8217t",Space,Str "quote",Space,Str "me."]]]
5356,Para [Str "And",Space,Str "a",Space,Str "following",Space,Str "paragraph."]
54−,HorizontalRule
57+,Div ("",["center"],[])
58+ [HorizontalRule]
5559,Header 1 ("code-blocks",[],[]) [Str "Code",Space,Str "Blocks"]
5660,Para [Str "Code:"]
5761,CodeBlock ("",[],[]) "---- (should be four hyphens)\n\nsub status {\n print \"working\";\n}\n\nthis code block is indented by one tab"
5862,Para [Str "And:"]
5963,CodeBlock ("",[],[]) " this code block is indented by two tabs\n\nThese should not be escaped: \\$ \\\\ \\> \\[ \\{"
6064,Para [Str "this",Space,Str "has",Space,Emph [Str "two",LineBreak,Str "lines"]]
61−,HorizontalRule
65+,Div ("",["center"],[])
66+ [HorizontalRule]
6267,Header 1 ("lists",[],[]) [Str "Lists"]
6368,Header 2 ("unordered",[],[]) [Str "Unordered"]
6469,Para [Str "Asterisks",Space,Str "tight:"]
@@ -179,7 +184,8 @@ Pandoc (Meta {unMeta = fromList [("author",MetaList [MetaInlines [Str "John",Spa
179184,Para [Str "Should",Space,Str "not",Space,Str "be",Space,Str "a",Space,Str "list",Space,Str "item:"]
180185,Para [Str "M.A.",Space,Str "2007"]
181186,Para [Str "B.",Space,Str "Williams"]
182−,HorizontalRule
187+,Div ("",["center"],[])
188+ [HorizontalRule]
183189,Header 1 ("definition-lists",[],[]) [Str "Definition",Space,Str "Lists"]
184190,Para [Str "Tight",Space,Str "using",Space,Str "spaces:"]
185191,DefinitionList
@@ -233,7 +239,8 @@ Pandoc (Meta {unMeta = fromList [("author",MetaList [MetaInlines [Str "John",Spa
233239,Para [Str "Code:"]
234240,CodeBlock ("",[],[]) "<hr />"
235241,Para [Str "Hr\8217s:"]
236−,HorizontalRule
242+,Div ("",["center"],[])
243+ [HorizontalRule]
237244,Header 1 ("inline-markup",[],[]) [Str "Inline",Space,Str "Markup"]
238245,Para [Str "This",Space,Str "is",Space,Emph [Str "emphasized"],Str ",",Space,Str "and",Space,Str "so",Space,Emph [Str "is",Space,Str "this"],Str "."]
239246,Para [Str "This",Space,Str "is",Space,Strong [Str "strong"],Str ",",Space,Str "and",Space,Str "so",Space,Strong [Str "is",Space,Str "this"],Str "."]
@@ -247,7 +254,8 @@ Pandoc (Meta {unMeta = fromList [("author",MetaList [MetaInlines [Str "John",Spa
247254,Para [Str "Superscripts:",Space,Str "a",Superscript [Str "bc"],Str "d",SoftBreak,Str "a",Superscript [Emph [Str "hello"]],Space,Str "a",Superscript [Str "hello",Space,Str "there"],Str "."]
248255,Para [Str "Subscripts:",Space,Str "H",Subscript [Str "2"],Str "O,",Space,Str "H",Subscript [Str "23"],Str "O,",SoftBreak,Str "H",Subscript [Str "many",Space,Str "of",Space,Str "them"],Str "O."]
249256,Para [Str "These",Space,Str "should",Space,Str "not",Space,Str "be",Space,Str "superscripts",Space,Str "or",Space,Str "subscripts,",Space,Str "because",Space,Str "of",Space,Str "the",SoftBreak,Str "unescaped",Space,Str "spaces:",Space,Str "a^b",Space,Str "c^d,",Space,Str "a",Math InlineMath "\\sim",Str "b",SoftBreak,Str "c",Math InlineMath "\\sim",Str "d."]
250−,HorizontalRule
257+,Div ("",["center"],[])
258+ [HorizontalRule]
251259,Header 1 ("smart-quotes-ellipses-dashes",[],[]) [Str "Smart",Space,Str "quotes,",Space,Str "ellipses,",Space,Str "dashes"]
252260,Para [Quoted DoubleQuote [Str "Hello,"],Space,Str "said",Space,Str "the",Space,Str "spider.",Space,Quoted DoubleQuote [Str "\8198",Quoted SingleQuote [Str "Shelob"],Space,Str "is",Space,Str "my",Space,Str "name."]]
253261,Para [Quoted SingleQuote [Str "A"],Str ",",Space,Quoted SingleQuote [Str "B"],Str ",",Space,Str "and",Space,Quoted SingleQuote [Str "C"],Space,Str "are",Space,Str "letters."]
@@ -257,7 +265,8 @@ Pandoc (Meta {unMeta = fromList [("author",MetaList [MetaInlines [Str "John",Spa
257265,Para [Str "Some",Space,Str "dashes:",Space,Str "one\8212two\8212three\8212four\8212five."]
258266,Para [Str "Dashes",Space,Str "between",Space,Str "numbers:",Space,Str "5\8211\&7,",Space,Str "255\8211\&66,",Space,Str "1987\8211\&1999."]
259267,Para [Str "Ellipses\8230and\8230and\8230."]
260−,HorizontalRule
268+,Div ("",["center"],[])
269+ [HorizontalRule]
261270,Header 1 ("latex",[],[]) [Str "LaTeX"]
262271,BulletList
263272 [[Para [Cite [Citation {citationId = "smith.1899", citationPrefix = [], citationSuffix = [Str "22-23"], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 0}] [RawInline (Format "latex") "\\cite[22-23]{smith.1899}"]]]
@@ -315,7 +324,8 @@ Pandoc (Meta {unMeta = fromList [("author",MetaList [MetaInlines [Str "John",Spa
315324 [Plain [Str "Vegetable"]]]])]
316325 (TableFoot ("",[],[])
317326 [])
318−,HorizontalRule
327+,Div ("",["center"],[])
328+ [HorizontalRule]
319329,Header 1 ("special-characters",[],[]) [Str "Special",Space,Str "Characters"]
320330,Para [Str "Here",Space,Str "is",Space,Str "some",Space,Str "unicode:"]
321331,BulletList
@@ -345,7 +355,8 @@ Pandoc (Meta {unMeta = fromList [("author",MetaList [MetaInlines [Str "John",Spa
345355,Para [Str "Bang:",Space,Str "!"]
346356,Para [Str "Plus:",Space,Str "+"]
347357,Para [Str "Minus:",Space,Str "-"]
348−,HorizontalRule
358+,Div ("",["center"],[])
359+ [HorizontalRule]
349360,Header 1 ("links",[],[]) [Str "Links"]
350361,Header 2 ("explicit",[],[]) [Str "Explicit"]
351362,Para [Str "Just",Space,Str "a",Space,Link ("",[],[]) [Str "URL"] ("/url/",""),Str "."]
@@ -386,12 +397,14 @@ Pandoc (Meta {unMeta = fromList [("author",MetaList [MetaInlines [Str "John",Spa
386397 [Para [Str "Blockquoted:",Space,Link ("",[],[]) [Str "http://example.com/"] ("http://example.com/","")]]
387398,Para [Str "Auto-links",Space,Str "should",Space,Str "not",Space,Str "occur",Space,Str "here:",Space,Code ("",[],[]) "<http://example.com/>"]
388399,CodeBlock ("",[],[]) "or here: <http://example.com/>"
389−,HorizontalRule
400+,Div ("",["center"],[])
401+ [HorizontalRule]
390402,Header 1 ("images",[],[]) [Str "Images"]
391403,Para [Str "From",Space,Quoted DoubleQuote [Str "Voyage",Space,Str "dans",Space,Str "la",Space,Str "Lune"],Space,Str "by",Space,Str "Georges",Space,Str "Melies",Space,Str "(1902):"]
392404,Para [Image ("",[],[]) [Str "image"] ("lalune.jpg","")]
393405,Para [Str "Here",Space,Str "is",Space,Str "a",Space,Str "movie",Space,Image ("",[],[]) [Str "image"] ("movie.jpg",""),Space,Str "icon."]
394−,HorizontalRule
406+,Div ("",["center"],[])
407+ [HorizontalRule]
395408,Header 1 ("footnotes",[],[]) [Str "Footnotes"]
396409,Para [Str "Here",Space,Str "is",Space,Str "a",Space,Str "footnote",SoftBreak,Str "reference,",Note [Para [Str "Here",Space,Str "is",Space,Str "the",Space,Str "footnote.",Space,Str "It",Space,Str "can",Space,Str "go",Space,Str "anywhere",Space,Str "after",Space,Str "the",Space,Str "footnote",SoftBreak,Str "reference.",Space,Str "It",Space,Str "need",Space,Str "not",Space,Str "be",Space,Str "placed",Space,Str "at",Space,Str "the",Space,Str "end",Space,Str "of",Space,Str "the",Space,Str "document."]],SoftBreak,Str "and",SoftBreak,Str "another.",Note [Para [Str "Here\8217s",Space,Str "the",Space,Str "long",Space,Str "note.",Space,Str "This",Space,Str "one",Space,Str "contains",Space,Str "multiple",Space,Str "blocks."],Para [Str "Subsequent",Space,Str "blocks",Space,Str "are",Space,Str "indented",Space,Str "to",Space,Str "show",Space,Str "that",Space,Str "they",Space,Str "belong",Space,Str "to",Space,Str "the",SoftBreak,Str "footnote",Space,Str "(as",Space,Str "with",Space,Str "list",Space,Str "items)."],CodeBlock ("",[],[]) " { <code> }",Para [Str "If",Space,Str "you",Space,Str "want,",Space,Str "you",Space,Str "can",Space,Str "indent",Space,Str "every",Space,Str "line,",Space,Str "but",Space,Str "you",Space,Str "can",Space,Str "also",Space,Str "be",Space,Str "lazy",SoftBreak,Str "and",Space,Str "just",Space,Str "indent",Space,Str "the",Space,Str "first",Space,Str "line",Space,Str "of",Space,Str "each",Space,Str "block."]],SoftBreak,Str "This",Space,Str "should",Space,Emph [Str "not"],Space,Str "be",Space,Str "a",Space,Str "footnote",Space,Str "reference,",Space,Str "because",Space,Str "it",Space,Str "contains",SoftBreak,Str "a",Space,Str "space.[^my",Space,Str "note]",Space,Str "Here",Space,Str "is",Space,Str "an",Space,Str "inline",SoftBreak,Str "note.",Note [Para [Str "This",Space,Str "is",Space,Emph [Str "easier"],Space,Str "to",Space,Str "type.",Space,Str "Inline",Space,Str "notes",Space,Str "may",Space,Str "contain",SoftBreak,Link ("",[],[]) [Str "links"] ("http://google.com",""),Space,Str "and",Space,Code ("",[],[]) "]",Space,Str "verbatim",Space,Str "characters,",SoftBreak,Str "as",Space,Str "well",Space,Str "as",Space,Str "[bracketed",Space,Str "text]."]]]
397410,BlockQuote