pandoc 2.14.0.1 → 2.14.0.2
raw patch · 33 files changed
+393/−185 lines, 33 filesdep ~citeprocPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: citeproc
API changes (from Hackage documentation)
Files
- CONTRIBUTING.md +6/−5
- MANUAL.txt +18/−12
- changelog.md +111/−0
- man/pandoc.1 +19/−12
- pandoc.cabal +2/−2
- src/Text/Pandoc/Citeproc.hs +5/−3
- src/Text/Pandoc/Class/IO.hs +21/−21
- src/Text/Pandoc/Class/PandocMonad.hs +6/−11
- src/Text/Pandoc/Lua/Module/Utils.hs +1/−1
- src/Text/Pandoc/MIME.hs +10/−0
- src/Text/Pandoc/MediaBag.hs +14/−11
- src/Text/Pandoc/PDF.hs +16/−3
- src/Text/Pandoc/Readers/DocBook.hs +2/−1
- src/Text/Pandoc/Readers/Docx/Parse.hs +11/−5
- src/Text/Pandoc/Readers/LaTeX.hs +4/−2
- src/Text/Pandoc/Readers/Markdown.hs +1/−1
- src/Text/Pandoc/Writers/Docbook.hs +1/−2
- src/Text/Pandoc/Writers/Docx/Table.hs +2/−2
- src/Text/Pandoc/Writers/HTML.hs +4/−3
- src/Text/Pandoc/Writers/LaTeX/Table.hs +10/−3
- src/Text/Pandoc/Writers/Markdown.hs +12/−35
- src/Text/Pandoc/Writers/Markdown/Inline.hs +15/−11
- stack.yaml +1/−1
- test/Tests/Writers/Docbook.hs +6/−6
- test/command/5367.md +6/−2
- test/command/7340.md +6/−0
- test/command/7376.md +16/−0
- test/command/pandoc-citeproc-356.md +2/−7
- test/pipe-tables.native +2/−10
- test/tables.latex +27/−3
- test/tables/nordics.latex +22/−4
- test/tables/planets.latex +4/−4
- test/tables/students.latex +10/−2
CONTRIBUTING.md view
@@ -406,11 +406,11 @@ tree automatically. - `Text.Pandoc.Readers.*` are the readers, and `Text.Pandoc.Writers.*` are the writers.- - `Text.Pandoc.Biblio` is a utility module for formatting citations- using citeproc-hs.+ - `Text.Pandoc.Citeproc.*` contain the code for citation handling,+ including an interface to the [citeproc] library. - `Text.Pandoc.Data` is used to embed data files when the `embed_data_files`- cabal flag is used. It is generated from `src/Text/Pandoc/Data.hsb` using- the preprocessor [hsb2hs].+ cabal flag is used.+ - `Text.Pandoc.Emoji` is a thin wrapper around [emojis]. - `Text.Pandoc.Highlighting` contains the interface to the skylighting library, which is used for code syntax highlighting. - `Text.Pandoc.ImageSize` is a utility module containing functions for@@ -421,7 +421,6 @@ - `Text.Pandoc.PDF` contains functions for producing a PDF from a LaTeX source. - `Text.Pandoc.Parsing` contains parsing functions used in multiple readers.- - `Text.Pandoc.Pretty` is a pretty-printing library specialized to the needs of pandoc. - `Text.Pandoc.SelfContained` contains functions for making an HTML file "self-contained," by importing remotely linked images, CSS,@@ -456,6 +455,8 @@ [EditorConfig]: https://editorconfig.org/ [Haskell platform]: https://www.haskell.org/platform/ [hlint]: https://hackage.haskell.org/package/hlint+[citeproc]: https://hackage.haskell.org/package/citeproc+[emojis]: https://hackage.haskell.org/package/emojis [hsb2hs]: https://hackage.haskell.org/package/hsb2hs [pre-commit hook]: https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks [GitHub labels]: https://github.com/jgm/pandoc/labels
MANUAL.txt view
@@ -1,7 +1,7 @@ --- title: Pandoc User's Guide author: John MacFarlane-date: May 31, 2021+date: June 11, 2021 --- # Synopsis@@ -675,12 +675,12 @@ : Extract images and other media contained in or linked from the source document to the path *DIR*, creating it if necessary, and adjust the images references in the document- so they point to the extracted files. If the source format is- a binary container (docx, epub, or odt), the media is- extracted from the container and the original- filenames are used. Otherwise the media is read from the- file system or downloaded, and new filenames are constructed- based on SHA1 hashes of the contents.+ so they point to the extracted files. Media are downloaded,+ read from the file system, or extracted from a binary+ container (e.g. docx), as needed. The original file paths+ are used if they are relative paths not containing `..`.+ Otherwise filenames are constructed from the SHA1 hash of+ the contents. `--abbreviations=`*FILE* @@ -1415,13 +1415,12 @@ `--gladtex` : Enclose TeX math in `<eq>` tags in HTML output. The resulting HTML- can then be processed by [GladTeX] to produce images of the typeset- formulas and an HTML file with links to these images.- So, the procedure is:+ can then be processed by [GladTeX] to produce SVG images of the typeset+ formulas and an HTML file with these images embedded. pandoc -s --gladtex input.md -o myfile.htex- gladtex -d myfile-images myfile.htex- # produces myfile.html and images in myfile-images+ gladtex -d image_dir myfile.htex+ # produces myfile.html and images in image_dir [MathML]: https://www.w3.org/Math/ [MathJax]: https://www.mathjax.org@@ -4199,6 +4198,12 @@ It consists of two paragraphs. ... +The literal block after the `|` must be indented relative to the+line containing the `|`. If it is not, the YAML will be invalid+and pandoc will not interpret it as metadata. For an overview+of the complex rules governing YAML, see the [Wikipedia entry on+YAML syntax].+ Template variables will be set automatically from the metadata. Thus, for example, in writing HTML, the variable `abstract` will be set to the HTML equivalent of the Markdown in the `abstract` field:@@ -4261,6 +4266,7 @@ if the link definition is somewhere else in the document. [YAML escape sequence]: https://yaml.org/spec/1.2/spec.html#id2776092+[Wikipedia entry on YAML syntax]: https://en.m.wikipedia.org/wiki/YAML#Syntax ## Backslash escapes
changelog.md view
@@ -1,5 +1,116 @@ # Revision history for pandoc +## pandoc 2.14.0.2 (2021-06-13)++ * Fix MediaBag regressions (#7345). iIn the 2.14 release `--extract-media`+ stopped working as before; there could be mismatches between the+ paths in the rendered document and the extracted media.+ This patch makes several changes that restore the earlier behavior+ (while keeping the same API). The `mediaPath` in 2.14 was always+ constructed from the SHA1 hash of the media contents. Now, we+ preserve the original path unless it's an absolute path or contains+ `..` segments (in that case we use a path based on the SHA1 hash of+ the contents).++ In Text.Pandoc.MediaBag, `mediaDirectory` and `mediaItems` now use the+ `mediaPath`, rather than the mediabag key, for the first component of the+ tuple. This makes more sense, I think, and fits with the documentation of+ these functions; eventually, though, we should rework the API so that+ `mediaItems` returns both the keys and the MediaItems.++ In Text.Pandoc.Class.IO, rewriting of source paths in `extractMedia` has+ been fixed.++ In Text.Pandoc.Class.PandocMonad, `fillMediaBag` has been modified so that+ it doesn't modify image paths (that was part of the problem in #7345).++ We now do path normalization (e.g. `\` separators on Windows) in+ writing the media.++ * Text.Pandoc.PDF:++ + Text.Pandoc.PDF: Fix regression in 2.14 for generation of PDFs with+ SVGs (#7344).+ + Only print relevant part of environment on `--verbose`. Since+ `--verbose` output might be put in an issue, we want to avoid+ spilling out secrets in environment variables.++ * Markdown reader: fix pipe table regression in 2.11.4 (#7343).+ Previously pipe tables with empty headers (that is, a header+ line with all empty cells) would be rendered as headerless+ tables. This broke in 2.11.4. The fix here is to produce an+ AST with an empty table head when a pipe table has all empty+ header cells.++ * LaTeX reader: don't allow optional `*` on symbol control sequences+ (#7340). Generally we allow optional starred variants of LaTeX commands+ (since many allow them, and if we don't accept these explicitly,+ ignoring the star usually gives acceptable results). But we+ don't want to do this for `\(*\)` and similar cases.++ * Docx reader: handle absolute URIs in Relationship Target (#7374).++ * Docx writer: fix handling of empty table headers (Albert Krewinkel,+ #7369). A table header which does not contain any cells is now treated as+ an empty header.++ * LaTeX writer: Fix regression in table header position (#7347).+ In recent versions the table headers were no longer bottom-aligned+ (if more than one line). This patch fixes that by using minipages+ for table headers in non-simple tables.++ * CommonMark writer:++ + Do not use simple class for fenced-divs (Jan Tojnar, amends #7242.)+ + Do not throw away attributes when `Ext_attributes` is enabled.+ `Ext_attributes` covers at least the following:+ `Ext_fenced_code_attributes`, `Ext_header_attributes`,+ `Ext_inline_code_attributes`, `Ext_link_attributes`.++ * Markdown writer:++ + Allow `pipe_tables` to be disabled for commonmark formats+ (`commonmark_x`, `gfm`) (#7375).+ + Re-use functions from Text.Pandoc.Markdown.Inline (Jan Tojnar).++ * DocBook writer: Remove non-existent admonitions (Jan Tojnar).+ `attention`, `error` and `hint` are reStructuredText specific.++ * HTML writer: Don't omit width attribute on div (#7342).++ * Text.Pandoc.MIME, `extensionFromMimeType`: add a few special cases.+ When we do a reverse lookup in the MIME table, we just get the+ last match, so when the same mime type is associated with several+ different extensions, we sometimes got weird results, e.g. `.vs`+ for `text/plain`. These special cases help us get the most standard+ extensions for mime types like `text/plain`.++ * Lua utils: fix handling of table headers in `from_simple_table` (Albert+ Krewinkel, #7369). Passing an empty list of header cells now results+ in an empty table header.++ * Text.Pandoc.Citeproc:++ + Avoid duplicate classes and attributes on references div.+ + Fix regression in citeproc processing (#7376). If inline+ references are used (in the metadata `references` field), we+ should still only include in the bibliography items that are+ actually cited (unless `nocite` is used).++ * Require citeproc 0.4.0.1. This fixes a bug which led to doubled+ "et al." in some (rare) circumstances.++ * MANUAL.txt:++ + Mention GladTeX for EPUB export (Sebastian Humenda).+ This updates the manual and the web site about the GladTeX usage.+ + More details and a useful link for YAML syntax.++ * CONTRIBUTING.md: update modules overview (Albert Krewinkel).++ * using-the-pandoc-api.md: switch from String to Text (Albert Krewinkel).++ ## pandoc 2.14.0.1 (2021-06-01) * Commonmark reader: Fix regression in 2.14 with YAML metdata block parsing,
man/pandoc.1 view
@@ -1,7 +1,7 @@ '\" t-.\" Automatically generated by Pandoc 2.14+.\" Automatically generated by Pandoc 2.14.0.1 .\"-.TH "Pandoc User\[cq]s Guide" "" "May 31, 2021" "pandoc 2.14.0.1" ""+.TH "Pandoc User\[cq]s Guide" "" "June 11, 2021" "pandoc 2.14.0.2" "" .hy .SH NAME pandoc - general markup converter@@ -716,11 +716,11 @@ document to the path \f[I]DIR\f[R], creating it if necessary, and adjust the images references in the document so they point to the extracted files.-If the source format is a binary container (docx, epub, or odt), the-media is extracted from the container and the original filenames are-used.-Otherwise the media is read from the file system or downloaded, and new-filenames are constructed based on SHA1 hashes of the contents.+Media are downloaded, read from the file system, or extracted from a+binary container (e.g.\ docx), as needed.+The original file paths are used if they are relative paths not+containing \f[C]..\f[R].+Otherwise filenames are constructed from the SHA1 hash of the contents. .TP \f[B]\f[CB]--abbreviations=\f[B]\f[R]\f[I]FILE\f[R] Specifies a custom abbreviations file, with abbreviations one to a line.@@ -1504,16 +1504,16 @@ .TP \f[B]\f[CB]--gladtex\f[B]\f[R] Enclose TeX math in \f[C]<eq>\f[R] tags in HTML output.-The resulting HTML can then be processed by GladTeX to produce images of-the typeset formulas and an HTML file with links to these images.-So, the procedure is:+The resulting HTML can then be processed by GladTeX to produce SVG+images of the typeset formulas and an HTML file with these images+embedded. .RS .IP .nf \f[C] pandoc -s --gladtex input.md -o myfile.htex-gladtex -d myfile-images myfile.htex-# produces myfile.html and images in myfile-images+gladtex -d image_dir myfile.htex+# produces myfile.html and images in image_dir \f[R] .fi .RE@@ -4819,6 +4819,13 @@ \&... \f[R] .fi+.PP+The literal block after the \f[C]|\f[R] must be indented relative to the+line containing the \f[C]|\f[R].+If it is not, the YAML will be invalid and pandoc will not interpret it+as metadata.+For an overview of the complex rules governing YAML, see the Wikipedia+entry on YAML syntax. .PP Template variables will be set automatically from the metadata. Thus, for example, in writing HTML, the variable \f[C]abstract\f[R] will
pandoc.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.2 name: pandoc-version: 2.14.0.1+version: 2.14.0.2 build-type: Simple license: GPL-2.0-or-later license-file: COPYING.md@@ -450,7 +450,7 @@ blaze-markup >= 0.8 && < 0.9, bytestring >= 0.9 && < 0.12, case-insensitive >= 1.2 && < 1.3,- citeproc >= 0.4 && < 0.4.1,+ citeproc >= 0.4.0.1 && < 0.4.1, commonmark >= 0.2 && < 0.3, commonmark-extensions >= 0.2.1.2 && < 0.3, commonmark-pandoc >= 0.2.1 && < 0.3,
src/Text/Pandoc/Citeproc.hs view
@@ -49,7 +49,6 @@ import System.FilePath (takeExtension) import Safe (lastMay, initSafe) - processCitations :: PandocMonad m => Pandoc -> m Pandoc processCitations (Pandoc meta bs) = do style <- getStyle (Pandoc meta bs)@@ -195,7 +194,9 @@ then const True else (`Set.member` citeIds) let inlineRefs = case lookupMeta "references" meta of- Just (MetaList rs) -> mapMaybe metaValueToReference rs+ Just (MetaList rs) ->+ filter (idpred . unItemId . referenceId)+ $ mapMaybe metaValueToReference rs _ -> [] externalRefs <- case lookupMeta "bibliography" meta of Just (MetaList xs) ->@@ -499,7 +500,8 @@ put True -- refHeader isn't used if you have an explicit references div let cs' = ordNub $ cs ++ refclasses- return $ Div ("refs",cs' ++ refclasses,kvs ++ refkvs) (xs ++ refs)+ let kvs' = ordNub $ kvs ++ refkvs+ return $ Div ("refs",cs',kvs') (xs ++ refs) go x = return x refTitle :: Meta -> Maybe [Inline]
src/Text/Pandoc/Class/IO.hs view
@@ -62,7 +62,7 @@ import Text.Pandoc.Error (PandocError (..)) import Text.Pandoc.Logging (LogMessage (..), messageVerbosity, showLogMessage) import Text.Pandoc.MIME (MimeType)-import Text.Pandoc.MediaBag (MediaBag, MediaItem(..), lookupMedia, mediaDirectory)+import Text.Pandoc.MediaBag (MediaBag, MediaItem(..), lookupMedia, mediaItems) import Text.Pandoc.Walk (walk) import qualified Control.Exception as E import qualified Data.ByteString as B@@ -200,32 +200,32 @@ extractMedia :: (PandocMonad m, MonadIO m) => FilePath -> Pandoc -> m Pandoc extractMedia dir d = do media <- getMediaBag- case [fp | (fp, _, _) <- mediaDirectory media] of- [] -> return d- fps -> do- mapM_ (writeMedia dir media) fps- return $ walk (adjustImagePath dir fps) d+ let items = mediaItems media+ if null items+ then return d+ else do+ mapM_ (writeMedia dir) items+ return $ walk (adjustImagePath dir media) d -- | Write the contents of a media bag to a path. writeMedia :: (PandocMonad m, MonadIO m)- => FilePath -> MediaBag -> FilePath+ => FilePath+ -> (FilePath, MimeType, BL.ByteString) -> m ()-writeMedia dir mediabag subpath = do- -- we join and split to convert a/b/c to a\b\c on Windows;- -- in zip containers all paths use /- let mbcontents = lookupMedia subpath mediabag- case mbcontents of- Nothing -> throwError $ PandocResourceNotFound $ pack subpath- Just item -> do- let fullpath = dir </> mediaPath item- liftIOError (createDirectoryIfMissing True) (takeDirectory fullpath)- logIOError $ BL.writeFile fullpath $ mediaContents item+writeMedia dir (fp, _mt, bs) = do+ -- we normalize to get proper path separators for the platform+ let fullpath = normalise $ dir </> fp+ liftIOError (createDirectoryIfMissing True) (takeDirectory fullpath)+ logIOError $ BL.writeFile fullpath bs -- | If the given Inline element is an image with a @src@ path equal to -- one in the list of @paths@, then prepends @dir@ to the image source; -- returns the element unchanged otherwise.-adjustImagePath :: FilePath -> [FilePath] -> Inline -> Inline-adjustImagePath dir paths (Image attr lab (src, tit))- | unpack src `elem` paths- = Image attr lab (pack (normalise $ dir </> unpack src), tit)+adjustImagePath :: FilePath -> MediaBag -> Inline -> Inline+adjustImagePath dir mediabag (Image attr lab (src, tit)) =+ case lookupMedia (T.unpack src) mediabag of+ Nothing -> Image attr lab (src, tit)+ Just item ->+ let fullpath = dir </> mediaPath item+ in Image attr lab (T.pack fullpath, tit) adjustImagePath _ _ x = x
src/Text/Pandoc/Class/PandocMonad.hs view
@@ -638,17 +638,12 @@ handleImage (Image attr lab (src, tit)) = catchError (do mediabag <- getMediaBag let fp = T.unpack src- src' <- T.pack <$> case lookupMedia fp mediabag of- Just item -> return $ mediaPath item- Nothing -> do- (bs, mt) <- fetchItem src- insertMedia fp mt (BL.fromStrict bs)- mediabag' <- getMediaBag- case lookupMedia fp mediabag' of- Just item -> return $ mediaPath item- Nothing -> throwError $ PandocSomeError $- src <> " not successfully inserted into MediaBag"- return $ Image attr lab (src', tit))+ case lookupMedia fp mediabag of+ Just _ -> return ()+ Nothing -> do+ (bs, mt) <- fetchItem src+ insertMedia fp mt (BL.fromStrict bs)+ return $ Image attr lab (src, tit)) (\e -> case e of PandocResourceNotFound _ -> do
src/Text/Pandoc/Lua/Module/Utils.hs view
@@ -146,7 +146,7 @@ nullAttr (Caption Nothing [Plain capt]) (zipWith (\a w -> (a, toColWidth w)) aligns widths)- (TableHead nullAttr [blockListToRow head'])+ (TableHead nullAttr [blockListToRow head' | not (null head') ]) [TableBody nullAttr 0 [] $ map blockListToRow body] (TableFoot nullAttr []) return (NumResults 1)
src/Text/Pandoc/MIME.hs view
@@ -43,6 +43,16 @@ getMimeTypeDef = fromMaybe "application/octet-stream" . getMimeType extensionFromMimeType :: MimeType -> Maybe T.Text+-- few special cases, where there are multiple options:+extensionFromMimeType "text/plain" = Just "txt"+extensionFromMimeType "video/quicktime" = Just "mov"+extensionFromMimeType "video/mpeg" = Just "mpeg"+extensionFromMimeType "video/dv" = Just "dv"+extensionFromMimeType "image/vnd.djvu" = Just "djvu"+extensionFromMimeType "image/tiff" = Just "tiff"+extensionFromMimeType "image/jpeg" = Just "jpg"+extensionFromMimeType "application/xml" = Just "xml"+extensionFromMimeType "application/ogg" = Just "ogg" extensionFromMimeType mimetype = M.lookup (T.takeWhile (/=';') mimetype) reverseMimeTypes -- note: we just look up the basic mime type, dropping the content-encoding etc.
src/Text/Pandoc/MediaBag.hs view
@@ -71,16 +71,21 @@ -> MediaBag -> MediaBag insertMedia fp mbMime contents (MediaBag mediamap) =- MediaBag (M.insert (canonicalize fp) mediaItem mediamap)- where mediaItem = MediaItem{ mediaPath = showDigest (sha1 contents) <>- "." <> ext+ MediaBag (M.insert fp' mediaItem mediamap)+ where mediaItem = MediaItem{ mediaPath = newpath , mediaContents = contents , mediaMimeType = mt }+ fp' = canonicalize fp+ newpath = if isRelative fp && ".." `notElem` splitPath fp+ then T.unpack fp'+ else showDigest (sha1 contents) <> "." <> ext fallback = case takeExtension fp of ".gz" -> getMimeTypeDef $ dropExtension fp _ -> getMimeTypeDef fp mt = fromMaybe fallback mbMime- ext = maybe (takeExtension fp) T.unpack $ extensionFromMimeType mt+ ext = case takeExtension fp of+ '.':e -> e+ _ -> maybe "" T.unpack $ extensionFromMimeType mt -- | Lookup a media item in a 'MediaBag', returning mime type and contents.@@ -92,13 +97,11 @@ -- | Get a list of the file paths stored in a 'MediaBag', with -- their corresponding mime types and the lengths in bytes of the contents. mediaDirectory :: MediaBag -> [(FilePath, MimeType, Int)]-mediaDirectory (MediaBag mediamap) =- M.foldrWithKey (\fp item ->- ((T.unpack fp, mediaMimeType item,- fromIntegral (BL.length (mediaContents item))):)) [] mediamap+mediaDirectory mediabag =+ map (\(fp, mt, bs) -> (fp, mt, fromIntegral (BL.length bs)))+ (mediaItems mediabag) mediaItems :: MediaBag -> [(FilePath, MimeType, BL.ByteString)] mediaItems (MediaBag mediamap) =- M.foldrWithKey (\fp item ->- ((T.unpack fp, mediaMimeType item, mediaContents item):))- [] mediamap+ map (\item -> (mediaPath item, mediaMimeType item, mediaContents item))+ (M.elems mediamap)
src/Text/Pandoc/PDF.hs view
@@ -202,7 +202,7 @@ Just "image/svg+xml" -> E.catch (do (exit, _) <- pipeProcess Nothing "rsvg-convert" ["-f","pdf","-a","--dpi-x",dpi,"--dpi-y",dpi,- "-o",pdfOut,fname] BL.empty+ "-o",pdfOut,svgIn] BL.empty if exit == ExitSuccess then return $ Right pdfOut else return $ Left "conversion from SVG failed")@@ -217,6 +217,7 @@ where pngOut = replaceDirectory (replaceExtension fname ".png") tmpdir pdfOut = replaceDirectory (replaceExtension fname ".pdf") tmpdir+ svgIn = tmpdir </> fname mime = getMimeType fname doNothing = return (Right fname) @@ -506,8 +507,20 @@ UTF8.hPutStrLn stderr $ T.pack program <> " " <> T.pack (unwords (map show programArgs)) UTF8.hPutStr stderr "\n"- UTF8.hPutStrLn stderr "[makePDF] Environment:"- mapM_ (UTF8.hPutStrLn stderr . tshow) env+ UTF8.hPutStrLn stderr "[makePDF] Relevant environment variables:"+ -- we filter out irrelevant stuff to avoid leaking passwords and keys!+ let isRelevant ("PATH",_) = True+ isRelevant ("TMPDIR",_) = True+ isRelevant ("PWD",_) = True+ isRelevant ("LANG",_) = True+ isRelevant ("HOME",_) = True+ isRelevant ("LUA_PATH",_) = True+ isRelevant ("LUA_CPATH",_) = True+ isRelevant ("SHELL",_) = True+ isRelevant ("TEXINPUTS",_) = True+ isRelevant ("TEXMFOUTPUT",_) = True+ isRelevant _ = False+ mapM_ (UTF8.hPutStrLn stderr . tshow) (filter isRelevant env) UTF8.hPutStr stderr "\n" UTF8.hPutStrLn stderr "[makePDF] Source:" UTF8.hPutStrLn stderr source
src/Text/Pandoc/Readers/DocBook.hs view
@@ -134,6 +134,7 @@ [ ] corpcredit - A corporation or organization credited in a document [ ] corpname - The name of a corporation [ ] country - The name of a country+[x] danger - An admonition set off from the text indicating hazardous situation [ ] database - The name of a database, or part of a database [x] date - The date of publication or revision of a document [ ] dedication - A wrapper for the dedication section of a book@@ -718,7 +719,7 @@ ] ++ admonitionTags admonitionTags :: [Text]-admonitionTags = ["important","caution","note","tip","warning"]+admonitionTags = ["caution","danger","important","note","tip","warning"] -- Trim leading and trailing newline characters trimNl :: Text -> Text
src/Text/Pandoc/Readers/Docx/Parse.hs view
@@ -479,20 +479,26 @@ then Just InDocument else Nothing -relElemToRelationship :: DocumentLocation -> Element -> Maybe Relationship-relElemToRelationship relType element | qName (elName element) == "Relationship" =+relElemToRelationship :: FilePath -> DocumentLocation -> Element+ -> Maybe Relationship+relElemToRelationship fp relType element | qName (elName element) == "Relationship" = do relId <- findAttr (QName "Id" Nothing Nothing) element target <- findAttr (QName "Target" Nothing Nothing) element- return $ Relationship relType relId target-relElemToRelationship _ _ = Nothing+ -- target may be relative (media/image1.jpeg) or absolute+ -- (/word/media/image1.jpeg); we need to relativize it (see #7374)+ let frontOfFp = T.pack $ takeWhile (/= '_') fp+ let target' = fromMaybe target $+ T.stripPrefix frontOfFp $ T.dropWhile (== '/') target+ return $ Relationship relType relId target'+relElemToRelationship _ _ _ = Nothing filePathToRelationships :: Archive -> FilePath -> FilePath -> [Relationship] filePathToRelationships ar docXmlPath fp | Just relType <- filePathToRelType fp docXmlPath , Just entry <- findEntryByPath fp ar , Just relElems <- parseXMLFromEntry entry =- mapMaybe (relElemToRelationship relType) $ elChildren relElems+ mapMaybe (relElemToRelationship fp relType) $ elChildren relElems filePathToRelationships _ _ _ = [] archiveToRelationships :: Archive -> FilePath -> [Relationship]
src/Text/Pandoc/Readers/LaTeX.hs view
@@ -24,7 +24,7 @@ import Control.Applicative (many, optional, (<|>)) import Control.Monad import Control.Monad.Except (throwError)-import Data.Char (isDigit, isLetter, toUpper, chr)+import Data.Char (isDigit, isLetter, isAlphaNum, toUpper, chr) import Data.Default import Data.List (intercalate) import qualified Data.Map as M@@ -300,7 +300,9 @@ inlineCommand' = try $ do Tok _ (CtrlSeq name) cmd <- anyControlSeq guard $ name /= "begin" && name /= "end" && name /= "and"- star <- option "" ("*" <$ symbol '*' <* sp)+ star <- if T.all isAlphaNum name+ then option "" ("*" <$ symbol '*' <* sp)+ else pure "" overlay <- option "" overlaySpecification let name' = name <> star <> overlay let names = ordNub [name', name] -- check non-starred as fallback
src/Text/Pandoc/Readers/Markdown.hs view
@@ -2254,4 +2254,4 @@ toRow = Row nullAttr . map B.simpleCell toHeaderRow :: [Blocks] -> [Row]-toHeaderRow l = [toRow l | not (null l)]+toHeaderRow l = [toRow l | not (null l) && not (all null l)]
src/Text/Pandoc/Writers/Docbook.hs view
@@ -198,8 +198,7 @@ blockToDocbook opts (Div (ident,classes,_) bs) = do version <- ask let identAttribs = [(idName version, ident) | not (T.null ident)]- admonitions = ["attention","caution","danger","error","hint",- "important","note","tip","warning"]+ admonitions = ["caution","danger","important","note","tip","warning"] case classes of (l:_) | l `elem` admonitions -> do let (mTitleBs, bodyBs) =
src/Text/Pandoc/Writers/Docx/Table.hs view
@@ -116,8 +116,8 @@ -> [Alignment] -> Part -> WS m [Element]-cellGridToOpenXML blocksToOpenXML rowType aligns part@(Part _ _ rowAttrs) =- if null (indices rowAttrs)+cellGridToOpenXML blocksToOpenXML rowType aligns part@(Part _ cellArray _) =+ if null (elems cellArray) then return mempty else mapM (rowToOpenXML blocksToOpenXML) $ partToRows rowType aligns part
src/Text/Pandoc/Writers/HTML.hs view
@@ -770,9 +770,10 @@ lookup "entry-spacing" kvs' >>= safeRead } let isCslBibEntry = "csl-entry" `elem` classes- let kvs = [(k,v) | (k,v) <- kvs', k /= "width"] ++- [("style", "width:" <> w <> ";") | "column" `elem` classes,- ("width", w) <- kvs'] +++ let kvs = [(k,v) | (k,v) <- kvs'+ , k /= "width" || "column" `notElem` classes] +++ [("style", "width:" <> w <> ";") | "column" `elem` classes+ , ("width", w) <- kvs'] ++ [("role", "doc-bibliography") | isCslBibBody && html5] ++ [("role", "doc-biblioentry") | isCslBibEntry && html5] let speakerNotes = "notes" `elem` classes
src/Text/Pandoc/Writers/LaTeX/Table.hs view
@@ -16,6 +16,7 @@ ) where import Control.Monad.State.Strict import Data.List (intersperse)+import qualified Data.List.NonEmpty as NonEmpty import Data.List.NonEmpty (NonEmpty ((:|))) import Data.Text (Text) import qualified Data.Text as T@@ -243,8 +244,13 @@ -> Ann.Cell -> LW m (Doc Text) cellToLaTeX blockListToLaTeX celltype annotatedCell = do- let (Ann.Cell _specs _colnum cell) = annotatedCell- let (Cell _attr align rowspan colspan blocks) = cell+ let (Ann.Cell specs _colnum cell) = annotatedCell+ let hasWidths = snd (NonEmpty.head specs) /= ColWidthDefault+ let specAlign = fst (NonEmpty.head specs)+ let (Cell _attr align' rowspan colspan blocks) = cell+ let align = case align' of+ AlignDefault -> specAlign+ _ -> align' beamer <- gets stBeamer externalNotes <- gets stExternalNotes inMinipage <- gets stInMinipage@@ -256,7 +262,7 @@ Plain{} -> True _ -> False result <-- if all isPlainOrPara blocks+ if not hasWidths || (celltype /= HeaderCell && all isPlainOrPara blocks) then blockListToLaTeX $ walk fixLineBreaks $ walk displayMathToInline blocks else do@@ -290,3 +296,4 @@ data CellType = HeaderCell | BodyCell+ deriving Eq
src/Text/Pandoc/Writers/Markdown.hs view
@@ -43,7 +43,7 @@ import Text.DocTemplates (Val(..), Context(..), FromContext(..)) import Text.Pandoc.Walk import Text.Pandoc.Writers.HTML (writeHtml5String)-import Text.Pandoc.Writers.Markdown.Inline (inlineListToMarkdown)+import Text.Pandoc.Writers.Markdown.Inline (inlineListToMarkdown, linkAttributes, attrsToMarkdown) import Text.Pandoc.Writers.Markdown.Types (MarkdownVariant(..), WriterState(..), WriterEnv(..),@@ -75,7 +75,6 @@ -- we set them here so that escapeText will behave -- properly. enableExtension Ext_all_symbols_escapable $- enableExtension Ext_pipe_tables $ enableExtension Ext_intraword_underscores $ writerExtensions opts } @@ -257,39 +256,12 @@ then hang (writerTabStop opts) (marker <> spacer) contents else marker <> spacer <> contents -attrsToMarkdown :: Attr -> Doc Text-attrsToMarkdown attribs = braces $ hsep [attribId, attribClasses, attribKeys]- where attribId = case attribs of- ("",_,_) -> empty- (i,_,_) -> "#" <> escAttr i- attribClasses = case attribs of- (_,[],_) -> empty- (_,cs,_) -> hsep $- map (escAttr . ("."<>))- cs- attribKeys = case attribs of- (_,_,[]) -> empty- (_,_,ks) -> hsep $- map (\(k,v) -> escAttr k- <> "=\"" <>- escAttr v <> "\"") ks- escAttr = mconcat . map escAttrChar . T.unpack- escAttrChar '"' = literal "\\\""- escAttrChar '\\' = literal "\\\\"- escAttrChar c = literal $ T.singleton c- -- | (Code) blocks with a single class can just use it standalone, -- no need to bother with curly braces. classOrAttrsToMarkdown :: Attr -> Doc Text classOrAttrsToMarkdown ("",[cls],_) = literal cls classOrAttrsToMarkdown attrs = attrsToMarkdown attrs -linkAttributes :: WriterOptions -> Attr -> Doc Text-linkAttributes opts attr =- if isEnabled Ext_link_attributes opts && attr /= nullAttr- then attrsToMarkdown attr- else empty- -- | Ordered list start parser for use in Para below. olMarker :: Parser Text ParserState () olMarker = do (start, style', delim) <- anyOrderedListMarker@@ -349,9 +321,12 @@ case () of _ | isEnabled Ext_fenced_divs opts && attrs /= nullAttr ->- nowrap (literal ":::" <+> classOrAttrsToMarkdown attrs) $$- chomp contents $$- literal ":::" <> blankline+ let attrsToMd = if variant == Commonmark+ then attrsToMarkdown+ else classOrAttrsToMarkdown+ in nowrap (literal ":::" <+> attrsToMd attrs) $$+ chomp contents $$+ literal ":::" <> blankline | isEnabled Ext_native_divs opts || (isEnabled Ext_raw_html opts && (variant == Commonmark ||@@ -393,7 +368,7 @@ -- title beginning with fig: indicates figure blockToMarkdown' opts (Para [Image attr alt (src,tgt@(T.stripPrefix "fig:" -> Just tit))]) | isEnabled Ext_raw_html opts &&- not (isEnabled Ext_link_attributes opts) &&+ not (isEnabled Ext_link_attributes opts || isEnabled Ext_attributes opts) && attr /= nullAttr = -- use raw HTML (<> blankline) . literal . T.strip <$> writeHtml5String opts{ writerTemplate = Nothing }@@ -458,7 +433,8 @@ && id' == autoId -> empty (id',_,_) | isEnabled Ext_mmd_header_identifiers opts -> space <> brackets (literal id')- _ | isEnabled Ext_header_attributes opts ->+ _ | isEnabled Ext_header_attributes opts ||+ isEnabled Ext_attributes opts -> space <> attrsToMarkdown attr | otherwise -> empty contents <- inlineListToMarkdown opts $@@ -517,7 +493,8 @@ endline c = literal $ T.replicate (endlineLen c) $ T.singleton c backticks = endline '`' tildes = endline '~'- attrs = if isEnabled Ext_fenced_code_attributes opts+ attrs = if isEnabled Ext_fenced_code_attributes opts ||+ isEnabled Ext_attributes opts then nowrap $ " " <> classOrAttrsToMarkdown attribs else case attribs of (_,cls:_,_) -> " " <> literal cls
src/Text/Pandoc/Writers/Markdown/Inline.hs view
@@ -11,7 +11,9 @@ Portability : portable -} module Text.Pandoc.Writers.Markdown.Inline (- inlineListToMarkdown+ inlineListToMarkdown,+ linkAttributes,+ attrsToMarkdown ) where import Control.Monad.Reader import Control.Monad.State.Strict@@ -115,7 +117,7 @@ linkAttributes :: WriterOptions -> Attr -> Doc Text linkAttributes opts attr =- if isEnabled Ext_link_attributes opts && attr /= nullAttr+ if (isEnabled Ext_link_attributes opts || isEnabled Ext_attributes opts) && attr /= nullAttr then attrsToMarkdown attr else empty @@ -392,13 +394,15 @@ then "“" <> contents <> "”" else "“" <> contents <> "”" inlineToMarkdown opts (Code attr str) = do- let tickGroups = filter (T.any (== '`')) $ T.group str- let longest = maybe 0 maximum $ nonEmpty $ map T.length tickGroups- let marker = T.replicate (longest + 1) "`"- let spacer = if longest == 0 then "" else " "- let attrs = if isEnabled Ext_inline_code_attributes opts && attr /= nullAttr- then attrsToMarkdown attr- else empty+ let tickGroups = filter (T.any (== '`')) $ T.group str+ let longest = maybe 0 maximum $ nonEmpty $ map T.length tickGroups+ let marker = T.replicate (longest + 1) "`"+ let spacer = if longest == 0 then "" else " "+ let attrsEnabled = isEnabled Ext_inline_code_attributes opts ||+ isEnabled Ext_attributes opts+ let attrs = if attrsEnabled && attr /= nullAttr+ then attrsToMarkdown attr+ else empty variant <- asks envVariant case variant of PlainText -> return $ literal str@@ -557,7 +561,7 @@ else "[" <> reftext <> "]" in return $ first <> second | isEnabled Ext_raw_html opts- , not (isEnabled Ext_link_attributes opts)+ , not (isEnabled Ext_link_attributes opts || isEnabled Ext_attributes opts) , attr /= nullAttr -> -- use raw HTML to render attributes literal . T.strip <$> writeHtml5String opts{ writerTemplate = Nothing }@@ -567,7 +571,7 @@ linkAttributes opts attr inlineToMarkdown opts img@(Image attr alternate (source, tit)) | isEnabled Ext_raw_html opts &&- not (isEnabled Ext_link_attributes opts) &&+ not (isEnabled Ext_link_attributes opts || isEnabled Ext_attributes opts) && attr /= nullAttr = -- use raw HTML literal . T.strip <$> writeHtml5String opts{ writerTemplate = Nothing } (Pandoc nullMeta [Plain [img]])
stack.yaml view
@@ -13,7 +13,7 @@ - jira-wiki-markup-1.4.0 - random-1.2.0 - unicode-collation-0.1.3-- citeproc-0.4+- citeproc-0.4.0.1 - commonmark-0.2 - commonmark-extensions-0.2.1.2 - commonmark-pandoc-0.2.1
test/Tests/Writers/Docbook.hs view
@@ -83,32 +83,32 @@ , "</warning>" ] , "admonition-with-title" =:- divWith ("foo", ["attention"], []) (+ divWith ("foo", ["note"], []) ( divWith ("foo", ["title"], []) (plain (text "This is title")) <> para "This is a test" ) =?> unlines- [ "<attention id=\"foo\">"+ [ "<note id=\"foo\">" , " <title>This is title</title>" , " <para>" , " This is a test" , " </para>"- , "</attention>"+ , "</note>" ] , "admonition-with-title-in-para" =:- divWith ("foo", ["attention"], []) (+ divWith ("foo", ["note"], []) ( divWith ("foo", ["title"], []) (para "This is title") <> para "This is a test" ) =?> unlines- [ "<attention id=\"foo\">"+ [ "<note id=\"foo\">" , " <title>This is title</title>" , " <para>" , " This is a test" , " </para>"- , "</attention>"+ , "</note>" ] , "single-child" =: divWith ("foo", [], []) (para "This is a test")
test/command/5367.md view
@@ -24,11 +24,15 @@ >{\centering\arraybackslash}p{(\columnwidth - 0\tabcolsep) * \real{0.17}}@{}} \caption[Sample table.]{Sample table.\footnote{caption footnote}}\tabularnewline \toprule-Fruit\footnote{header footnote} \\+\begin{minipage}[b]{\linewidth}\centering+Fruit\footnote{header footnote}+\end{minipage} \\ \midrule \endfirsthead \toprule-Fruit{} \\+\begin{minipage}[b]{\linewidth}\centering+Fruit{}+\end{minipage} \\ \midrule \endhead Bans\footnote{table cell footnote} \\
+ test/command/7340.md view
@@ -0,0 +1,6 @@+```+% pandoc -f latex -t native+\(*\)+^D+[Para [Math InlineMath "*"]]+```
+ test/command/7376.md view
@@ -0,0 +1,16 @@+```+% pandoc --citeproc -t plain+---+references:+- id: item1+ type: book+ author:+ - family: Doe+ given: Jane+ issued: 2020+ title: The title+...+^D+++```
test/command/pandoc-citeproc-356.md view
@@ -15,11 +15,6 @@ [@bar] ^D-(Alice 2042)--::: {#refs .references .csl-bib-body .hanging-indent}-::: {#ref-foo .csl-entry}-Alice. 2042.-:::-:::+[WARNING] Citeproc: citation bar not found+(**bar?**) ```
test/pipe-tables.native view
@@ -131,13 +131,7 @@ ,(AlignLeft,ColWidthDefault) ,(AlignCenter,ColWidthDefault)] (TableHead ("",[],[])- [Row ("",[],[])- [Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1)- []- ,Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1)- []- ,Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1)- []]])+ []) [(TableBody ("",[],[]) (RowHeadColumns 0) [] [Row ("",[],[])@@ -213,9 +207,7 @@ []) [(AlignCenter,ColWidthDefault)] (TableHead ("",[],[])- [Row ("",[],[])- [Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1)- []]])+ []) [(TableBody ("",[],[]) (RowHeadColumns 0) [] [Row ("",[],[])
test/tables.latex view
@@ -56,11 +56,27 @@ >{\raggedright\arraybackslash}p{(\columnwidth - 6\tabcolsep) * \real{0.35}}@{}} \caption{Here's the caption. It may span multiple lines.}\tabularnewline \toprule-Centered Header & Left Aligned & Right Aligned & Default aligned \\+\begin{minipage}[b]{\linewidth}\centering+Centered Header+\end{minipage} & \begin{minipage}[b]{\linewidth}\raggedright+Left Aligned+\end{minipage} & \begin{minipage}[b]{\linewidth}\raggedleft+Right Aligned+\end{minipage} & \begin{minipage}[b]{\linewidth}\raggedright+Default aligned+\end{minipage} \\ \midrule \endfirsthead \toprule-Centered Header & Left Aligned & Right Aligned & Default aligned \\+\begin{minipage}[b]{\linewidth}\centering+Centered Header+\end{minipage} & \begin{minipage}[b]{\linewidth}\raggedright+Left Aligned+\end{minipage} & \begin{minipage}[b]{\linewidth}\raggedleft+Right Aligned+\end{minipage} & \begin{minipage}[b]{\linewidth}\raggedright+Default aligned+\end{minipage} \\ \midrule \endhead First & row & 12.0 & Example of a row that spans multiple lines. \\@@ -76,7 +92,15 @@ >{\raggedleft\arraybackslash}p{(\columnwidth - 6\tabcolsep) * \real{0.16}} >{\raggedright\arraybackslash}p{(\columnwidth - 6\tabcolsep) * \real{0.35}}@{}} \toprule-Centered Header & Left Aligned & Right Aligned & Default aligned \\+\begin{minipage}[b]{\linewidth}\centering+Centered Header+\end{minipage} & \begin{minipage}[b]{\linewidth}\raggedright+Left Aligned+\end{minipage} & \begin{minipage}[b]{\linewidth}\raggedleft+Right Aligned+\end{minipage} & \begin{minipage}[b]{\linewidth}\raggedright+Default aligned+\end{minipage} \\ \midrule \endhead First & row & 12.0 & Example of a row that spans multiple lines. \\
test/tables/nordics.latex view
@@ -5,13 +5,31 @@ >{\raggedright\arraybackslash}p{(\columnwidth - 6\tabcolsep) * \real{0.20}}@{}} \caption{States belonging to the \emph{Nordics.}}\tabularnewline \toprule-Name & Capital & \vtop{\hbox{\strut Population}\hbox{\strut (in 2018)}} &-\vtop{\hbox{\strut Area}\hbox{\strut (in km\textsuperscript{2})}} \\+\begin{minipage}[b]{\linewidth}\centering+Name+\end{minipage} & \begin{minipage}[b]{\linewidth}\centering+Capital+\end{minipage} & \begin{minipage}[b]{\linewidth}\centering+Population\\+(in 2018)+\end{minipage} & \begin{minipage}[b]{\linewidth}\centering+Area\\+(in km\textsuperscript{2})+\end{minipage} \\ \midrule \endfirsthead \toprule-Name & Capital & \vtop{\hbox{\strut Population}\hbox{\strut (in 2018)}} &-\vtop{\hbox{\strut Area}\hbox{\strut (in km\textsuperscript{2})}} \\+\begin{minipage}[b]{\linewidth}\centering+Name+\end{minipage} & \begin{minipage}[b]{\linewidth}\centering+Capital+\end{minipage} & \begin{minipage}[b]{\linewidth}\centering+Population\\+(in 2018)+\end{minipage} & \begin{minipage}[b]{\linewidth}\centering+Area\\+(in km\textsuperscript{2})+\end{minipage} \\ \midrule \endhead Denmark & Copenhagen & 5,809,502 & 43,094 \\
test/tables/planets.latex view
@@ -1,18 +1,18 @@ \begin{longtable}[]{@{}cclrrrrrrrrl@{}} \caption{Data about the planets of our solar system.}\tabularnewline \toprule-\multicolumn{2}{l}{} & Name & Mass (10\^{}24kg) & Diameter (km) & Density+\multicolumn{2}{c}{} & Name & Mass (10\^{}24kg) & Diameter (km) & Density (kg/m\^{}3) & Gravity (m/s\^{}2) & Length of day (hours) & Distance from Sun (10\^{}6km) & Mean temperature (C) & Number of moons & Notes \\ \midrule \endfirsthead \toprule-\multicolumn{2}{l}{} & Name & Mass (10\^{}24kg) & Diameter (km) & Density+\multicolumn{2}{c}{} & Name & Mass (10\^{}24kg) & Diameter (km) & Density (kg/m\^{}3) & Gravity (m/s\^{}2) & Length of day (hours) & Distance from Sun (10\^{}6km) & Mean temperature (C) & Number of moons & Notes \\ \midrule \endhead-\multicolumn{2}{l}{\multirow{4}{*}{Terrestrial planets}} & Mercury & 0.330 &+\multicolumn{2}{c}{\multirow{4}{*}{Terrestrial planets}} & Mercury & 0.330 & 4,879 & 5427 & 3.7 & 4222.6 & 57.9 & 167 & 0 & Closest to the Sun \\ & & Venus & 4.87 & 12,104 & 5243 & 8.9 & 2802.0 & 108.2 & 464 & 0 & \\ & & Earth & 5.97 & 12,756 & 5514 & 9.8 & 24.0 & 149.6 & 15 & 1 & Our world \\@@ -24,7 +24,7 @@ & \multirow{2}{*}{Ice giants} & Uranus & 86.8 & 51,118 & 1271 & 8.7 & 17.2 & 2872.5 & -195 & 27 & \\ & & Neptune & 102 & 49,528 & 1638 & 11.0 & 16.1 & 4495.1 & -200 & 14 & \\-\multicolumn{2}{l}{Dwarf planets} & Pluto & 0.0146 & 2,370 & 2095 & 0.7 &+\multicolumn{2}{c}{Dwarf planets} & Pluto & 0.0146 & 2,370 & 2095 & 0.7 & 153.3 & 5906.4 & -225 & 5 & Declassified as a planet in 2006. \\ \bottomrule \end{longtable}
test/tables/students.latex view
@@ -3,11 +3,19 @@ >{\raggedright\arraybackslash}p{(\columnwidth - 2\tabcolsep) * \real{0.50}}@{}} \caption{List of Students}\tabularnewline \toprule-Student ID & Name \\+\begin{minipage}[b]{\linewidth}\centering+Student ID+\end{minipage} & \begin{minipage}[b]{\linewidth}\centering+Name+\end{minipage} \\ \midrule \endfirsthead \toprule-Student ID & Name \\+\begin{minipage}[b]{\linewidth}\centering+Student ID+\end{minipage} & \begin{minipage}[b]{\linewidth}\centering+Name+\end{minipage} \\ \midrule \endhead \multicolumn{2}{l}{Computer Science} \\