pandoc 3.1 → 3.1.1
raw patch · 44 files changed
+604/−153 lines, 44 filesdep ~commonmark-extensionsdep ~zip-archivePVP ok
version bump matches the API change (PVP)
Dependency ranges changed: commonmark-extensions, zip-archive
API changes (from Hackage documentation)
Files
- AUTHORS.md +4/−0
- MANUAL.txt +14/−23
- README.md +1/−1
- changelog.md +108/−0
- data/templates/default.asciidoc +3/−1
- data/templates/default.asciidoctor +3/−1
- data/templates/default.chunkedhtml +4/−0
- data/templates/default.context +1/−0
- data/templates/default.html4 +3/−0
- data/templates/default.html5 +3/−0
- data/templates/default.latex +6/−0
- man/pandoc.1 +15/−26
- pandoc.cabal +4/−4
- src/Text/Pandoc/CSV.hs +4/−1
- src/Text/Pandoc/Data.hs +2/−1
- src/Text/Pandoc/Readers/DocBook.hs +14/−20
- src/Text/Pandoc/Readers/Docx/Parse.hs +2/−1
- src/Text/Pandoc/Readers/EPUB.hs +2/−1
- src/Text/Pandoc/Readers/HTML/TagCategories.hs +1/−1
- src/Text/Pandoc/Readers/JATS.hs +10/−3
- src/Text/Pandoc/Readers/LaTeX/Table.hs +2/−2
- src/Text/Pandoc/Readers/Org/Blocks.hs +1/−1
- src/Text/Pandoc/Readers/RST.hs +4/−1
- src/Text/Pandoc/Writers/AsciiDoc.hs +13/−7
- src/Text/Pandoc/Writers/ChunkedHTML.hs +2/−10
- src/Text/Pandoc/Writers/JATS.hs +25/−7
- src/Text/Pandoc/Writers/LaTeX/Table.hs +16/−4
- test/Tests/Writers/JATS.hs +3/−1
- test/command/5321.md +2/−10
- test/command/8638.md +20/−0
- test/command/8653.md +23/−0
- test/command/8659.md +54/−0
- test/command/8661.md +9/−0
- test/command/8665.md +29/−0
- test/command/figures-jats.md +17/−0
- test/command/jats-figure-alt-text.md +1/−4
- test/docbook-reader.native +31/−5
- test/docbook-xref.docbook +23/−0
- test/docbook-xref.native +114/−11
- test/writer.context +1/−0
- test/writer.jats_archiving +3/−2
- test/writer.jats_articleauthoring +3/−2
- test/writer.jats_publishing +3/−2
- test/writers-lang-and-dir.context +1/−0
AUTHORS.md view
@@ -242,8 +242,10 @@ - Michael Snoyman - Michael Thompson - Mike Tzou+- Mikołaj Machowski - Milan Bracke - MinRK+- Morgan Willcock - Morton Fox - Nathan Gass - Naveen@@ -271,6 +273,7 @@ - Paul Rivier - Paul Tilley - Paulo Tanimoto+- Pavol Otto - Pete Ryland - Peter Fabinksi - Peter Wang@@ -360,6 +363,7 @@ - Yoan Blanc - Yuchen Pei - Zihang Chen+- arcnmx - a-vrma - andrebauer - black-desk
MANUAL.txt view
@@ -1,7 +1,7 @@ --- title: Pandoc User's Guide author: John MacFarlane-date: February 8, 2023+date: March 5, 2023 --- # Synopsis@@ -1480,9 +1480,8 @@ : Convert TeX math to [MathML] (in `epub3`, `docbook4`, `docbook5`, `jats`, `html4` and `html5`). This is the- default in `odt` output. Note that currently only Firefox- and Safari (and select e-book readers) natively support- MathML.+ default in `odt` output. MathML is supported natively by+ the main web browsers and select e-book readers. `--webtex`[`=`*URL*] @@ -2002,6 +2001,10 @@ | ``` | ``` | +----------------------------------+-----------------------------------+ | ``` | ``` yaml |+| --chunk-template="%i.html" | chunk-template: "%i.html" |+| ``` | ``` |++----------------------------------+-----------------------------------++| ``` | ``` yaml | | --epub-subdirectory="" | epub-subdirectory: '' | | ``` | ``` | +----------------------------------+-----------------------------------+@@ -2905,7 +2908,7 @@ 12pt. To use another size, set `documentclass` to one of the [KOMA-Script] classes, such as `scrartcl` or `scrbook`. -`mainfont`, `sansfont`, `monofont`, `mathfont`, `CJKmainfont`+`mainfont`, `sansfont`, `monofont`, `mathfont`, `CJKmainfont`, `CJKsansfont`, `CJKmonofont` : font families for use with `xelatex` or `lualatex`: take the name of any system font, using the [`fontspec`] package. `CJKmainfont` uses the [`xecjk`] package.@@ -2946,7 +2949,7 @@ : causes links to be printed as footnotes `urlstyle`-: style for URLs (e.g., tt, same)+: style for URLs (e.g., `tt`, `rm`, `sf`, and, the default, `same`) #### Front matter @@ -3071,6 +3074,10 @@ `toc` : include table of contents (can also be set using `--toc/--table-of-contents`)+ +`urlstyle`+: typeface style for links without link text, e.g. `normal`, `bold`, `slanted`, `boldslanted`,+ `type`, `cap`, `small` `whitespace` : spacing between paragraphs, e.g. `none`, `small` (using@@ -6089,23 +6096,7 @@ frubulicious zoosnaps are quantical. For a survey of the literature, see @baz [chap. 1]. -## Raw content in a style -To include raw content in a prefix, suffix, delimiter, or term,-surround it with these tags indicating the format:-- {{jats}}<ref>{{/jats}}--Without the tags, the string will be interpreted as a string-and escaped in the output, rather than being passed through raw.--This feature allows stylesheets to be customized to give-different output for different output formats. However,-stylesheets customized in this way will not be usable-by other CSL implementations.--- ## Placement of the bibliography If the style calls for a list of works cited, it will be placed@@ -6982,7 +6973,7 @@ ```` If you include raw HTML or TeX in an output cell, use the-[raw attribute][Extension: `fenced_attribute`], as shown+[raw attribute](#extension-raw_attribute), as shown in the last cell of the example above. Although pandoc can process "bare" raw HTML and TeX, the result is often interspersed raw elements and normal textual elements, and
README.md view
@@ -255,7 +255,7 @@ ## License -© 2006-2022 John MacFarlane (jgm@berkeley.edu). Released under the+© 2006-2023 John MacFarlane (jgm@berkeley.edu). Released under the [GPL](https://www.gnu.org/licenses/old-licenses/gpl-2.0.html "GNU General Public License"), version 2 or greater. This software carries no warranty of any kind. (See COPYRIGHT for full copyright and warranty notices.)
changelog.md view
@@ -1,5 +1,113 @@ # Revision history for pandoc +## pandoc 3.1.1 (2023-03-05)++ * EPUB reader: Give additional information in error if the epub+ zip container can't be unpacked.++ * TSV reader: don't gobble tabs as whitespace (#8661).++ * Org reader: accept empty tables (#8659).++ * LaTeX reader: fix multiplication syntax for tabular (#8658).+ We recognized `*{6}{...}` but not `*6{...}` or `*6c`.++ * Docx reader: parse image alt texts in LibreOffice generated files.+ LibreOffice tags images slightly differently than Word; this change lets+ the parses take that difference into account when looking for an image+ description (alt text).++ * DocBook reader:++ + Fix `<xref>` references to tables in DocBook files+ (#8626, Pavol Otto).+ + Parse `figure` as a Figure element in the AST (#8668).++ * JATS reader: avoid generating duplicate figure captions (#8669).++ * RST reader: align with spec in syntax for role names (#8653).+ In particular, we now allow colons in row names.++ * Add note on converting from .doc format to FAQs (#8654).++ * Trap error in getAppUserDataDirectory (#8648).+ This can raise an error if pandoc is run in a non-user environment.++ * LaTeX writer: do not use longtable foot with Beamer (#8638, Albert+ Krewinkel). The table foot is made part of the table body, as+ otherwise it won't show up in the output. The root cause for+ this is that longtable cannot detect page breaks in Beamer.+ + * LaTeX template: Add CJKsansfont and CJKmonofont for XeLaTeX+ (#8656, Yudong Jin). `CJKsansfont` and `CJKmonofont` will be+ set for xelatex only if `CJKmainfont` is also provided.++ * URL style in ConTeXt (#8612, Thomas Hodgson). Previously, a+ URL like this would be in monospace text:+ `\useURL[url1][https://example.com]`. Now, it will match the+ main text unless the `linkstyle` variable is set, which+ controls the styling of all links. Closes #8602.++ * Asciidoc writer: Properly escape `|` in table cells (#8665).++ * asciidoc{,tor} template: fix revision date when author is unset+ (#8637, arcnmx). Revision line syntax is only valid in+ combination with an author line, so the date attribute must be+ set explicitly when the author is missing++ * HTML writer: allow "track" element to be treated as block-level HTML+ (#8629).++ * Include needed polyfill when MathJaX is used (#8625).++ * JATS writer: include alt-text in `<graphic>`,+ `<inline-graphic>` elements (#8631, Albert Krewinkel).++ * Chunked HTML writer: Retain metadata in processing sections+ for chunked HTML (#8620). Previously we suppressed metadata+ in all but the top page, in order to prevent the title block+ from being printed on every page. This prevented use of+ custom variables set by metadata fields. This commit moves+ to a better solution: a conditional in the default template+ restricts the title block to the top page.++ * Lua API:++ + Add new function `pandoc.system.cputime` (Albert+ Krewinkel). The function returns the CPU time consumed by+ pandoc and can be used to benchmark Lua computations.+ + Add module `pandoc.json` to handle JSON encoding (#8605,+ Albert Krewinkel).++ * Use pandoc-lua-marshal 0.2.1 (Albert Krewinkel).+ All major AST elements now have `__tojson` metamethods that return the+ JSON representation of an element. This allows to JSON-encode these+ elements with libraries that respect the `__tojson` metamethod,+ including dkjson.++ * Use latest zip-archive. This allows pandoc to open certain+ epubs that it could not open before.++ * Use commonmark-extensions 0.2.3.4. This fixes some bugs involving+ definition lists and inline formatting.++ * Use latest skylighting-format-context++ * MANUAL.txt:++ + Document chunk-template in defaults file.+ + Remove obsolete "raw content in a style" section.+ + Revise documentation for `--mathml` to reflect support in all major+ browsers (#8667).++ * docs/custom-readers.md: Update JSON parsing example. The example now+ uses the built-in `pandoc.json` library to parse the API output.++ * doc/press.md: Add article on CiTO in J Cheminform by @egonw.++ * doc/lua-filters.md: fix typo in `run_json_filter` (Morgan Willcock).++ ## pandoc 3.1 (2023-02-09) * Fix regression with `--print-highlight-style` option (#8586).
data/templates/default.asciidoc view
@@ -2,9 +2,11 @@ = $title$ $if(author)$ $for(author)$$author$$sep$; $endfor$-$endif$ $if(date)$ $date$+$endif$+$elseif(date)$+:revdate: $date$ $endif$ $if(keywords)$ :keywords: $for(keywords)$$keywords$$sep$, $endfor$
data/templates/default.asciidoctor view
@@ -2,9 +2,11 @@ = $title$ $if(author)$ $for(author)$$author$$sep$; $endfor$-$endif$ $if(date)$ $date$+$endif$+$elseif(date)$+:revdate: $date$ $endif$ $if(keywords)$ :keywords: $for(keywords)$$keywords$$sep$, $endfor$
data/templates/default.chunkedhtml view
@@ -63,6 +63,9 @@ </span> </div> </nav>+$if(top)$+$-- only print title block if this is NOT the top page+$else$ $if(title)$ <header id="title-block-header"> <h1 class="title">$title$</h1>@@ -80,6 +83,7 @@ <div class="abstract-title">$abstract-title$</div> $abstract$ </div>+$endif$ $endif$ </header> $endif$
data/templates/default.context view
@@ -23,6 +23,7 @@ style=$linkstyle$, color=$linkcolor$, contrastcolor=$linkcontrastcolor$]+\setupurl[style=$urlstyle$] % make chapter, section bookmarks visible when opening document \placebookmarks[chapter, section, subsection, subsubsection, subsubsubsection, subsubsubsubsection][chapter, section]
data/templates/default.html4 view
@@ -27,6 +27,9 @@ $header-includes$ $endfor$ $if(math)$+$if(mathjax)$+ <script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>+$endif$ $math$ $endif$ </head>
data/templates/default.html5 view
@@ -27,6 +27,9 @@ $header-includes$ $endfor$ $if(math)$+$if(mathjax)$+ <script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>+$endif$ $math$ $endif$ <!--[if lt IE 9]>
data/templates/default.latex view
@@ -162,6 +162,12 @@ \ifXeTeX \usepackage{xeCJK} \setCJKmainfont[$for(CJKoptions)$$CJKoptions$$sep$,$endfor$]{$CJKmainfont$}+ $if(CJKsansfont)$+ \setCJKsansfont[$for(CJKoptions)$$CJKoptions$$sep$,$endfor$]{$CJKsansfont$}+ $endif$+ $if(CJKmonofont)$+ \setCJKmonofont[$for(CJKoptions)$$CJKoptions$$sep$,$endfor$]{$CJKmonofont$}+ $endif$ \fi $endif$ $if(luatexjapresetoptions)$
man/pandoc.1 view
@@ -14,7 +14,7 @@ . ftr VB CB . ftr VBI CBI .\}-.TH "Pandoc User\[cq]s Guide" "" "February 8, 2023" "pandoc 3.1" ""+.TH "Pandoc User\[cq]s Guide" "" "March 5, 2023" "pandoc 3.1.1" "" .hy .SH NAME pandoc - general markup converter@@ -1593,8 +1593,8 @@ \f[V]docbook5\f[R], \f[V]jats\f[R], \f[V]html4\f[R] and \f[V]html5\f[R]). This is the default in \f[V]odt\f[R] output.-Note that currently only Firefox and Safari (and select e-book readers)-natively support MathML.+MathML is supported natively by the main web browsers and select e-book+readers. .TP \f[V]--webtex\f[R][\f[V]=\f[R]\f[I]URL\f[R]] Convert TeX formulas to \f[V]<img>\f[R] tags that link to an external@@ -2020,6 +2020,8 @@ --split-level 2 split-level: 2 + --chunk-template=\[dq]%i.html\[dq] chunk-template: \[dq]%i.html\[dq] + --epub-subdirectory=\[dq]\[dq] epub-subdirectory: \[aq]\[aq] --ipynb-output best ipynb-output: best @@ -3000,7 +3002,7 @@ To use another size, set \f[V]documentclass\f[R] to one of the KOMA-Script classes, such as \f[V]scrartcl\f[R] or \f[V]scrbook\f[R]. .TP-\f[V]mainfont\f[R], \f[V]sansfont\f[R], \f[V]monofont\f[R], \f[V]mathfont\f[R], \f[V]CJKmainfont\f[R]+\f[V]mainfont\f[R], \f[V]sansfont\f[R], \f[V]monofont\f[R], \f[V]mathfont\f[R], \f[V]CJKmainfont\f[R], \f[V]CJKsansfont\f[R], \f[V]CJKmonofont\f[R] font families for use with \f[V]xelatex\f[R] or \f[V]lualatex\f[R]: take the name of any system font, using the \f[V]fontspec\f[R] package. \f[V]CJKmainfont\f[R] uses the \f[V]xecjk\f[R] package.@@ -3050,7 +3052,8 @@ causes links to be printed as footnotes .TP \f[V]urlstyle\f[R]-style for URLs (e.g., tt, same)+style for URLs (e.g., \f[V]tt\f[R], \f[V]rm\f[R], \f[V]sf\f[R], and, the+default, \f[V]same\f[R]) .SS Front matter .TP \f[V]lof\f[R], \f[V]lot\f[R]@@ -3170,6 +3173,11 @@ include table of contents (can also be set using \f[V]--toc/--table-of-contents\f[R]) .TP+\f[V]urlstyle\f[R]+typeface style for links without link text, e.g.\ \f[V]normal\f[R],+\f[V]bold\f[R], \f[V]slanted\f[R], \f[V]boldslanted\f[R],+\f[V]type\f[R], \f[V]cap\f[R], \f[V]small\f[R]+.TP \f[V]whitespace\f[R] spacing between paragraphs, e.g.\ \f[V]none\f[R], \f[V]small\f[R] (using \f[V]setupwhitespace\f[R])@@ -6835,24 +6843,6 @@ of the literature, see \[at]baz [chap. 1]. \f[R] .fi-.SS Raw content in a style-.PP-To include raw content in a prefix, suffix, delimiter, or term, surround-it with these tags indicating the format:-.IP-.nf-\f[C]-{{jats}}<ref>{{/jats}}-\f[R]-.fi-.PP-Without the tags, the string will be interpreted as a string and escaped-in the output, rather than being passed through raw.-.PP-This feature allows stylesheets to be customized to give different-output for different output formats.-However, stylesheets customized in this way will not be usable by other-CSL implementations. .SS Placement of the bibliography .PP If the style calls for a list of works cited, it will be placed in a div@@ -7879,9 +7869,8 @@ \f[R] .fi .PP-If you include raw HTML or TeX in an output cell, use the [raw-attribute][Extension: \f[V]fenced_attribute\f[R]], as shown in the last-cell of the example above.+If you include raw HTML or TeX in an output cell, use the raw attribute,+as shown in the last cell of the example above. Although pandoc can process \[lq]bare\[rq] raw HTML and TeX, the result is often interspersed raw elements and normal textual elements, and in an output cell pandoc expects a single, connected raw block.
pandoc.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.4 name: pandoc-version: 3.1+version: 3.1.1 build-type: Simple license: GPL-2.0-or-later license-file: COPYING.md@@ -473,7 +473,7 @@ case-insensitive >= 1.2 && < 1.3, citeproc >= 0.8.1 && < 0.9, commonmark >= 0.2.2 && < 0.3,- commonmark-extensions >= 0.2.3.3 && < 0.3,+ commonmark-extensions >= 0.2.3.4 && < 0.3, commonmark-pandoc >= 0.2.1.3 && < 0.3, connection >= 0.3.1, containers >= 0.6.0.1 && < 0.7,@@ -519,7 +519,7 @@ unicode-collation >= 0.1.1 && < 0.2, unicode-transforms >= 0.3 && < 0.5, yaml >= 0.11 && < 0.12,- zip-archive >= 0.2.3.4 && < 0.5,+ zip-archive >= 0.4.3 && < 0.5, zlib >= 0.5 && < 0.7, xml >= 1.3.12 && < 1.4 @@ -761,7 +761,7 @@ text >= 1.1.1.0 && < 2.1, time >= 1.5 && < 1.14, xml >= 1.3.12 && < 1.4,- zip-archive >= 0.2.3.4 && < 0.5+ zip-archive >= 0.4.3 && < 0.5 other-modules: Tests.Old Tests.Command Tests.Helpers
src/Text/Pandoc/CSV.hs view
@@ -80,7 +80,10 @@ pCSVDelim :: CSVOptions -> Parser () pCSVDelim opts = do char (csvDelim opts)- unless (csvKeepSpace opts) $ skipMany (oneOf " \t")+ let sp = case csvDelim opts of+ '\t' -> char ' '+ _ -> oneOf " \t"+ unless (csvKeepSpace opts) $ skipMany sp endline :: Parser () endline = do
src/Text/Pandoc/Data.hs view
@@ -239,8 +239,9 @@ defaultUserDataDir = do xdgDir <- E.catch (getXdgDirectory XdgData "pandoc") (\(_ :: E.SomeException) -> return mempty)- legacyDir <- getAppUserDataDirectory "pandoc" xdgExists <- doesDirectoryExist xdgDir+ legacyDir <- E.catch (getAppUserDataDirectory "pandoc")+ (\(_ :: E.SomeException) -> return mempty) legacyDirExists <- doesDirectoryExist legacyDir if not xdgExists && legacyDirExists then return legacyDir
src/Text/Pandoc/Readers/DocBook.hs view
@@ -541,8 +541,6 @@ , dbQuoteType :: QuoteType , dbMeta :: Meta , dbBook :: Bool- , dbFigureTitle :: Inlines- , dbFigureId :: Text , dbContent :: [Content] } deriving Show @@ -551,8 +549,6 @@ , dbQuoteType = DoubleQuote , dbMeta = mempty , dbBook = False- , dbFigureTitle = mempty- , dbFigureId = mempty , dbContent = [] } @@ -589,11 +585,15 @@ tit <- case filterChild (named "title") e of Just t -> getInlines t Nothing -> return mempty- let ident = attrValue "id" e- modify $ \st -> st{ dbFigureTitle = tit, dbFigureId = ident }- res <- getBlocks e- modify $ \st -> st{ dbFigureTitle = mempty, dbFigureId = mempty }- return res+ contents <- getBlocks e+ let contents' =+ case toList contents of+ [Para [img@Image{}]] -> plain (fromList [img])+ _ -> contents+ return $ figureWith+ (attrValue "id" e, [], [])+ (simpleCaption $ plain tit)+ contents' -- convenience function to get an attribute value, defaulting to "" attrValue :: Text -> Element -> Text@@ -803,8 +803,6 @@ -- A DocBook mediaobject is a wrapper around a set of alternative presentations getMediaobject :: PandocMonad m => Element -> DB m Inlines getMediaobject e = do- figTitle <- gets dbFigureTitle- ident <- gets dbFigureId let (imageUrl, tit, attr) = case filterElements (named "imageobject") e of [] -> (mempty, mempty, nullAttr)@@ -822,23 +820,18 @@ h = case atVal "depth" of "" -> [] d -> [("height", d)]- id' = case atVal "id" of- x | T.null x -> ident- | otherwise -> x+ id' = atVal "id" cs = T.words $ atVal "role" atr = (id', cs, w ++ h) in (atVal "fileref", atr) in (imageUrl', tit', attr')- let getCaption el = case filterChild (\x -> named "caption" x+ let capt = case filterChild (\x -> named "caption" x || named "textobject" x- || named "alt" x) el of+ || named "alt" x) e of Nothing -> return mempty Just z -> trimInlines . mconcat <$> mapM parseInline (elContent z)- let (capt, title) = if null figTitle- then (getCaption e, tit)- else (return figTitle, "fig:" <> tit)- fmap (imageWith attr imageUrl title) capt+ fmap (imageWith attr imageUrl tit) capt getBlocks :: PandocMonad m => Element -> DB m Blocks getBlocks e = mconcat <$>@@ -1359,6 +1352,7 @@ "cmdsynopsis" -> descendantContent "command" el "funcsynopsis" -> descendantContent "function" el "figure" -> descendantContent "title" el+ "table" -> descendantContent "title" el _ -> qName (elName el) <> "_title" where xrefLabel = attrValue "xreflabel" el
src/Text/Pandoc/Readers/Docx/Parse.hs view
@@ -810,7 +810,8 @@ getTitleAndAlt :: NameSpaces -> Element -> (T.Text, T.Text) getTitleAndAlt ns element =- let mbDocPr = findChildByName ns "wp" "inline" element >>=+ let mbDocPr = (findChildByName ns "wp" "inline" element <|> -- Word+ findChildByName ns "wp" "anchor" element) >>= -- LibreOffice findChildByName ns "wp" "docPr" title = fromMaybe "" (mbDocPr >>= findAttrByName ns "" "title") alt = fromMaybe "" (mbDocPr >>= findAttrByName ns "" "descr")
src/Text/Pandoc/Readers/EPUB.hs view
@@ -51,7 +51,8 @@ readEPUB :: PandocMonad m => ReaderOptions -> BL.ByteString -> m Pandoc readEPUB opts bytes = case toArchiveOrFail bytes of Right archive -> archiveToEPUB opts archive- Left _ -> throwError $ PandocParseError "Couldn't extract ePub file"+ Left e -> throwError $ PandocParseError $+ "Couldn't extract ePub file: " <> T.pack e -- runEPUB :: Except PandocError a -> Either PandocError a -- runEPUB = runExcept
src/Text/Pandoc/Readers/HTML/TagCategories.hs view
@@ -28,7 +28,7 @@ eitherBlockOrInline = fromList ["audio", "applet", "button", "iframe", "embed", "del", "ins", "progress", "map", "area", "noscript", "script",- "object", "svg", "video", "source"]+ "object", "svg", "video", "source", "track"] blockHtmlTags :: Set Text blockHtmlTags = fromList
src/Text/Pandoc/Readers/JATS.hs view
@@ -47,6 +47,7 @@ , jatsBook :: Bool , jatsFootnotes :: Map.Map Text Blocks , jatsContent :: [Content]+ , jatsInFigure :: Bool } deriving Show instance Default JATSState where@@ -55,7 +56,8 @@ , jatsMeta = mempty , jatsBook = False , jatsFootnotes = mempty- , jatsContent = [] }+ , jatsContent = []+ , jatsInFigure = False } readJATS :: (PandocMonad m, ToSources a)@@ -188,7 +190,11 @@ <$> getBlocks e "table-wrap" -> divWith (attrValue "id" e, ["table-wrap"], []) <$> getBlocks e- "caption" -> divWith (attrValue "id" e, ["caption"], []) <$> sect 6+ "caption" -> do+ inFigure <- gets jatsInFigure+ if inFigure -- handled by parseFigure+ then return mempty+ else divWith (attrValue "id" e, ["caption"], []) <$> sect 6 "fn-group" -> parseFootnoteGroup "ref-list" -> parseRefList e "?xml" -> return mempty@@ -232,12 +238,13 @@ items' <- mapM getBlocks items return (mconcat $ intersperse (str "; ") terms', items') parseFigure = do+ modify $ \st -> st{ jatsInFigure = True } capt <- case filterChild (named "caption") e of Just t -> mconcat . intersperse linebreak <$> mapM getInlines (filterChildren (const True) t) Nothing -> return mempty contents <- getBlocks e-+ modify $ \st -> st{ jatsInFigure = False } return $ figureWith (attrValue "id" e, [], []) (simpleCaption $ plain capt)
src/Text/Pandoc/Readers/LaTeX/Table.hs view
@@ -106,9 +106,9 @@ let starAlign = do -- '*{2}{r}' == 'rr', we just expand like a macro symbol '*' spaces- ds <- trim . untokenize <$> braced+ ds <- trim . untokenize <$> bracedOrToken spaces- spec <- braced+ spec <- bracedOrToken case safeRead ds of Just n -> do TokStream _ ts <- getInput
src/Text/Pandoc/Readers/Org/Blocks.hs view
@@ -685,7 +685,7 @@ tableContentRow :: PandocMonad m => OrgParser m OrgTableRow tableContentRow = try $- OrgContentRow . sequence <$> (tableStart *> many1Till tableContentCell newline)+ OrgContentRow . sequence <$> (tableStart *> manyTill tableContentCell newline) tableContentCell :: PandocMonad m => OrgParser m (F Blocks) tableContentCell = try $
src/Text/Pandoc/Readers/RST.hs view
@@ -1480,8 +1480,11 @@ removeSpace (x:xs) = x : map headSpace xs removeSpace [] = [] +-- single words consisting of alphanumerics plus isolated (no two adjacent)+-- internal hyphens, underscores, periods, colons and plus signs;+-- no whitespace or other characters are allowed roleName :: PandocMonad m => RSTParser m Text-roleName = many1Char (letter <|> char '-')+roleName = many1Char (alphaNum <|> try (oneOf "-_.:+" <* lookAhead alphaNum)) roleMarker :: PandocMonad m => RSTParser m Text roleMarker = char ':' *> roleName <* char ':'
src/Text/Pandoc/Writers/AsciiDoc.hs view
@@ -109,13 +109,19 @@ Just tpl -> renderTemplate tpl context -- | Escape special characters for AsciiDoc.-escapeString :: Text -> Text-escapeString t- | T.any (== '{') t = T.concatMap escChar t- | otherwise = t- where escChar '{' = "\\{"- escChar c = T.singleton c+escapeString :: PandocMonad m => Text -> ADW m (Doc Text)+escapeString t = do+ parentTableLevel <- gets tableNestingLevel+ let needsEscape '{' = True+ needsEscape '|' = parentTableLevel > 0+ needsEscape _ = False+ let escChar c | needsEscape c = "\\" <> T.singleton c+ | otherwise = T.singleton c+ if T.any needsEscape t+ then return $ literal $ T.concatMap escChar t+ else return $ literal t + -- | Ordered list start parser for use in Para below. olMarker :: Parsec Text ParserState Char olMarker = do (start, style', delim) <- anyOrderedListMarker@@ -538,7 +544,7 @@ if isAsciidoctor then text "`+" <> contents <> "+`" else text "`" <> contents <> "`"-inlineToAsciiDoc _ (Str str) = return $ literal $ escapeString str+inlineToAsciiDoc _ (Str str) = escapeString str inlineToAsciiDoc _ (Math InlineMath str) = do isAsciidoctor <- gets asciidoctorVariant modify $ \st -> st{ hasMath = True }
src/Text/Pandoc/Writers/ChunkedHTML.hs view
@@ -1,10 +1,4 @@-{-# LANGUAGE LambdaCase #-}-{-# LANGUAGE BangPatterns #-}-{-# LANGUAGE MultiWayIf #-} {-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE ScopedTypeVariables #-}-{-# LANGUAGE TypeApplications #-}-{-# LANGUAGE ViewPatterns #-} {- | Module : Text.Pandoc.Writers.ChunkedHTML Copyright : Copyright (C) 2023 John MacFarlane@@ -45,6 +39,7 @@ import System.FilePath (isRelative, normalise) import Data.List (isInfixOf) import Text.Pandoc.Walk (walkM)+import Text.Pandoc.Builder (setMeta) -- | Splits document into HTML chunks, dividing them by section, -- and returns a zip archive of a folder of files.@@ -126,10 +121,7 @@ where opts' = opts{ writerVariables = addContextVars opts' topChunk chunk $ writerVariables opts }- meta' = if chunk == topChunk- then meta- else Meta $ M.fromList [("pagetitle", MetaString- (stringify $ chunkHeading chunk))]+ meta' = setMeta "pagetitle" (MetaString (stringify $ chunkHeading chunk)) meta blocks = chunkContents chunk tocTreeToContext :: Tree SecInfo -> Context Text
src/Text/Pandoc/Writers/JATS.hs view
@@ -351,11 +351,16 @@ blockToJATS _ HorizontalRule = return empty -- not semantic blockToJATS opts (Table attr caption colspecs thead tbody tfoot) = tableToJATS opts (Ann.toTable attr caption colspecs thead tbody tfoot)-blockToJATS opts (Figure (ident, _, kvs) caption body) = do- capt <- case caption of- Caption _ [] -> pure empty- Caption _ cpt -> inTagsSimple "caption" <$> blocksToJATS opts cpt- figbod <- blocksToJATS opts body+blockToJATS opts (Figure (ident, _, kvs) (Caption _short longcapt) body) = do+ -- Remove the alt text from images if it's the same as the caption text.+ let unsetAltIfDupl = \case+ Image attr alt tgt+ | stringify alt == stringify longcapt -> Image attr [] tgt+ inline -> inline+ capt <- if null longcapt+ then pure empty+ else inTagsSimple "caption" <$> blocksToJATS opts longcapt+ figbod <- blocksToJATS opts $ walk unsetAltIfDupl body let figattr = [("id", escapeNCName ident) | not (T.null ident)] ++ [(k,v) | (k,v) <- kvs , k `elem` [ "fig-type", "orientation"@@ -520,11 +525,17 @@ contents <- inlinesToJATS opts txt return $ inTags False "ext-link" attr contents inlineToJATS _ (Image attr alt tgt) = do- return $ selfClosingTag "inline-graphic" (graphicAttr attr alt tgt)+ let elattr = graphicAttr attr alt tgt+ return $ case altToJATS alt of+ Nothing -> selfClosingTag "inline-graphic" elattr+ Just altTag -> inTags True "inline-graphic" elattr altTag graphic :: Attr -> [Inline] -> Target -> (Doc Text) graphic attr alt tgt =- selfClosingTag "graphic" (graphicAttr attr alt tgt)+ let elattr = graphicAttr attr alt tgt+ in case altToJATS alt of+ Nothing -> selfClosingTag "graphic" elattr+ Just altTag -> inTags True "graphic" elattr altTag graphicAttr :: Attr -> [Inline] -> Target -> [(Text, Text)] graphicAttr (ident, _, kvs) _alt (src, tit) =@@ -540,6 +551,13 @@ , "xlink:actuate", "xlink:href", "xlink:role" , "xlink:show", "xlink:type"] ]++altToJATS :: [Inline] -> Maybe (Doc Text)+altToJATS alt =+ if null alt+ then Nothing+ else Just . inTagsSimple "alt-text" .+ hsep . map literal . T.words $ stringify alt imageMimeType :: Text -> [(Text, Text)] -> (Text, Text) imageMimeType src kvs =
src/Text/Pandoc/Writers/LaTeX/Table.hs view
@@ -76,16 +76,28 @@ pure $ "\\midrule\\noalign{}" $$ vcat lastfoot modify $ \s -> s{ stTable = True } notes <- notesToLaTeX <$> gets stNotes+ beamer <- gets stBeamer return $ "\\begin{longtable}[]" <> braces ("@{}" <> colDescriptors tbl <> "@{}") -- the @{} removes extra space at beginning and end $$ head' $$ "\\endhead"- $$ foot'- $$ "\\bottomrule\\noalign{}"- $$ "\\endlastfoot"- $$ vcat rows'+ $$ vcat+ -- Longtable is not able to detect pagebreaks in Beamer; this+ -- causes problems with the placement of the footer, so make+ -- footer and bottom rule part of the body when targeting Beamer.+ -- See issue #8638.+ (if beamer+ then [ vcat rows'+ , foot'+ , "\\bottomrule\\noalign{}"+ ]+ else [ foot'+ , "\\bottomrule\\noalign{}"+ , "\\endlastfoot"+ , vcat rows'+ ]) $$ "\\end{longtable}" $$ captNotes $$ notes
test/Tests/Writers/JATS.hs view
@@ -134,7 +134,9 @@ , "containing image" =: header 1 (image "imgs/foo.jpg" "" (text "Alt text")) =?> "<sec>\n\- \ <title><inline-graphic mimetype=\"image\" mime-subtype=\"jpeg\" xlink:href=\"imgs/foo.jpg\" /></title>\n\+ \ <title><inline-graphic mimetype=\"image\" mime-subtype=\"jpeg\" xlink:href=\"imgs/foo.jpg\">\n\+ \ <alt-text>Alt text</alt-text>\n\+ \ </inline-graphic></title>\n\ \</sec>" ]
test/command/5321.md view
@@ -10,10 +10,7 @@ [ Figure ( "fig-1" , [] , [] ) (Caption Nothing [ Plain [ Str "bar" ] ])- [ Div- ( "" , [ "caption" ] , [] )- [ Header 6 ( "" , [] , [] ) [] , Para [ Str "bar" ] ]- , Para+ [ Para [ Image ( "" , [] , [] ) [ Str "baz" ] ( "foo.png" , "" ) ] ] ]@@ -33,12 +30,7 @@ ( "fig-1" , [] , [] ) (Caption Nothing [ Plain [ Str "foo" , LineBreak , Str "bar" ] ])- [ Div- ( "" , [ "caption" ] , [] )- [ Header 6 ( "" , [] , [] ) [ Str "foo" ]- , Para [ Str "bar" ]- ]- , Para+ [ Para [ Image ( "" , [] , [] ) [ Str "baz" ] ( "foo.png" , "" ) ] ] ]
+ test/command/8638.md view
@@ -0,0 +1,20 @@+# Beamer tables must not use longtable footer+```+% pandoc -t beamer+| fruit | price |+|---------|------:|+| apple | 2.05 |+| oranges | 4.25 |+^D+\begin{frame}+\begin{longtable}[]{@{}lr@{}}+\toprule\noalign{}+fruit & price \\+\midrule\noalign{}+\endhead+apple & 2.05 \\+oranges & 4.25 \\+\bottomrule\noalign{}+\end{longtable}+\end{frame}+```
+ test/command/8653.md view
@@ -0,0 +1,23 @@+```+% pandoc -f rst -t native+.. role:: py:class(emphasis)++:py:class:`foo`+^D+[ Para [ Emph [ Str "foo" ] ] ]+```++```+% pandoc -f rst -t native+:py:class:`foo`+^D+[ Para+ [ Code+ ( ""+ , [ "interpreted-text" ]+ , [ ( "role" , "py:class" ) ]+ )+ "foo"+ ]+]+```
+ test/command/8659.md view
@@ -0,0 +1,54 @@+# A single pipe is parsed as an empty table+```+% pandoc -f org -t html+|+^D+<table>+<tbody>+<tr class="odd">+</tr>+</tbody>+</table>+```+# Accepts an empty org table within a grid table cell++The misaligned pipe in the first row is treated as an empty table.++```+% pandoc -f org -t html++-----+-----+-----+-----------++| | | | |++:====+=====+====:+==========:++| a | b | c | d |++-----+-----+-----+-----------++^D+<table style="width:42%;">+<colgroup>+<col style="width: 8%" />+<col style="width: 8%" />+<col style="width: 8%" />+<col style="width: 16%" />+</colgroup>+<thead>+<tr class="header">+<th style="text-align: left;"></th>+<th></th>+<th style="text-align: right;"></th>+<th style="text-align: right;"><table>+<tbody>+<tr class="odd">+</tr>+</tbody>+</table></th>+</tr>+</thead>+<tbody>+<tr class="odd">+<td style="text-align: left;">a</td>+<td>b</td>+<td style="text-align: right;">c</td>+<td style="text-align: right;">d</td>+</tr>+</tbody>+</table>+```
+ test/command/8661.md view
@@ -0,0 +1,9 @@+```+% pandoc -f tsv -t gfm+a b c+ 6+^D+| a | b | c |+|-----|-----|-----|+| | | 6 |+```
+ test/command/8665.md view
@@ -0,0 +1,29 @@+```+% pandoc -f docbook -t asciidoctor+<informaltable frame="all" rowsep="1" colsep="1">+ <tgroup cols="1">+ <thead>+ <row>+ <entry align="left" valign="top">h1</entry>+ <entry align="left" valign="top">h2</entry>+ </row>+ </thead>+ <tbody>+ <row>+ <entry align="left" valign="top">+ <simpara>!@#$%^&*(){}|~?+-',."<>[]\`</simpara>+ </entry>+ <entry align="left" valign="top">+ <simpara>col 2</simpara>+ </entry>+ </row>+ </tbody>+ </tgroup>+</informaltable>+^D+[cols=",",options="header",]+|===+|h1 |h2+|!@#$%^&*()\{}\|~?+-',."<>[]\` |col 2+|===+```
test/command/figures-jats.md view
@@ -12,3 +12,20 @@ <graphic id="fig-id-2" mimetype="image" mime-subtype="png" xlink:href="foo.png" xlink:title="fig:" /> </fig> ```++Figure float with caption and alt text.++```+% pandoc -f native -t jats+[Figure ("fig-id",[],[]) (Caption Nothing [Para [Str "Caption"]]) [Para [Str "Text"],+Para [Image ("fig-id-2",[],[]) [Str "alt"] ("foo.png", "fig:")]]]++^D+<fig id="fig-id">+ <caption><p>Caption</p></caption>+ <p>Text</p>+ <graphic id="fig-id-2" mimetype="image" mime-subtype="png" xlink:href="foo.png" xlink:title="fig:">+ <alt-text>alt</alt-text>+ </graphic>+</fig>+```
test/command/jats-figure-alt-text.md view
@@ -11,10 +11,7 @@ [ Figure ( "fig-1" , [] , [] ) (Caption Nothing [ Plain [ Str "bar" ] ])- [ Div- ( "" , [ "caption" ] , [] )- [ Header 6 ( "" , [] , [] ) [] , Para [ Str "bar" ] ]- , Plain [ Str "alternative-decription" ]+ [ Plain [ Str "alternative-decription" ] , Para [ Image ( "" , [] , [] ) [ Str "baz" ] ( "foo.png" , "" ) ] ]
test/docbook-reader.native view
@@ -1565,11 +1565,37 @@ , Space , Str "(1902):" ]- , Para- [ Image- ( "" , [] , [] )- [ Str "lalune" , Space , Str "fig" , Space , Str "caption" ]- ( "lalune.jpg" , "fig:" )+ , Figure+ ( "" , [] , [] )+ (Caption+ Nothing+ [ Plain+ [ Str "lalune"+ , Space+ , Str "fig"+ , Space+ , Str "caption"+ ]+ ])+ [ Plain+ [ Image+ ( "" , [] , [] )+ [ Str "lalune"+ , Space+ , Str "alt"+ , Space+ , Str "text"+ , Space+ , Str "shadowed"+ , Space+ , Str "by"+ , Space+ , Str "fig"+ , Space+ , Str "caption"+ ]+ ( "lalune.jpg" , "" )+ ] ] , Para [ Str "Here"
test/docbook-xref.docbook view
@@ -27,6 +27,9 @@ <listitem><para>A link to a <sgmltag>figure</sgmltag> element: <xref linkend="fig01"/>. </para></listitem>+<listitem><para>A link to a+<sgmltag>table</sgmltag> element: <xref linkend="table01"/>.+</para></listitem> </itemizedlist> </chapter> @@ -76,6 +79,26 @@ <textobject><phrase>An illustration of the Pythagorean Theorem</phrase></textobject> </mediaobject> </figure>++<table id="table01" frame="all" rowsep="1" colsep="1">+ <title>Supported features by version</title>+ <tgroup cols="2">+ <colspec colname="col_1" colwidth="50*"/>+ <colspec colname="col_2" colwidth="50*"/>+ <thead>+ <row>+ <entry>Version</entry>+ <entry>Feat</entry>+ </row>+ </thead>+ <tbody>+ <row>+ <entry>Free</entry>+ <entry>no</entry>+ </row>+ </tbody>+ </tgroup>+</table> </chapter> </book>
test/docbook-xref.native view
@@ -168,6 +168,33 @@ , Str "." ] ]+ , [ Para+ [ Str "A"+ , Space+ , Str "link"+ , Space+ , Str "to"+ , Space+ , Str "a"+ , SoftBreak+ , Str "table"+ , Space+ , Str "element:"+ , Space+ , Link+ ( "" , [] , [] )+ [ Str "Supported"+ , Space+ , Str "features"+ , Space+ , Str "by"+ , Space+ , Str "version"+ ]+ ( "#table01" , "" )+ , Str "."+ ]+ ] ] , Header 1@@ -201,17 +228,93 @@ , Plain [ Str "int1" ] , Plain [ Str "int" ] , Plain [ Str "int2" ]- , Para- [ Image- ( "fig01" , [] , [] )- [ Str "The"- , Space- , Str "Pythagorean"- , Space- , Str "Theorem"- , Space- , Str "Illustrated"+ , Figure+ ( "fig01" , [] , [] )+ (Caption+ Nothing+ [ Plain+ [ Str "The"+ , Space+ , Str "Pythagorean"+ , Space+ , Str "Theorem"+ , Space+ , Str "Illustrated"+ ]+ ])+ [ Plain+ [ Image+ ( "" , [] , [] )+ [ Str "An"+ , Space+ , Str "illustration"+ , Space+ , Str "of"+ , Space+ , Str "the"+ , Space+ , Str "Pythagorean"+ , Space+ , Str "Theorem"+ ]+ ( "figures/pythag.png" , "" ) ]- ( "figures/pythag.png" , "fig:" ) ]+ , Table+ ( "" , [] , [] )+ (Caption+ Nothing+ [ Plain+ [ Str "Supported"+ , Space+ , Str "features"+ , Space+ , Str "by"+ , Space+ , Str "version"+ ]+ ])+ [ ( AlignDefault , ColWidth 0.5 )+ , ( AlignDefault , ColWidth 0.5 )+ ]+ (TableHead+ ( "" , [] , [] )+ [ Row+ ( "" , [] , [] )+ [ Cell+ ( "" , [] , [] )+ AlignDefault+ (RowSpan 1)+ (ColSpan 1)+ [ Plain [ Str "Version" ] ]+ , Cell+ ( "" , [] , [] )+ AlignDefault+ (RowSpan 1)+ (ColSpan 1)+ [ Plain [ Str "Feat" ] ]+ ]+ ])+ [ TableBody+ ( "" , [] , [] )+ (RowHeadColumns 0)+ []+ [ Row+ ( "" , [] , [] )+ [ Cell+ ( "" , [] , [] )+ AlignDefault+ (RowSpan 1)+ (ColSpan 1)+ [ Plain [ Str "Free" ] ]+ , Cell+ ( "" , [] , [] )+ AlignDefault+ (RowSpan 1)+ (ColSpan 1)+ [ Plain [ Str "no" ] ]+ ]+ ]+ ]+ (TableFoot ( "" , [] , [] ) []) ]
test/writer.context view
@@ -6,6 +6,7 @@ style=, color=, contrastcolor=]+\setupurl[style=] % make chapter, section bookmarks visible when opening document \placebookmarks[chapter, section, subsection, subsubsection, subsubsubsection, subsubsubsubsection][chapter, section]
test/writer.jats_archiving view
@@ -845,8 +845,9 @@ <graphic mimetype="image" mime-subtype="jpeg" xlink:href="lalune.jpg" xlink:title="Voyage dans la Lune" /> </fig> <p>Here is a movie- <inline-graphic mimetype="image" mime-subtype="jpeg" xlink:href="movie.jpg" />- icon.</p>+ <inline-graphic mimetype="image" mime-subtype="jpeg" xlink:href="movie.jpg">+ <alt-text>movie</alt-text>+ </inline-graphic> icon.</p> </sec> <sec id="footnotes"> <title>Footnotes</title>
test/writer.jats_articleauthoring view
@@ -830,8 +830,9 @@ <graphic mimetype="image" mime-subtype="jpeg" xlink:href="lalune.jpg" xlink:title="Voyage dans la Lune" /> </fig> <p>Here is a movie- <inline-graphic mimetype="image" mime-subtype="jpeg" xlink:href="movie.jpg" />- icon.</p>+ <inline-graphic mimetype="image" mime-subtype="jpeg" xlink:href="movie.jpg">+ <alt-text>movie</alt-text>+ </inline-graphic> icon.</p> </sec> <sec id="footnotes"> <title>Footnotes</title>
test/writer.jats_publishing view
@@ -845,8 +845,9 @@ <graphic mimetype="image" mime-subtype="jpeg" xlink:href="lalune.jpg" xlink:title="Voyage dans la Lune" /> </fig> <p>Here is a movie- <inline-graphic mimetype="image" mime-subtype="jpeg" xlink:href="movie.jpg" />- icon.</p>+ <inline-graphic mimetype="image" mime-subtype="jpeg" xlink:href="movie.jpg">+ <alt-text>movie</alt-text>+ </inline-graphic> icon.</p> </sec> <sec id="footnotes"> <title>Footnotes</title>
test/writers-lang-and-dir.context view
@@ -4,6 +4,7 @@ style=, color=, contrastcolor=]+\setupurl[style=] % make chapter, section bookmarks visible when opening document \placebookmarks[chapter, section, subsection, subsubsection, subsubsubsection, subsubsubsubsection][chapter, section]