From 64376955745cf4fd407947eb8022460bf498176b Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 26 Aug 2017 21:30:00 -0700 Subject: Markdown writer: don't crash on Str "". --- src/Text/Pandoc/Writers/Markdown.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs index 95977ce17..523dfeaed 100644 --- a/src/Text/Pandoc/Writers/Markdown.hs +++ b/src/Text/Pandoc/Writers/Markdown.hs @@ -931,7 +931,7 @@ avoidBadWrapsInList (s:Str cs:[]) avoidBadWrapsInList (x:xs) = x : avoidBadWrapsInList xs isOrderedListMarker :: String -> Bool -isOrderedListMarker xs = (last xs `elem` ['.',')']) && +isOrderedListMarker xs = not (null xs) && (last xs `elem` ['.',')']) && isRight (runParser (anyOrderedListMarker >> eof) defaultParserState "" xs) -- cgit v1.2.3 From 8fcf66453cc4f9d1cf9413aa466477e56290d733 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 27 Aug 2017 17:01:24 -0700 Subject: RST reader: Fixed `..include::` directive. Closes #3880. --- pandoc.cabal | 1 + src/Text/Pandoc/Readers/RST.hs | 18 +++++++++--------- test/command/3880.md | 6 ++++++ test/command/3880.txt | 1 + 4 files changed, 17 insertions(+), 9 deletions(-) create mode 100644 test/command/3880.md create mode 100644 test/command/3880.txt diff --git a/pandoc.cabal b/pandoc.cabal index 0907ed82f..2228c7ff5 100644 --- a/pandoc.cabal +++ b/pandoc.cabal @@ -138,6 +138,7 @@ Extra-Source-Files: test/*.native test/command/*.md test/command/3533-rst-csv-tables.csv + test/command/3880.txt test/command/abbrevs test/command/SVG_logo-without-xml-declaration.svg test/command/SVG_logo.svg diff --git a/src/Text/Pandoc/Readers/RST.hs b/src/Text/Pandoc/Readers/RST.hs index 190b065fb..daaeff2f0 100644 --- a/src/Text/Pandoc/Readers/RST.hs +++ b/src/Text/Pandoc/Readers/RST.hs @@ -219,7 +219,6 @@ block = choice [ codeBlock , directive , anchor , comment - , include , header , hrule , lineBlock -- must go before definitionList @@ -460,16 +459,16 @@ tab-width encoding -} -include :: PandocMonad m => RSTParser m Blocks -include = try $ do - string ".. include::" - skipMany spaceChar - f <- trim <$> anyLine - fields <- many $ rawFieldListItem 3 +includeDirective :: PandocMonad m + => String -> [(String, String)] -> String + -> RSTParser m Blocks +includeDirective top fields body = do + let f = trim top + guard $ not (null f) + guard $ null (trim body) -- options let (startLine :: Maybe Int) = lookup "start-line" fields >>= safeRead let (endLine :: Maybe Int) = lookup "end-line" fields >>= safeRead - guard $ not (null f) oldPos <- getPosition oldInput <- getInput containers <- stateContainers <$> getState @@ -501,7 +500,7 @@ include = try $ do Just patt -> drop 1 . dropWhile (not . (patt `isInfixOf`)) Nothing -> id) $ contentLines' - let contents' = unlines contentLines'' + let contents' = unlines contentLines'' ++ "\n" case lookup "code" fields of Just lang -> do let numberLines = lookup "number-lines" fields @@ -687,6 +686,7 @@ directive' = do $ lookup "height" fields >>= (lengthToDim . filter (not . isSpace)) case label of + "include" -> includeDirective top fields body' "table" -> tableDirective top fields body' "list-table" -> listTableDirective top fields body' "csv-table" -> csvTableDirective top fields body' diff --git a/test/command/3880.md b/test/command/3880.md new file mode 100644 index 000000000..b8edaf08f --- /dev/null +++ b/test/command/3880.md @@ -0,0 +1,6 @@ +``` +pandoc -f rst -t native +.. include:: command/3880.txt +^D +[Para [Str "hi"]] +``` diff --git a/test/command/3880.txt b/test/command/3880.txt new file mode 100644 index 000000000..45b983be3 --- /dev/null +++ b/test/command/3880.txt @@ -0,0 +1 @@ +hi -- cgit v1.2.3 From 05bb8ef4aa6faa6a4da3c54a0483d42b846733ca Mon Sep 17 00:00:00 2001 From: Alexander Date: Mon, 28 Aug 2017 17:48:46 +0300 Subject: RST reader: handle blank lines correctly in line blocks (#3881) Previously pandoc would sometimes combine two line blocks separated by blanks, and ignore trailing blank lines within the line block. Test is checked to be consisted with http://rst.ninjs.org/ --- src/Text/Pandoc/Parsing.hs | 2 +- test/Tests/Readers/RST.hs | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Text/Pandoc/Parsing.hs b/src/Text/Pandoc/Parsing.hs index 9ed18d4e0..2543f11f0 100644 --- a/src/Text/Pandoc/Parsing.hs +++ b/src/Text/Pandoc/Parsing.hs @@ -838,7 +838,7 @@ blankLineBlockLine = try (char '|' >> blankline) lineBlockLines :: Monad m => ParserT [Char] st m [String] lineBlockLines = try $ do lines' <- many1 (lineBlockLine <|> ((:[]) <$> blankLineBlockLine)) - skipMany1 $ blankline <|> blankLineBlockLine + skipMany $ blankline return lines' -- | Parse a table using 'headerParser', 'rowParser', diff --git a/test/Tests/Readers/RST.hs b/test/Tests/Readers/RST.hs index 61a2673f5..928fc1a99 100644 --- a/test/Tests/Readers/RST.hs +++ b/test/Tests/Readers/RST.hs @@ -136,6 +136,19 @@ tests = [ "line block with blank line" =: para "but must stop here") , "line block with 3 lines" =: "| a\n| b\n| c" =?> lineBlock ["a", "b", "c"] + , "line blocks with blank lines" =: T.unlines + [ "|" + , "" + , "|" + , "| a" + , "| b" + , "|" + , "" + , "|" + ] =?> + lineBlock [""] <> + lineBlock ["", "a", "b", ""] <> + lineBlock [""] , "quoted literal block using >" =: "::\n\n> quoted\n> block\n\nOrdinary paragraph" =?> codeBlock "> quoted\n> block" <> para "Ordinary paragraph" , "quoted literal block using | (not a line block)" =: "::\n\n| quoted\n| block\n\nOrdinary paragraph" -- cgit v1.2.3 From 2e26046e1334d85efab9cfc2775cf59a66e8b459 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Mon, 28 Aug 2017 23:33:21 -0700 Subject: HTML writer: ensure we don't get two style attributes for width & height. --- src/Text/Pandoc/Writers/HTML.hs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs index 9ac37a0ba..87f61126b 100644 --- a/src/Text/Pandoc/Writers/HTML.hs +++ b/src/Text/Pandoc/Writers/HTML.hs @@ -47,7 +47,7 @@ import Control.Monad.State.Strict import Data.Char (ord, toLower) import Data.Text (Text) import qualified Data.Text.Lazy as TL -import Data.List (intersperse, isPrefixOf) +import Data.List (intersperse, isPrefixOf, partition, intercalate) import Data.Maybe (catMaybes, fromMaybe, isJust, isNothing) import Data.Monoid ((<>)) import qualified Data.Set as Set @@ -569,8 +569,14 @@ imgAttrsToHtml opts attr = do isNotDim _ = True dimensionsToAttrList :: Attr -> [(String, String)] -dimensionsToAttrList attr = (go Width) ++ (go Height) +dimensionsToAttrList attr = consolidateStyles $ go Width ++ go Height where + consolidateStyles xs = + case partition isStyle xs of + ([], _) -> xs + (ss, rest) -> ("style", intercalate ";" $ map snd ss) : rest + isStyle ("style", _) = True + isStyle _ = False go dir = case (dimension dir attr) of (Just (Pixel a)) -> [(show dir, show a)] (Just x) -> [("style", show dir ++ ":" ++ show x)] -- cgit v1.2.3 From 22a4adf4ec172545fb1ed72bb85c30dc1186de62 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Tue, 29 Aug 2017 09:04:59 -0700 Subject: Add a type sig to satisfy ghc 7.10.3. --- src/Text/Pandoc/Writers/HTML.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs index 87f61126b..1641b991c 100644 --- a/src/Text/Pandoc/Writers/HTML.hs +++ b/src/Text/Pandoc/Writers/HTML.hs @@ -571,6 +571,7 @@ imgAttrsToHtml opts attr = do dimensionsToAttrList :: Attr -> [(String, String)] dimensionsToAttrList attr = consolidateStyles $ go Width ++ go Height where + consolidateStyles :: [(String, String)] -> [(String, String)] consolidateStyles xs = case partition isStyle xs of ([], _) -> xs -- cgit v1.2.3 From 2d936ff4e08c8b77f2dac0b278b85bb7f66658af Mon Sep 17 00:00:00 2001 From: Alexander Date: Tue, 29 Aug 2017 19:15:06 +0300 Subject: hlint Muse reader (#3884) --- src/Text/Pandoc/Readers/Muse.hs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Text/Pandoc/Readers/Muse.hs b/src/Text/Pandoc/Readers/Muse.hs index 77f75c8c6..2947c50d6 100644 --- a/src/Text/Pandoc/Readers/Muse.hs +++ b/src/Text/Pandoc/Readers/Muse.hs @@ -261,8 +261,7 @@ verseLines = do verseTag :: PandocMonad m => MuseParser m (F Blocks) verseTag = do (_, content) <- htmlElement "verse" - parsedContent <- parseFromString verseLines content - return parsedContent + parseFromString verseLines content commentTag :: PandocMonad m => MuseParser m (F Blocks) commentTag = parseHtmlContent "comment" anyChar >> return mempty @@ -379,8 +378,8 @@ definitionListItem = try $ do pure $ do lineContent' <- lineContent pure (B.text term, [lineContent']) where - termParser = (many1 spaceChar) >> -- Initial space as required by Amusewiki, but not Emacs Muse - (many1Till anyChar $ lookAhead (void (try (spaceChar >> string "::")) <|> void newline)) + termParser = many1 spaceChar >> -- Initial space as required by Amusewiki, but not Emacs Muse + many1Till anyChar (lookAhead (void (try (spaceChar >> string "::")) <|> void newline)) endOfInput = try $ skipMany blankline >> skipSpaces >> eof twoBlankLines = try $ blankline >> skipMany1 blankline newDefinitionListItem = try $ void termParser -- cgit v1.2.3 From 14f813c3f294739f3965058e27eb228ab3ed90d5 Mon Sep 17 00:00:00 2001 From: Alexander Date: Tue, 29 Aug 2017 22:40:34 +0300 Subject: Muse reader: parse verse markup (#3882) --- src/Text/Pandoc/Readers/Muse.hs | 22 +++++++++++++++++++++- test/Tests/Readers/Muse.hs | 24 ++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/src/Text/Pandoc/Readers/Muse.hs b/src/Text/Pandoc/Readers/Muse.hs index 2947c50d6..a4512cdd7 100644 --- a/src/Text/Pandoc/Readers/Muse.hs +++ b/src/Text/Pandoc/Readers/Muse.hs @@ -32,7 +32,6 @@ TODO: - {{{ }}} syntax for - Page breaks (five "*") - Headings with anchors (make it round trip with Muse writer) -- Verse markup (">") - Org tables - table.el tables - Images with attributes (floating and width) @@ -181,6 +180,7 @@ blockElements = choice [ comment , rightTag , quoteTag , verseTag + , lineBlock , bulletList , orderedList , definitionList @@ -298,6 +298,26 @@ noteBlock = try $ do blocksTillNote = many1Till block (eof <|> () <$ lookAhead noteMarker) +-- +-- Verse markup +-- + +lineVerseLine :: PandocMonad m => MuseParser m String +lineVerseLine = try $ do + char '>' + white <- many1 (char ' ' >> pure '\160') + rest <- anyLine + return $ tail white ++ rest + +blanklineVerseLine :: PandocMonad m => MuseParser m Char +blanklineVerseLine = try $ char '>' >> blankline + +lineBlock :: PandocMonad m => MuseParser m (F Blocks) +lineBlock = try $ do + lns <- many1 (pure <$> blanklineVerseLine <|> lineVerseLine) + lns' <- mapM (parseFromString' (trimInlinesF . mconcat <$> many inline)) lns + return $ B.lineBlock <$> sequence lns' + -- -- lists -- diff --git a/test/Tests/Readers/Muse.hs b/test/Tests/Readers/Muse.hs index 1f3218daf..4e5e5b606 100644 --- a/test/Tests/Readers/Muse.hs +++ b/test/Tests/Readers/Muse.hs @@ -145,6 +145,30 @@ tests = , " with a continuation" ] =?> blockQuote (para "This is a quotation with a continuation") + , "Verse" =: + T.unlines [ "> This is" + , "> First stanza" + , ">" -- Emacs produces verbatim ">" here, we follow Amusewiki + , "> And this is" + , "> Second stanza" + , ">" + , "" + , ">" + , "" + , "> Another verse" + , "> is here" + ] =?> + lineBlock [ "This is" + , "First stanza" + , "" + , "And this is" + , "\160\160Second stanza" + , "" + ] <> + lineBlock [ "" ] <> + lineBlock [ "Another verse" + , "\160\160\160is here" + ] ] , "Quote tag" =: "Hello, world" =?> blockQuote (para $ text "Hello, world") , "Verse tag" =: -- cgit v1.2.3 From 9ada1defb572cacdf561e9d436a6961f8ea426e0 Mon Sep 17 00:00:00 2001 From: Albert Krewinkel Date: Wed, 30 Aug 2017 15:09:54 +0200 Subject: Document fallback functions in lua filters --- doc/lua-filters.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/lua-filters.md b/doc/lua-filters.md index 5d0bfaf1e..23ea59a43 100644 --- a/doc/lua-filters.md +++ b/doc/lua-filters.md @@ -111,6 +111,11 @@ inline element must return an inline, and a block element must remain a block element after filter application. Pandoc will throw an error if this condition is violated. +If there is no function matching the element's node type, then +the filtering system will look for a more general fallback +function. Two fallback functions are supported, `Inline` and +`Block`. Each matches elements of the respective type. + Elements without matching functions are left untouched. See [module documentation](pandoc-module.html) for a list of pandoc -- cgit v1.2.3 From 50ec64ffbc56db2c2312feb606df4bc36142b3f0 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Wed, 30 Aug 2017 17:05:12 -0700 Subject: HTML reader: improved handling of figure. Previously we had a parse failure if the figure contained anything besides an image and caption. --- src/Text/Pandoc/Readers/HTML.hs | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/Text/Pandoc/Readers/HTML.hs b/src/Text/Pandoc/Readers/HTML.hs index d85488478..257c16735 100644 --- a/src/Text/Pandoc/Readers/HTML.hs +++ b/src/Text/Pandoc/Readers/HTML.hs @@ -58,7 +58,7 @@ import Data.Maybe ( fromMaybe, isJust, isNothing ) import Data.List.Split ( wordsBy ) import Data.List ( intercalate, isPrefixOf ) import Data.Char ( isDigit, isLetter, isAlphaNum ) -import Control.Monad ( guard, mzero, void, unless, mplus ) +import Control.Monad ( guard, mzero, void, unless, mplus, msum ) import Control.Arrow ((***)) import Control.Applicative ( (<|>) ) import Data.Monoid (First (..)) @@ -576,23 +576,23 @@ pPara = do return $ B.para contents pFigure :: PandocMonad m => TagParser m Blocks -pFigure = do +pFigure = try $ do TagOpen _ _ <- pSatisfy (matchTagOpen "figure" []) skipMany pBlank - let pImg = pOptInTag "p" pImage <* skipMany pBlank - pCapt = option mempty $ pInTags "figcaption" inline <* skipMany pBlank - pImgCapt = do - img <- pImg - cap <- pCapt - return (img, cap) - pCaptImg = do - cap <- pCapt - img <- pImg - return (img, cap) - (imgMany, caption) <- pImgCapt <|> pCaptImg + let pImg = (\x -> (Just x, Nothing)) <$> + (pOptInTag "p" pImage <* skipMany pBlank) + pCapt = (\x -> (Nothing, Just x)) <$> + (pInTags "figcaption" inline <* skipMany pBlank) + pSkip = (Nothing, Nothing) <$ pSatisfy (not . matchTagClose "figure") + res <- many (pImg <|> pCapt <|> pSkip) + let mbimg = msum $ map fst res + let mbcap = msum $ map snd res TagClose _ <- pSatisfy (matchTagClose "figure") - let (Image attr _ (url, tit)):_ = B.toList imgMany - return $ B.para $ B.imageWith attr url ("fig:" ++ tit) caption + let caption = fromMaybe mempty mbcap + case B.toList <$> mbimg of + Just [Image attr _ (url, tit)] -> + return $ B.para $ B.imageWith attr url ("fig:" ++ tit) caption + Nothing -> mzero pCodeBlock :: PandocMonad m => TagParser m Blocks pCodeBlock = try $ do @@ -961,7 +961,7 @@ blockHtmlTags = Set.fromList "dir", "div", "dl", "dt", "fieldset", "figcaption", "figure", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup", "hr", "html", - "isindex", "main", "menu", "noframes", "ol", "output", "p", "pre", + "isindex", "main", "menu", "meta", "noframes", "ol", "output", "p", "pre", "section", "table", "tbody", "textarea", "thead", "tfoot", "ul", "dd", "dt", "frameset", "li", "tbody", "td", "tfoot", @@ -1048,7 +1048,7 @@ x `closes` "p" | x `elem` ["address", "article", "aside", "blockquote", "dir", "div", "dl", "fieldset", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "header", "hr", "main", "menu", "nav", "ol", "p", "pre", "section", "table", "ul"] = True -"meta" `closes` "meta" = True +_ `closes` "meta" = True "form" `closes` "form" = True "label" `closes` "label" = True "map" `closes` "map" = True -- cgit v1.2.3 From bc47cfd40e408b50c010e9d56a7a010a95cde0c8 Mon Sep 17 00:00:00 2001 From: Albert Krewinkel Date: Thu, 31 Aug 2017 13:17:38 +0200 Subject: Add ldoc template for lua module documentation The template can be used instead of the default template by calling ldoc with the `-l doc` option, where *doc* is the directory of the template. --- doc/ldoc.ltp | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 doc/ldoc.ltp diff --git a/doc/ldoc.ltp b/doc/ldoc.ltp new file mode 100644 index 000000000..3fa96bb0f --- /dev/null +++ b/doc/ldoc.ltp @@ -0,0 +1,38 @@ +# local iter = ldoc.modules.iter +# local M = ldoc.markup + +

Module $(module.name)

+ +

$(M(module.summary))

+ +# for kind, items in module.kinds() do + +

$(kind)

+
+# for item in items() do ldoc.item = item -- provides context for M() +
$(ldoc.display_name(item))
+
+

$(item.summary)

+# if item.params and #item.params > 0 then + $(module.kinds:type_of(item).subnames): +
+# for p in iter(item.params) do +
$(p):
+
$(M(item.params.map[p]))
+# end -- for +
+# end -- if params +# if item.ret then +

Returns: $(item.ret[1])

+# end -- if returns +# if item.usage then +

Usage:

+
$(item.usage[1])
+# end -- if usage +# if item.see then + See also: $(item.see[1].label) + +# end -- if see +# end -- for items +
+# end -- for kinds -- cgit v1.2.3 From 1a4658c57390415ec8d59504d096d4383b8970d4 Mon Sep 17 00:00:00 2001 From: Albert Krewinkel Date: Thu, 31 Aug 2017 13:22:27 +0200 Subject: data/pandoc.lua: fix typos in documentation --- data/pandoc.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/pandoc.lua b/data/pandoc.lua index 16387d27b..bce4e9326 100644 --- a/data/pandoc.lua +++ b/data/pandoc.lua @@ -135,7 +135,7 @@ end -- @section document --- A complete pandoc document --- @function Panoc +-- @function Pandoc -- @tparam {Block,...} blocks document content -- @tparam[opt] Meta meta document meta data function M.Pandoc(blocks, meta) @@ -772,7 +772,7 @@ M.UpperAlpha = "UpperAlpha" -- `--from` command line option. -- @tparam string markup the markup to be parsed -- @tparam[opt] string format format specification, defaults to "markdown". --- @return Doc pandoc document +-- @treturn Pandoc pandoc document -- @usage -- local org_markup = "/emphasis/" -- Input to be read -- local document = pandoc.read(org_markup, "org") -- cgit v1.2.3 From 79b1a701b8452db4e49f633d0cc9dae7d0d93a0d Mon Sep 17 00:00:00 2001 From: Albert Krewinkel Date: Thu, 31 Aug 2017 13:23:24 +0200 Subject: lua-filters.md: append docs for pandoc's lua module The documentation was generated from `data/pandoc.lua` using the following command: ldoc -l doc -d /tmp data/pandoc.lua; pandoc -t markdown --columns=65 \ --atx-headers /tmp/index.html >> \ doc/lua-filters.md --- doc/lua-filters.md | 737 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 736 insertions(+), 1 deletion(-) diff --git a/doc/lua-filters.md b/doc/lua-filters.md index 23ea59a43..9e4d438ea 100644 --- a/doc/lua-filters.md +++ b/doc/lua-filters.md @@ -1,6 +1,6 @@ % Pandoc Lua Filters % Albert Krewinkel, John MacFarlane -% August 21, 2017 +% August 31, 2017 # Introduction @@ -309,3 +309,738 @@ then running `pandoc --lua-filter=meta-vars.lua occupations.md` will output: ``` + +# Module pandoc + +Lua functions for pandoc scripts. + +## Pandoc Document + +[`Pandoc (blocks[, meta])`]{#Pandoc} + +: A complete pandoc document + + Parameters: + + `blocks`: + : document content + + `meta`: + : document meta data + +## MetaValue + +[`MetaBlocks (blocks)`]{#MetaBlocks} + +: Meta blocks + + Parameters: + + `blocks`: + : blocks + +[`MetaInlines (inlines)`]{#MetaInlines} + +: Meta inlines + + Parameters: + + `inlines`: + : inlines + +[`MetaList (meta_values)`]{#MetaList} + +: Meta list + + Parameters: + + `meta_values`: + : list of meta values + +[`MetaMap (key_value_map)`]{#MetaMap} + +: Meta map + + Parameters: + + `key_value_map`: + : a string-indexed map of meta values + +[`MetaString (str)`]{#MetaString} + +: Creates string to be used in meta data. + + Parameters: + + `str`: + : string value + +[`MetaBool (bool)`]{#MetaBool} + +: Creates boolean to be used in meta data. + + Parameters: + + `bool`: + : boolean value + +## Blocks + +[`Block`]{#Block} + +: Block elements + +[`BlockQuote (content)`]{#BlockQuote} + +: Creates a block quote element + + Parameters: + + `content`: + : block content + + Returns: block quote element + +[`BulletList (content)`]{#BulletList} + +: Creates a bullet (i.e. + + Parameters: + + `content`: + : list of items + + Returns: block quote element + +[`CodeBlock (text[, attr])`]{#CodeBlock} + +: Creates a code block element + + Parameters: + + `text`: + : code string + + `attr`: + : element attributes + + Returns: code block element + +[`DefinitionList (content)`]{#DefinitionList} + +: Creates a definition list, containing terms and their + explanation. + + Parameters: + + `content`: + : list of items + + Returns: block quote element + +[`Div (content[, attr])`]{#Div} + +: Creates a div element + + Parameters: + + `content`: + : block content + + `attr`: + : element attributes + + Returns: code block element + +[`Header (level, content[, attr])`]{#Header} + +: Creates a block quote element. + + Parameters: + + `level`: + : header level + + `content`: + : inline content + + `attr`: + : element attributes + + Returns: header element + +[`HorizontalRule ()`]{#HorizontalRule} + +: Creates a horizontal rule. + + Returns: horizontal rule + +[`LineBlock (content)`]{#LineBlock} + +: Creates a line block element. + + Parameters: + + `content`: + : inline content + + Returns: block quote element + +[`Null ()`]{#Null} + +: Creates a null element. + + Returns: null element + +[`OrderedList (items[, listAttributes])`]{#OrderedList} + +: Creates an ordered list. + + Parameters: + + `items`: + : list items + + `listAttributes`: + : list parameters + + Returns: + +[`Para (content)`]{#Para} + +: Creates a para element. + + Parameters: + + `content`: + : inline content + + Returns: block quote element + +[`Plain (content)`]{#Plain} + +: Creates a plain element. + + Parameters: + + `content`: + : inline content + + Returns: block quote element + +[`RawBlock (format, text)`]{#RawBlock} + +: Creates a raw content block of the specified format. + + Parameters: + + `format`: + : format of content + + `text`: + : string content + + Returns: block quote element + +[`Table (caption, aligns, widths, headers, rows)`]{#Table} + +: Creates a table element. + + Parameters: + + `caption`: + : table caption + + `aligns`: + : alignments + + `widths`: + : column widths + + `headers`: + : header row + + `rows`: + : table rows + + Returns: block quote element + +## Inline + +[`Inline`]{#Inline} + +: Inline element class + +[`Cite (content, citations)`]{#Cite} + +: Creates a Cite inline element + + Parameters: + + `content`: + : List of inlines + + `citations`: + : List of citations + + Returns: citations element + +[`Code (text[, attr])`]{#Code} + +: Creates a Code inline element + + Parameters: + + `text`: + : brief image description + + `attr`: + : additional attributes + + Returns: code element + +[`Emph (content)`]{#Emph} + +: Creates an inline element representing emphasised text. + + Parameters: + + `content`: + : inline content + + Returns: emphasis element + +[`Image (caption, src[, title[, attr]])`]{#Image} + +: Creates a Image inline element + + Parameters: + + `caption`: + : text used to describe the image + + `src`: + : path to the image file + + `title`: + : brief image description + + `attr`: + : additional attributes + + Returns: image element + +[`LineBreak ()`]{#LineBreak} + +: Create a LineBreak inline element + + Returns: linebreak element + +[`Link (content, target[, title[, attr]])`]{#Link} + +: Creates a link inline element, usually a hyperlink. + + Parameters: + + `content`: + : text for this link + + `target`: + : the link target + + `title`: + : brief link description + + `attr`: + : additional attributes + + Returns: image element + +[`Math (mathtype, text)`]{#Math} + +: Creates a Math element, either inline or displayed. + + Parameters: + + `mathtype`: + : rendering specifier + + `text`: + : Math content + + Returns: Math element + +[`DisplayMath (text)`]{#DisplayMath} + +: Creates a DisplayMath element (DEPRECATED). + + Parameters: + + `text`: + : Math content + + Returns: Math element + +[`InlineMath (text)`]{#InlineMath} + +: Creates an InlineMath inline element (DEPRECATED). + + Parameters: + + `text`: + : Math content + + Returns: Math element + +[`Note (content)`]{#Note} + +: Creates a Note inline element + + Parameters: + + `content`: + : footnote block content + +[`Quoted (quotetype, content)`]{#Quoted} + +: Creates a Quoted inline element given the quote type and + quoted content. + + Parameters: + + `quotetype`: + : type of quotes to be used + + `content`: + : inline content + + Returns: quoted element + +[`SingleQuoted (content)`]{#SingleQuoted} + +: Creates a single-quoted inline element (DEPRECATED). + + Parameters: + + `content`: + : inline content + + Returns: quoted element + + See also: [Quoted](#Quoted) + +[`DoubleQuoted (content)`]{#DoubleQuoted} + +: Creates a single-quoted inline element (DEPRECATED). + + Parameters: + + `content`: + : inline content + + Returns: quoted element + + See also: [Quoted](#Quoted) + +[`RawInline (format, text)`]{#RawInline} + +: Creates a RawInline inline element + + Parameters: + + `format`: + : format of the contents + + `text`: + : string content + + Returns: raw inline element + +[`SmallCaps (content)`]{#SmallCaps} + +: Creates text rendered in small caps + + Parameters: + + `content`: + : inline content + + Returns: smallcaps element + +[`SoftBreak ()`]{#SoftBreak} + +: Creates a SoftBreak inline element. + + Returns: softbreak element + +[`Space ()`]{#Space} + +: Create a Space inline element + + Returns: space element + +[`Span (content[, attr])`]{#Span} + +: Creates a Span inline element + + Parameters: + + `content`: + : inline content + + `attr`: + : additional attributes + + Returns: span element + +[`Str (text)`]{#Str} + +: Creates a Str inline element + + Parameters: + + `text`: + : content + + Returns: string element + +[`Strikeout (content)`]{#Strikeout} + +: Creates text which is striked out. + + Parameters: + + `content`: + : inline content + + Returns: strikeout element + +[`Strong (content)`]{#Strong} + +: Creates a Strong element, whose text is usually displayed in + a bold font. + + Parameters: + + `content`: + : inline content + + Returns: strong element + +[`Subscript (content)`]{#Subscript} + +: Creates a Subscript inline element + + Parameters: + + `content`: + : inline content + + Returns: subscript element + +[`Superscript (content)`]{#Superscript} + +: Creates a Superscript inline element + + Parameters: + + `content`: + : inline content + + Returns: strong element + +## Helpers + +[`Attr ([identifier[, classes[, attributes]]])`]{#Attr} + +: Create a new set of attributes (Attr). + + Parameters: + + `identifier`: + : element identifier + + `classes`: + : element classes + + `attributes`: + : table containing string keys and values + + Returns: element attributes + +[`Citation (id, mode[, prefix[, suffix[, note_num[, hash]]]])`]{#Citation} + +: Creates a single citation. + + Parameters: + + `id`: + : citation identifier (like a bibtex key) + + `mode`: + : citation mode + + `prefix`: + : citation prefix + + `suffix`: + : citation suffix + + `note_num`: + : note number + + `hash`: + : hash number + +## Constants + +[`AuthorInText`]{#AuthorInText} + +: Author name is mentioned in the text. + + See also: [Citation](#Citation) + +[`SuppressAuthor`]{#SuppressAuthor} + +: Author name is suppressed. + + See also: [Citation](#Citation) + +[`NormalCitation`]{#NormalCitation} + +: Default citation style is used. + + See also: [Citation](#Citation) + +[`AlignLeft`]{#AlignLeft} + +: Table cells aligned left. + + See also: [Table](#Table) + +[`AlignRight`]{#AlignRight} + +: Table cells right-aligned. + + See also: [Table](#Table) + +[`AlignCenter`]{#AlignCenter} + +: Table cell content is centered. + + See also: [Table](#Table) + +[`AlignDefault`]{#AlignDefault} + +: Table cells are alignment is unaltered. + + See also: [Table](#Table) + +[`DefaultDelim`]{#DefaultDelim} + +: Default list number delimiters are used. + + See also: [OrderedList](#OrderedList) + +[`Period`]{#Period} + +: List numbers are delimited by a period. + + See also: [OrderedList](#OrderedList) + +[`OneParen`]{#OneParen} + +: List numbers are delimited by a single parenthesis. + + See also: [OrderedList](#OrderedList) + +[`TwoParens`]{#TwoParens} + +: List numbers are delimited by a double parentheses. + + See also: [OrderedList](#OrderedList) + +[`DefaultStyle`]{#DefaultStyle} + +: List are numbered in the default style + + See also: [OrderedList](#OrderedList) + +[`Example`]{#Example} + +: List items are numbered as examples. + + See also: [OrderedList](#OrderedList) + +[`Decimal`]{#Decimal} + +: List are numbered using decimal integers. + + See also: [OrderedList](#OrderedList) + +[`LowerRoman`]{#LowerRoman} + +: List are numbered using lower-case roman numerals. + + See also: [OrderedList](#OrderedList) + +[`UpperRoman`]{#UpperRoman} + +: List are numbered using upper-case roman numerals + + See also: [OrderedList](#OrderedList) + +[`LowerAlpha`]{#LowerAlpha} + +: List are numbered using lower-case alphabetic characters. + + See also: [OrderedList](#OrderedList) + +[`UpperAlpha`]{#UpperAlpha} + +: List are numbered using upper-case alphabetic characters. + + See also: [OrderedList](#OrderedList) + +## Helper Functions + +[`read (markup[, format])`]{#read} + +: Parse the given string into a Pandoc document. + + Parameters: + + `markup`: + : the markup to be parsed + + `format`: + : format specification, defaults to \"markdown\". + + Returns: pandoc document + + Usage: + + local org_markup = "/emphasis/" -- Input to be read + local document = pandoc.read(org_markup, "org") + -- Get the first block of the document + local block = document.blocks[1] + -- The inline element in that block is an `Emph` + assert(block.content[1].t == "Emph") + +[`global_filter ()`]{#global_filter} + +: Use functions defined in the global namespace to create a + pandoc filter. + + Returns: A list of filter functions + + Usage: + + -- within a file defining a pandoc filter: + function Str(text) + return pandoc.Str(utf8.upper(text)) + end + + return {pandoc.global_filter()} + -- the above is equivallent to + -- return {{Str = Str}} -- cgit v1.2.3 From 6a6c3858b47671f02f4f50ca2d6ab97d280a0f49 Mon Sep 17 00:00:00 2001 From: Albert Krewinkel Date: Thu, 31 Aug 2017 18:02:07 +0200 Subject: Org writer: stop using raw HTML to wrap divs Div's are difficult to translate into org syntax, as there are multiple div-like structures (drawers, special blocks, greater blocks) which all have their advantages and disadvantages. Previously pandoc would use raw HTML to preserve the full div information; this was rarely useful and resulted in visual clutter. Div-rendering was changed to discard the div's classes and key-value pairs if there is no natural way to translate the div into an org structure. Closes: #3771 --- src/Text/Pandoc/Writers/Org.hs | 63 +++++++++++++++++------------------------- test/command/3771.md | 14 ++++++++++ 2 files changed, 40 insertions(+), 37 deletions(-) create mode 100644 test/command/3771.md diff --git a/src/Text/Pandoc/Writers/Org.hs b/src/Text/Pandoc/Writers/Org.hs index 48f17c4fb..88f42acd4 100644 --- a/src/Text/Pandoc/Writers/Org.hs +++ b/src/Text/Pandoc/Writers/Org.hs @@ -129,36 +129,25 @@ blockToOrg (Div (_,classes@(cls:_),kvs) bs) | "drawer" `elem` classes = do blankline $$ contents $$ blankline $$ drawerEndTag $$ blankline -blockToOrg (Div attrs bs) = do +blockToOrg (Div (ident, classes, kv) bs) = do contents <- blockListToOrg bs + -- if one class looks like the name of a greater block then output as such: + -- The ID, if present, is added via the #+NAME keyword; other classes and + -- key-value pairs are kept as #+ATTR_HTML attributes. let isGreaterBlockClass = (`elem` ["center", "quote"]) . map toLower - return $ case attrs of - ("", [], []) -> - -- nullAttr, treat contents as if it wasn't wrapped - blankline $$ contents $$ blankline - (ident, [], []) -> - -- only an id: add id as an anchor, unwrap the rest - blankline $$ "<<" <> text ident <> ">>" $$ contents $$ blankline - (ident, classes, kv) -> - -- if one class looks like the name of a greater block then output as - -- such: The ID, if present, is added via the #+NAME keyword; other - -- classes and key-value pairs are kept as #+ATTR_HTML attributes. - let - (blockTypeCand, classes') = partition isGreaterBlockClass classes - in case blockTypeCand of - (blockType:classes'') -> - blankline $$ attrHtml (ident, classes'' <> classes', kv) $$ - "#+BEGIN_" <> text blockType $$ contents $$ - "#+END_" <> text blockType $$ blankline - _ -> - -- fallback: wrap in div tags - let - startTag = tagWithAttrs "div" attrs - endTag = text "" - in blankline $$ "#+BEGIN_HTML" $$ - nest 2 startTag $$ "#+END_HTML" $$ blankline $$ - contents $$ blankline $$ "#+BEGIN_HTML" $$ - nest 2 endTag $$ "#+END_HTML" $$ blankline + (blockTypeCand, classes') = partition isGreaterBlockClass classes + return $ case blockTypeCand of + (blockType:classes'') -> + blankline $$ attrHtml (ident, classes'' <> classes', kv) $$ + "#+BEGIN_" <> text blockType $$ contents $$ + "#+END_" <> text blockType $$ blankline + _ -> + -- fallback with id: add id as an anchor if present, discard classes and + -- key-value pairs, unwrap the content. + let contents' = if not (null ident) + then "<<" <> text ident <> ">>" $$ contents + else contents + in blankline $$ contents' $$ blankline blockToOrg (Plain inlines) = inlineListToOrg inlines -- title beginning with fig: indicates that the image is a figure blockToOrg (Para [Image attr txt (src,'f':'i':'g':':':tit)]) = do @@ -173,7 +162,7 @@ blockToOrg (Para inlines) = do blockToOrg (LineBlock lns) = do let splitStanza [] = [] splitStanza xs = case break (== mempty) xs of - (l, []) -> l : [] + (l, []) -> [l] (l, _:r) -> l : splitStanza r let joinWithLinefeeds = nowrap . mconcat . intersperse cr let joinWithBlankLines = mconcat . intersperse blankline @@ -213,7 +202,7 @@ blockToOrg (Table caption' _ _ headers rows) = do caption'' <- inlineListToOrg caption' let caption = if null caption' then empty - else ("#+CAPTION: " <> caption'') + else "#+CAPTION: " <> caption'' headers' <- mapM blockListToOrg headers rawRows <- mapM (mapM blockListToOrg) rows let numChars = maximum . map offset @@ -289,8 +278,8 @@ propertiesDrawer (ident, classes, kv) = let drawerStart = text ":PROPERTIES:" drawerEnd = text ":END:" - kv' = if (classes == mempty) then kv else ("CLASS", unwords classes):kv - kv'' = if (ident == mempty) then kv' else ("CUSTOM_ID", ident):kv' + kv' = if classes == mempty then kv else ("CLASS", unwords classes):kv + kv'' = if ident == mempty then kv' else ("CUSTOM_ID", ident):kv' properties = vcat $ map kvToOrgProperty kv'' in drawerStart <> cr <> properties <> cr <> drawerEnd @@ -303,7 +292,7 @@ attrHtml :: Attr -> Doc attrHtml ("" , [] , []) = mempty attrHtml (ident, classes, kvs) = let - name = if (null ident) then mempty else "#+NAME: " <> text ident <> cr + name = if null ident then mempty else "#+NAME: " <> text ident <> cr keyword = "#+ATTR_HTML" classKv = ("class", unwords classes) kvStrings = map (\(k,v) -> ":" <> k <> " " <> v) (classKv:kvs) @@ -370,19 +359,19 @@ inlineToOrg SoftBreak = do WrapPreserve -> return cr WrapAuto -> return space WrapNone -> return space -inlineToOrg (Link _ txt (src, _)) = do +inlineToOrg (Link _ txt (src, _)) = case txt of [Str x] | escapeURI x == src -> -- autolink - do return $ "[[" <> text (orgPath x) <> "]]" + return $ "[[" <> text (orgPath x) <> "]]" _ -> do contents <- inlineListToOrg txt return $ "[[" <> text (orgPath src) <> "][" <> contents <> "]]" -inlineToOrg (Image _ _ (source, _)) = do +inlineToOrg (Image _ _ (source, _)) = return $ "[[" <> text (orgPath source) <> "]]" inlineToOrg (Note contents) = do -- add to notes in state notes <- gets stNotes modify $ \st -> st { stNotes = contents:notes } - let ref = show $ (length notes) + 1 + let ref = show $ length notes + 1 return $ "[fn:" <> text ref <> "]" orgPath :: String -> String diff --git a/test/command/3771.md b/test/command/3771.md new file mode 100644 index 000000000..1d3a75ae1 --- /dev/null +++ b/test/command/3771.md @@ -0,0 +1,14 @@ +``` +% pandoc -f html -t org +
+ Today is a nice day. +
+
+ Tomorrow will be rainy. +
+^D +Today is a nice day. + +<> +Tomorrow will be rainy. +``` -- cgit v1.2.3 From aa90919fe9c78acf74371ce1e43757776c04b506 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Mon, 4 Sep 2017 17:07:20 -0700 Subject: Add 'static' Cabal flag, use it for linux statically linked. --- linux/Dockerfile | 10 ++++++---- pandoc.cabal | 7 ++++++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/linux/Dockerfile b/linux/Dockerfile index b725bbaa5..a8dc9bfd2 100644 --- a/linux/Dockerfile +++ b/linux/Dockerfile @@ -5,7 +5,7 @@ ADD https://raw.githubusercontent.com/mitchty/alpine-ghc/master/mitch.tishmack%4 /etc/apk/keys/mitch.tishmack@gmail.com-55881c97.rsa.pub RUN apk update RUN apk add alpine-sdk git ca-certificates ghc cabal stack zlib-dev \ - dpkg fakeroot sed gawk grep + dpkg fakeroot sed gawk grep llvm linux-headers RUN stack update RUN stack config set system-ghc --global true RUN mkdir -p /etc/stack @@ -16,13 +16,15 @@ RUN git clone https://github.com/jgm/pandoc WORKDIR /usr/src/pandoc RUN stack install --stack-yaml stack.pkg.yaml --only-dependencies \ --flag 'pandoc:embed_data_files' \ - --test --ghc-options '-O2 -optc-Os -optl-static -fPIC' \ + --ghc-options '-fPIC -fllvm' \ pandoc pandoc-citeproc CMD git pull && \ git checkout -b work $TREE && \ stack install --stack-yaml stack.pkg.yaml \ - --local-bin-path /artifacts --flag 'pandoc:embed_data_files' \ - --test --ghc-options '-O2 -optc-Os -optl-static -fPIC' \ + --flag 'pandoc:static' \ + --flag 'pandoc:embed_data_files' \ + --ghc-options '-fPIC -fllvm' \ + --local-bin-path /artifacts \ pandoc pandoc-citeproc && \ bash linux/make_deb.sh && \ bash linux/make_tarball.sh diff --git a/pandoc.cabal b/pandoc.cabal index 2228c7ff5..093c9196d 100644 --- a/pandoc.cabal +++ b/pandoc.cabal @@ -265,6 +265,10 @@ Source-repository head type: git location: git://github.com/jgm/pandoc.git +Flag static + Description: Use static linking for pandoc executable. + Default: False + Flag embed_data_files Description: Embed data files in binary for relocatable executable. Default: False @@ -483,7 +487,8 @@ Executable pandoc Build-Depends: pandoc, base >= 4.7 && < 5 Ghc-Options: -rtsopts -with-rtsopts=-K16m -Wall -fno-warn-unused-do-bind Ghc-Prof-Options: -fprof-auto-exported -rtsopts -with-rtsopts=-K16m - + if flag(static) + Ld-options: -static Default-Language: Haskell98 Other-Extensions: PatternGuards, OverloadedStrings, ScopedTypeVariables, GeneralizedNewtypeDeriving, -- cgit v1.2.3 From 76e580d5718fcbccaedcc953a05589a30e8b51d1 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Mon, 4 Sep 2017 17:11:01 -0700 Subject: Use latest pandoc-citeproc in stack.pkg.yaml. --- stack.pkg.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stack.pkg.yaml b/stack.pkg.yaml index d9de4fdd9..c93c9e920 100644 --- a/stack.pkg.yaml +++ b/stack.pkg.yaml @@ -14,7 +14,7 @@ packages: - '.' - location: git: https://github.com/jgm/pandoc-citeproc.git - commit: 71ca48b6e0044ea959d8e7882b03cceba9c7960c + commit: 5a7f26b61c8577916093851cdeb31fa9a198edcb extra-dep: false extra-deps: - hslua-0.8.0 -- cgit v1.2.3 From 1d0805ce414398d5ff70c9ed3dbe1288356c7dd9 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Mon, 4 Sep 2017 18:11:26 -0700 Subject: HTML reader: Fix pattern match. --- src/Text/Pandoc/Readers/HTML.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Text/Pandoc/Readers/HTML.hs b/src/Text/Pandoc/Readers/HTML.hs index 257c16735..2093be19c 100644 --- a/src/Text/Pandoc/Readers/HTML.hs +++ b/src/Text/Pandoc/Readers/HTML.hs @@ -592,7 +592,7 @@ pFigure = try $ do case B.toList <$> mbimg of Just [Image attr _ (url, tit)] -> return $ B.para $ B.imageWith attr url ("fig:" ++ tit) caption - Nothing -> mzero + _ -> mzero pCodeBlock :: PandocMonad m => TagParser m Blocks pCodeBlock = try $ do -- cgit v1.2.3 From 2637df2bdfdffe55dc7363feac188d9144f18fea Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Mon, 4 Sep 2017 18:11:55 -0700 Subject: Revert use of llvm backend in static linux build. It was failing for reasons I couldn't diagnose. --- linux/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/linux/Dockerfile b/linux/Dockerfile index a8dc9bfd2..c347d4ccc 100644 --- a/linux/Dockerfile +++ b/linux/Dockerfile @@ -5,7 +5,7 @@ ADD https://raw.githubusercontent.com/mitchty/alpine-ghc/master/mitch.tishmack%4 /etc/apk/keys/mitch.tishmack@gmail.com-55881c97.rsa.pub RUN apk update RUN apk add alpine-sdk git ca-certificates ghc cabal stack zlib-dev \ - dpkg fakeroot sed gawk grep llvm linux-headers + dpkg fakeroot sed gawk grep linux-headers RUN stack update RUN stack config set system-ghc --global true RUN mkdir -p /etc/stack @@ -23,7 +23,7 @@ CMD git pull && \ stack install --stack-yaml stack.pkg.yaml \ --flag 'pandoc:static' \ --flag 'pandoc:embed_data_files' \ - --ghc-options '-fPIC -fllvm' \ + --ghc-options '-O2 -optc-Os -fPIC' \ --local-bin-path /artifacts \ pandoc pandoc-citeproc && \ bash linux/make_deb.sh && \ -- cgit v1.2.3 From c09b586147d607f645a639a47c7781e8d8655e20 Mon Sep 17 00:00:00 2001 From: Alexander Date: Tue, 5 Sep 2017 07:22:40 +0300 Subject: Muse reader: parse
tag (#3888) --- src/Text/Pandoc/Readers/Muse.hs | 7 +++++++ test/Tests/Readers/Muse.hs | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/src/Text/Pandoc/Readers/Muse.hs b/src/Text/Pandoc/Readers/Muse.hs index a4512cdd7..1951a47af 100644 --- a/src/Text/Pandoc/Readers/Muse.hs +++ b/src/Text/Pandoc/Readers/Muse.hs @@ -179,6 +179,7 @@ blockElements = choice [ comment , centerTag , rightTag , quoteTag + , divTag , verseTag , lineBlock , bulletList @@ -245,6 +246,12 @@ rightTag = blockTag id "right" quoteTag :: PandocMonad m => MuseParser m (F Blocks) quoteTag = withQuoteContext InDoubleQuote $ blockTag B.blockQuote "quote" +--
tag is supported by Emacs Muse, but not Amusewiki 2.025 +divTag :: PandocMonad m => MuseParser m (F Blocks) +divTag = do + (attrs, content) <- parseHtmlContentWithAttrs "div" block + return $ (B.divWith attrs) <$> mconcat content + verseLine :: PandocMonad m => MuseParser m String verseLine = do line <- anyLine <|> many1Till anyChar eof diff --git a/test/Tests/Readers/Muse.hs b/test/Tests/Readers/Muse.hs index 4e5e5b606..714736c7f 100644 --- a/test/Tests/Readers/Muse.hs +++ b/test/Tests/Readers/Muse.hs @@ -145,6 +145,14 @@ tests = , " with a continuation" ] =?> blockQuote (para "This is a quotation with a continuation") + , testGroup "Div" + [ "Div without id" =: + "
Foo bar
" =?> + divWith nullAttr (para "Foo bar") + , "Div with id" =: + "
Foo bar
" =?> + divWith ("foo", [], []) (para "Foo bar") + ] , "Verse" =: T.unlines [ "> This is" , "> First stanza" -- cgit v1.2.3 From d02518bf1b8e831136626f5909b8e45fcbfb2ad1 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Mon, 4 Sep 2017 21:54:53 -0700 Subject: Make sure bash is available in linux package build environment. --- linux/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux/Dockerfile b/linux/Dockerfile index c347d4ccc..91df3b8a2 100644 --- a/linux/Dockerfile +++ b/linux/Dockerfile @@ -5,7 +5,7 @@ ADD https://raw.githubusercontent.com/mitchty/alpine-ghc/master/mitch.tishmack%4 /etc/apk/keys/mitch.tishmack@gmail.com-55881c97.rsa.pub RUN apk update RUN apk add alpine-sdk git ca-certificates ghc cabal stack zlib-dev \ - dpkg fakeroot sed gawk grep linux-headers + dpkg fakeroot sed gawk grep bash linux-headers RUN stack update RUN stack config set system-ghc --global true RUN mkdir -p /etc/stack -- cgit v1.2.3 From 9fdc089cd85e46148720f368644e8badd168f5b8 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Mon, 4 Sep 2017 21:56:06 -0700 Subject: Plain writer: don't use   to separate list and indented code. There's no need for it in this context, since this isn't to be interpreted using Markdown rules. --- src/Text/Pandoc/Writers/Markdown.hs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs index 523dfeaed..9d6064af6 100644 --- a/src/Text/Pandoc/Writers/Markdown.hs +++ b/src/Text/Pandoc/Writers/Markdown.hs @@ -787,6 +787,7 @@ blockListToMarkdown :: PandocMonad m -> MD m Doc blockListToMarkdown opts blocks = do inlist <- asks envInList + isPlain <- asks envPlain -- a) insert comment between list and indented code block, or the -- code block will be treated as a list continuation paragraph -- b) change Plain to Para unless it's followed by a RawBlock @@ -813,9 +814,11 @@ blockListToMarkdown opts blocks = do isListBlock (OrderedList _ _) = True isListBlock (DefinitionList _) = True isListBlock _ = False - commentSep = if isEnabled Ext_raw_html opts - then RawBlock "html" "\n" - else RawBlock "markdown" " \n" + commentSep = if isPlain + then Null + else if isEnabled Ext_raw_html opts + then RawBlock "html" "\n" + else RawBlock "markdown" " \n" mapM (blockToMarkdown opts) (fixBlocks blocks) >>= return . cat getKey :: Doc -> Key -- cgit v1.2.3 From 4170a184797ecacc5e9dc7462eb29c313598489f Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Tue, 5 Sep 2017 08:36:13 -0700 Subject: Another try to get linux static linking working again. --- linux/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/linux/Dockerfile b/linux/Dockerfile index 91df3b8a2..f75db2c89 100644 --- a/linux/Dockerfile +++ b/linux/Dockerfile @@ -16,14 +16,14 @@ RUN git clone https://github.com/jgm/pandoc WORKDIR /usr/src/pandoc RUN stack install --stack-yaml stack.pkg.yaml --only-dependencies \ --flag 'pandoc:embed_data_files' \ - --ghc-options '-fPIC -fllvm' \ + --ghc-options '-O2 -optc-Os -optl=-pthread -optl=-static -fPIC' \ pandoc pandoc-citeproc CMD git pull && \ git checkout -b work $TREE && \ stack install --stack-yaml stack.pkg.yaml \ --flag 'pandoc:static' \ --flag 'pandoc:embed_data_files' \ - --ghc-options '-O2 -optc-Os -fPIC' \ + --ghc-options '-O2 -optc-Os -optl=-pthread -optl=-static -fPIC' \ --local-bin-path /artifacts \ pandoc pandoc-citeproc && \ bash linux/make_deb.sh && \ -- cgit v1.2.3 From 350c282f205f48c6d0f7a96bf349b585a16fbcf4 Mon Sep 17 00:00:00 2001 From: Alexander Date: Tue, 5 Sep 2017 19:41:27 +0300 Subject: Muse reader: require at least one space char after * in header (#3895) --- src/Text/Pandoc/Readers/Muse.hs | 2 +- test/Tests/Readers/Muse.hs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Text/Pandoc/Readers/Muse.hs b/src/Text/Pandoc/Readers/Muse.hs index 1951a47af..63bdfcba7 100644 --- a/src/Text/Pandoc/Readers/Muse.hs +++ b/src/Text/Pandoc/Readers/Muse.hs @@ -213,7 +213,7 @@ header = try $ do getPosition >>= \pos -> guard (st == NullState && q == NoQuote && sourceColumn pos == 1) level <- liftM length $ many1 $ char '*' guard $ level <= 5 - skipSpaces + spaceChar content <- trimInlinesF . mconcat <$> manyTill inline newline attr <- registerHeader ("", [], []) (runF content defaultParserState) return $ B.headerWith attr level <$> content diff --git a/test/Tests/Readers/Muse.hs b/test/Tests/Readers/Muse.hs index 714736c7f..d9222b1dc 100644 --- a/test/Tests/Readers/Muse.hs +++ b/test/Tests/Readers/Muse.hs @@ -224,6 +224,7 @@ tests = , "Subsubsection" =: "***** Fifth level\n" =?> header 5 "Fifth level" + , "Whitespace is required after *" =: "**Not a header\n" =?> para "**Not a header" , "No headers in footnotes" =: T.unlines [ "Foo[1]" , "[1] * Bar" -- cgit v1.2.3 From 146a10780e05006f97cd4ba3a0dd02b903533db6 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Tue, 5 Sep 2017 09:55:42 -0700 Subject: LaTeX reader: support `\k` ogonek accent. --- src/Text/Pandoc/Readers/LaTeX.hs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index 06e112cef..7b7ac1c01 100644 --- a/src/Text/Pandoc/Readers/LaTeX.hs +++ b/src/Text/Pandoc/Readers/LaTeX.hs @@ -961,6 +961,10 @@ hacek 'Z' = "Ž" hacek 'z' = "ž" hacek c = [c] +ogonek :: Char -> String +ogonek 'a' = "ą" +ogonek c = [c] + breve :: Char -> String breve 'A' = "Ă" breve 'a' = "ă" @@ -1286,6 +1290,7 @@ inlineCommands = M.fromList $ , ("c", option (str "c") $ try $ tok >>= accent cedilla) , ("v", option (str "v") $ try $ tok >>= accent hacek) , ("u", option (str "u") $ try $ tok >>= accent breve) + , ("k", option (str "k") $ try $ tok >>= accent ogonek) , ("i", lit "i") , ("\\", linebreak <$ (do inTableCell <- sInTableCell <$> getState guard $ not inTableCell -- cgit v1.2.3 From d62c4a92470de3b0aa73ddb3fe921a1f9b154b41 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Tue, 5 Sep 2017 10:58:34 -0700 Subject: LaTeX reader: Improve handling of accents. Handle ogonek, and fall back correctly with forms like `\"{}`. --- src/Text/Pandoc/Readers/LaTeX.hs | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index 7b7ac1c01..b6b53e1fc 100644 --- a/src/Text/Pandoc/Readers/LaTeX.hs +++ b/src/Text/Pandoc/Readers/LaTeX.hs @@ -770,11 +770,13 @@ keyval = try $ do keyvals :: PandocMonad m => LP m [(String, String)] keyvals = try $ symbol '[' >> manyTill keyval (symbol ']') -accent :: (Char -> String) -> Inlines -> LP m Inlines -accent f ils = +accent :: PandocMonad m => Char -> (Char -> String) -> LP m Inlines +accent c f = try $ do + ils <- tok case toList ils of (Str (x:xs) : ys) -> return $ fromList (Str (f x ++ xs) : ys) - [] -> mzero + [Space] -> return $ str [c] + [] -> return $ str [c] _ -> return ils grave :: Char -> String @@ -1279,18 +1281,18 @@ inlineCommands = M.fromList $ , ("copyright", lit "©") , ("textasciicircum", lit "^") , ("textasciitilde", lit "~") - , ("H", try $ tok >>= accent hungarumlaut) - , ("`", option (str "`") $ try $ tok >>= accent grave) - , ("'", option (str "'") $ try $ tok >>= accent acute) - , ("^", option (str "^") $ try $ tok >>= accent circ) - , ("~", option (str "~") $ try $ tok >>= accent tilde) - , ("\"", option (str "\"") $ try $ tok >>= accent umlaut) - , (".", option (str ".") $ try $ tok >>= accent dot) - , ("=", option (str "=") $ try $ tok >>= accent macron) - , ("c", option (str "c") $ try $ tok >>= accent cedilla) - , ("v", option (str "v") $ try $ tok >>= accent hacek) - , ("u", option (str "u") $ try $ tok >>= accent breve) - , ("k", option (str "k") $ try $ tok >>= accent ogonek) + , ("H", accent '\779' hungarumlaut) + , ("`", accent '`' grave) + , ("'", accent '\'' acute) + , ("^", accent '^' circ) + , ("~", accent '~' tilde) + , ("\"", accent '\776' umlaut) + , (".", accent '\775' dot) + , ("=", accent '\772' macron) + , ("c", accent '\807' cedilla) + , ("v", accent 'ˇ' hacek) + , ("u", accent '\774' breve) + , ("k", accent '\808' ogonek) , ("i", lit "i") , ("\\", linebreak <$ (do inTableCell <- sInTableCell <$> getState guard $ not inTableCell -- cgit v1.2.3 From bc5624dac2da7674f42838db8672520e8949c9db Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Tue, 5 Sep 2017 13:46:44 -0700 Subject: Markdown writer: make Span with null attribute transparent. That is, we don't use brackets or `` tags to mark spans when there are no attributes; we simply output the contents. --- src/Text/Pandoc/Writers/Markdown.hs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs index 9d6064af6..3dbfe3f11 100644 --- a/src/Text/Pandoc/Writers/Markdown.hs +++ b/src/Text/Pandoc/Writers/Markdown.hs @@ -949,11 +949,10 @@ inlineToMarkdown opts (Span attrs ils) = do contents <- inlineListToMarkdown opts ils return $ case plain of True -> contents - False | isEnabled Ext_bracketed_spans opts -> + False | attrs == nullAttr -> contents + | isEnabled Ext_bracketed_spans opts -> "[" <> contents <> "]" <> - if attrs == nullAttr - then "{}" - else linkAttributes opts attrs + linkAttributes opts attrs | isEnabled Ext_raw_html opts || isEnabled Ext_native_spans opts -> tagWithAttrs "span" attrs <> contents <> text "" -- cgit v1.2.3 From 0b05222a9c915d2062e416d177d36af4b474e0c2 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Tue, 5 Sep 2017 13:54:44 -0700 Subject: LaTeX reader: Better support for ogonek accents. --- src/Text/Pandoc/Readers/LaTeX.hs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index b6b53e1fc..d0e95bd85 100644 --- a/src/Text/Pandoc/Readers/LaTeX.hs +++ b/src/Text/Pandoc/Readers/LaTeX.hs @@ -965,6 +965,15 @@ hacek c = [c] ogonek :: Char -> String ogonek 'a' = "ą" +ogonek 'e' = "ę" +ogonek 'o' = "ǫ" +ogonek 'i' = "į" +ogonek 'u' = "ų" +ogonek 'A' = "Ą" +ogonek 'E' = "Ę" +ogonek 'I' = "Į" +ogonek 'O' = "Ǫ" +ogonek 'U' = "Ų" ogonek c = [c] breve :: Char -> String @@ -1293,6 +1302,7 @@ inlineCommands = M.fromList $ , ("v", accent 'ˇ' hacek) , ("u", accent '\774' breve) , ("k", accent '\808' ogonek) + , ("textogonekcentered", accent '\808' ogonek) , ("i", lit "i") , ("\\", linebreak <$ (do inTableCell <- sInTableCell <$> getState guard $ not inTableCell -- cgit v1.2.3 From 743413a5b506351499fa2fb66d4184d74e125c54 Mon Sep 17 00:00:00 2001 From: Alexander Date: Wed, 6 Sep 2017 18:48:06 +0300 Subject: Muse reader: Allow finishing header with EOF (#3897) --- src/Text/Pandoc/Readers/Muse.hs | 14 +++++++++----- test/Tests/Readers/Muse.hs | 12 ++++++------ 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/Text/Pandoc/Readers/Muse.hs b/src/Text/Pandoc/Readers/Muse.hs index 63bdfcba7..2454057fa 100644 --- a/src/Text/Pandoc/Readers/Muse.hs +++ b/src/Text/Pandoc/Readers/Muse.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE FlexibleContexts #-} {- Copyright (C) 2017 Alexander Krotov @@ -100,6 +101,9 @@ parseBlocks = do -- utility functions -- +eol :: Stream s m Char => ParserT s st m () +eol = void newline <|> eof + nested :: PandocMonad m => MuseParser m a -> MuseParser m a nested p = do nestlevel <- stateMaxNestingLevel <$> getState @@ -195,7 +199,7 @@ comment = try $ do char ';' space many $ noneOf "\n" - void newline <|> eof + eol return mempty separator :: PandocMonad m => MuseParser m (F Blocks) @@ -203,7 +207,7 @@ separator = try $ do string "----" many $ char '-' many spaceChar - void newline <|> eof + eol return $ return B.horizontalRule header :: PandocMonad m => MuseParser m (F Blocks) @@ -214,7 +218,7 @@ header = try $ do level <- liftM length $ many1 $ char '*' guard $ level <= 5 spaceChar - content <- trimInlinesF . mconcat <$> manyTill inline newline + content <- trimInlinesF . mconcat <$> manyTill inline eol attr <- registerHeader ("", [], []) (runF content defaultParserState) return $ B.headerWith attr level <$> content @@ -464,10 +468,10 @@ museAppendElement tbl element = tableCell :: PandocMonad m => MuseParser m (F Blocks) tableCell = try $ liftM B.plain . trimInlinesF . mconcat <$> manyTill inline (lookAhead cellEnd) - where cellEnd = try $ void (many1 spaceChar >> char '|') <|> void newline <|> eof + where cellEnd = try $ void (many1 spaceChar >> char '|') <|> eol tableElements :: PandocMonad m => MuseParser m [MuseTableElement] -tableElements = tableParseElement `sepEndBy1` (void newline <|> eof) +tableElements = tableParseElement `sepEndBy1` eol elementsToTable :: [MuseTableElement] -> F MuseTable elementsToTable = foldM museAppendElement emptyTable diff --git a/test/Tests/Readers/Muse.hs b/test/Tests/Readers/Muse.hs index d9222b1dc..dac167a92 100644 --- a/test/Tests/Readers/Muse.hs +++ b/test/Tests/Readers/Muse.hs @@ -210,21 +210,21 @@ tests = ] , testGroup "Headers" [ "Part" =: - "* First level\n" =?> + "* First level" =?> header 1 "First level" , "Chapter" =: - "** Second level\n" =?> + "** Second level" =?> header 2 "Second level" , "Section" =: - "*** Third level\n" =?> + "*** Third level" =?> header 3 "Third level" , "Subsection" =: - "**** Fourth level\n" =?> + "**** Fourth level" =?> header 4 "Fourth level" , "Subsubsection" =: - "***** Fifth level\n" =?> + "***** Fifth level" =?> header 5 "Fifth level" - , "Whitespace is required after *" =: "**Not a header\n" =?> para "**Not a header" + , "Whitespace is required after *" =: "**Not a header" =?> para "**Not a header" , "No headers in footnotes" =: T.unlines [ "Foo[1]" , "[1] * Bar" -- cgit v1.2.3 From 19a06b0c831c08265194092bce27458a608f1a85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Haisman?= Date: Thu, 7 Sep 2017 00:28:37 +0200 Subject: Add simple Emacs mode to help with Pandoc templates editing. (#3889) tools/pandoc-template-mode.el --- tools/pandoc-template-mode.el | 58 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 tools/pandoc-template-mode.el diff --git a/tools/pandoc-template-mode.el b/tools/pandoc-template-mode.el new file mode 100644 index 000000000..7a6346458 --- /dev/null +++ b/tools/pandoc-template-mode.el @@ -0,0 +1,58 @@ + ;;; pandoc-template-mode.el --- Pandoc-Template major mode + +;; Copyright (C) 2017 + +;; Author: Václav Haisman +;; Keywords: extensions + +;; This file is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 2, or (at your option) +;; any later version. + +;; This file is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs; see the file COPYING. If not, write to +;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +;; Boston, MA 02111-1307, USA. + + ;;; Commentary: + +;; + + ;;; Code: + +(defvar pandoc-template-font-lock-keywords + '(("\\(\\$\\)\\(if\\|for\\)(\\([^)]+\\))\\(\\$\\)" + (1 font-lock-preprocessor-face) + (2 font-lock-keyword-face) + (3 font-lock-variable-name-face) + (4 font-lock-preprocessor-face)) + ("\\(\\$\\)\\(endif\\|endfor\\|else\\)\\(\\$\\)" + (1 font-lock-preprocessor-face) + (2 font-lock-keyword-face) + (3 font-lock-preprocessor-face)) + ("\\(\\$\\)\\(sep\\)\\(\\$\\)" + (1 font-lock-preprocessor-face) + (2 font-lock-builtin-face) + (3 font-lock-preprocessor-face)) + ("\\(\\$\\)\\([^$]+\\)\\(\\$\\)" + (1 font-lock-preprocessor-face) + (2 font-lock-variable-name-face) + (3 font-lock-preprocessor-face)) + ) + "Keyword highlighting specification for `pandoc-template-mode'.") + + ;;;###autoload +(define-derived-mode pandoc-template-mode fundamental-mode "Pandoc-Template" + "A major mode for editing Pandoc-Template files." + :syntax-table nil + (setq-local font-lock-defaults + '(pandoc-template-font-lock-keywords))) + +(provide 'pandoc-template-mode) + ;;; pandoc-template.el ends here -- cgit v1.2.3 From de93744179cbd3eb4113584786a5aa3021578d4a Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Thu, 7 Sep 2017 10:13:40 -0700 Subject: cabal: add custom-setup stanza, lowercase field names. --- pandoc.cabal | 189 ++++++++++++++++++++++++++++++----------------------------- 1 file changed, 96 insertions(+), 93 deletions(-) diff --git a/pandoc.cabal b/pandoc.cabal index 093c9196d..2f932e0a8 100644 --- a/pandoc.cabal +++ b/pandoc.cabal @@ -1,19 +1,19 @@ -Name: pandoc -Version: 2.0 -Cabal-Version: >= 1.10 -Build-Type: Custom -License: GPL -License-File: COPYING.md -Copyright: (c) 2006-2017 John MacFarlane -Author: John MacFarlane -Maintainer: John MacFarlane -Bug-Reports: https://github.com/jgm/pandoc/issues -Stability: alpha -Homepage: http://pandoc.org -Category: Text -Tested-With: GHC == 7.8.4, GHC == 7.10.3, GHC == 8.0.2 -Synopsis: Conversion between markup formats -Description: Pandoc is a Haskell library for converting from one markup +name: pandoc +version: 2.0 +cabal-version: >= 1.10 +build-type: Custom +license: GPL +license-file: COPYING.md +copyright: (c) 2006-2017 John MacFarlane +author: John MacFarlane +maintainer: John MacFarlane +bug-reports: https://github.com/jgm/pandoc/issues +stability: alpha +homepage: http://pandoc.org +category: Text +tested-with: GHC == 7.8.4, GHC == 7.10.3, GHC == 8.0.2 +synopsis: Conversion between markup formats +description: Pandoc is a Haskell library for converting from one markup format to another, and a command-line tool that uses this library. It can read several dialects of Markdown and (subsets of) HTML, reStructuredText, LaTeX, DocBook, @@ -35,7 +35,7 @@ Description: Pandoc is a Haskell library for converting from one markup which convert this native representation into a target format. Thus, adding an input or output format requires only adding a reader or writer. -Data-Files: +data-files: -- templates data/templates/default.html4 data/templates/default.html5 @@ -119,7 +119,7 @@ Data-Files: data/jats.csl -- documentation MANUAL.txt, COPYRIGHT -Extra-Source-Files: +extra-source-files: -- documentation INSTALL.md, BUGS, README.md, CONTRIBUTING.md, changelog man/pandoc.1 @@ -261,36 +261,39 @@ Extra-Source-Files: test/odt/markdown/*.md test/odt/native/*.native test/lua/*.lua -Source-repository head +source-repository head type: git location: git://github.com/jgm/pandoc.git -Flag static +flag static Description: Use static linking for pandoc executable. Default: False -Flag embed_data_files +flag embed_data_files Description: Embed data files in binary for relocatable executable. Default: False -Flag trypandoc +flag trypandoc Description: Build trypandoc cgi executable. Default: False -Flag weigh-pandoc +flag weigh-pandoc Description: Build weigh-pandoc to measure memory usage. Default: False -Flag network-uri +flag network-uri Description: Get Network.URI from the network-uri package Default: True -Flag old-locale +flag old-locale Description: Use old-locale and time < 1.5 Default: False -Library - Build-Depends: base >= 4.7 && < 5, +custom-setup + setup-depends: base, Cabal + +library + build-depends: base >= 4.7 && < 5, syb >= 0.1 && < 0.8, containers >= 0.4.2.1 && < 0.6, unordered-containers >= 0.2 && < 0.3, @@ -336,37 +339,37 @@ Library http-types >= 0.8 && < 0.10, csv-conduit >= 0.6 && < 0.7 if os(windows) - Cpp-options: -D_WINDOWS + cpp-options: -D_WINDOWS else - Build-Depends: unix >= 2.4 && < 2.8 + build-depends: unix >= 2.4 && < 2.8 if flag(old-locale) - Build-Depends: old-locale >= 1 && < 1.1, + build-depends: old-locale >= 1 && < 1.1, time >= 1.2 && < 1.5 else - Build-Depends: time >= 1.5 && < 1.9 + build-depends: time >= 1.5 && < 1.9 if flag(network-uri) - Build-Depends: network-uri >= 2.6 && < 2.7, network >= 2.6 + build-depends: network-uri >= 2.6 && < 2.7, network >= 2.6 else - Build-Depends: network >= 2 && < 2.6 + build-depends: network >= 2 && < 2.6 if flag(embed_data_files) cpp-options: -DEMBED_DATA_FILES build-depends: file-embed >= 0.0 && < 0.1 other-modules: Text.Pandoc.Data if os(windows) - Cpp-options: -D_WINDOWS - Ghc-Options: -Wall -fno-warn-unused-do-bind - Ghc-Prof-Options: -fprof-auto-exported - Default-Language: Haskell98 - Other-Extensions: PatternGuards, OverloadedStrings, + cpp-options: -D_WINDOWS + ghc-options: -Wall -fno-warn-unused-do-bind + ghc-prof-options: -fprof-auto-exported + default-language: Haskell98 + other-extensions: PatternGuards, OverloadedStrings, ScopedTypeVariables, GeneralizedNewtypeDeriving, RelaxedPolyRec, DeriveDataTypeable, TypeSynonymInstances, FlexibleInstances - Hs-Source-Dirs: src + hs-source-dirs: src if impl(ghc < 7.10) - Hs-Source-Dirs: prelude - Other-Modules: Prelude + hs-source-dirs: prelude + other-modules: Prelude - Exposed-Modules: Text.Pandoc, + exposed-modules: Text.Pandoc, Text.Pandoc.App, Text.Pandoc.Options, Text.Pandoc.Extensions, @@ -444,7 +447,7 @@ Library Text.Pandoc.Emoji, Text.Pandoc.ImageSize, Text.Pandoc.Class - Other-Modules: Text.Pandoc.Readers.Docx.Lists, + other-modules: Text.Pandoc.Readers.Docx.Lists, Text.Pandoc.Readers.Docx.Combine, Text.Pandoc.Readers.Docx.Parse, Text.Pandoc.Readers.Docx.Util, @@ -481,67 +484,67 @@ Library Text.Pandoc.Compat.Time, Paths_pandoc - Buildable: True + buildable: True -Executable pandoc - Build-Depends: pandoc, base >= 4.7 && < 5 - Ghc-Options: -rtsopts -with-rtsopts=-K16m -Wall -fno-warn-unused-do-bind - Ghc-Prof-Options: -fprof-auto-exported -rtsopts -with-rtsopts=-K16m +executable pandoc + build-depends: pandoc, base >= 4.7 && < 5 + ghc-options: -rtsopts -with-rtsopts=-K16m -Wall -fno-warn-unused-do-bind + ghc-prof-options: -fprof-auto-exported -rtsopts -with-rtsopts=-K16m if flag(static) - Ld-options: -static - Default-Language: Haskell98 - Other-Extensions: PatternGuards, OverloadedStrings, + ld-options: -static + default-language: Haskell98 + other-extensions: PatternGuards, OverloadedStrings, ScopedTypeVariables, GeneralizedNewtypeDeriving, RelaxedPolyRec, DeriveDataTypeable, TypeSynonymInstances, FlexibleInstances - Hs-Source-Dirs: . + hs-source-dirs: . if impl(ghc < 7.10) - Hs-Source-Dirs: prelude - Other-Modules: Prelude - Main-Is: pandoc.hs - Buildable: True - Other-Modules: Paths_pandoc + hs-source-dirs: prelude + other-modules: Prelude + main-is: pandoc.hs + buildable: True + other-modules: Paths_pandoc -Executable trypandoc - Main-Is: trypandoc.hs - Hs-Source-Dirs: trypandoc +executable trypandoc + main-is: trypandoc.hs + hs-source-dirs: trypandoc if impl(ghc < 7.10) - Hs-Source-Dirs: prelude - Other-Modules: Prelude + hs-source-dirs: prelude + other-modules: Prelude default-language: Haskell2010 if flag(trypandoc) - Build-Depends: base, aeson, pandoc, + build-depends: base, aeson, pandoc, text, wai-extra, wai >= 0.3, http-types - Buildable: True + buildable: True else - Buildable: False + buildable: False -Executable weigh-pandoc - Main-Is: weigh-pandoc.hs - Hs-Source-Dirs: benchmark +executable weigh-pandoc + main-is: weigh-pandoc.hs + hs-source-dirs: benchmark if impl(ghc < 7.10) - Hs-Source-Dirs: prelude - Other-Modules: Prelude + hs-source-dirs: prelude + other-modules: Prelude if flag(weigh-pandoc) - Build-Depends: pandoc, + build-depends: pandoc, base >= 4.2 && < 5, text, weigh >= 0.0 && < 0.1, mtl >= 2.2 && < 2.3 - Buildable: True + buildable: True else - Buildable: False - Ghc-Options: -rtsopts -Wall -fno-warn-unused-do-bind - Default-Language: Haskell98 + buildable: False + ghc-options: -rtsopts -Wall -fno-warn-unused-do-bind + default-language: Haskell98 -Test-Suite test-pandoc - Type: exitcode-stdio-1.0 - Main-Is: test-pandoc.hs - Hs-Source-Dirs: test +test-suite test-pandoc + type: exitcode-stdio-1.0 + main-is: test-pandoc.hs + hs-source-dirs: test if impl(ghc < 7.10) - Hs-Source-Dirs: prelude - Other-Modules: Prelude - Build-Depends: base >= 4.2 && < 5, + hs-source-dirs: prelude + other-modules: Prelude + build-depends: base >= 4.2 && < 5, syb >= 0.1 && < 0.8, pandoc, pandoc-types >= 1.17.1 && < 1.18, @@ -563,7 +566,7 @@ Test-Suite test-pandoc executable-path >= 0.0 && < 0.1, zip-archive >= 0.2.3.4 && < 0.4, mtl >= 2.2 && < 2.3 - Other-Modules: Tests.Old + other-modules: Tests.Old Tests.Command Tests.Helpers Tests.Lua @@ -591,21 +594,21 @@ Test-Suite test-pandoc Tests.Writers.RST Tests.Writers.TEI Tests.Writers.Muse - Ghc-Options: -rtsopts -Wall -fno-warn-unused-do-bind -threaded - Default-Language: Haskell98 + ghc-options: -rtsopts -Wall -fno-warn-unused-do-bind -threaded + default-language: Haskell98 benchmark benchmark-pandoc - Type: exitcode-stdio-1.0 - Main-Is: benchmark-pandoc.hs - Hs-Source-Dirs: benchmark + type: exitcode-stdio-1.0 + main-is: benchmark-pandoc.hs + hs-source-dirs: benchmark if impl(ghc < 7.10) - Hs-Source-Dirs: prelude - Other-Modules: Prelude - Build-Depends: pandoc, + hs-source-dirs: prelude + other-modules: Prelude + build-depends: pandoc, time, bytestring, containers, base >= 4.2 && < 5, text >= 0.11 && < 1.3, syb >= 0.1 && < 0.8, criterion >= 1.0 && < 1.3 - Ghc-Options: -rtsopts -Wall -fno-warn-unused-do-bind - Default-Language: Haskell98 + ghc-options: -rtsopts -Wall -fno-warn-unused-do-bind + default-language: Haskell98 -- cgit v1.2.3 From a90f131937460f21005a997e0a1f10b930b203b2 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Thu, 7 Sep 2017 22:05:22 -0700 Subject: LaTeX writer: use proper code for list enumerators. This should fix problems with lists that don't use arabic numerals. Closes #3891. --- src/Text/Pandoc/Writers/LaTeX.hs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index 4a81cd245..2da087077 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -628,6 +628,7 @@ blockToLaTeX (OrderedList (start, numstyle, numdelim) lst) = do put $ st {stOLLevel = oldlevel + 1} items <- mapM listItemToLaTeX lst modify (\s -> s {stOLLevel = oldlevel}) + let beamer = stBeamer st let tostyle x = case numstyle of Decimal -> "\\arabic" <> braces x UpperRoman -> "\\Roman" <> braces x @@ -641,11 +642,21 @@ blockToLaTeX (OrderedList (start, numstyle, numdelim) lst) = do TwoParens -> parens x Period -> x <> "." _ -> x <> "." + let exemplar = case numstyle of + Decimal -> "1" + UpperRoman -> "I" + LowerRoman -> "i" + UpperAlpha -> "A" + LowerAlpha -> "a" + Example -> "1" + DefaultStyle -> "1" let enum = text $ "enum" ++ map toLower (toRomanNumeral oldlevel) let stylecommand = if numstyle == DefaultStyle && numdelim == DefaultDelim then empty - else "\\def" <> "\\label" <> enum <> - braces (todelim $ tostyle enum) + else if beamer + then brackets (todelim exemplar) + else "\\def" <> "\\label" <> enum <> + braces (todelim $ tostyle enum) let resetcounter = if start == 1 || oldlevel > 4 then empty else "\\setcounter" <> braces enum <> -- cgit v1.2.3 From 5fc4980216bf0a6b425827417655991859cba5ec Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Thu, 7 Sep 2017 22:10:13 -0700 Subject: Markdown writer: Escape pipe characters when `pipe_tables` enabled. Closes #3887. --- src/Text/Pandoc/Writers/Markdown.hs | 1 + test/command/3497.md | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs index 3dbfe3f11..0221ba6ef 100644 --- a/src/Text/Pandoc/Writers/Markdown.hs +++ b/src/Text/Pandoc/Writers/Markdown.hs @@ -288,6 +288,7 @@ escapeString opts (c:cs) = | otherwise -> ">" ++ escapeString opts cs _ | c `elem` ['\\','`','*','_','[',']','#'] -> '\\':c:escapeString opts cs + '|' | isEnabled Ext_pipe_tables opts -> '\\':'|':escapeString opts cs '^' | isEnabled Ext_superscript opts -> '\\':'^':escapeString opts cs '~' | isEnabled Ext_subscript opts -> '\\':'~':escapeString opts cs '$' | isEnabled Ext_tex_math_dollars opts -> '\\':'$':escapeString opts cs diff --git a/test/command/3497.md b/test/command/3497.md index 326817b0d..ca591cdd6 100644 --- a/test/command/3497.md +++ b/test/command/3497.md @@ -46,6 +46,6 @@ Also escape things that might become line blocks or tables: % pandoc -t markdown \| hi \| ^D -\| hi | +\| hi \| ``` -- cgit v1.2.3 From 732005456e2b28150943a5a4e11bca6e1566f309 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Thu, 7 Sep 2017 22:16:23 -0700 Subject: LaTeX template: load polyglossia after header-includes. It needs to be loaded as late as possible. Closes #3898. --- data/templates/default.latex | 18 +++++++++--------- test/writers-lang-and-dir.latex | 12 ++++++------ 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/data/templates/default.latex b/data/templates/default.latex index 357549d98..d100fd4d7 100644 --- a/data/templates/default.latex +++ b/data/templates/default.latex @@ -192,6 +192,15 @@ $else$ \renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}} \fi $endif$ + +% set default figure placement to htbp +\makeatletter +\def\fps@figure{htbp} +\makeatother + +$for(header-includes)$ +$header-includes$ +$endfor$ $if(lang)$ \ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex \usepackage[shorthands=off,$for(babel-otherlangs)$$babel-otherlangs$,$endfor$main=$babel-lang$]{babel} @@ -225,15 +234,6 @@ $if(dir)$ \fi $endif$ -% set default figure placement to htbp -\makeatletter -\def\fps@figure{htbp} -\makeatother - -$for(header-includes)$ -$header-includes$ -$endfor$ - $if(title)$ \title{$title$$if(thanks)$\thanks{$thanks$}$endif$} $endif$ diff --git a/test/writers-lang-and-dir.latex b/test/writers-lang-and-dir.latex index b8481c879..ae29cd1bb 100644 --- a/test/writers-lang-and-dir.latex +++ b/test/writers-lang-and-dir.latex @@ -44,6 +44,12 @@ \let\oldsubparagraph\subparagraph \renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}} \fi + +% set default figure placement to htbp +\makeatletter +\def\fps@figure{htbp} +\makeatother + \ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex \usepackage[shorthands=off,ngerman,british,nswissgerman,spanish,french,main=english]{babel} \newcommand{\textgerman}[2][]{\foreignlanguage{ngerman}{#2}} @@ -77,12 +83,6 @@ \newenvironment{LTR}{\beginL}{\endL} \fi -% set default figure placement to htbp -\makeatletter -\def\fps@figure{htbp} -\makeatother - - \date{} \begin{document} -- cgit v1.2.3