pandoc 2.9 → 2.9.1
raw patch · 42 files changed
+1348/−485 lines, 42 filesdep +jira-wiki-markup
Dependencies added: jira-wiki-markup
Files
- AUTHORS.md +1/−0
- MANUAL.txt +5/−3
- README.md +3/−0
- changelog.md +79/−9
- man/pandoc.1 +6/−3
- man/pandoc.1.after +3/−0
- man/pandoc.1.before +2/−0
- man/pandoc.1.template +0/−10
- pandoc.cabal +9/−7
- src/Text/Pandoc/App/Opt.hs +3/−1
- src/Text/Pandoc/MIME.hs +2/−1
- src/Text/Pandoc/PDF.hs +1/−1
- src/Text/Pandoc/Readers.hs +3/−0
- src/Text/Pandoc/Readers/HTML.hs +2/−1
- src/Text/Pandoc/Readers/Jira.hs +173/−0
- src/Text/Pandoc/Readers/Org.hs +1/−2
- src/Text/Pandoc/Readers/Org/Blocks.hs +11/−5
- src/Text/Pandoc/Readers/Org/DocumentTree.hs +26/−11
- src/Text/Pandoc/Readers/Org/Parsing.hs +1/−0
- src/Text/Pandoc/Shared.hs +17/−13
- src/Text/Pandoc/Templates.hs +4/−3
- src/Text/Pandoc/Writers/CommonMark.hs +3/−5
- src/Text/Pandoc/Writers/HTML.hs +7/−4
- src/Text/Pandoc/Writers/Jira.hs +203/−247
- src/Text/Pandoc/Writers/Markdown.hs +1/−2
- src/Text/Pandoc/Writers/RTF.hs +1/−2
- stack.yaml +1/−0
- test/Tests/Old.hs +2/−0
- test/Tests/Readers/HTML.hs +4/−0
- test/Tests/Readers/Jira.hs +114/−0
- test/Tests/Readers/Org/Block/Header.hs +10/−0
- test/Tests/Readers/Org/Block/Table.hs +7/−0
- test/command/3706.md +10/−9
- test/command/5986.md +16/−0
- test/command/section-divs.md +25/−0
- test/command/toc.md +56/−0
- test/jira-reader.jira +284/−0
- test/jira-reader.native +185/−0
- test/tables.jira +18/−23
- test/test-pandoc.hs +2/−0
- test/writer.jira +46/−123
- trypandoc/index.html +1/−0
AUTHORS.md view
@@ -97,6 +97,7 @@ - Ilya V. Portnov - Ivan Trubach - Ivo Clarysse+- Jared Lander - J. B. Rainsberger - J. Lewis Muir - Jaime Marquínez Ferrándiz
MANUAL.txt view
@@ -1,7 +1,7 @@ --- title: Pandoc User's Guide author: John MacFarlane-date: December 12, 2019+date: December 21, 2019 --- # Synopsis@@ -240,6 +240,7 @@ - `html` ([HTML]) - `ipynb` ([Jupyter notebook]) - `jats` ([JATS] XML)+ - `jira` ([Jira] wiki markup) - `json` (JSON version of native AST) - `latex` ([LaTeX]) - `markdown` ([Pandoc's Markdown])@@ -506,8 +507,9 @@ `--base-header-level=`*NUMBER* -: *Deprecated. Use `--shift-heading-level-by` instead.*- Specify the base level for headings (defaults to 1).+: *Deprecated. Use `--shift-heading-level-by`=X instead,+ where X = NUMBER - 1.* Specify the base level for headings+ (defaults to 1). `--strip-empty-paragraphs`
README.md view
@@ -48,6 +48,9 @@ - `ipynb` ([Jupyter notebook](https://nbformat.readthedocs.io/en/latest/)) - `jats` ([JATS](https://jats.nlm.nih.gov) XML)+ - `jira`+ ([Jira](https://jira.atlassian.com/secure/WikiRendererHelpAction.jspa?section=all)+ wiki markup) - `json` (JSON version of native AST) - `latex` ([LaTeX](http://latex-project.org)) - `markdown` ([Pandoc’s
changelog.md view
@@ -1,7 +1,77 @@ # Revision history for pandoc -## pandoc 2.9 (PROVISIONAL)+## pandoc 2.9.1 (2019-12-23) + * Add Jira reader (Albert Krewinkel, #5556).++ * Jira writer: use jira-wiki-markup renderer (Albert Krewinkel,+ #5926). The following improvements are included in this change:++ + non-jira raw blocks are fully discarded instead of showing+ as blank lines;+ + table cells can contain multiple blocks;+ + unnecessary blank lines are removed from the output;+ + markup chars within words are properly surrounded by+ braces;+ + preserving soft linebreaks via `--wrap=preserve` is+ supported.++ Note that backslashes are rendered as HTML entities, as there+ appears no alternative to produce a plain backslash if it is+ followed by markup. This may cause problems when used with+ confluence, where rendering seems to fail in this case.++ * Fix regression with `--number-sections`. Starting with 2.8,+ `--number-sections` also had the effect of `--section-divs`,+ even if `--section-divs` was not specified.++ * Improved table of contents generation in markdown, RTF,+ commonmark, better handling cases where section headings are+ enclosed in divs.++ * Ensure that later default file values for `variable` replace+ earlier ones (5988).++ * HTML reader: Add `nav` to list of block-level tags.++ * Org reader (Albert Krewinkel):++ + Wrap named table in Div, using name as id (#5984).+ Tables which are given a name via `#+NAME:` or `#+LABEL:`+ are wrapped in an additional Div, with the name set as the+ Div's ID.+ + Report parsing errors properly.+ + Fix parsing problem for colons in headline (#5993).++ * Text.Pandoc.PDF: Ensure UTF8 when printing source in+ `--verbose` mode, avoiding an error on platforms that+ default to something other than UTF-8 (#5997).++ * Text.Pandoc.Templates: Strip directory before trying to find+ partial in data files (#5987).++ * Text.Pandoc.Shared: Improve `makeSections` so we don't get+ doubled "number" attributes in EPUB output (or anywhere+ else) (#5986).++ * Added tests for `--toc` and `--section-divs`.++ * Text.Pandoc.MIME: Added glsl MIME type for WebGL maps (#6000,+ Jared Lander).++ * MANUAL: A bit clearer explanation for `--base-header-level`.+ We now say exactly how to translate between the deprecated+ `--base-header-level` and `--shift-heading-level-by`.++ * lua-filters.md:++ + Remove spurious dot in title (#5996, Mauro Bieg).+ + Replace metadata example with image centering (#6004,+ Albert Krewinkel). Thanks to @efx for proposing this filter.+++## pandoc 2.9 (2019-12-11)+ * Text.Pandoc.Templates [API change] + Add Monad wrappers `WithDefaultPartials` and `WithPartials`.@@ -1604,7 +1674,7 @@ the title slide (for beamer). This change makes possible 2D reveal.js slideshows with content in the top slide on each stack (#4317, #5237).- + * Add command line option `--ipynb-output=all|none|best` (#5339). Output cells in ipynb notebooks often contain several different versions of an output, with different MIME types, e.g. an HTML@@ -1751,7 +1821,7 @@ `utils`, and `text`, respectively. * Text.Pandoc.Lua (Albert Krewinkel):- + + Split `StackInstances` into smaller Marshaling modules. + Get `CommonState` from Lua global. This allows more control over the common state from within Lua scripts.@@ -2088,7 +2158,7 @@ * Text.Pandoc.Writers: Changed types of `writeJSON`; it now runs in an instance of PandocMonad, like the other readers and- writers. [API change] + writers. [API change] * Text.Pandoc.Error: Added `PandocUTF8DecodingError` constructor for `PandocError`. [API change]@@ -2427,7 +2497,7 @@ used when `raw_html` is enabled. * Powerpoint writer: support raw openxml (Jesse Rosenthal, #4976).- This allows raw openxml blocks and inlines to be used in the pptx + This allows raw openxml blocks and inlines to be used in the pptx writer. Caveats: (1) It's up to the user to write well-formed openxml. The chances for corruption, especially with such a brittle format as pptx, is high. (2) Because of@@ -2504,7 +2574,7 @@ using a generic `for` loop with pairs`: for field_name, field_content in pairs(element) do- ... + ... end Raw table fields of AST elements should be considered an@@ -5971,7 +6041,7 @@ * HTML reader: parse a span with class `smallcaps` as `SmallCaps`. * LaTeX reader:- + + Implemented `\graphicspath` (#736). + Properly handle column prefixes/suffixes. For example, in `\begin{tabular}{>{$}l<{$}>{$}l<{$} >{$}l<{$}}`@@ -7249,7 +7319,7 @@ This is needed for dependency version numbers to be available, with Cabal > 2. -## pandoc 1.19.2.3 (2017-09-09) +## pandoc 1.19.2.3 (2017-09-09) * Add CPP to Setup.hs so it works with Cabal >= 2 and < 2. @@ -8683,7 +8753,7 @@ benefit that footnotes and links can be in different files, but for some purposes it is useful to parse the individual files first and then combine their outputs (e.g. when the files use footnotes- or links with the same labels). The `--file-scope` option causes + or links with the same labels). The `--file-scope` option causes pandoc to parse the files first, and then combine the parsed output, instead of combining before parsing. `--file-scope` is selected automatically for binary input files (which cannot be concatenated)
man/pandoc.1 view
@@ -1,5 +1,5 @@ .\"t-.TH PANDOC 1 "December 12, 2019" "pandoc 2.9"+.TH PANDOC 1 "December 21, 2019" "pandoc 2.9.1" .SH NAME pandoc - general markup converter .SH SYNOPSIS@@ -250,6 +250,8 @@ .IP \[bu] 2 \f[C]jats\f[R] (JATS XML) .IP \[bu] 2+\f[C]jira\f[R] (Jira wiki markup)+.IP \[bu] 2 \f[C]json\f[R] (JSON version of native AST) .IP \[bu] 2 \f[C]latex\f[R] (LaTeX)@@ -525,8 +527,9 @@ pandoc uses a level-1 heading to render the document title. .TP \f[B]\f[CB]--base-header-level=\f[B]\f[R]\f[I]NUMBER\f[R]-\f[I]Deprecated. Use \f[CI]--shift-heading-level-by\f[I] instead.\f[R]-Specify the base level for headings (defaults to 1).+\f[I]Deprecated. Use \f[CI]--shift-heading-level-by\f[I]=X instead,+where X = NUMBER - 1.\f[R] Specify the base level for headings (defaults+to 1). .TP \f[B]\f[CB]--strip-empty-paragraphs\f[B]\f[R] \f[I]Deprecated. Use the \f[CI]+empty_paragraphs\f[I] extension
+ man/pandoc.1.after view
@@ -0,0 +1,3 @@+.PP+The Pandoc source code and all documentation may be downloaded+from <http://pandoc.org>.
+ man/pandoc.1.before view
@@ -0,0 +1,2 @@+.SH NAME+pandoc - general markup converter
− man/pandoc.1.template
@@ -1,10 +0,0 @@-$if(has-tables)$-.\"t-$endif$-.TH PANDOC 1 "$date$" "$version$"-.SH NAME-pandoc - general markup converter-$body$-.PP-The Pandoc source code and all documentation may be downloaded-from <http://pandoc.org>.
pandoc.cabal view
@@ -1,5 +1,5 @@ name: pandoc-version: 2.9+version: 2.9.1 cabal-version: 2.0 build-type: Simple license: GPL-2@@ -18,8 +18,8 @@ this library. It can read several dialects of Markdown and (subsets of) HTML, reStructuredText, LaTeX, DocBook, JATS, MediaWiki markup, DokuWiki markup, TWiki markup,- TikiWiki markup, Creole 1.0, Haddock markup, OPML,- Emacs Org-Mode, Emacs Muse, txt2tags, ipynb (Jupyter+ TikiWiki markup, Jira markup, Creole 1.0, Haddock markup,+ OPML, Emacs Org-Mode, Emacs Muse, txt2tags, ipynb (Jupyter notebooks), Vimwiki, Word Docx, ODT, EPUB, FictionBook2, roff man, and Textile, and it can write Markdown, reStructuredText, XHTML, HTML 5, LaTeX, ConTeXt, DocBook,@@ -188,7 +188,8 @@ stack.yaml -- files needed to build man page man/manfilter.lua- man/pandoc.1.template+ man/pandoc.1.before+ man/pandoc.1.after -- trypandoc trypandoc/Makefile trypandoc/index.html@@ -243,9 +244,9 @@ test/mediawiki-reader.wiki test/vimwiki-reader.wiki test/creole-reader.txt- test/creole-reader.native test/rst-reader.rst test/jats-reader.xml+ test/jira-reader.jira test/s5-basic.html test/s5-fancy.html test/s5-fragment.html@@ -325,9 +326,7 @@ test/lhs-test.fragment.html+lhs test/pipe-tables.txt test/dokuwiki_external_images.dokuwiki- test/dokuwiki_external_images.native test/dokuwiki_multiblock_table.dokuwiki- test/dokuwiki_multiblock_table.native test/fb2/*.markdown test/fb2/*.fb2 test/fb2/images-embedded.html@@ -405,6 +404,7 @@ blaze-html >= 0.9 && < 0.10, blaze-markup >= 0.8 && < 0.9, vector >= 0.10 && < 0.13,+ jira-wiki-markup >= 1.0 && < 1.1, hslua >= 1.0.1 && < 1.1, hslua-module-system >= 0.2 && < 0.3, hslua-module-text >= 0.2 && < 0.3,@@ -487,6 +487,7 @@ Text.Pandoc.Readers.Org, Text.Pandoc.Readers.DocBook, Text.Pandoc.Readers.JATS,+ Text.Pandoc.Readers.Jira, Text.Pandoc.Readers.OPML, Text.Pandoc.Readers.Textile, Text.Pandoc.Readers.Native,@@ -750,6 +751,7 @@ Tests.Readers.LaTeX Tests.Readers.HTML Tests.Readers.JATS+ Tests.Readers.Jira Tests.Readers.Markdown Tests.Readers.Org Tests.Readers.Org.Block
src/Text/Pandoc/App/Opt.hs view
@@ -180,7 +180,9 @@ parseYAML v >>= \x -> return (\o -> o{ optTemplate = unpack <$> x }) "variables" -> parseYAML v >>= \x -> return (\o -> o{ optVariables =- optVariables o <> x })+ x <> optVariables o })+ -- Note: x comes first because <> for Context is left-biased union+ -- and we want to favor later default files. See #5988. "metadata" -> parseYAML v >>= \x -> return (\o -> o{ optMetadata = optMetadata o <> contextToMeta x })
src/Text/Pandoc/MIME.hs view
@@ -9,7 +9,7 @@ Stability : alpha Portability : portable -Mime type lookup for ODT writer.+Mime type lookup. -} module Text.Pandoc.MIME ( MimeType, getMimeType, getMimeTypeDef, extensionFromMimeType, mediaCategory ) where@@ -195,6 +195,7 @@ ,("gjc","chemical/x-gaussian-input") ,("gjf","chemical/x-gaussian-input") ,("gl","video/gl")+ ,("glsl","text/plain") ,("gnumeric","application/x-gnumeric") ,("gpt","chemical/x-mopac-graph") ,("gsf","application/x-font")
src/Text/Pandoc/PDF.hs view
@@ -507,7 +507,7 @@ mapM_ print env putStr "\n" putStrLn $ "[makePDF] Source:"- putStrLn source+ UTF8.putStrLn source handlePDFProgramNotFound :: String -> IE.IOError -> IO a handlePDFProgramNotFound program e
src/Text/Pandoc/Readers.hs view
@@ -37,6 +37,7 @@ , readLaTeX , readHtml , readJATS+ , readJira , readTextile , readDocBook , readOPML@@ -78,6 +79,7 @@ import Text.Pandoc.Readers.Haddock import Text.Pandoc.Readers.HTML (readHtml) import Text.Pandoc.Readers.JATS (readJATS)+import Text.Pandoc.Readers.Jira (readJira) import Text.Pandoc.Readers.LaTeX import Text.Pandoc.Readers.Markdown import Text.Pandoc.Readers.MediaWiki@@ -121,6 +123,7 @@ ,("textile" , TextReader readTextile) -- TODO : textile+lhs ,("html" , TextReader readHtml) ,("jats" , TextReader readJATS)+ ,("jira" , TextReader readJira) ,("latex" , TextReader readLaTeX) ,("haddock" , TextReader readHaddock) ,("twiki" , TextReader readTWiki)
src/Text/Pandoc/Readers/HTML.hs view
@@ -1039,7 +1039,8 @@ "dir", "div", "dl", "dt", "fieldset", "figcaption", "figure", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup", "hr", "html",- "isindex", "main", "menu", "meta", "noframes", "ol", "output", "p", "pre",+ "isindex", "main", "menu", "meta", "noframes", "nav",+ "ol", "output", "p", "pre", "section", "table", "tbody", "textarea", "thead", "tfoot", "ul", "dd", "dt", "frameset", "li", "tbody", "td", "tfoot",
+ src/Text/Pandoc/Readers/Jira.hs view
@@ -0,0 +1,173 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE LambdaCase #-}+{-# LANGUAGE OverloadedStrings #-}+{- |+ Module : Text.Pandoc.Readers.Org+ Copyright : © 2019 Albert Krewinkel+ License : GNU GPL, version 2 or above++ Maintainer : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>++Conversion of jira wiki formatted plain text to 'Pandoc' document.+-}+module Text.Pandoc.Readers.Jira ( readJira ) where++import Prelude+import Control.Monad.Except (throwError)+import Data.Text (Text, append, pack, singleton, unpack)+import Text.HTML.TagSoup.Entity (lookupEntity)+import Text.Jira.Parser (parse)+import Text.Pandoc.Class (PandocMonad (..))+import Text.Pandoc.Builder+import Text.Pandoc.Error (PandocError (PandocParseError))+import Text.Pandoc.Options (ReaderOptions)+import Text.Pandoc.Shared (stringify)++import qualified Text.Jira.Markup as Jira++-- | Read Jira wiki markup.+readJira :: PandocMonad m+ => ReaderOptions+ -> Text+ -> m Pandoc+readJira _opts s = case parse s of+ Right d -> return $ jiraToPandoc d+ Left e -> throwError . PandocParseError $+ "Jira parse error" `append` pack (show e)++jiraToPandoc :: Jira.Doc -> Pandoc+jiraToPandoc (Jira.Doc blks) = doc $ foldMap jiraToPandocBlocks blks++--+-- Blocks+--++-- | Converts a Jira block to a Pandoc block.+jiraToPandocBlocks :: Jira.Block -> Blocks+jiraToPandocBlocks = \case+ Jira.BlockQuote blcks -> blockQuote $ foldMap jiraToPandocBlocks blcks+ Jira.Code lang ps txt -> toPandocCodeBlocks (Just lang) ps txt+ Jira.Color c blcks -> divWith (mempty, mempty, [("color", colorName c)]) $+ foldMap jiraToPandocBlocks blcks+ Jira.Header lvl inlns -> header lvl $ foldMap jiraToPandocInlines inlns+ Jira.HorizontalRule -> horizontalRule+ Jira.List style items -> toPandocList style items+ Jira.NoFormat ps txt -> toPandocCodeBlocks Nothing ps txt+ Jira.Panel ps blcks -> toPandocDiv ps blcks+ Jira.Para inlns -> para $ foldMap jiraToPandocInlines inlns+ Jira.Table rows -> toPandocTable rows++-- | Create a pandoc list – either to a @'BulletList'@ or an @'OrderedList'@.+toPandocList :: Jira.ListStyle -> [[Jira.Block]] -> Blocks+toPandocList style items =+ let items' = map (foldMap jiraToPandocBlocks) items+ in if style == Jira.Enumeration+ then orderedList items'+ else bulletList items'++-- | Create a pandoc @'CodeBlock'@+toPandocCodeBlocks :: Maybe Jira.Language -> [Jira.Parameter] -> Text -> Blocks+toPandocCodeBlocks langMay params txt =+ let classes = case langMay of+ Just (Jira.Language lang) -> [lang]+ Nothing -> []+ in codeBlockWith ("", classes, map paramToPair params) txt++-- | Create a pandoc @'Div'@+toPandocDiv :: [Jira.Parameter] -> [Jira.Block] -> Blocks+toPandocDiv params =+ divWith ("", [], map paramToPair params) . foldMap jiraToPandocBlocks++paramToPair :: Jira.Parameter -> (Text, Text)+paramToPair (Jira.Parameter key value) = (key, value)++-- | Give textual representation of a color.+colorName :: Jira.ColorName -> Text+colorName (Jira.ColorName name) = name++-- | Create a pandoc @'Table'@.+-- This relies on 'simpleTable' to sanitize the table.+toPandocTable :: [Jira.Row] -> Blocks+toPandocTable rows =+ let (headerRow, bodyRows) = splitIntoHeaderAndBody rows+ in simpleTable+ (rowToBlocksList headerRow)+ (map rowToBlocksList bodyRows)++rowToBlocksList :: Jira.Row -> [Blocks]+rowToBlocksList (Jira.Row cells) =+ map cellContent cells+ where+ cellContent cell = let content = case cell of+ Jira.HeaderCell x -> x+ Jira.BodyCell x -> x+ in foldMap jiraToPandocBlocks content++splitIntoHeaderAndBody :: [Jira.Row] -> (Jira.Row, [Jira.Row])+splitIntoHeaderAndBody [] = (Jira.Row [], [])+splitIntoHeaderAndBody rows@(first@(Jira.Row cells) : rest) =+ let isHeaderCell (Jira.HeaderCell{}) = True+ isHeaderCell (Jira.BodyCell{}) = False+ in if all isHeaderCell cells+ then (first, rest)+ else (Jira.Row [], rows)++--+-- Inlines+--++-- | Converts a Jira inline to a Pandoc block.+jiraToPandocInlines :: Jira.Inline -> Inlines+jiraToPandocInlines = \case+ Jira.Anchor t -> spanWith (t, [], []) mempty+ Jira.AutoLink url -> link (Jira.fromURL url) "" (str (Jira.fromURL url))+ Jira.Emoji icon -> str . iconUnicode $ icon+ Jira.Entity entity -> str . fromEntity $ entity+ Jira.Image _ url -> image (Jira.fromURL url) "" mempty+ Jira.Link alias url -> link (Jira.fromURL url) "" (fromInlines alias)+ Jira.Linebreak -> linebreak+ Jira.Monospaced inlns -> code . stringify . toList . fromInlines $ inlns+ Jira.Space -> space+ Jira.SpecialChar c -> str (Data.Text.singleton c)+ Jira.Str t -> str t+ Jira.Styled style inlns -> fromStyle style $ fromInlines inlns+ where+ fromInlines = foldMap jiraToPandocInlines+ fromEntity e = case lookupEntity (unpack e ++ ";") of+ Nothing -> "&" `append` e `append` ";"+ Just cs -> pack cs++ fromStyle = \case+ Jira.Emphasis -> emph+ Jira.Insert -> spanWith ("", ["inserted"], [])+ Jira.Strikeout -> strikeout+ Jira.Strong -> strong+ Jira.Subscript -> subscript+ Jira.Superscript -> superscript++-- | Get unicode representation of a Jira icon.+iconUnicode :: Jira.Icon -> Text+iconUnicode = \case+ Jira.IconSlightlySmiling -> "🙂"+ Jira.IconFrowning -> "🙁"+ Jira.IconTongue -> "😛"+ Jira.IconSmiling -> "😃"+ Jira.IconWinking -> "😉"+ Jira.IconThumbsUp -> "👍"+ Jira.IconThumbsDown -> "👎"+ Jira.IconInfo -> "ℹ"+ Jira.IconCheckmark -> "✓"+ Jira.IconX -> "🅇"+ Jira.IconAttention -> "⚠"+ Jira.IconPlus -> "⊞"+ Jira.IconMinus -> "⊟"+ Jira.IconQuestionmark -> "?"+ Jira.IconOn -> "💡"+ Jira.IconOff -> "💡"+ Jira.IconStar -> "★"+ Jira.IconStarRed -> "★"+ Jira.IconStarGreen -> "★"+ Jira.IconStarBlue -> "★"+ Jira.IconStarYellow -> "★"+ Jira.IconFlag -> "⚑"+ Jira.IconFlagOff -> "⚐"
src/Text/Pandoc/Readers/Org.hs view
@@ -18,7 +18,6 @@ import Text.Pandoc.Class (PandocMonad) import Text.Pandoc.Definition-import Text.Pandoc.Error import Text.Pandoc.Options import Text.Pandoc.Parsing (reportLogMessages) import Text.Pandoc.Shared (crFilter)@@ -39,7 +38,7 @@ (crFilter s <> "\n\n") case parsed of Right result -> return result- Left _ -> throwError $ PandocParseError "problem parsing org"+ Left e -> throwError e -- -- Parser
src/Text/Pandoc/Readers/Org/Blocks.hs view
@@ -33,7 +33,7 @@ import Text.Pandoc.Options import Text.Pandoc.Shared (compactify, compactifyDL, safeRead) -import Control.Monad (foldM, guard, mzero, void)+import Control.Monad (foldM, guard, mplus, mzero, void) import Data.Char (isSpace) import Data.Default (Default) import Data.List (foldl')@@ -613,10 +613,16 @@ guard =<< not . isFirstInListItem <$> getState blockAttrs <- blockAttributes lookAhead tableStart- do- rows <- tableRows- let caption = fromMaybe (return mempty) $ blockAttrCaption blockAttrs- return $ (<$> caption) . orgToPandocTable . normalizeTable =<< rowsToTable rows+ rows <- tableRows++ let caption = fromMaybe mempty (blockAttrCaption blockAttrs)+ let orgTbl = normalizeTable <$> rowsToTable rows+ -- wrap table in div if a name or label is given+ let identMb = blockAttrName blockAttrs `mplus` blockAttrLabel blockAttrs+ let wrap = case identMb of+ Just ident -> B.divWith (ident, mempty, mempty)+ Nothing -> id+ return . fmap wrap $ (orgToPandocTable <$> orgTbl <*> caption) orgToPandocTable :: OrgTable -> Inlines
src/Text/Pandoc/Readers/Org/DocumentTree.hs view
@@ -1,6 +1,7 @@ {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE TupleSections #-} {- | Module : Text.Pandoc.Readers.Org.DocumentTree Copyright : Copyright (C) 2014-2019 Albert Krewinkel@@ -16,8 +17,8 @@ ) where import Prelude-import Control.Arrow ((***))-import Control.Monad (guard, void)+import Control.Arrow ((***), first)+import Control.Monad (guard) import Data.List (intersperse) import Data.Maybe (mapMaybe) import Data.Text (Text)@@ -110,15 +111,13 @@ level <- headerStart guard (lvl <= level) todoKw <- optionMaybe todoKeyword- title <- trimInlinesF . mconcat <$> manyTill inline endOfTitle- tags <- option [] headerTags- newline+ (title, tags) <- manyThen inline endOfTitle planning <- option emptyPlanning planningInfo properties <- option mempty propertiesDrawer contents <- blocks children <- many (headline blocks inline (level + 1)) return $ do- title' <- title+ title' <- trimInlinesF (mconcat title) contents' <- contents children' <- sequence children return Headline@@ -132,13 +131,29 @@ , headlineChildren = children' } where- endOfTitle :: Monad m => OrgParser m ()- endOfTitle = void . lookAhead $ optional headerTags *> newline+ endOfTitle :: Monad m => OrgParser m [Tag]+ endOfTitle = try $ do+ skipSpaces+ tags <- option [] (headerTags <* skipSpaces)+ newline+ return tags headerTags :: Monad m => OrgParser m [Tag]- headerTags = try $- let tag = orgTagWord <* char ':'- in map toTag <$> (skipSpaces *> char ':' *> many1 tag <* skipSpaces)+ headerTags = try $ do+ char ':'+ endBy1 (toTag <$> orgTagWord) (char ':')++ manyThen :: Monad m+ => OrgParser m a+ -> OrgParser m b+ -> OrgParser m ([a], b)+ manyThen p end = (([],) <$> try end) <|> do+ x <- p+ first (x:) <$> manyThen p end++ -- titleFollowedByTags :: Monad m => OrgParser m (Inlines, [Tag])+ -- titleFollowedByTags = do+ unprunedHeadlineToBlocks :: Monad m => Headline -> OrgParserState -> OrgParser m [Block] unprunedHeadlineToBlocks hdln st =
src/Text/Pandoc/Readers/Org/Parsing.hs view
@@ -94,6 +94,7 @@ , sepBy , sepBy1 , sepEndBy1+ , endBy1 , option , optional , optionMaybe
@@ -582,25 +582,20 @@ let attr = ("",classes,kvs') return $ Div divattr (Header level' attr title' : sectionContents') : rest'- go (Div (dident,dclasses,dkvs)- (Header level (ident,classes,kvs) title':ys) : xs)+ go (Div divattr@(dident,dclasses,_) (Header level hattr title':ys) : xs) | all (\case Header level' _ _ -> level' > level _ -> True) ys , "column" `notElem` dclasses , "columns" `notElem` dclasses = do- inner <- go (Header level (ident,classes,kvs) title':ys)- let inner' =- case inner of- (Div (dident',dclasses',dkvs') zs@(Header{}:zs') : ws)- | T.null dident ->- Div (dident',dclasses' ++ dclasses,dkvs' ++ dkvs) zs : ws- | otherwise -> -- keep id on header so we don't lose anchor- Div (dident,dclasses ++ dclasses',dkvs ++ dkvs')- (Header level (dident',classes,kvs) title':zs') : ws- _ -> inner -- shouldn't happen+ inner <- go (Header level hattr title':ys) rest <- go xs- return $ inner' ++ rest+ return $+ case inner of+ [Div divattr'@(dident',_,_) zs]+ | T.null dident || T.null dident' || dident == dident'+ -> Div (combineAttr divattr' divattr) zs : rest+ _ -> Div divattr inner : rest go (Div attr xs : rest) = do xs' <- go xs rest' <- go rest@@ -608,6 +603,14 @@ go (x:xs) = (x :) <$> go xs go [] = return [] + combineAttr :: Attr -> Attr -> Attr+ combineAttr (id1, classes1, kvs1) (id2, classes2, kvs2) =+ (if T.null id1 then id2 else id1,+ ordNub (classes1 ++ classes2),+ foldr (\(k,v) kvs -> case lookup k kvs of+ Nothing -> (k,v):kvs+ Just _ -> kvs) mempty (kvs1 ++ kvs2))+ headerLtEq :: Int -> Block -> Bool headerLtEq level (Header l _ _) = l <= level headerLtEq level (Div _ (b:_)) = headerLtEq level b@@ -642,6 +645,7 @@ , m + n == 0 = headerShift n $ B.setTitle (B.fromList ils) $ Pandoc meta bs headerShift n (Pandoc meta bs) = Pandoc meta (walk shift bs)+ where shift :: Block -> Block shift (Header level attr inner)
src/Text/Pandoc/Templates.hs view
@@ -25,7 +25,7 @@ ) where import Prelude-import System.FilePath ((<.>), (</>))+import System.FilePath ((<.>), (</>), takeFileName) import Text.DocTemplates (Template, TemplateMonad(..), compileTemplate, renderTemplate) import Text.Pandoc.Class (PandocMonad, readDataFile, fetchItem, CommonState(..), getCommonState, modifyCommonState)@@ -48,7 +48,7 @@ instance PandocMonad m => TemplateMonad (WithDefaultPartials m) where getPartial fp = WithDefaultPartials $- UTF8.toText <$> readDataFile fp+ UTF8.toText <$> readDataFile ("templates" </> takeFileName fp) instance PandocMonad m => TemplateMonad (WithPartials m) where getPartial fp = WithPartials $ getTemplate fp@@ -68,7 +68,8 @@ `catchError` (\e -> case e of PandocResourceNotFound _ ->- readDataFile ("templates" </> tp)+ -- see #5987 on reason for takeFileName+ readDataFile ("templates" </> takeFileName tp) _ -> throwError e)) -- | Get default template for the specified writer.
src/Text/Pandoc/Writers/CommonMark.hs view
@@ -28,7 +28,7 @@ import Text.Pandoc.Class (PandocMonad) import Text.Pandoc.Definition import Text.Pandoc.Options-import Text.Pandoc.Shared (capitalize, isHeaderBlock, isTightList,+import Text.Pandoc.Shared (capitalize, isTightList, linesToPara, onlySimpleTableCells, taskListItemToAscii, tshow) import Text.Pandoc.Templates (renderTemplate) import Text.Pandoc.Walk (walk, walkM)@@ -40,12 +40,10 @@ -- | Convert Pandoc to CommonMark. writeCommonMark :: PandocMonad m => WriterOptions -> Pandoc -> m Text writeCommonMark opts (Pandoc meta blocks) = do- let headerBlocks = filter isHeaderBlock blocks toc <- if writerTableOfContents opts- then blocksToCommonMark opts- [ toTableOfContents opts headerBlocks ]+ then blocksToCommonMark opts [ toTableOfContents opts blocks ] else return mempty- + let (blocks', notes) = runState (walkM processNotes blocks) [] notes' = if null notes then []
src/Text/Pandoc/Writers/HTML.hs view
@@ -630,7 +630,8 @@ htmlLines <- inlineListToHtml opts $ intercalate [LineBreak] lns return $ H.div ! A.class_ "line-block" $ htmlLines blockToHtml opts (Div (ident, "section":dclasses, dkvs)- (Header level hattr ils : xs)) = do+ (Header level+ hattr@(hident,hclasses,hkvs) ils : xs)) = do slideVariant <- gets stSlideVariant slideLevel <- gets stSlideLevel let slide = slideVariant /= NoSlides &&@@ -663,7 +664,8 @@ (z:zs) -> ([],z ++ concatMap inDiv zs) titleContents <- blockListToHtml opts titleBlocks innerContents <- blockListToHtml opts innerSecs- let classes' = ["title-slide" | titleSlide] ++ ["slide" | slide] +++ let classes' = ordNub $+ ["title-slide" | titleSlide] ++ ["slide" | slide] ++ ["section" | (slide || writerSectionDivs opts) && not html5 ] ++ ["level" <> tshow level | slide || writerSectionDivs opts ]@@ -683,8 +685,9 @@ else id) $ t <> if null innerSecs then mempty else nl opts <> innerContents- else if writerSectionDivs opts || slide || not (null dclasses) ||- not (null dkvs)+ else if writerSectionDivs opts || slide ||+ (hident /= ident && not (T.null hident || T.null ident)) ||+ (hclasses /= dclasses) || (hkvs /= dkvs) then addAttrs opts attr $ secttag $ nl opts <> header' <> nl opts <>
src/Text/Pandoc/Writers/Jira.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE LambdaCase #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE NoImplicitPrelude #-} {- |@@ -16,296 +17,251 @@ -} module Text.Pandoc.Writers.Jira ( writeJira ) where import Prelude-import Control.Monad.State.Strict+import Control.Monad.Reader (ReaderT, ask, asks, runReaderT)+import Control.Monad.State.Strict (StateT, evalStateT, gets, modify) import Data.Foldable (find)-import Data.Text (Text, pack)-import Text.Pandoc.Class (PandocMonad, report)+import Data.Text (Text)+import Text.Jira.Parser (plainText)+import Text.Jira.Printer (prettyBlocks, prettyInlines)+import Text.Pandoc.Class (PandocMonad) import Text.Pandoc.Definition-import Text.Pandoc.Logging (LogMessage (BlockNotRendered, InlineNotRendered))-import Text.Pandoc.Options (WriterOptions (writerTemplate))-import Text.Pandoc.Shared (blocksToInlines, linesToPara)+import Text.Pandoc.Options (WriterOptions (writerTemplate, writerWrapText),+ WrapOption (..))+import Text.Pandoc.Shared (linesToPara) import Text.Pandoc.Templates (renderTemplate) import Text.Pandoc.Writers.Math (texMathToInlines)-import Text.Pandoc.Writers.Shared (metaToContext, defField)-import qualified Data.Text as T+import Text.Pandoc.Writers.Shared (defField, metaToContext) import Text.DocLayout (literal, render)+import qualified Data.Text as T+import qualified Text.Jira.Markup as Jira -data WriterState = WriterState- { stNotes :: [Text] -- Footnotes- , stListLevel :: Text -- String at beginning of list items, e.g. "**"- }+-- | Convert Pandoc to Jira.+writeJira :: PandocMonad m => WriterOptions -> Pandoc -> m Text+writeJira opts = runDefaultConverter (writerWrapText opts) (pandocToJira opts) --- | Initial writer state-startState :: WriterState-startState = WriterState- { stNotes = []- , stListLevel = ""- }+-- | State to keep track of footnotes.+newtype ConverterState = ConverterState { stNotes :: [Text] } -type JiraWriter = StateT WriterState+-- | Initial converter state.+startState :: ConverterState+startState = ConverterState { stNotes = [] } --- | Convert Pandoc to Jira.-writeJira :: PandocMonad m => WriterOptions -> Pandoc -> m Text-writeJira opts document =- evalStateT (pandocToJira opts document) startState+-- | Converter monad+type JiraConverter m = ReaderT WrapOption (StateT ConverterState m) +-- | Run a converter using the default state+runDefaultConverter :: PandocMonad m+ => WrapOption+ -> (a -> JiraConverter m Text)+ -> a+ -> m Text+runDefaultConverter wrap c x = evalStateT (runReaderT (c x) wrap) startState+ -- | Return Jira representation of document. pandocToJira :: PandocMonad m- => WriterOptions -> Pandoc -> JiraWriter m Text+ => WriterOptions -> Pandoc -> JiraConverter m Text pandocToJira opts (Pandoc meta blocks) = do+ wrap <- ask metadata <- metaToContext opts- (fmap literal . blockListToJira opts)- (fmap literal . inlineListToJira opts) meta- body <- blockListToJira opts blocks+ (fmap literal . runDefaultConverter wrap blockListToJira)+ (fmap literal . runDefaultConverter wrap inlineListToJira) meta+ body <- blockListToJira blocks notes <- gets $ T.intercalate "\n" . reverse . stNotes- let main = body <> if T.null notes- then mempty- else T.pack "\n\n" <> notes+ let main = body <> if T.null notes then mempty else "\n\n" <> notes let context = defField "body" main metadata return $ case writerTemplate opts of Nothing -> main Just tpl -> render Nothing $ renderTemplate tpl context --- | Escape one character as needed for Jira.-escapeCharForJira :: Char -> Text-escapeCharForJira c =- let specialChars = "_*-+~^|!{}[]" :: String- in case c of- '\x2013' -> " -- "- '\x2014' -> " --- "- '\x2026' -> "..."- _ | c `elem` specialChars -> T.cons '\\' (T.singleton c)- _ -> T.singleton c+blockListToJira :: PandocMonad m => [Block] -> JiraConverter m Text+blockListToJira = fmap prettyBlocks . toJiraBlocks --- | Escape string as needed for Jira.-escapeStringForJira :: Text -> Text-escapeStringForJira = T.concatMap escapeCharForJira+inlineListToJira :: PandocMonad m => [Inline] -> JiraConverter m Text+inlineListToJira = fmap prettyInlines . toJiraInlines --- | Create an anchor macro from the given element attributes.-anchor :: Attr -> Text-anchor (ident,_,_) =- if ident == ""- then ""- else "{anchor:" <> ident <> "}"+toJiraBlocks :: PandocMonad m => [Block] -> JiraConverter m [Jira.Block]+toJiraBlocks blocks = do+ let convert = \case+ BlockQuote bs -> singleton . Jira.BlockQuote+ <$> toJiraBlocks bs -- FIXME!+ BulletList items -> singleton . Jira.List Jira.CircleBullets+ <$> toJiraItems items+ CodeBlock attr cs -> toJiraCode attr cs+ DefinitionList items -> toJiraDefinitionList items+ Div attr bs -> toJiraPanel attr bs+ Header lvl attr xs -> toJiraHeader lvl attr xs+ HorizontalRule -> return . singleton $ Jira.HorizontalRule+ LineBlock xs -> toJiraBlocks [linesToPara xs]+ OrderedList _ items -> singleton . Jira.List Jira.Enumeration+ <$> toJiraItems items+ Para xs -> singleton . Jira.Para <$> toJiraInlines xs+ Plain xs -> singleton . Jira.Para <$> toJiraInlines xs+ RawBlock fmt cs -> rawBlockToJira fmt cs+ Null -> return mempty+ Table _ _ _ hd body -> singleton <$> do+ headerRow <- if null hd+ then Just <$> toRow Jira.HeaderCell hd+ else pure Nothing+ bodyRows <- mapM (toRow Jira.BodyCell) body+ let rows = case headerRow of+ Just header -> header : bodyRows+ Nothing -> bodyRows+ return $ Jira.Table rows+ jiraBlocks <- mapM convert blocks+ return $ mconcat jiraBlocks --- | Append a newline character unless we are in a list.-appendNewlineUnlessInList :: PandocMonad m- => Text- -> JiraWriter m Text-appendNewlineUnlessInList t = do- listLevel <- gets stListLevel- return (if T.null listLevel then t <> "\n" else t)+toRow :: PandocMonad m+ => ([Jira.Block] -> Jira.Cell)+ -> [TableCell]+ -> JiraConverter m Jira.Row+toRow mkCell cells = Jira.Row <$>+ mapM (fmap mkCell . toJiraBlocks) cells --- | Convert Pandoc block element to Jira.-blockToJira :: PandocMonad m- => WriterOptions -- ^ Options- -> Block -- ^ Block element- -> JiraWriter m Text+toJiraItems :: PandocMonad m => [[Block]] -> JiraConverter m [[Jira.Block]]+toJiraItems = mapM toJiraBlocks -blockToJira _ Null = return ""+toJiraCode :: PandocMonad m+ => Attr+ -> Text+ -> JiraConverter m [Jira.Block]+toJiraCode (ident, classes, _attribs) code = do+ let lang = case find (\c -> T.toLower c `elem` knownLanguages) classes of+ Nothing -> Jira.Language "java"+ Just l -> Jira.Language l+ let addAnchor b = if T.null ident+ then b+ else [Jira.Para (singleton (Jira.Anchor ident))] <> b+ return . addAnchor . singleton $ Jira.Code lang mempty code -blockToJira opts (Div attr bs) =- (anchor attr <>) <$> blockListToJira opts bs+-- | Creates a Jira definition list+toJiraDefinitionList :: PandocMonad m+ => [([Inline], [[Block]])]+ -> JiraConverter m [Jira.Block]+toJiraDefinitionList defItems = do+ let convertDefItem (term, defs) = do+ jiraTerm <- Jira.Para <$> styled Jira.Strong term+ jiraDefs <- mconcat <$> mapM toJiraBlocks defs+ return $ jiraTerm : jiraDefs+ singleton . Jira.List Jira.CircleBullets <$> mapM convertDefItem defItems -blockToJira opts (Plain inlines) =- inlineListToJira opts inlines+-- | Creates a Jira panel+toJiraPanel :: PandocMonad m+ => Attr -> [Block]+ -> JiraConverter m [Jira.Block]+toJiraPanel attr blocks = do+ jiraBlocks <- toJiraBlocks blocks+ return $ if attr == nullAttr+ then jiraBlocks+ else singleton (Jira.Panel [] jiraBlocks) -blockToJira opts (Para inlines) = do- contents <- inlineListToJira opts inlines- appendNewlineUnlessInList contents+-- | Creates a Jira header+toJiraHeader :: PandocMonad m+ => Int -> Attr -> [Inline]+ -> JiraConverter m [Jira.Block]+toJiraHeader lvl (ident, _, _) inlines =+ let anchor = Jira.Anchor ident+ in singleton . Jira.Header lvl . (anchor :) <$> toJiraInlines inlines -blockToJira opts (LineBlock lns) =- blockToJira opts $ linesToPara lns+-- | Handles raw block. Jira is included verbatim, everything else is+-- discarded.+rawBlockToJira :: PandocMonad m+ => Format -> Text+ -> JiraConverter m [Jira.Block]+rawBlockToJira fmt cs = do+ rawInlines <- toJiraRaw fmt cs+ return $+ if null rawInlines+ then mempty+ else singleton (Jira.Para rawInlines) -blockToJira _ b@(RawBlock f str) =- if f == Format "jira"- then return str- else "" <$ report (BlockNotRendered b)+toJiraRaw :: PandocMonad m+ => Format -> Text -> JiraConverter m [Jira.Inline]+toJiraRaw fmt cs = case fmt of+ Format "jira" -> return . singleton $ Jira.Str cs+ _ -> return mempty -blockToJira _ HorizontalRule = return "----\n" -blockToJira opts (Header level attr inlines) = do- contents <- inlineListToJira opts inlines- let prefix = "h" <> pack (show level) <> ". "- return $ prefix <> anchor attr <> contents <> "\n"--blockToJira _ (CodeBlock attr@(_,classes,_) str) = do- let lang = find (\c -> T.toLower c `elem` knownLanguages) classes- let start = case lang of- Nothing -> "{code}"- Just l -> "{code:" <> l <> "}"- let anchorMacro = anchor attr- appendNewlineUnlessInList . T.intercalate "\n" $- (if anchorMacro == "" then id else (anchorMacro :))- [start, str, "{code}"]--blockToJira opts (BlockQuote [p@(Para _)]) = do- contents <- blockToJira opts p- return ("bq. " <> contents)--blockToJira opts (BlockQuote blocks) = do- contents <- blockListToJira opts blocks- appendNewlineUnlessInList . T.unlines $- [ "{quote}", contents, "{quote}"]--blockToJira opts (Table _caption _aligns _widths headers rows) = do- headerCells <- mapM blocksToCell headers- bodyRows <- mapM (mapM blocksToCell) rows- let tblHead = headerCellsToRow headerCells- let tblBody = map cellsToRow bodyRows- return $ if all null headers- then T.unlines tblBody- else T.unlines (tblHead : tblBody)- where- blocksToCell :: PandocMonad m => [Block] -> JiraWriter m Text- blocksToCell = inlineListToJira opts . blocksToInlines-- cellsToRow :: [Text] -> Text- cellsToRow cells = "|" <> T.intercalate "|" cells <> "|"-- headerCellsToRow :: [Text] -> Text- headerCellsToRow cells = "||" <> T.intercalate "||" cells <> "||"--blockToJira opts (BulletList items) =- listWithMarker opts items '*'--blockToJira opts (OrderedList _listAttr items) =- listWithMarker opts items '#'--blockToJira opts (DefinitionList items) =- blockToJira opts (BulletList (map defToBulletItem items))- where- defToBulletItem :: ([Inline], [[Block]]) -> [Block]- defToBulletItem (inlns, defs) =- let term = Plain [Strong inlns]- blks = mconcat defs- in term : blks---- Auxiliary functions for lists:---- | Create a list using the given character as bullet item marker.-listWithMarker :: PandocMonad m- => WriterOptions- -> [[Block]]- -> Char- -> JiraWriter m Text-listWithMarker opts items marker = do- modify $ \s -> s { stListLevel = stListLevel s `T.snoc` marker }- contents <- mapM (listItemToJira opts) items- modify $ \s -> s { stListLevel = T.init (stListLevel s) }- appendNewlineUnlessInList $ T.intercalate "\n" contents---- | Convert bullet or ordered list item (list of blocks) to Jira.-listItemToJira :: PandocMonad m- => WriterOptions- -> [Block]- -> JiraWriter m Text-listItemToJira opts items = do- contents <- blockListToJira opts items- marker <- gets stListLevel- return $ marker <> " " <> contents---- | Convert list of Pandoc block elements to Jira.-blockListToJira :: PandocMonad m- => WriterOptions -- ^ Options- -> [Block] -- ^ List of block elements- -> JiraWriter m Text-blockListToJira opts blocks =- T.intercalate "\n" <$> mapM (blockToJira opts) blocks---- | Convert list of Pandoc inline elements to Jira.-inlineListToJira :: PandocMonad m- => WriterOptions- -> [Inline]- -> JiraWriter m Text-inlineListToJira opts lst =- T.concat <$> mapM (inlineToJira opts) lst---- | Convert Pandoc inline element to Jira.-inlineToJira :: PandocMonad m- => WriterOptions- -> Inline- -> JiraWriter m Text--inlineToJira opts (Span attr lst) =- (anchor attr <>) <$> inlineListToJira opts lst--inlineToJira opts (Emph lst) = do- contents <- inlineListToJira opts lst- return $ "_" <> contents <> "_"--inlineToJira opts (Strong lst) = do- contents <- inlineListToJira opts lst- return $ "*" <> contents <> "*"--inlineToJira opts (Strikeout lst) = do- contents <- inlineListToJira opts lst- return $ "-" <> contents <> "-"--inlineToJira opts (Superscript lst) = do- contents <- inlineListToJira opts lst- return $ "{^" <> contents <> "^}"--inlineToJira opts (Subscript lst) = do- contents <- inlineListToJira opts lst- return $ "{~" <> contents <> "~}"--inlineToJira opts (SmallCaps lst) = inlineListToJira opts lst--inlineToJira opts (Quoted SingleQuote lst) = do- contents <- inlineListToJira opts lst- return $ "'" <> contents <> "'"--inlineToJira opts (Quoted DoubleQuote lst) = do- contents <- inlineListToJira opts lst- return $ "\"" <> contents <> "\""--inlineToJira opts (Cite _ lst) = inlineListToJira opts lst--inlineToJira _ (Code attr str) =- return (anchor attr <> "{{" <> str <> "}}")--inlineToJira _ (Str str) = return $ escapeStringForJira str--inlineToJira opts (Math InlineMath str) =- lift (texMathToInlines InlineMath str) >>= inlineListToJira opts--inlineToJira opts (Math DisplayMath str) = do- mathInlines <- lift (texMathToInlines DisplayMath str)- contents <- inlineListToJira opts mathInlines- return $ "\\\\" <> contents <> "\\\\"+--+-- Inlines+-- -inlineToJira _opts il@(RawInline f str) =- if f == Format "jira"- then return str- else "" <$ report (InlineNotRendered il)+toJiraInlines :: PandocMonad m => [Inline] -> JiraConverter m [Jira.Inline]+toJiraInlines inlines = do+ let convert = \case+ Cite _ xs -> toJiraInlines xs+ Code _ cs -> return . singleton $+ Jira.Monospaced (escapeSpecialChars cs)+ Emph xs -> styled Jira.Emphasis xs+ Image _ _ (src, _) -> pure . singleton $ Jira.Image [] (Jira.URL src)+ LineBreak -> pure . singleton $ Jira.Linebreak+ Link _ xs (tgt, _) -> singleton . flip Jira.Link (Jira.URL tgt)+ <$> toJiraInlines xs+ Math mtype cs -> mathToJira mtype cs+ Note bs -> registerNotes bs+ Quoted qt xs -> quotedToJira qt xs+ RawInline fmt cs -> toJiraRaw fmt cs+ SmallCaps xs -> styled Jira.Strong xs+ SoftBreak -> do+ preserveBreak <- asks (== WrapPreserve)+ pure . singleton $ if preserveBreak+ then Jira.Linebreak+ else Jira.Space+ Space -> pure . singleton $ Jira.Space+ Span _attr xs -> toJiraInlines xs+ Str s -> pure $ escapeSpecialChars s+ Strikeout xs -> styled Jira.Strikeout xs+ Strong xs -> styled Jira.Strong xs+ Subscript xs -> styled Jira.Subscript xs+ Superscript xs -> styled Jira.Superscript xs+ jiraInlines <- mapM convert inlines+ return $ mconcat jiraInlines -inlineToJira _ LineBreak = return "\n"+singleton :: a -> [a]+singleton = (:[]) -inlineToJira _ SoftBreak = return " "+styled :: PandocMonad m+ => Jira.InlineStyle -> [Inline]+ -> JiraConverter m [Jira.Inline]+styled s = fmap (singleton . Jira.Styled s) . toJiraInlines -inlineToJira _ Space = return " "+-- | Converts a plain text value to Jira inlines, ensuring that all+-- special characters will be handled appropriately.+escapeSpecialChars :: Text -> [Jira.Inline]+escapeSpecialChars t = case plainText t of+ Right xs -> xs+ Left _ -> singleton $ Jira.Str t -inlineToJira opts (Link _attr txt (src, _title)) = do- linkText <- inlineListToJira opts txt- return $ T.concat- [ "["- , if null txt then "" else linkText <> "|"- , src- , "]"- ]+mathToJira :: PandocMonad m+ => MathType+ -> Text+ -> JiraConverter m [Jira.Inline]+mathToJira mtype cs = do+ mathInlines <- toJiraInlines =<< texMathToInlines mtype cs+ return $ case mtype of+ InlineMath -> mathInlines+ DisplayMath -> Jira.Linebreak : mathInlines ++ [Jira.Linebreak] -inlineToJira _opts (Image attr _alt (src, _title)) =- return . T.concat $ [anchor attr, "!", src, "!"]+quotedToJira :: PandocMonad m+ => QuoteType+ -> [Inline]+ -> JiraConverter m [Jira.Inline]+quotedToJira qtype xs = do+ let quoteChar = case qtype of+ DoubleQuote -> "\""+ SingleQuote -> "'"+ let surroundWithQuotes = (Jira.Str quoteChar :) . (++ [Jira.Str quoteChar])+ surroundWithQuotes <$> toJiraInlines xs -inlineToJira opts (Note contents) = do+registerNotes :: PandocMonad m => [Block] -> JiraConverter m [Jira.Inline]+registerNotes contents = do curNotes <- gets stNotes let newnum = length curNotes + 1- contents' <- blockListToJira opts contents- let thisnote = "[" <> pack (show newnum) <> "] " <> contents' <> "\n"+ contents' <- blockListToJira contents+ let thisnote = "\\[" <> T.pack (show newnum) <> "] " <> contents' <> "\n" modify $ \s -> s { stNotes = thisnote : curNotes }- return $ "[" <> pack (show newnum) <> "]"+ return . singleton . Jira.Str $+ "[" <> T.pack (show newnum) <> "]" -- | Language codes recognized by jira knownLanguages :: [Text]
src/Text/Pandoc/Writers/Markdown.hs view
@@ -208,9 +208,8 @@ mmdTitleBlock metadata | otherwise -> empty Nothing -> empty- let headerBlocks = filter isHeaderBlock blocks toc <- if writerTableOfContents opts- then blockToMarkdown opts ( toTableOfContents opts headerBlocks )+ then blockToMarkdown opts ( toTableOfContents opts blocks ) else return mempty -- Strip off final 'references' header if markdown citations enabled let blocks' = if isEnabled Ext_citations opts
src/Text/Pandoc/Writers/RTF.hs view
@@ -103,8 +103,7 @@ (fmap literal . inlinesToRTF) meta' body <- blocksToRTF 0 AlignDefault blocks- toc <- blocksToRTF 0 AlignDefault- [toTableOfContents options $ filter isHeaderBlock blocks]+ toc <- blocksToRTF 0 AlignDefault [toTableOfContents options blocks] let context = defField "body" body $ defField "spacer" spacer $(if writerTableOfContents options
stack.yaml view
@@ -20,6 +20,7 @@ - regex-pcre-builtin-0.95.0.8.8.35 - doclayout-0.2.0.1 - emojis-0.1+- jira-wiki-markup-1.0.0 - HsYAML-0.2.0.0 - HsYAML-aeson-0.2.0.0 - doctemplates-0.8
test/Tests/Old.hs view
@@ -100,6 +100,8 @@ ] , testGroup "jira" [ testGroup "writer" $ writerTests' "jira"+ , test' "reader" ["-r", "jira", "-w", "native", "-s"]+ "jira-reader.jira" "jira-reader.native" ] , testGroup "native" [ testGroup "writer" $ writerTests' "native"
test/Tests/Readers/HTML.hs view
@@ -21,6 +21,7 @@ import Test.Tasty.Options (IsOption(defaultValue)) import Tests.Helpers import Text.Pandoc+import Text.Pandoc.Shared (isHeaderBlock) import Text.Pandoc.Arbitrary () import Text.Pandoc.Builder import Text.Pandoc.Walk (walk)@@ -35,6 +36,9 @@ makeRoundTrip CodeBlock{} = Para [Str "code block was here"] makeRoundTrip LineBlock{} = Para [Str "line block was here"] makeRoundTrip RawBlock{} = Para [Str "raw block was here"]+makeRoundTrip (Div attr bs) = Div attr $ filter (not . isHeaderBlock) bs+-- avoids round-trip failures related to makeSections+-- e.g. with [Div ("loc",[],[("a","11"),("b_2","a b c")]) [Header 3 ("",[],[]) []]] makeRoundTrip x = x removeRawInlines :: Inline -> Inline
+ test/Tests/Readers/Jira.hs view
@@ -0,0 +1,114 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE ScopedTypeVariables #-}+{- |+ Module : Tests.Readers.Jira+ Copyright : © 2019 Albert Krewinel+ License : GNU GPL, version 2 or above++ Maintainer : Albert Krewinkel <tarleb@zeitkraut.de>+ Stability : alpha+ Portability : portable++Tests for the RST reader.+-}+module Tests.Readers.Jira (tests) where++import Prelude+import Data.Text (Text)+import Test.Tasty (TestTree, testGroup)+import Tests.Helpers (ToString, purely, test, (=?>))+import Text.Pandoc (def)+import Text.Pandoc.Readers.Jira (readJira)+import Text.Pandoc.Builder++jira :: Text -> Pandoc+jira = purely $ readJira def++infix 4 =:+(=:) :: ToString c+ => String -> (Text, c) -> TestTree+(=:) = test jira++tests :: [TestTree]+tests =+ [ testGroup "para"+ [ "Simple sentence" =:+ "Hello, World!" =?> para "Hello, World!"+ ]++ , testGroup "header"+ [ "header" =:+ "h1. Main\n" =?> header 1 "Main"+ ]++ , testGroup "list"+ [ "simple list" =:+ "* foo\n* bar\n" =?> bulletList [para "foo", para "bar"]++ , "list with minus as bullets" =:+ "- foo\n- bar\n" =?> bulletList [para "foo", para "bar"]++ , "ordered list / enumeration" =:+ "# first\n# second\n" =?> orderedList [para "first", para "second"]+ ]++ , testGroup "block quote"+ [ "simple block quote" =:+ "bq. _Don't_ quote me on this." =?>+ blockQuote (para $ emph "Don't" <> space <> "quote me on this.")+ ]++ , testGroup "table"+ [ "table without header" =:+ "| one | two |\n| three | four |\n" =?>+ simpleTable []+ [ [para "one", para "two"]+ , [para "three", para "four"]]++ , "table with header" =:+ "|| one || two ||\n| three | four |\n| five | six |\n" =?>+ simpleTable [para "one", para "two"]+ [ [para "three", para "four"]+ , [para "five", para "six"]]++ , "table with column header" =:+ "|| language | haskell | lua |\n|| type | static | dynamic |\n" =?>+ simpleTable []+ [ [para "language", para "haskell", para "lua"]+ , [para "type", para "static", para "dynamic"]]+ ]++ , testGroup "inlines"+ [ "emphasis" =:+ "*quid pro quo*" =?>+ para (strong "quid pro quo")++ , "deleted" =:+ "-old-" =?>+ para (strikeout "old")++ , "monospaced" =:+ "{{this *is* monospace}}" =?>+ para (code "this is monospace")++ , "sub- and superscript" =:+ "HCO ~3~^-^" =?>+ para ("HCO " <> subscript "3" <> superscript "-")++ , "linebreak" =:+ "first\nsecond" =?>+ para ("first" <> linebreak <> "second")++ , "link" =:+ "[Example|https://example.org]" =?>+ para (link "https://example.org" "" "Example")++ , "image" =:+ "!https://example.com/image.jpg!" =?>+ para (image "https://example.com/image.jpg" "" mempty)++ , "HTML entity" =:+ "me & you" =?> para "me & you"+ ]+ ]
test/Tests/Readers/Org/Block/Header.hs view
@@ -142,6 +142,16 @@ "* This: is not: tagged" =?> headerWith ("this-is-not-tagged", [], []) 1 "This: is not: tagged" + , "Untagged header time followed by colon" =:+ "** Meeting at 5:23: free food" =?>+ let attr = ("meeting-at-523-free-food", [], [])+ in headerWith attr 2 "Meeting at 5:23: free food"++ , "tag followed by text" =:+ "*** Looks like a :tag: but isn't" =?>+ let attr = ("looks-like-a-tag-but-isnt", [], [])+ in headerWith attr 3 "Looks like a :tag: but isn't"+ , "Header starting with strokeout text" =: T.unlines [ "foo" , ""
test/Tests/Readers/Org/Block/Table.hs view
@@ -160,4 +160,11 @@ [ [ plain "x", plain "6" ] , [ plain "9", plain "42" ] ]++ , "named table" =:+ T.unlines [ "#+NAME: x-marks-the-spot"+ , "| x |"+ ] =?>+ divWith ("x-marks-the-spot", mempty, mempty)+ (simpleTable' 1 mempty [ [ plain "x" ] ]) ]
test/command/3706.md view
@@ -15,15 +15,16 @@ | 2 | La | | 3 | La | ^D-[Table [Str "Lalelu."] [AlignDefault,AlignDefault] [0.0,0.0]- [[Plain [Str "Id"]]- ,[Plain [Str "Desc"]]]- [[[Plain [Str "1"]]- ,[Plain [Str "La"]]]- ,[[Plain [Str "2"]]- ,[Plain [Str "La"]]]- ,[[Plain [Str "3"]]- ,[Plain [Str "La"]]]]]+[Div ("tab",[],[])+ [Table [Str "Lalelu."] [AlignDefault,AlignDefault] [0.0,0.0]+ [[Plain [Str "Id"]]+ ,[Plain [Str "Desc"]]]+ [[[Plain [Str "1"]]+ ,[Plain [Str "La"]]]+ ,[[Plain [Str "2"]]+ ,[Plain [Str "La"]]]+ ,[[Plain [Str "3"]]+ ,[Plain [Str "La"]]]]]] ``` ```
+ test/command/5986.md view
@@ -0,0 +1,16 @@+```+% pandoc -t epub --number-sections --toc --metadata title=Foo -o - | pandoc -f epub -t html+# Hi+^D+<p><span id="title_page.xhtml"></span></p>+<p><span id="nav.xhtml"></span></p>+<nav type="landmarks" id="landmarks" hidden="hidden">+<ol>+<li><a href="#nav.xhtml#toc">Table of contents</a></li>+</ol>+</nav>+<p><span id="ch001.xhtml"></span></p>+<section id="ch001.xhtml#hi" class="level1" data-number="1">+<h1 data-number="1"><span class="header-section-number">1</span> Hi</h1>+</section>+```
+ test/command/section-divs.md view
@@ -0,0 +1,25 @@+```+% pandoc --section-divs+::: {#hi .section .level1}+# Hi++::: {#there .section .level2}+## there+:::+:::++::: {#ok .section .level1}+Ok+==+:::+^D+<section id="hi" class="level1">+<h1>Hi</h1>+<section id="there" class="level2">+<h2>there</h2>+</section>+</section>+<section id="ok" class="level1">+<h1>Ok</h1>+</section>+```
+ test/command/toc.md view
@@ -0,0 +1,56 @@+```+% pandoc -s --toc -t markdown+# A+## b+# B+## b++::: interior+# C+## cc+# D+:::++::: blue+# E+## e+:::+^D+- [A](#a)+ - [b](#b)+- [B](#b-1)+ - [b](#b-2)+- [E](#e)+ - [e](#e-1)++A+=++b+-++B+=++b+-++::: {.interior}+C+=++cc+--++D+=+:::++::: {.blue}+E+=++e+-+:::+```
+ test/jira-reader.jira view
@@ -0,0 +1,284 @@+h1. {anchor:headers}Headers+h2. {anchor:level-2-with-an-embedded-link}Level 2 with an [embedded link|https://test.example/url]+h3. {anchor:level-3-with-emphasis}Level 3 with _emphasis_+h4. Level 4+h5. Level 5+h6. Level 6++h0. this is not a header.++----+h1. Paragraphs+Here’s a regular paragraph.++Here’s one with a bullet. * criminey.++There should be a hard line break+here.++----+h1. Block Quotes+E-mail style:++bq. This is a block quote. It is pretty short.+{quote}+Code in a block quote:++{code:java}+sub status {+ print "working";+}+{code}++An enumeration:++# item one+# item two+{quote}++A following paragraph.++----+h1. Code Blocks++Code:++{code:java}+---- (should be four hyphens)++sub status {+ print "working";+}+{code}+And:++{code:java}+ this code block is indented by two tabs++These should not be escaped: \$ \\ \> \[ \{+{code}++----+h1. {anchor:lists}Lists+h2. {anchor:unordered}Unordered+Asterisks:++* asterisk 1+* asterisk 2+* asterisk 3++Minuses:++- Minus 1+- Minus 2+- Minus 3++h2. Ordered++# First+# Second+# Third++Linebreak in paragraph:++# Item 1, line one.+Item 1. line two. The quick brown fox jumped over the lazy dog’s back.+# Item 2.+# Item 3.++h2. Nested+* Tab+** Tab+*** Tab++Here’s another:++# First+# Second:+#* Fee+#* Fie+#* Foe+# Third++Nested enumerations:++# Essential+## Important+### Relevant+#### Insignificant++----+h1. Linebreaks and Markup in Lists++* *apple*+red fruit+* *orange*+orange fruit+* *banana*+yellow fruit++Multiple blocks with italics:++* *_apple_*+red fruit+contains seeds, crisp, pleasant to taste+* *_orange_*+orange fruit+{code:java}+{ orange code block }+{code}+bq. orange block quote++----+h1. Colored Text Blocks+{color:red}+This is red.+{color}++h2. Eiffel 65++{color:blue}+da ba dee+{color}++----+h1. Inline Markup+This is _emphasized_, and so _is this_.++This is *strong*, and so *is this*.++An _[emphasized link|https://my.example/url]_.++*_This is strong and em._*++So is *_this_* word.++This is code: {{>}}, {{$}}, {{\}}, {{\$}}, {{<html>}}.++-This is _strikeout_.-++Superscripts: a{^}bc{^}d a{^}_hello_{^} a{^}hello there{^}.++Subscripts: H{~}2{~}O, C{~}6{~}H{~}12{~}O{~}6{~}, C{~} n {~}H{~}_2n_{~}O{~}n{~}.++These should not be superscripts or subscripts, because of markers used within words: a^b c^d, a~b c~d.++----+h1. Dashes, and emoticons++Some dashes: one -- two --- three.++Sure (/)+Nope (x)++Nice :D++Capital d\:D++----+h1. Math++* 2 + 2 = 4+* _x_ ∈ {_}y{_}+* _α_ ∧ {_}ω{_}+* _p_-Tree+* Here’s one more: _α_ + {_}ω{_} × {_}x{_}^2^.+++----+h1. Special Characters+Here is some unicode:++* I hat: Î+* o umlaut: ö+* section: §+* set membership: ∈+* copyright: ©++AT&T has an ampersand in their name.++AT&T is another way to write it.++This & that.++4 < 5.++6 > 5.++Backslash: \++Backtick: `++Asterisk: *++Underscore: _++Left brace: {++Right brace: }++Left bracket: [++Right bracket: ]++Left paren: (++Right paren: )++Greater-than: >++Hash: #++Period: .++Bang: !++Plus: +++Minus: -++----+h1. Links+h2. Explicit+Just a [URL|https://example.org/url].++[File URL|file://some/file/name/].++[IRC link|irc://example.org/pandoc].++[Email link|mailto:nobody@nowhere.invalid]++[Not a link|not a URL].++h2. Reference+With [embedded \[brackets\]|https://example.net/url/].++https://pandoc.org by itself should be a link.++h2. With ampersands+Here’s a [link with an ampersand in the URL|http://example.com/?foo=1&bar=2].++Here’s a link with an ampersand in the link text: [AT&T|http://att.com/].++h2. Autolinks+With an ampersand: http://example.com/?foo=1&bar=2++* In a list?+* http://example.com/+* It should.++An e-mail address: mailto:nobody@nowhere.invalid++bq. Blockquoted: http://example.com/++{code:java}+Autolink should not occur here: <http://example.com/>+{code}++----+h1. Images+From "Voyage dans la Lune" by Georges Melies (1902):++!lalune.jpg!++Here is a movie !movie.jpg! icon.
+ test/jira-reader.native view
@@ -0,0 +1,185 @@+Pandoc (Meta {unMeta = fromList []})+[Header 1 ("",[],[]) [Span ("headers",[],[]) [],Str "Headers"]+,Header 2 ("",[],[]) [Span ("level-2-with-an-embedded-link",[],[]) [],Str "Level",Space,Str "2",Space,Str "with",Space,Str "an",Space,Link ("",[],[]) [Str "embedded",Space,Str "link"] ("https://test.example/url","")]+,Header 3 ("",[],[]) [Span ("level-3-with-emphasis",[],[]) [],Str "Level",Space,Str "3",Space,Str "with",Space,Emph [Str "emphasis"]]+,Header 4 ("",[],[]) [Str "Level",Space,Str "4"]+,Header 5 ("",[],[]) [Str "Level",Space,Str "5"]+,Header 6 ("",[],[]) [Str "Level",Space,Str "6"]+,Para [Str "h0.",Space,Str "this",Space,Str "is",Space,Str "not",Space,Str "a",Space,Str "header."]+,HorizontalRule+,Header 1 ("",[],[]) [Str "Paragraphs"]+,Para [Str "Here\8217s",Space,Str "a",Space,Str "regular",Space,Str "paragraph."]+,Para [Str "Here\8217s",Space,Str "one",Space,Str "with",Space,Str "a",Space,Str "bullet.",Space,Str "*",Space,Str "criminey."]+,Para [Str "There",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "hard",Space,Str "line",Space,Str "break",LineBreak,Str "here."]+,HorizontalRule+,Header 1 ("",[],[]) [Str "Block",Space,Str "Quotes"]+,Para [Str "E-mail",Space,Str "style:"]+,BlockQuote+ [Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "block",Space,Str "quote.",Space,Str "It",Space,Str "is",Space,Str "pretty",Space,Str "short."]]+,BlockQuote+ [Para [Str "Code",Space,Str "in",Space,Str "a",Space,Str "block",Space,Str "quote:"]+ ,CodeBlock ("",["java"],[]) "sub status {\n print \"working\";\n}\n"+ ,Para [Str "An",Space,Str "enumeration:"]+ ,OrderedList (1,DefaultStyle,DefaultDelim)+ [[Para [Str "item",Space,Str "one"]]+ ,[Para [Str "item",Space,Str "two"]]]]+,Para [Str "A",Space,Str "following",Space,Str "paragraph."]+,HorizontalRule+,Header 1 ("",[],[]) [Str "Code",Space,Str "Blocks"]+,Para [Str "Code:"]+,CodeBlock ("",["java"],[]) "---- (should be four hyphens)\n\nsub status {\n print \"working\";\n}\n"+,Para [Str "And:"]+,CodeBlock ("",["java"],[]) " this code block is indented by two tabs\n\nThese should not be escaped: \\$ \\\\ \\> \\[ \\{\n"+,HorizontalRule+,Header 1 ("",[],[]) [Span ("lists",[],[]) [],Str "Lists"]+,Header 2 ("",[],[]) [Span ("unordered",[],[]) [],Str "Unordered"]+,Para [Str "Asterisks:"]+,BulletList+ [[Para [Str "asterisk",Space,Str "1"]]+ ,[Para [Str "asterisk",Space,Str "2"]]+ ,[Para [Str "asterisk",Space,Str "3"]]]+,Para [Str "Minuses:"]+,BulletList+ [[Para [Str "Minus",Space,Str "1"]]+ ,[Para [Str "Minus",Space,Str "2"]]+ ,[Para [Str "Minus",Space,Str "3"]]]+,Header 2 ("",[],[]) [Str "Ordered"]+,OrderedList (1,DefaultStyle,DefaultDelim)+ [[Para [Str "First"]]+ ,[Para [Str "Second"]]+ ,[Para [Str "Third"]]]+,Para [Str "Linebreak",Space,Str "in",Space,Str "paragraph:"]+,OrderedList (1,DefaultStyle,DefaultDelim)+ [[Para [Str "Item",Space,Str "1,",Space,Str "line",Space,Str "one.",LineBreak,Str "Item",Space,Str "1.",Space,Str "line",Space,Str "two.",Space,Str "The",Space,Str "quick",Space,Str "brown",Space,Str "fox",Space,Str "jumped",Space,Str "over",Space,Str "the",Space,Str "lazy",Space,Str "dog\8217s",Space,Str "back."]]+ ,[Para [Str "Item",Space,Str "2."]]+ ,[Para [Str "Item",Space,Str "3."]]]+,Header 2 ("",[],[]) [Str "Nested"]+,BulletList+ [[Para [Str "Tab"]+ ,BulletList+ [[Para [Str "Tab"]+ ,BulletList+ [[Para [Str "Tab"]]]]]]]+,Para [Str "Here\8217s",Space,Str "another:"]+,OrderedList (1,DefaultStyle,DefaultDelim)+ [[Para [Str "First"]]+ ,[Para [Str "Second:"]+ ,BulletList+ [[Para [Str "Fee"]]+ ,[Para [Str "Fie"]]+ ,[Para [Str "Foe"]]]]+ ,[Para [Str "Third"]]]+,Para [Str "Nested",Space,Str "enumerations:"]+,OrderedList (1,DefaultStyle,DefaultDelim)+ [[Para [Str "Essential"]+ ,OrderedList (1,DefaultStyle,DefaultDelim)+ [[Para [Str "Important"]+ ,OrderedList (1,DefaultStyle,DefaultDelim)+ [[Para [Str "Relevant"]+ ,OrderedList (1,DefaultStyle,DefaultDelim)+ [[Para [Str "Insignificant"]]]]]]]]]+,HorizontalRule+,Header 1 ("",[],[]) [Str "Linebreaks",Space,Str "and",Space,Str "Markup",Space,Str "in",Space,Str "Lists"]+,BulletList+ [[Para [Strong [Str "apple"],LineBreak,Str "red",Space,Str "fruit"]]+ ,[Para [Strong [Str "orange"],LineBreak,Str "orange",Space,Str "fruit"]]+ ,[Para [Strong [Str "banana"],LineBreak,Str "yellow",Space,Str "fruit"]]]+,Para [Str "Multiple",Space,Str "blocks",Space,Str "with",Space,Str "italics:"]+,BulletList+ [[Para [Strong [Emph [Str "apple"]],LineBreak,Str "red",Space,Str "fruit",LineBreak,Str "contains",Space,Str "seeds,",Space,Str "crisp,",Space,Str "pleasant",Space,Str "to",Space,Str "taste"]]+ ,[Para [Strong [Emph [Str "orange"]],LineBreak,Str "orange",Space,Str "fruit"]+ ,CodeBlock ("",["java"],[]) "{ orange code block }\n"+ ,BlockQuote+ [Para [Str "orange",Space,Str "block",Space,Str "quote"]]]]+,HorizontalRule+,Header 1 ("",[],[]) [Str "Colored",Space,Str "Text",Space,Str "Blocks"]+,Div ("",[],[("color","red")])+ [Para [LineBreak,Str "This",Space,Str "is",Space,Str "red."]]+,Header 2 ("",[],[]) [Str "Eiffel",Space,Str "65"]+,Div ("",[],[("color","blue")])+ [Para [LineBreak,Str "da",Space,Str "ba",Space,Str "dee"]]+,HorizontalRule+,Header 1 ("",[],[]) [Str "Inline",Space,Str "Markup"]+,Para [Str "This",Space,Str "is",Space,Emph [Str "emphasized"],Str ",",Space,Str "and",Space,Str "so",Space,Emph [Str "is",Space,Str "this"],Str "."]+,Para [Str "This",Space,Str "is",Space,Strong [Str "strong"],Str ",",Space,Str "and",Space,Str "so",Space,Strong [Str "is",Space,Str "this"],Str "."]+,Para [Str "An",Space,Emph [Link ("",[],[]) [Str "emphasized",Space,Str "link"] ("https://my.example/url","")],Str "."]+,Para [Strong [Emph [Str "This",Space,Str "is",Space,Str "strong",Space,Str "and",Space,Str "em."]]]+,Para [Str "So",Space,Str "is",Space,Strong [Emph [Str "this"]],Space,Str "word."]+,Para [Str "This",Space,Str "is",Space,Str "code:",Space,Code ("",[],[]) ">",Str ",",Space,Code ("",[],[]) "$",Str ",",Space,Code ("",[],[]) "\\",Str ",",Space,Code ("",[],[]) "\\$",Str ",",Space,Code ("",[],[]) "<html>",Str "."]+,Para [Strikeout [Str "This",Space,Str "is",Space,Emph [Str "strikeout"],Str "."]]+,Para [Str "Superscripts:",Space,Str "a",Superscript [Str "bc"],Str "d",Space,Str "a",Superscript [Emph [Str "hello"]],Space,Str "a",Superscript [Str "hello\160there"],Str "."]+,Para [Str "Subscripts:",Space,Str "H",Subscript [Str "2"],Str "O,",Space,Str "C",Subscript [Str "6"],Str "H",Subscript [Str "12"],Str "O",Subscript [Str "6"],Str ",",Space,Str "C",Subscript [Str "\160n\160"],Str "H",Subscript [Emph [Str "2n"]],Str "O",Subscript [Str "n"],Str "."]+,Para [Str "These",Space,Str "should",Space,Str "not",Space,Str "be",Space,Str "superscripts",Space,Str "or",Space,Str "subscripts,",Space,Str "because",Space,Str "of",Space,Str "markers",Space,Str "used",Space,Str "within",Space,Str "words:",Space,Str "a^b",Space,Str "c^d,",Space,Str "a~b",Space,Str "c~d."]+,HorizontalRule+,Header 1 ("",[],[]) [Str "Dashes,",Space,Str "and",Space,Str "emoticons"]+,Para [Str "Some",Space,Str "dashes:",Space,Str "one",Space,Str "\8211",Space,Str "two",Space,Str "\8212",Space,Str "three."]+,Para [Str "Sure",Space,Str "\10003",LineBreak,Str "Nope",Space,Str "\127303"]+,Para [Str "Nice",Space,Str "\128515"]+,Para [Str "Capital",Space,Str "d:D"]+,HorizontalRule+,Header 1 ("",[],[]) [Str "Math"]+,BulletList+ [[Para [Str "2\8197+\8197\&2\8196=\8196\&4"]]+ ,[Para [Emph [Str "x"],Str "\8196\8712\8196",Emph [Str "y"]]]+ ,[Para [Emph [Str "\945"],Str "\8197\8743\8197",Emph [Str "\969"]]]+ ,[Para [Emph [Str "p"],Str "-Tree"]]+ ,[Para [Str "Here\8217s",Space,Str "one",Space,Str "more:",Space,Emph [Str "\945"],Str "\8197+\8197",Emph [Str "\969"],Str "\8197\215\8197",Emph [Str "x"],Superscript [Str "2"],Str "."]]]+,HorizontalRule+,Header 1 ("",[],[]) [Str "Special",Space,Str "Characters"]+,Para [Str "Here",Space,Str "is",Space,Str "some",Space,Str "unicode:"]+,BulletList+ [[Para [Str "I",Space,Str "hat:",Space,Str "\206"]]+ ,[Para [Str "o",Space,Str "umlaut:",Space,Str "\246"]]+ ,[Para [Str "section:",Space,Str "\167"]]+ ,[Para [Str "set",Space,Str "membership:",Space,Str "\8712"]]+ ,[Para [Str "copyright:",Space,Str "\169"]]]+,Para [Str "AT&T",Space,Str "has",Space,Str "an",Space,Str "ampersand",Space,Str "in",Space,Str "their",Space,Str "name."]+,Para [Str "AT&T",Space,Str "is",Space,Str "another",Space,Str "way",Space,Str "to",Space,Str "write",Space,Str "it."]+,Para [Str "This",Space,Str "&",Space,Str "that."]+,Para [Str "4",Space,Str "<",Space,Str "5."]+,Para [Str "6",Space,Str ">",Space,Str "5."]+,Para [Str "Backslash:",Space,Str "\\"]+,Para [Str "Backtick:",Space,Str "`"]+,Para [Str "Asterisk:",Space,Str "*"]+,Para [Str "Underscore:",Space,Str "_"]+,Para [Str "Left",Space,Str "brace:",Space,Str "{"]+,Para [Str "Right",Space,Str "brace:",Space,Str "}"]+,Para [Str "Left",Space,Str "bracket:",Space,Str "["]+,Para [Str "Right",Space,Str "bracket:",Space,Str "]"]+,Para [Str "Left",Space,Str "paren:",Space,Str "("]+,Para [Str "Right",Space,Str "paren:",Space,Str ")"]+,Para [Str "Greater-than:",Space,Str ">"]+,Para [Str "Hash:",Space,Str "#"]+,Para [Str "Period:",Space,Str "."]+,Para [Str "Bang:",Space,Str "!"]+,Para [Str "Plus:",Space,Str "+"]+,Para [Str "Minus:",Space,Str "-"]+,HorizontalRule+,Header 1 ("",[],[]) [Str "Links"]+,Header 2 ("",[],[]) [Str "Explicit"]+,Para [Str "Just",Space,Str "a",Space,Link ("",[],[]) [Str "URL"] ("https://example.org/url",""),Str "."]+,Para [Link ("",[],[]) [Str "File",Space,Str "URL"] ("file://some/file/name/",""),Str "."]+,Para [Link ("",[],[]) [Str "IRC",Space,Str "link"] ("irc://example.org/pandoc",""),Str "."]+,Para [Link ("",[],[]) [Str "Email",Space,Str "link"] ("mailto:nobody@nowhere.invalid","")]+,Para [Str "[Not",Space,Str "a",Space,Str "link|not",Space,Str "a",Space,Str "URL]."]+,Header 2 ("",[],[]) [Str "Reference"]+,Para [Str "With",Space,Link ("",[],[]) [Str "embedded",Space,Str "[brackets]"] ("https://example.net/url/",""),Str "."]+,Para [Link ("",[],[]) [Str "https://pandoc.org by itself should be a link."] ("https://pandoc.org by itself should be a link.","")]+,Header 2 ("",[],[]) [Str "With",Space,Str "ampersands"]+,Para [Str "Here\8217s",Space,Str "a",Space,Link ("",[],[]) [Str "link",Space,Str "with",Space,Str "an",Space,Str "ampersand",Space,Str "in",Space,Str "the",Space,Str "URL"] ("http://example.com/?foo=1&bar=2",""),Str "."]+,Para [Str "Here\8217s",Space,Str "a",Space,Str "link",Space,Str "with",Space,Str "an",Space,Str "ampersand",Space,Str "in",Space,Str "the",Space,Str "link",Space,Str "text:",Space,Link ("",[],[]) [Str "AT&T"] ("http://att.com/",""),Str "."]+,Header 2 ("",[],[]) [Str "Autolinks"]+,Para [Str "With",Space,Str "an",Space,Str "ampersand:",Space,Link ("",[],[]) [Str "http://example.com/?foo=1&bar=2"] ("http://example.com/?foo=1&bar=2","")]+,BulletList+ [[Para [Str "In",Space,Str "a",Space,Str "list?"]]+ ,[Para [Link ("",[],[]) [Str "http://example.com/"] ("http://example.com/","")]]+ ,[Para [Str "It",Space,Str "should."]]]+,Para [Str "An",Space,Str "e-mail",Space,Str "address:",Space,Link ("",[],[]) [Str "mailto:nobody@nowhere.invalid"] ("mailto:nobody@nowhere.invalid","")]+,BlockQuote+ [Para [Str "Blockquoted:",Space,Link ("",[],[]) [Str "http://example.com/"] ("http://example.com/","")]]+,CodeBlock ("",["java"],[]) "Autolink should not occur here: <http://example.com/>\n"+,HorizontalRule+,Header 1 ("",[],[]) [Str "Images"]+,Para [Str "From",Space,Str "\"Voyage",Space,Str "dans",Space,Str "la",Space,Str "Lune\"",Space,Str "by",Space,Str "Georges",Space,Str "Melies",Space,Str "(1902):"]+,Para [Image ("",[],[]) [] ("lalune.jpg","")]+,Para [Str "Here",Space,Str "is",Space,Str "a",Space,Str "movie",Space,Image ("",[],[]) [] ("movie.jpg",""),Space,Str "icon."]]
test/tables.jira view
@@ -1,43 +1,38 @@ Simple table with caption: -||Right||Left||Center||Default||-|12|12|12|12|-|123|123|123|123|-|1|1|1|1|+| 12 | 12 | 12 | 12 |+| 123 | 123 | 123 | 123 |+| 1 | 1 | 1 | 1 | Simple table without caption: -||Right||Left||Center||Default||-|12|12|12|12|-|123|123|123|123|-|1|1|1|1|+| 12 | 12 | 12 | 12 |+| 123 | 123 | 123 | 123 |+| 1 | 1 | 1 | 1 | Simple table indented two spaces: -||Right||Left||Center||Default||-|12|12|12|12|-|123|123|123|123|-|1|1|1|1|+| 12 | 12 | 12 | 12 |+| 123 | 123 | 123 | 123 |+| 1 | 1 | 1 | 1 | Multiline table with caption: -||Centered Header||Left Aligned||Right Aligned||Default aligned||-|First|row|12.0|Example of a row that spans multiple lines.|-|Second|row|5.0|Here’s another one. Note the blank line between rows.|+| First | row | 12.0 | Example of a row that spans multiple lines. |+| Second | row | 5.0 | Here’s another one. Note the blank line between rows. | Multiline table without caption: -||Centered Header||Left Aligned||Right Aligned||Default aligned||-|First|row|12.0|Example of a row that spans multiple lines.|-|Second|row|5.0|Here’s another one. Note the blank line between rows.|+| First | row | 12.0 | Example of a row that spans multiple lines. |+| Second | row | 5.0 | Here’s another one. Note the blank line between rows. | Table without column headers: -|12|12|12|12|-|123|123|123|123|-|1|1|1|1|+| 12 | 12 | 12 | 12 |+| 123 | 123 | 123 | 123 |+| 1 | 1 | 1 | 1 | Multiline table without column headers: -|First|row|12.0|Example of a row that spans multiple lines.|-|Second|row|5.0|Here’s another one. Note the blank line between rows.|+| First | row | 12.0 | Example of a row that spans multiple lines. |+| Second | row | 5.0 | Here’s another one. Note the blank line between rows. |
test/test-pandoc.hs view
@@ -17,6 +17,7 @@ import qualified Tests.Readers.FB2 import qualified Tests.Readers.HTML import qualified Tests.Readers.JATS+import qualified Tests.Readers.Jira import qualified Tests.Readers.LaTeX import qualified Tests.Readers.Markdown import qualified Tests.Readers.Muse@@ -73,6 +74,7 @@ , testGroup "Markdown" Tests.Readers.Markdown.tests , testGroup "HTML" Tests.Readers.HTML.tests , testGroup "JATS" Tests.Readers.JATS.tests+ , testGroup "Jira" Tests.Readers.Jira.tests , testGroup "Org" Tests.Readers.Org.tests , testGroup "RST" Tests.Readers.RST.tests , testGroup "Docx" Tests.Readers.Docx.tests
test/writer.jira view
@@ -1,59 +1,43 @@ This is a set of tests for pandoc. Most of them are adapted from John Gruber’s markdown test suite. ----- h1. {anchor:headers}Headers- h2. {anchor:level-2-with-an-embedded-link}Level 2 with an [embedded link|/url]- h3. {anchor:level-3-with-emphasis}Level 3 with _emphasis_- h4. {anchor:level-4}Level 4- h5. {anchor:level-5}Level 5- h1. {anchor:level-1}Level 1- h2. {anchor:level-2-with-emphasis}Level 2 with _emphasis_- h3. {anchor:level-3}Level 3- with no blank line h2. {anchor:level-2}Level 2- with no blank line ----- h1. {anchor:paragraphs}Paragraphs- Here’s a regular paragraph. -In Markdown 1.0.0 and earlier. Version 8. This line turns into a list item. Because a hard\-wrapped line in the middle of a paragraph looked like a list item.+In Markdown 1.0.0 and earlier. Version 8. This line turns into a list item. Because a hard-wrapped line in the middle of a paragraph looked like a list item. -Here’s one with a bullet. \* criminey.+Here’s one with a bullet. * criminey. There should be a hard line break here. ----- h1. {anchor:block-quotes}Block Quotes--E\-mail style:+E-mail style: bq. This is a block quote. It is pretty short.- {quote} Code in a block quote: -{code}+{code:java} sub status { print "working"; } {code}- A list: # item one@@ -62,23 +46,17 @@ Nested block quotes: bq. nested- bq. nested- {quote}-- This should not be a block quote: 2 > 1. And a following paragraph. ----- h1. {anchor:code-blocks}Code Blocks- Code: -{code}+{code:java} ---- (should be four hyphens) sub status {@@ -87,21 +65,16 @@ this code block is indented by one tab {code}- And: -{code}+{code:java} this code block is indented by two tabs These should not be escaped: \$ \\ \> \[ \{ {code}- ----- h1. {anchor:lists}Lists- h2. {anchor:unordered}Unordered- Asterisks tight: * asterisk 1@@ -139,7 +112,6 @@ * Minus 3 h2. {anchor:ordered}Ordered- Tight: # First@@ -172,7 +144,6 @@ # Item 3. h2. {anchor:nested}Nested- * Tab ** Tab *** Tab@@ -196,14 +167,12 @@ # Third h2. {anchor:tabs-and-spaces}Tabs and spaces- * this is a list item indented with tabs * this is a list item indented with spaces ** this is an example list item indented with tabs ** this is an example list item indented with spaces h2. {anchor:fancy-list-markers}Fancy list markers- # begins with 2 # and now 3 with a continuation@@ -232,9 +201,7 @@ B. Williams ----- h1. {anchor:definition-lists}Definition Lists- Tight using spaces: * *apple*@@ -269,7 +236,7 @@ contains seeds, crisp, pleasant to taste * *_orange_* orange fruit-{code}+{code:java} { orange code block } {code} bq. orange block quote@@ -303,86 +270,62 @@ *# sublist h1. {anchor:html-blocks}HTML Blocks- Simple block on one line: foo+ And nested without indentation: foo bar-Interpreted markdown in a table: --+Interpreted markdown in a table: This is _emphasized_ - And this is *strong* --- Here’s a simple block: foo This should be a code block, though: -{code}+{code:java} <div> foo </div> {code}- As should this: -{code}+{code:java} <div>foo</div> {code}- Now, nested: foo-This should just be an HTML comment: +This should just be an HTML comment: Multiline: -- Code block: -{code}+{code:java} <!-- Comment --> {code}- Just plain comment, with trailing spaces on the line: - Code: -{code}+{code:java} <hr /> {code}- Hr’s: --------- ----- h1. {anchor:inline-markup}Inline Markup- This is _emphasized_, and so _is this_. This is *strong*, and so *is this*.@@ -397,20 +340,18 @@ So is *_this_* word. -This is code: {{>}}, {{$}}, {{\}}, {{\$}}, {{<html>}}.+This is code: {{>}}, {{$}}, {{\}}, {{\$}}, {{<html>}}. -This is _strikeout_.- -Superscripts: a{^bc^}d a{^_hello_^} a{^hello there^}.+Superscripts: a{^}bc{^}d a{^}_hello_{^} a{^}hello there{^}. -Subscripts: H{~2~}O, H{~23~}O, H{~many of them~}O.+Subscripts: H{~}2{~}O, H{~}23{~}O, H{~}many of them{~}O. -These should not be superscripts or subscripts, because of the unescaped spaces: a\^b c\^d, a\~b c\~d.+These should not be superscripts or subscripts, because of the unescaped spaces: a^b c^d, a~b c~d. ----- h1. {anchor:smart-quotes-ellipses-dashes}Smart quotes, ellipses, dashes- "Hello," said the spider. "'Shelob' is my name." 'A', 'B', and 'C' are letters.@@ -421,39 +362,36 @@ Here is some quoted '{{code}}' and a "[quoted link|http://example.com/?foo=1&bar=2]". -Some dashes: one --- two --- three --- four --- five.+Some dashes: one—two — three—four — five. -Dashes between numbers: 5 -- 7, 255 -- 66, 1987 -- 1999.+Dashes between numbers: 5–7, 255–66, 1987–1999. -Ellipses...and...and....+Ellipses…and…and…. ----- h1. {anchor:latex}LaTeX- * -* 2 \+ 2 = 4-* _x_ ∈ _y_-* _α_ ∧ _ω_+* 2 + 2 = 4+* _x_ ∈ {_}y{_}+* _α_ ∧ {_}ω{_} * 223 * _p_\-Tree-* Here’s some display math: \\$$\frac\{d\}\{dx\}f(x)=\lim\_\{h\to 0\}\frac\{f(x\+h)\-f(x)\}\{h\}$$\\-* Here’s one that has a line break in it: _α_ \+ _ω_ × _x_{^2^}.+* Here’s some display math: +$$\frac{d\}\{dx}f\(x)=\lim\_\{h\to 0\}\frac{f(x+h)-f\(x)\}\{h}$$ +* Here’s one that has a line break in it: _α_ + {_}ω{_} × {_}x{_}^2^.+ These shouldn’t be math: * To get the famous equation, write {{$e = mc^2$}}.-* $22,000 is a _lot_ of money. So is $34,000. (It worked if "lot" is emphasized.)-* Shoes ($20) and socks ($5).+* $22,000 is a _lot_ of money. So is $34,000. \(It worked if "lot" is emphasized.)+* Shoes \($20) and socks \($5). * Escaped {{$}}: $73 _this should be emphasized_ 23$. Here’s a LaTeX table: - ----- h1. {anchor:special-characters}Special Characters- Here is some unicode: * I hat: Î@@ -472,7 +410,7 @@ 6 > 5. -Backslash: \+Backslash: \ Backtick: ` @@ -488,11 +426,11 @@ Right bracket: \] -Left paren: (+Left paren: \( Right paren: ) -Greater\-than: >+Greater-than: > Hash: # @@ -505,11 +443,8 @@ Minus: \- ----- h1. {anchor:links}Links- h2. {anchor:explicit}Explicit- Just a [URL|/url/]. [URL and title|/url/].@@ -522,14 +457,13 @@ [URL and title|/url/] -[with\_underscore|/url/with_underscore]+[with_underscore|/url/with_underscore] [Email link|mailto:nobody@nowhere.net] [Empty|]. h2. {anchor:reference}Reference- Foo [bar|/url/]. With [embedded \[brackets\]|/url/].@@ -544,16 +478,14 @@ This should \[not\]\[\] be a link. -{code}+{code:java} [not]: /url {code}- Foo [bar|/url/]. Foo [biz|/url/]. h2. {anchor:with-ampersands}With ampersands- Here’s a [link with an ampersand in the URL|http://example.com/?foo=1&bar=2]. Here’s a link with an amersand in the link text: [AT&T|http://att.com/].@@ -563,64 +495,55 @@ Here’s an [inline link in pointy braces|/script?foo=1&bar=2]. h2. {anchor:autolinks}Autolinks- With an ampersand: [http://example.com/?foo=1&bar=2|http://example.com/?foo=1&bar=2] * In a list? * [http://example.com/|http://example.com/] * It should. -An e\-mail address: [nobody@nowhere.net|mailto:nobody@nowhere.net]+An e-mail address: [nobody@nowhere.net|mailto:nobody@nowhere.net] bq. Blockquoted: [http://example.com/|http://example.com/]--Auto\-links should not occur here: {{<http://example.com/>}}+Auto-links should not occur here: {{<http://example.com/>}} -{code}+{code:java} or here: <http://example.com/> {code}- ----- h1. {anchor:images}Images--From "Voyage dans la Lune" by Georges Melies (1902):+From "Voyage dans la Lune" by Georges Melies \(1902): !lalune.jpg! Here is a movie !movie.jpg! icon. ----- h1. {anchor:footnotes}Footnotes- Here is a footnote reference,[1] and another.[2] This should _not_ be a footnote reference, because it contains a space.\[\^my note\] Here is an inline note.[3] bq. Notes can go in quotes.[4]- # And in list items.[5] This paragraph should not be part of the note, as it is not indented. -[1] Here is the footnote. It can go anywhere after the footnote reference. It need not be placed at the end of the document.+\[1] Here is the footnote. It can go anywhere after the footnote reference. It need not be placed at the end of the document. -[2] Here’s the long note. This one contains multiple blocks.+\[2] Here’s the long note. This one contains multiple blocks. -Subsequent blocks are indented to show that they belong to the footnote (as with list items).+Subsequent blocks are indented to show that they belong to the footnote \(as with list items). -{code}+{code:java} { <code> } {code}- If you want, you can indent every line, but you can also be lazy and just indent the first line of each block. -[3] This is _easier_ to type. Inline notes may contain [links|http://google.com] and {{]}} verbatim characters, as well as \[bracketed text\].+\[3] This is _easier_ to type. Inline notes may contain [links|http://google.com] and {{\]}} verbatim characters, as well as \[bracketed text]. -[4] In quote.+\[4] In quote. -[5] In list.+\[5] In list.
trypandoc/index.html view
@@ -94,6 +94,7 @@ <option value="haddock">Haddock markup</option> <option value="html">HTML</option> <option value="jats">JATS</option>+ <option value="jira">Jira</option> <option value="ipynb">Jupyter Notebook (ipynb)</option> <option value="latex">LaTeX</option> <option value="man">Man</option>