packages feed

pandoc 2.2.2.1 → 2.2.3

raw patch · 27 files changed

+443/−188 lines, 27 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Text.Pandoc.Shared: blocksToInlinesWithSep :: Inlines -> [Block] -> Inlines
+ Text.Pandoc.Shared: defaultBlocksSeparator :: Inlines

Files

INSTALL.md view
@@ -334,5 +334,5 @@ [openSUSE]: https://software.opensuse.org/package/pandoc [source tarball]: http://hackage.haskell.org/package/pandoc [stack]: http://docs.haskellstack.org/en/stable/install_and_upgrade.html-[cabal-install]: http://hackage.haskell.org/trac/hackage/wiki/CabalInstall+[cabal-install]: http://hackage.haskell.org/package/cabal-install [uninstaller]: https://raw.githubusercontent.com/jgm/pandoc/master/macos/uninstall-pandoc.pl
MANUAL.txt view
@@ -1,6 +1,6 @@ % Pandoc User's Guide % John MacFarlane-% July 19, 2018+% August 5, 2018  Synopsis ========@@ -155,9 +155,10 @@ `xelatex` will use [`mathspec`] instead of [`unicode-math`]. The [`upquote`] and [`microtype`] packages are used if available, and [`csquotes`] will be used for [typography]-if added to the template or included in any header file. The-[`natbib`], [`biblatex`], [`bibtex`], and [`biber`] packages can-optionally be used for [citation rendering].+if `\usepackage{csquotes}` is present in the template or+included via `/H/--include-in-header`.  The [`natbib`],+[`biblatex`], [`bibtex`], and [`biber`] packages can optionally+be used for [citation rendering].  [`amsfonts`]: https://ctan.org/pkg/amsfonts [`amsmath`]: https://ctan.org/pkg/amsmath@@ -1917,7 +1918,7 @@ :  `latex`, `org`, `textile`  output formats-:  `textile`+:  `textile`, `commonmark`  #### [Extension: `native_divs`] {#native_divs} @@ -4448,26 +4449,30 @@ `allowframebreaks`, `b`, `c`, `t`, `environment`, `label`, `plain`, `shrink`, `standout`, `noframenumbering`. -Background in reveal.js------------------------+Background in reveal.js and beamer+---------------------------------- -Background images can be added to self-contained reveal.js slideshows.+Background images can be added to self-contained reveal.js slideshows and +to beamer slideshows. -For the same image on every slide, use the reveal.js configuration-option `parallaxBackgroundImage` either in the YAML metadata block-or as a command-line variable. You can also set-`parallaxBackgroundHorizontal` and `parallaxBackgroundVertical` the same-way and must also set `parallaxBackgroundSize` to have your values-take effect.+For the same image on every slide, use the  configuration+option `background-image` either in the YAML metadata block+or as a command-line variable. (There are no other options in+beamer and the rest of this section concerns reveal.js slideshows.) -To set an image for a particular slide, add+For reveal.js, you can instead use the reveal.js-native option +`parallaxBackgroundImage`. You can also set `parallaxBackgroundHorizontal` +and `parallaxBackgroundVertical` the same way and must also set +`parallaxBackgroundSize` to have your values take effect.++To set an image for a particular reveal.js slide, add `{data-background-image="/path/to/image"}` to the first slide-level header on the slide (which may even be empty).  In reveal.js's overview mode, the parallaxBackgroundImage will show up only on the first slide. -Other background settings also work on individual slides, including+Other reveal.js background settings also work on individual slides, including `data-background-size`, `data-background-repeat`, `data-background-color`, `data-transition`, and `data-transition-speed`. @@ -4475,7 +4480,7 @@ documentation](https://github.com/hakimel/reveal.js#slide-backgrounds) for more details. -For example:+For example in reveal.js:  ``` ---
README.md view
@@ -38,9 +38,9 @@     e-book)   - `gfm` ([GitHub-Flavored     Markdown](https://help.github.com/articles/github-flavored-markdown/)),-    or `markdown_github`, which provides deprecated and less accurate-    support for Github-Flavored Markdown; please use `gfm` instead,-    unless you need to use extensions other than `smart`.+    or the deprecated and less accurate `markdown_github`; use+    [`markdown_github`](#markdown-variants) only if you need extensions+    not supported in [`gfm`](#markdown-variants).   - `haddock` ([Haddock     markup](https://www.haskell.org/haddock/doc/html/ch03s08.html))   - `html` ([HTML](http://www.w3.org/html/))@@ -92,9 +92,9 @@     e-book)   - `gfm` ([GitHub-Flavored     Markdown](https://help.github.com/articles/github-flavored-markdown/)),-    or `markdown_github`, which provides deprecated and less accurate-    support for Github-Flavored Markdown; please use `gfm` instead,-    unless you use extensions that do not work with `gfm`.+    or the deprecated and less accurate `markdown_github`; use+    [`markdown_github`](#markdown-variants) only if you need extensions+    not supported in [`gfm`](#markdown-variants).   - `haddock` ([Haddock     markup](https://www.haskell.org/haddock/doc/html/ch03s08.html))   - `html` or `html5` ([HTML](http://www.w3.org/html/), i.e.
changelog view
@@ -1,3 +1,89 @@+pandoc (2.2.3)++  * RST reader: improve parsing of inline interpreted text roles (#4811).++    + Use a Span with class "title-reference" for the default+      title-reference role.+    + Use `B.text` to split up contents into `Space`s, `SoftBreak`s,+      and `Str`s for `title-reference`.+    + Use Code with class "interpreted-text" instead of Span and Str for+      unknown roles.  (The RST writer has also been modified to round-trip+      this properly.)+    + Disallow blank lines in interpreted text.+    + Backslash-escape now works in interpreted text.+    + Backticks followed by alphanumerics no longer end interpreted text.+    + Remove support for nested inlines (Francesco Occhipinti).+      RST does not allow nested emphasis, links, or other inline+      constructs.  This fixes several bugs (#4581, #4561, #4792).++  * Org reader: fix parsers relying on `parseFromString` (#4784, Albert+    Krewinkel).  Emphasis was not parsed when it followed directly after+    some block types (e.g., lists).++  * Markdown reader: Allow unquoted numbers and booleans as YAML mapping+    keys.  Previously in 2.2.2 you could not do+    ```+    ---+    0: bar+    ...+    ```+    but only+    ```+    ---+    '0': bar+    ...+    ```+    With this change, both forms work.++  * DocBook reader: metadata handling improvements.+    Now we properly parse title and subtitle elements that are direct+    children of book and article (as well as children of bookinfo,+    articleinfo, or info).  We also now use the `subtitle` metadata+    field for subtitles, rather than tacking the subtitle on to the+    title.++  * RST writer:++    + Allow images to be directly nested within links (#4810, Francesco+      Occhipinti).+    + Use `titleblock` instead of `title` variable for title block (#4803,+      Francesco Occhipinti).  `titleblock` contains a properly formatted+      title and subtitle (using top-level headers).  `title` and+      `subtitle` variables are still available and just contain the+      title and subtitle text.  Note that this change will require an+      update to custom rst templates.+    + Render Code with class "interpreted-text" as interpreted text role.++  * MediaWiki writer: Avoid extra blank line in tables with empty cells+    (#4794).  Note that the old output is semantically identical, but the+    new output looks better.++  * Lua Utils module: add function `blocks_to_inlines` (#4799, Albert+    Krewinkel).  Exposes a function converting which flattenes a list of+    blocks into a list of inlines. An example use case would be the+    conversion of Note elements into other inlines.++  * RST template:  use `titleblock` instead of `title`.  Users of+    custom RST templates will want to update this.++  * LaTeX template: Moved some beamer code in default.latex template.+    This change allows beamer themes to change the template and font (as+    Metropolis does) (#4450).++  * Better error message on `-t pdf -o out.pdf` (#1155, Mauro Bieg).++  * Added test case for #4669 to repository.++  * INSTALL.md: Fix broken link for cabal-install (#4806, ChanHoHo).++  * MANUAL.txt:++    + Add beamer info for slide backgrounds (#4802, John Muccigrosso).+    + Clarify when `csquotes` is used in LaTeX writer (#4514).+    + Add `commonmark` to list of output formats where `raw_tex` has an+      effect (see #4527).++ pandoc (2.2.2.1)    * Fix regression finding templates in user data directory (#4777).@@ -2609,6 +2695,11 @@       more consistent with other Markdown implementations, and with itself       (since the two-space version of a line break doesn't work inside ATX       headers, and neither version works inside Setext headers).++    + A space between the opening # and the header is now required for+      pandoc and GitHub markdown (but not the other flavors). Disable+      the `space_in_atx_header` extension (#3512) to restore the+      original behavior.     * Org reader (Albert Krewinkel, unless noted):
data/templates/default.latex view
@@ -20,7 +20,42 @@ $for(beameroption)$ \setbeameroption{$beameroption$} $endfor$+% Prevent slide breaks in the middle of a paragraph:+\widowpenalties 1 10000+\raggedbottom+$if(section-titles)$+\setbeamertemplate{part page}{+\centering+\begin{beamercolorbox}[sep=16pt,center]{part title}+  \usebeamerfont{part title}\insertpart\par+\end{beamercolorbox}+}+\setbeamertemplate{section page}{+\centering+\begin{beamercolorbox}[sep=12pt,center]{part title}+  \usebeamerfont{section title}\insertsection\par+\end{beamercolorbox}+}+\setbeamertemplate{subsection page}{+\centering+\begin{beamercolorbox}[sep=8pt,center]{part title}+  \usebeamerfont{subsection title}\insertsubsection\par+\end{beamercolorbox}+}+\AtBeginPart{+  \frame{\partpage}+}+\AtBeginSection{+  \ifbibliography+  \else+    \frame{\sectionpage}+  \fi+}+\AtBeginSubsection{+  \frame{\subsectionpage}+} $endif$+$endif$ $if(beamerarticle)$ \usepackage{beamerarticle} % needs to be loaded first $endif$@@ -197,43 +232,6 @@ % margins by default, and it is still possible to overwrite the defaults % using explicit options in \includegraphics[width, height, ...]{} \setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}-$endif$-$if(beamer)$-% Prevent slide breaks in the middle of a paragraph:-\widowpenalties 1 10000-\raggedbottom-$if(section-titles)$-\setbeamertemplate{part page}{-\centering-\begin{beamercolorbox}[sep=16pt,center]{part title}-  \usebeamerfont{part title}\insertpart\par-\end{beamercolorbox}-}-\setbeamertemplate{section page}{-\centering-\begin{beamercolorbox}[sep=12pt,center]{part title}-  \usebeamerfont{section title}\insertsection\par-\end{beamercolorbox}-}-\setbeamertemplate{subsection page}{-\centering-\begin{beamercolorbox}[sep=8pt,center]{part title}-  \usebeamerfont{subsection title}\insertsubsection\par-\end{beamercolorbox}-}-\AtBeginPart{-  \frame{\partpage}-}-\AtBeginSection{-  \ifbibliography-  \else-    \frame{\sectionpage}-  \fi-}-\AtBeginSubsection{-  \frame{\subsectionpage}-}-$endif$ $endif$ $if(links-as-notes)$ % Make links footnotes instead of hotlinks:
data/templates/default.rst view
@@ -1,5 +1,5 @@-$if(title)$-$title$+$if(titleblock)$+$titleblock$  $endif$ $for(author)$
man/pandoc.1 view
@@ -1,5 +1,5 @@ .\"t-.TH PANDOC 1 "July 19, 2018" "pandoc 2.2.2.1"+.TH PANDOC 1 "August 5, 2018" "pandoc 2.2.3" .SH NAME pandoc - general markup converter .SH SYNOPSIS@@ -187,8 +187,9 @@ If the \f[C]mathspec\f[] variable is set, \f[C]xelatex\f[] will use \f[C]mathspec\f[] instead of \f[C]unicode\-math\f[]. The \f[C]upquote\f[] and \f[C]microtype\f[] packages are used if-available, and \f[C]csquotes\f[] will be used for typography if added to-the template or included in any header file.+available, and \f[C]csquotes\f[] will be used for typography if+\f[C]\\usepackage{csquotes}\f[] is present in the template or included+via \f[C]/H/\-\-include\-in\-header\f[]. The \f[C]natbib\f[], \f[C]biblatex\f[], \f[C]bibtex\f[], and \f[C]biber\f[] packages can optionally be used for citation rendering. .SS Reading from the Web@@ -2364,7 +2365,7 @@ .RE .TP .B output formats-\f[C]textile\f[]+\f[C]textile\f[], \f[C]commonmark\f[] .RS .RE .SS Extension: \f[C]native_divs\f[]@@ -5562,32 +5563,38 @@ \f[C]allowframebreaks\f[], \f[C]b\f[], \f[C]c\f[], \f[C]t\f[], \f[C]environment\f[], \f[C]label\f[], \f[C]plain\f[], \f[C]shrink\f[], \f[C]standout\f[], \f[C]noframenumbering\f[].-.SS Background in reveal.js+.SS Background in reveal.js and beamer .PP-Background images can be added to self\-contained reveal.js slideshows.+Background images can be added to self\-contained reveal.js slideshows+and to beamer slideshows. .PP-For the same image on every slide, use the reveal.js configuration-option \f[C]parallaxBackgroundImage\f[] either in the YAML metadata-block or as a command\-line variable.+For the same image on every slide, use the configuration option+\f[C]background\-image\f[] either in the YAML metadata block or as a+command\-line variable.+(There are no other options in beamer and the rest of this section+concerns reveal.js slideshows.)+.PP+For reveal.js, you can instead use the reveal.js\-native option+\f[C]parallaxBackgroundImage\f[]. You can also set \f[C]parallaxBackgroundHorizontal\f[] and \f[C]parallaxBackgroundVertical\f[] the same way and must also set \f[C]parallaxBackgroundSize\f[] to have your values take effect. .PP-To set an image for a particular slide, add+To set an image for a particular reveal.js slide, add \f[C]{data\-background\-image="/path/to/image"}\f[] to the first slide\-level header on the slide (which may even be empty). .PP In reveal.js\[aq]s overview mode, the parallaxBackgroundImage will show up only on the first slide. .PP-Other background settings also work on individual slides, including-\f[C]data\-background\-size\f[], \f[C]data\-background\-repeat\f[],-\f[C]data\-background\-color\f[], \f[C]data\-transition\f[], and-\f[C]data\-transition\-speed\f[].+Other reveal.js background settings also work on individual slides,+including \f[C]data\-background\-size\f[],+\f[C]data\-background\-repeat\f[], \f[C]data\-background\-color\f[],+\f[C]data\-transition\f[], and \f[C]data\-transition\-speed\f[]. .PP See the reveal.js documentation for more details. .PP-For example:+For example in reveal.js: .IP .nf \f[C]
pandoc.cabal view
@@ -1,5 +1,5 @@ name:            pandoc-version:         2.2.2.1+version:         2.2.3 cabal-version:   2.0 build-type:      Custom license:         GPL-2
src/Text/Pandoc/App.hs view
@@ -142,6 +142,13 @@ pdfEngines :: [String] pdfEngines = ordNub $ map snd engines +pdfIsNoWriterErrorMsg :: String+pdfIsNoWriterErrorMsg =+  "To create a pdf using pandoc, use " +++  "-t latex|beamer|context|ms|html5" +++  "\nand specify an output file with " +++  ".pdf extension (-o filename.pdf)."+ pdfWriterAndProg :: Maybe String              -- ^ user-specified writer name                  -> Maybe String              -- ^ user-specified pdf-engine                  -> IO (String, Maybe String) -- ^ IO (writerName, maybePdfEngineProg)@@ -165,6 +172,7 @@                                  []      -> Left $                                    "pdf-engine " ++ eng ++ " not known" +      engineForWriter "pdf" = Left pdfIsNoWriterErrorMsg       engineForWriter w = case [e |  (f,e) <- engines, f == baseWriterName w] of                                 eng : _ -> Right eng                                 []      -> Left $@@ -233,11 +241,7 @@                else case getWriter (map toLower writerName) of                          Left e  -> E.throwIO $ PandocAppError $                            if format == "pdf"-                              then e ++-                               "\nTo create a pdf using pandoc, use " ++-                               "-t latex|beamer|context|ms|html5" ++-                               "\nand specify an output file with " ++-                               ".pdf extension (-o filename.pdf)."+                              then e ++ "\n" ++ pdfIsNoWriterErrorMsg                               else e                          Right (w, es) -> return (w :: Writer PandocIO, es) 
src/Text/Pandoc/Lua/Module/Utils.hs view
@@ -42,6 +42,7 @@ import qualified Data.Digest.Pure.SHA as SHA import qualified Data.ByteString.Lazy as BSL import qualified Foreign.Lua as Lua+import qualified Text.Pandoc.Builder as B import qualified Text.Pandoc.Filter.JSON as JSONFilter import qualified Text.Pandoc.Shared as Shared @@ -49,6 +50,7 @@ pushModule :: Maybe FilePath -> Lua NumResults pushModule mbDatadir = do   Lua.newtable+  addFunction "blocks_to_inlines" blocksToInlines   addFunction "hierarchicalize" hierarchicalize   addFunction "normalize_date" normalizeDate   addFunction "run_json_filter" (runJSONFilter mbDatadir)@@ -56,6 +58,14 @@   addFunction "stringify" stringify   addFunction "to_roman_numeral" toRomanNumeral   return 1++-- | Squashes a list of blocks into inlines.+blocksToInlines :: [Block] -> Lua.Optional [Inline] -> Lua [Inline]+blocksToInlines blks optSep = do+  let sep = case Lua.fromOptional optSep of+              Just x -> B.fromList x+              Nothing -> Shared.defaultBlocksSeparator+  return $ B.toList (Shared.blocksToInlinesWithSep sep blks)  -- | Convert list of Pandoc blocks into (hierarchical) list of Elements. hierarchicalize :: [Block] -> Lua [Shared.Element]
src/Text/Pandoc/Readers/DocBook.hs view
@@ -537,7 +537,6 @@ data DBState = DBState{ dbSectionLevel :: Int                       , dbQuoteType    :: QuoteType                       , dbMeta         :: Meta-                      , dbAcceptsMeta  :: Bool                       , dbBook         :: Bool                       , dbFigureTitle  :: Inlines                       , dbContent      :: [Content]@@ -547,7 +546,6 @@   def = DBState{ dbSectionLevel = 0                , dbQuoteType = DoubleQuote                , dbMeta = mempty-               , dbAcceptsMeta = False                , dbBook = False                , dbFigureTitle = mempty                , dbContent = [] }@@ -609,18 +607,26 @@  -- -acceptingMetadata :: PandocMonad m => DB m a -> DB m a-acceptingMetadata p = do-  modify (\s -> s { dbAcceptsMeta = True } )-  res <- p-  modify (\s -> s { dbAcceptsMeta = False })-  return res--checkInMeta :: (PandocMonad m, Monoid a) => DB m () -> DB m a-checkInMeta p = do-  accepts <- dbAcceptsMeta <$> get-  when accepts p-  return mempty+addMetadataFromElement :: PandocMonad m => Element -> DB m Blocks+addMetadataFromElement e = do+    case filterChild (named "title") e of+         Nothing -> return ()+         Just z  -> do+           getInlines z >>= addMeta "title"+           addMetaField "subtitle" z+    case filterChild (named "authorgroup") e of+         Nothing -> return ()+         Just z  -> addMetaField "author" z+    addMetaField "subtitle" e+    addMetaField "author" e+    addMetaField "date" e+    addMetaField "release" e+    return mempty+  where addMetaField fieldname elt =+            case filterChildren (named fieldname) elt of+                   []  -> return ()+                   [z] -> getInlines z >>= addMeta fieldname+                   zs  -> mapM getInlines zs >>= addMeta fieldname  addMeta :: PandocMonad m => ToMetaValue a => String -> a -> DB m () addMeta field val = modify (setMeta field val)@@ -718,11 +724,6 @@         "attribution" -> return mempty         "titleabbrev" -> return mempty         "authorinitials" -> return mempty-        "title" ->  checkInMeta getTitle-        "author" -> checkInMeta getAuthor-        "authorgroup" -> checkInMeta getAuthorGroup-        "releaseinfo" -> checkInMeta (getInlines e >>= addMeta "release")-        "date" -> checkInMeta getDate         "bibliography" -> sect 0         "bibliodiv" -> sect 1         "biblioentry" -> parseMixed para (elContent e)@@ -788,8 +789,8 @@         "figure" -> getFigure e         "mediaobject" -> para <$> getMediaobject e         "caption" -> return mempty-        "info" -> metaBlock-        "articleinfo" -> metaBlock+        "info" -> addMetadataFromElement e+        "articleinfo" -> addMetadataFromElement e         "sectioninfo" -> return mempty  -- keywords & other metadata         "refsectioninfo" -> return mempty  -- keywords & other metadata         "refsect1info" -> return mempty  -- keywords & other metadata@@ -803,10 +804,11 @@         "chapterinfo" -> return mempty  -- keywords & other metadata         "glossaryinfo" -> return mempty  -- keywords & other metadata         "appendixinfo" -> return mempty  -- keywords & other metadata-        "bookinfo" -> metaBlock+        "bookinfo" -> addMetadataFromElement e         "article" -> modify (\st -> st{ dbBook = False }) >>-                           getBlocks e-        "book" -> modify (\st -> st{ dbBook = True }) >>  getBlocks e+                           addMetadataFromElement e >> getBlocks e+        "book" -> modify (\st -> st{ dbBook = True }) >>+                    addMetadataFromElement e >> getBlocks e         "table" -> parseTable         "informaltable" -> parseTable         "informalexample" -> divWith ("", ["informalexample"], []) <$>@@ -816,6 +818,8 @@         "screen" -> codeBlockWithLang         "programlisting" -> codeBlockWithLang         "?xml"  -> return mempty+        "title" -> return mempty     -- handled in parent element+        "subtitle" -> return mempty  -- handled in parent element         _       -> getBlocks e    where parseMixed container conts = do            let (ils,rest) = break isBlockElement conts@@ -857,19 +861,6 @@                      terms' <- mapM getInlines terms                      items' <- mapM getBlocks items                      return (mconcat $ intersperse (str "; ") terms', items')-         getTitle =  do-                     tit <- getInlines e-                     subtit <-  case filterChild (named "subtitle") e of-                                  Just s  -> (text ": " <>) <$>-                                              getInlines s-                                  Nothing -> return mempty-                     addMeta "title" (tit <> subtit)--         getAuthor = (:[]) <$> getInlines e >>= addMeta "author"-         getAuthorGroup = do-          let terms = filterChildren (named "author") e-          mapM getInlines terms >>= addMeta "author"-         getDate = getInlines e >>= addMeta "date"          parseTable = do                       let isCaption x = named "title" x || named "caption" x                       caption <- case filterChild isCaption e of@@ -935,7 +926,6 @@                      modify $ \st -> st{ dbSectionLevel = n - 1 }                      return $ headerWith (ident,[],[]) n' headerText <> b          lineItems = mapM getInlines $ filterChildren (named "line") e-         metaBlock = acceptingMetadata (getBlocks e) >> return mempty  getInlines :: PandocMonad m => Element -> DB m Inlines getInlines e' = (trimInlines . mconcat) <$>
src/Text/Pandoc/Readers/Markdown.hs view
@@ -230,7 +230,6 @@                    $ nullMeta   updateState $ \st -> st{ stateMeta' = stateMeta' st <> meta' } - yamlMetaBlock :: PandocMonad m => MarkdownParser m (F Blocks) yamlMetaBlock = try $ do   guardEnabled Ext_yaml_metadata_block@@ -242,29 +241,31 @@   -- by including --- and ..., we allow yaml blocks with just comments:   let rawYaml = unlines ("---" : (rawYamlLines ++ ["..."]))   optional blanklines-  case YAML.decodeStrict (UTF8.fromString rawYaml) of-       Right (YAML.Mapping _ hashmap : _) -> do+  case YAML.decodeNode' YAML.failsafeSchemaResolver False False+               (UTF8.fromStringLazy rawYaml) of+       Right [YAML.Doc (YAML.Mapping _ hashmap)] -> do          let alist = M.toList hashmap          mapM_ (\(key, v) ->-           case YAML.parseEither (YAML.parseYAML key) of-                Left e  -> fail e-                Right k -> do-                  if ignorable k-                     then return ()-                     else do-                       v' <- yamlToMeta v-                       let k' = T.unpack k-                       updateState $ \st -> st{ stateMeta' =-                          do m <- stateMeta' st-                             -- if there's already a value, leave it unchanged-                             case lookupMeta k' m of-                                  Just _ -> return m-                                  Nothing -> do-                                    v'' <- v'-                                    return $ B.setMeta (T.unpack k) v'' m}-           ) alist+           case key of+                (YAML.Scalar (YAML.SStr t))       -> handleKey t v+                (YAML.Scalar (YAML.SUnknown _ t)) -> handleKey t v+                _                -> fail "Non-string key in YAML mapping") alist+           where handleKey k v =+                    if ignorable k+                       then return ()+                       else do+                         v' <- yamlToMeta v+                         let k' = T.unpack k+                         updateState $ \st -> st{ stateMeta' =+                            do m <- stateMeta' st+                               -- if there's already a value, leave it unchanged+                               case lookupMeta k' m of+                                    Just _ -> return m+                                    Nothing -> do+                                      v'' <- v'+                                      return $ B.setMeta (T.unpack k) v'' m}        Right [] -> return ()-       Right (YAML.Scalar YAML.SNull:_) -> return ()+       Right [YAML.Doc (YAML.Scalar YAML.SNull)] -> return ()        Right _ -> do                   logMessage $                      CouldNotParseYamlMetadata "not an object"@@ -303,11 +304,12 @@            => YAML.Node -> MarkdownParser m (F MetaValue) yamlToMeta (YAML.Scalar x) =   case x of-       YAML.SStr t   -> toMetaValue t-       YAML.SBool b  -> return $ return $ MetaBool b-       YAML.SFloat d -> return $ return $ MetaString (show d)-       YAML.SInt i   -> return $ return $ MetaString (show i)-       _             -> return $ return $ MetaString ""+       YAML.SStr t       -> toMetaValue t+       YAML.SBool b      -> return $ return $ MetaBool b+       YAML.SFloat d     -> return $ return $ MetaString (show d)+       YAML.SInt i       -> return $ return $ MetaString (show i)+       YAML.SUnknown _ t -> toMetaValue t+       YAML.SNull        -> return $ return $ MetaString "" yamlToMeta (YAML.Sequence _ xs) = do   xs' <- mapM yamlToMeta xs   return $ do
src/Text/Pandoc/Readers/Org/Parsing.hs view
@@ -137,14 +137,13 @@     <* updateLastPreCharPos     <* updateLastForbiddenCharPos --- The version Text.Pandoc.Parsing cannot be used, as we need additional parts--- of the state saved and restored.+-- | Like @'Text.Pandoc.Parsing'@, but resets the position of the last character+-- allowed before emphasised text. parseFromString :: Monad m => OrgParser m a -> String -> OrgParser m a parseFromString parser str' = do-  oldLastPreCharPos <- orgStateLastPreCharPos <$> getState   updateState $ \s -> s{ orgStateLastPreCharPos = Nothing }   result <- P.parseFromString parser str'-  updateState $ \s -> s{ orgStateLastPreCharPos = oldLastPreCharPos }+  updateState $ \s -> s { orgStateLastPreCharPos = Nothing }   return result  -- | Skip one or more tab or space characters.
src/Text/Pandoc/Readers/RST.hs view
@@ -37,7 +37,7 @@ import Control.Monad (forM_, guard, liftM, mplus, mzero, when) import Control.Monad.Except (throwError) import Control.Monad.Identity (Identity (..))-import Data.Char (isHexDigit, isSpace, toLower, toUpper)+import Data.Char (isHexDigit, isSpace, toLower, toUpper, isAlphaNum) import Data.List (deleteFirstsBy, elemIndex, intercalate, isInfixOf, isSuffixOf,                   nub, sort, transpose, union) import qualified Data.Map as M@@ -1313,20 +1313,25 @@  inline :: PandocMonad m => RSTParser m Inlines inline = choice [ note          -- can start with whitespace, so try before ws-                , whitespace                 , link-                , str                 , endline                 , strong                 , emph                 , code                 , subst                 , interpretedRole-                , smart-                , hyphens-                , escapedChar-                , symbol ] <?> "inline"+                , inlineContent ] <?> "inline" +-- strings, spaces and other characters that can appear either by+-- themselves or within inline markup+inlineContent :: PandocMonad m => RSTParser m Inlines+inlineContent = choice [ whitespace+                       , str+                       , smart+                       , hyphens+                       , escapedChar+                       , symbol ] <?> "inline content"+ parseInlineFromString :: PandocMonad m => String -> RSTParser m Inlines parseInlineFromString = parseFromString' (trimInlines . mconcat <$> many inline) @@ -1368,11 +1373,11 @@  emph :: PandocMonad m => RSTParser m Inlines emph = B.emph . trimInlines . mconcat <$>-         enclosed (atStart $ char '*') (char '*') inline+         enclosed (atStart $ char '*') (char '*') inlineContent  strong :: PandocMonad m => RSTParser m Inlines strong = B.strong . trimInlines . mconcat <$>-          enclosed (atStart $ string "**") (try $ string "**") inline+          enclosed (atStart $ string "**") (try $ string "**") inlineContent  -- Note, this doesn't precisely implement the complex rule in -- http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#inline-markup-recognition-rules@@ -1380,7 +1385,6 @@ -- -- TODO: --  - Classes are silently discarded in addNewRole---  - Lacks sensible implementation for title-reference (which is the default) --  - Allows direct use of the :raw: role, rST only allows inherited use. interpretedRole :: PandocMonad m => RSTParser m Inlines interpretedRole = try $ do@@ -1390,12 +1394,12 @@ renderRole :: PandocMonad m            => String -> Maybe String -> String -> Attr -> RSTParser m Inlines renderRole contents fmt role attr = case role of-    "sup"  -> return $ B.superscript $ B.str contents-    "superscript" -> return $ B.superscript $ B.str contents-    "sub"  -> return $ B.subscript $ B.str contents-    "subscript"  -> return $ B.subscript $ B.str contents-    "emphasis" -> return $ B.emph $ B.str contents-    "strong" -> return $ B.strong $ B.str contents+    "sup"  -> return $ B.superscript $ treatAsText contents+    "superscript" -> return $ B.superscript $ treatAsText contents+    "sub"  -> return $ B.subscript $ treatAsText contents+    "subscript"  -> return $ B.subscript $ treatAsText contents+    "emphasis" -> return $ B.emph $ treatAsText contents+    "strong" -> return $ B.strong $ treatAsText contents     "rfc-reference" -> return $ rfcLink contents     "RFC" -> return $ rfcLink contents     "pep-reference" -> return $ pepLink contents@@ -1406,7 +1410,7 @@     "title" -> titleRef contents     "t" -> titleRef contents     "code" -> return $ B.codeWith (addClass "sourceCode" attr) contents-    "span" -> return $ B.spanWith attr $ B.str contents+    "span" -> return $ B.spanWith attr $ treatAsText contents     "raw" -> return $ B.rawInline (fromMaybe "" fmt) contents     custom -> do         customRoles <- stateRstCustomRoles <$> getState@@ -1414,14 +1418,20 @@             Just (newRole, newFmt, newAttr) ->                 renderRole contents newFmt newRole newAttr             Nothing -> -- undefined role-                return $ B.spanWith ("",[],[("role",role)]) (B.str contents)+                return $ B.codeWith ("",["interpreted-text"],[("role",role)])+                          contents  where-   titleRef ref = return $ B.str ref -- FIXME: Not a sensible behaviour+   titleRef ref = return $ B.spanWith ("",["title-ref"],[]) $ treatAsText ref    rfcLink rfcNo = B.link rfcUrl ("RFC " ++ rfcNo) $ B.str ("RFC " ++ rfcNo)      where rfcUrl = "http://www.faqs.org/rfcs/rfc" ++ rfcNo ++ ".html"    pepLink pepNo = B.link pepUrl ("PEP " ++ pepNo) $ B.str ("PEP " ++ pepNo)      where padNo = replicate (4 - length pepNo) '0' ++ pepNo            pepUrl = "http://www.python.org/dev/peps/pep-" ++ padNo ++ "/"+   treatAsText = B.text . handleEscapes+   handleEscapes [] = []+   handleEscapes ('\\':' ':cs) = handleEscapes cs+   handleEscapes ('\\':c:cs) = c : handleEscapes cs+   handleEscapes (c:cs) = c : handleEscapes cs  addClass :: String -> Attr -> Attr addClass c (ident, classes, keyValues) = (ident, classes `union` [c], keyValues)@@ -1445,7 +1455,18 @@   return (role,contents)  unmarkedInterpretedText :: PandocMonad m => RSTParser m [Char]-unmarkedInterpretedText = enclosed (atStart $ char '`') (char '`') anyChar+unmarkedInterpretedText = try $ do+  atStart (char '`')+  contents <- mconcat <$> (many1+       (  many1 (noneOf "`\\\n")+      <|> (char '\\' >> ((\c -> ['\\',c]) <$> noneOf "\n"))+      <|> (string "\n" <* notFollowedBy blankline)+      <|> try (string "`" <*+                notFollowedBy (() <$ roleMarker) <*+                lookAhead (satisfy isAlphaNum))+       ))+  char '`'+  return contents  whitespace :: PandocMonad m => RSTParser m Inlines whitespace = B.space <$ skipMany1 spaceChar <?> "whitespace"@@ -1480,7 +1501,7 @@   char '`'   notFollowedBy (char '`') -- `` marks start of inline code   label' <- trimInlines . mconcat <$>-             manyTill (notFollowedBy (char '`') >> inline) (char '<')+             manyTill (notFollowedBy (char '`') >> inlineContent) (char '<')   src <- trim <$> manyTill (noneOf ">\n") (char '>')   skipSpaces   string "`_"
src/Text/Pandoc/Shared.hs view
@@ -94,6 +94,8 @@                      -- * for squashing blocks                      blocksToInlines,                      blocksToInlines',+                     blocksToInlinesWithSep,+                     defaultBlocksSeparator,                      -- * Safe read                      safeRead,                      -- * Temp directory@@ -757,11 +759,18 @@   mconcat . intersperse sep . map blockToInlines  blocksToInlines' :: [Block] -> Inlines-blocksToInlines' = blocksToInlinesWithSep parSep-  where parSep = B.space <> B.str "¶" <> B.space+blocksToInlines' = blocksToInlinesWithSep defaultBlocksSeparator  blocksToInlines :: [Block] -> [Inline] blocksToInlines = B.toList . blocksToInlines'++-- | Inline elements used to separate blocks when squashing blocks into+-- inlines.+defaultBlocksSeparator :: Inlines+defaultBlocksSeparator =+  -- This is used in the pandoc.utils.blocks_to_inlines function. Docs+  -- there should be updated if this is changed.+  B.space <> B.str "¶" <> B.space   --
src/Text/Pandoc/Writers/MediaWiki.hs view
@@ -313,6 +313,7 @@   let sep = case bs of                  [Plain _] -> " "                  [Para  _] -> " "+                 []        -> ""                  _         -> "\n"   return $ marker ++ attr ++ sep ++ trimr contents 
src/Text/Pandoc/Writers/RST.hs view
@@ -83,13 +83,14 @@   let render' :: Doc -> Text       render' = render colwidth   let subtit = case lookupMeta "subtitle" meta of-                    Just (MetaBlocks [Plain xs]) -> xs-                    _                            -> []+                    Just (MetaBlocks [Plain xs])  -> xs+                    Just (MetaInlines xs)         -> xs+                    _                             -> []   title <- titleToRST (docTitle meta) subtit   metadata <- metaToJSON opts                 (fmap render' . blockListToRST)                 (fmap (stripEnd . render') . inlineListToRST)-                $ B.deleteMeta "title" $ B.deleteMeta "subtitle" meta+                meta   body <- blockListToRST' True $ case writerTemplate opts of                                       Just _  -> normalizeHeadings 1 blocks                                       Nothing -> blocks@@ -105,7 +106,7 @@               $ defField "toc-depth" (show $ writerTOCDepth opts)               $ defField "number-sections" (writerNumberSections opts)               $ defField "math" hasMath-              $ defField "title" (render Nothing title :: String)+              $ defField "titleblock" (render Nothing title :: String)               $ defField "math" hasMath               $ defField "rawtex" rawTeX metadata   case writerTemplate opts of@@ -472,6 +473,8 @@           -- them and they will be readable and parsable           (Quoted _ _, _)          -> keep f i           (_, Quoted _ _)          -> keep f i+          -- inlineToRST handles this case properly so it's safe to keep+          (Link _ _ _, Image _ _ _) -> keep f i           -- parent inlines would prevent links from being correctly           -- parsed, in this case we prioritise the content over the           -- style@@ -571,15 +574,18 @@      else return $ "“" <> contents <> "”" inlineToRST (Cite _  lst) =   writeInlines lst+inlineToRST (Code (_,["interpreted-text"],[("role",role)]) str) = do+  return $ ":" <> text role <> ":`" <> text str <> "`" inlineToRST (Code _ str) = do   opts <- gets stOptions   -- we trim the string because the delimiters must adjoin a   -- non-space character; see #3496   -- we use :literal: when the code contains backticks, since   -- :literal: allows backslash-escapes; see #3974-  return $ if '`' `elem` str-              then ":literal:`" <> text (escapeString opts (trim str)) <> "`"-              else "``" <> text (trim str) <> "``"+  return $+    if '`' `elem` str+       then ":literal:`" <> text (escapeString opts (trim str)) <> "`"+       else "``" <> text (trim str) <> "``" inlineToRST (Str str) = do   opts <- gets stOptions   return $ text $
test/Tests/Lua.hs view
@@ -109,7 +109,8 @@     assertFilterConversion "pandoc.utils doesn't work as expected."       "test-pandoc-utils.lua"       (doc $ para "doesn't matter")-      (doc $ mconcat [ plain (str "hierarchicalize: OK")+      (doc $ mconcat [ plain (str "blocks_to_inlines: OK")+                     , plain (str "hierarchicalize: OK")                      , plain (str "normalize_date: OK")                      , plain (str "pipe: OK")                      , plain (str "failing pipe: OK")
test/Tests/Readers/Org/Block/List.hs view
@@ -243,4 +243,15 @@       mconcat [ para "CLOSED: [2015-10-19 Mon 15:03]"               , bulletList [ plain "Note taken on [2015-10-19 Mon 13:24]" ]               ]++  , "Markup after header and list" =:+      T.unlines [ "* headline"+                , "- list"+                , ""+                , "~variable name~"+                ] =?>+      mconcat [ headerWith ("headline", [], []) 1 "headline"+              , bulletList [ plain "list" ]+              , para (code "variable name")+              ]   ]
test/Tests/Readers/RST.hs view
@@ -177,7 +177,7 @@             =: ".. role:: haskell(code)\n.. role:: lhs(haskell)\n\n:lhs:`text`"             =?> para (codeWith ("", ["lhs", "haskell", "sourceCode"], []) "text")           , "unknown role" =: ":unknown:`text`" =?>-              para (spanWith ("",[],[("role","unknown")]) (str "text"))+              para (codeWith ("",["interpreted-text"],[("role","unknown")]) "text")           ]         , testGroup "footnotes"           [ "remove space before note" =: T.unlines@@ -187,5 +187,16 @@             , "   bar"             ] =?>               para ("foo" <> note (para "bar"))+          ]+        , testGroup "inlines"+          [ "links can contain an URI without being parsed twice (#4581)" =:+            "`http://loc <http://loc>`__" =?>+            para (link "http://loc" "" "http://loc")+          , "inline markup cannot be nested" =:+            "**a*b*c**" =?>+            para (strong "a*b*c")+          , "bare URI parsing disabled inside emphasis (#4561)" =:+            "*http://location*" =?>+            para (emph (text "http://location"))           ]         ]
test/Tests/Writers/RST.hs view
@@ -16,6 +16,11 @@      => String -> (a, String) -> TestTree (=:) = test (purely (writeRST def . toPandoc)) +testTemplate :: (ToString a, ToString c, ToPandoc a) =>+                String -> String -> (a, c) -> TestTree+testTemplate t =+  test (purely (writeRST def{ writerTemplate = Just t }) . toPandoc)+ tests :: [TestTree] tests = [ testGroup "rubrics"           [ "in list item" =:@@ -156,4 +161,7 @@               , "Header 2"               , "--------"]           ]+        , testTemplate "$subtitle$\n" "subtitle" $+          (setMeta "subtitle" ("subtitle" :: Inlines) $ doc $ plain "") =?>+          ("subtitle" :: String)         ]
test/command/3407.md view
@@ -1,6 +1,6 @@ ``` % pandoc -f native -t rst-[Para [Span ("",[],[("role","foo")]) [Str "text"]]]+[Para [Code ("",["interpreted-text"],[("role","foo")]) "text"]] ^D :foo:`text` ```@@ -9,5 +9,5 @@ % pandoc -f rst -t native :foo:`text` ^D-[Para [Span ("",[],[("role","foo")]) [Str "text"]]]+[Para [Code ("",["interpreted-text"],[("role","foo")]) "text"]] ```
+ test/command/4794.md view
@@ -0,0 +1,18 @@+```+% pandoc -f markdown -t mediawiki+| Column1 | Column2 | Column3 |+| ------- | ------- | ------- |+| text    |         | text    |+^D+{|+! Column1+! Column2+! Column3+|-+| text+|+| text+|}+++```
+ test/command/4811.md view
@@ -0,0 +1,48 @@+No blank lines in inline interpreted roles:++```+% pandoc -f rst -t native+`no++blank`:myrole:+^D+[Para [Str "`no"]+,Para [Str "blank`:myrole:"]]+```++Backslash escape behaves properly in interpreted roles:++```+% pandoc -f rst -t native+`hi\ there`:sup:++`hi\ there`:code:+^D+[Para [Superscript [Str "hithere"]]+,Para [Code ("",["sourceCode"],[]) "hi\\ there"]]+```++Backtick followed by alphanumeric doesn't end the span:+```+% pandoc -f rst -t native+`hi`there`:myrole:+^D+[Para [Code ("",["interpreted-text"],[("role","myrole")]) "hi`there"]]+```++Newline is okay, as long as not blank:+```+% pandoc -f rst -t native+`hi+there`:myrole:+^D+[Para [Code ("",["interpreted-text"],[("role","myrole")]) "hi\nthere"]]+```++Use span for title-reference:+```+% pandoc -f rst -t native+`default`+^D+[Para [Span ("",["title-ref"],[]) [Str "default"]]]+```
test/docbook-xref.native view
@@ -1,4 +1,4 @@-Pandoc (Meta {unMeta = fromList []})+Pandoc (Meta {unMeta = fromList [("title",MetaInlines [Str "An",Space,Str "Example",Space,Str "Book"])]}) [Header 1 ("ch01",[],[]) [Str "XRef",Space,Str "Samples"] ,Para [Str "This",Space,Str "paragraph",Space,Str "demonstrates",Space,Str "several",Space,Str "features",Space,Str "of",SoftBreak,Str "XRef."] ,BulletList
test/lua/test-pandoc-utils.lua view
@@ -1,5 +1,19 @@ utils = require 'pandoc.utils' +-- Squash blocks to inlines+------------------------------------------------------------------------+function test_blocks_to_inlines ()+  local blocks = {+    pandoc.Para{ pandoc.Str 'Paragraph1' },+    pandoc.Para{ pandoc.Emph 'Paragraph2' }+  }+  local inlines = utils.blocks_to_inlines(blocks, {pandoc.LineBreak()})+  return #inlines == 3+    and inlines[1].text == "Paragraph1"+    and inlines[2].t == 'LineBreak'+    and inlines[3].content[1].text == "Paragraph2"+end+ -- hierarchicalize ------------------------------------------------------------------------ function test_hierarchicalize ()@@ -110,6 +124,7 @@  function Para (el)   return {+    pandoc.Plain{pandoc.Str("blocks_to_inlines: " .. run(test_blocks_to_inlines))},     pandoc.Plain{pandoc.Str("hierarchicalize: " .. run(test_hierarchicalize))},     pandoc.Plain{pandoc.Str("normalize_date: " .. run(test_normalize_date))},     pandoc.Plain{pandoc.Str("pipe: " .. run(test_pipe))},
test/rst-reader.native view
@@ -326,7 +326,7 @@ ,Para [Math DisplayMath "\\alpha = beta",Math DisplayMath "E = mc^2"] ,Para [Str "Some",Space,Superscript [Str "of"],Space,Str "these",Space,Superscript [Str "words"],Space,Str "are",Space,Str "in",Space,Superscript [Str "superscript"],Str "."] ,Para [Str "Reset",Space,Str "default-role",Space,Str "to",Space,Str "the",Space,Str "default",Space,Str "default."]-,Para [Str "And",Space,Str "now",Space,Str "some-invalid-string-3231231",Space,Str "is",Space,Str "nonsense."]+,Para [Str "And",Space,Str "now",Space,Span ("",["title-ref"],[]) [Str "some-invalid-string-3231231"],Space,Str "is",Space,Str "nonsense."] ,Para [Str "And",Space,Str "now",Space,Str "with",Space,RawInline (Format "html") "<b>inline</b> <span id=\"test\">HTML</span>",Str "."] ,Para [Str "And",Space,Str "some",Space,Str "inline",Space,Str "haskell",Space,Code ("",["haskell","sourceCode"],[]) "fmap id [1,2..10]",Str "."] ,Para [Str "Indirect",Space,Str "python",Space,Str "role",Space,Code ("",["py","python","indirect","sourceCode"],[]) "[x*x for x in [1,2,3,4,5]]",Str "."]