pandoc 0.4 → 0.41
raw patch · 21 files changed
+145/−47 lines, 21 files
Files
- INSTALL +9/−0
- debian/changelog +35/−1
- pandoc.cabal +1/−1
- src/Main.hs +1/−1
- src/Text/Pandoc/Readers/HTML.hs +20/−7
- src/Text/Pandoc/Readers/LaTeX.hs +2/−1
- src/Text/Pandoc/Readers/Markdown.hs +7/−18
- src/Text/Pandoc/Readers/RST.hs +6/−14
- src/Text/Pandoc/Writers/Markdown.hs +4/−4
- tests/testsuite.native +2/−0
- tests/testsuite.txt +4/−0
- tests/writer.context +4/−0
- tests/writer.docbook +6/−0
- tests/writer.html +4/−0
- tests/writer.latex +4/−0
- tests/writer.man +4/−0
- tests/writer.markdown +4/−0
- tests/writer.native +2/−0
- tests/writer.rst +4/−0
- tests/writer.rtf +2/−0
- web/highlight.css +20/−0
INSTALL view
@@ -40,6 +40,15 @@ make test + Note: if you see errors like the following, they're due to differences+ between different versions of the xhtml library, and can safely be+ disregarded:++ 2c2+ < <html xmlns="http://www.w3.org/1999/xhtml"+ ---+ > <html+ 4. Install: sudo make install
debian/changelog view
@@ -1,3 +1,38 @@+pandoc (0.41) unstable; urgency=low++ [ John MacFarlane ]++ * Fixed bugs in HTML reader:+ + Skip material at end *only if* </html> is present (previously,+ only part of the document would be parsed if an error was+ found; now a proper error message is given).+ + Added new constant eitherBlockOrInline with elements that may+ count either as block-level or as inline. Modified isInline and+ isBlock to take this into account.+ + Modified rawHtmlBlock to accept any tag (even an inline tag):+ this is innocuous, because rawHtmlBlock is tried only if a regular+ inline element can't be parsed.+ + Added a necessary 'try' in definition of 'para'.++ * Fixed bug in markdown ordered list parsing. The problem was that+ anyOrderedListStart did not check for a space following the+ ordered list marker. So in 'A.B. 2007' the parser would be+ expecting a list item, but would not find one, causing an error.+ Fixed a similar bug in the RST reader. Resolves Issue #22.++ * Refactored RST and Markdown readers using parseFromString.++ * LaTeX reader will now skip anything after \end{document}.++ * Fixed blockquote output in markdown writer: previously, block+ quotes in indented contexts would be indented only in the first+ line.++ * Added note to INSTALL about variations in versions of the xhtml+ library that can lead to failed tests (thanks to Leif LeBaron).++ -- John MacFarlane <jgm@berkeley.edu> Sun, 19 Aug 2007 00:00:00 -0400+ pandoc (0.4) unstable; urgency=low [ John MacFarlane ]@@ -404,7 +439,6 @@ libghc6-xhtml-dev. Removed libghc6-html-dev. + Suggest texlive-latex-recommended | tetex-extra instead of tetex-bin. This brings in fancyvrb and unicode support.- -- Recai Oktaş <roktas@debian.org> Tue, 16 Jan 2007 00:37:21 +0200
pandoc.cabal view
@@ -1,5 +1,5 @@ Name: pandoc-Version: 0.4+Version: 0.41 License: GPL License-File: COPYING Copyright: (c) 2006-2007 John MacFarlane
src/Main.hs view
@@ -43,7 +43,7 @@ import Control.Monad ( (>>=) ) version :: String-version = "0.4"+version = "0.41" copyrightMessage :: String copyrightMessage = "\nCopyright (C) 2006-7 John MacFarlane\n\
src/Text/Pandoc/Readers/HTML.hs view
@@ -59,12 +59,22 @@ -- Constants -- +eitherBlockOrInline = ["applet", "button", "del", "iframe", "ins",+ "map", "area", "object", "script"]+ inlineHtmlTags = ["a", "abbr", "acronym", "b", "basefont", "bdo", "big", "br", "cite", "code", "dfn", "em", "font", "i", "img", "input", "kbd", "label", "q", "s", "samp", "select", "small", "span", "strike", "strong", "sub", "sup",- "textarea", "tt", "u", "var"]+ "textarea", "tt", "u", "var"] ++ eitherBlockOrInline +blockHtmlTags = ["address", "blockquote", "center", "dir", "div",+ "dl", "fieldset", "form", "h1", "h2", "h3", "h4",+ "h5", "h6", "hr", "isindex", "menu", "noframes",+ "noscript", "ol", "p", "pre", "table", "ul", "dd",+ "dt", "frameset", "li", "tbody", "td", "tfoot",+ "th", "thead", "tr"] ++ eitherBlockOrInline+ -- -- HTML utility functions --@@ -171,12 +181,15 @@ char '>' return $ "</" ++ tag ++ ">" --- | Returns @True@ if the tag is an inline tag.+-- | Returns @True@ if the tag is (or can be) an inline tag. isInline tag = (extractTagType tag) `elem` inlineHtmlTags +-- | Returns @True@ if the tag is (or can be) a block tag.+isBlock tag = (extractTagType tag) `elem` blockHtmlTags + anyHtmlBlockTag = try $ do tag <- anyHtmlTag <|> anyHtmlEndTag- if isInline tag then fail "inline tag" else return tag+ if isBlock tag then return tag else fail "inline tag" anyHtmlInlineTag = try $ do tag <- anyHtmlTag <|> anyHtmlEndTag@@ -193,7 +206,7 @@ rawHtmlBlock = try $ do notFollowedBy' (htmlTag "/body" <|> htmlTag "/html")- body <- htmlBlockElement <|> anyHtmlBlockTag+ body <- htmlBlockElement <|> anyHtmlTag <|> anyHtmlEndTag sp <- many space state <- getState if stateParseRaw state then return (RawHtml (body ++ sp)) else return Null@@ -260,8 +273,7 @@ spaces optional (htmlEndTag "body") spaces- optional (htmlEndTag "html")- many anyChar -- ignore anything after </html>+ optional (htmlEndTag "html" >> many anyChar) -- ignore anything after </html> eof return $ Pandoc (Meta title authors date) blocks @@ -383,7 +395,8 @@ -- paragraph block -- -para = htmlTag "p" >> inlinesTilEnd "p" >>= return . Para . normalizeSpaces+para = try $ htmlTag "p" >> inlinesTilEnd "p" >>= + return . Para . normalizeSpaces -- -- plain block
src/Text/Pandoc/Readers/LaTeX.hs view
@@ -117,7 +117,8 @@ spaces blocks <- parseBlocks spaces- optional $ try (string "\\end{document}") -- might not be present (fragment)+ optional $ try (string "\\end{document}" >> many anyChar) + -- might not be present (fragment) spaces eof state <- getState
src/Text/Pandoc/Readers/Markdown.hs view
@@ -195,10 +195,7 @@ raw <- sepBy rawLines (try (blankline >> indentSpaces)) optional blanklines -- parse the extracted text, which may contain various block elements:- rest <- getInput- setInput $ (joinWithSep "\n" raw) ++ "\n\n"- contents <- parseBlocks- setInput rest+ contents <- parseFromString parseBlocks $ (joinWithSep "\n" raw) ++ "\n\n" return $ NoteBlock ref contents --@@ -307,10 +304,7 @@ blockQuote = do raw <- emailBlockQuote <|> emacsBoxQuote -- parse the extracted block, which may contain various block elements:- rest <- getInput- setInput $ (joinWithSep "\n" raw) ++ "\n\n"- contents <- parseBlocks- setInput rest+ contents <- parseFromString parseBlocks $ (joinWithSep "\n" raw) ++ "\n\n" return $ BlockQuote contents --@@ -334,8 +328,9 @@ if stateStrict state then do many1 digit char '.'+ spaceChar return (1, DefaultStyle, DefaultDelim)- else anyOrderedListMarker+ else anyOrderedListMarker >>~ spaceChar orderedListStart style delim = try $ do optional newline -- if preceded by a Plain block in a list context@@ -346,7 +341,7 @@ char '.' return 1 else orderedListMarker style delim - oneOf spaceChars+ spaceChar skipSpaces -- parse a line of a list item (start = parser for beginning of list item)@@ -392,11 +387,8 @@ let oldContext = stateParserContext state setState $ state {stateParserContext = ListItemState} -- parse the extracted block, which may contain various block elements:- rest <- getInput let raw = concat (first:continuations)- setInput raw- contents <- parseBlocks- setInput rest+ contents <- parseFromString parseBlocks raw updateState (\st -> st {stateParserContext = oldContext}) return contents @@ -418,10 +410,7 @@ state <- getState let oldContext = stateParserContext state -- parse the extracted block, which may contain various block elements:- rest <- getInput- setInput (concat raw)- contents <- parseBlocks- setInput rest+ contents <- parseFromString parseBlocks $ concat raw updateState (\st -> st {stateParserContext = oldContext}) return ((normalizeSpaces term), contents)
src/Text/Pandoc/Readers/RST.hs view
@@ -328,10 +328,7 @@ blockQuote = try $ do raw <- indentedBlock True -- parse the extracted block, which may contain various block elements:- rest <- getInput- setInput $ raw ++ "\n\n"- contents <- parseBlocks- setInput rest+ contents <- parseFromString parseBlocks $ raw ++ "\n\n" return $ BlockQuote contents --@@ -344,10 +341,7 @@ term <- many1Till inline endline raw <- indentedBlock True -- parse the extracted block, which may contain various block elements:- rest <- getInput- setInput $ raw ++ "\n\n"- contents <- parseBlocks- setInput rest+ contents <- parseFromString parseBlocks $ raw ++ "\n\n" return (normalizeSpaces term, contents) definitionList = try $ do@@ -408,17 +402,14 @@ -- see definition of "endline" state <- getState let oldContext = stateParserContext state- remaining <- getInput setState $ state {stateParserContext = ListItemState} -- parse the extracted block, which may itself contain block elements- setInput $ concat (first:rest) ++ blanks- parsed <- parseBlocks- setInput remaining + parsed <- parseFromString parseBlocks $ concat (first:rest) ++ blanks updateState (\st -> st {stateParserContext = oldContext}) return parsed orderedList = try $ do- (start, style, delim) <- lookAhead anyOrderedListMarker + (start, style, delim) <- lookAhead (anyOrderedListMarker >>~ spaceChar) items <- many1 (listItem (orderedListStart style delim)) let items' = compactify items return $ OrderedList (start, style, delim) items'@@ -551,7 +542,8 @@ -- parse potential list-starts at beginning of line differently in a list: st <- getState if ((stateParserContext st) == ListItemState)- then notFollowedBy' anyOrderedListMarker >> notFollowedBy' bulletListStart+ then notFollowedBy (anyOrderedListMarker >> spaceChar) >>+ notFollowedBy' bulletListStart else return () return Space
src/Text/Pandoc/Writers/Markdown.hs view
@@ -91,8 +91,8 @@ -- | Return markdown representation of a note. noteToMarkdown :: WriterOptions -> Int -> [Block] -> State WriterState Doc-noteToMarkdown opts num note = do- contents <- blockListToMarkdown opts note+noteToMarkdown opts num blocks = do+ contents <- blockListToMarkdown opts blocks let marker = text "[^" <> text (show num) <> text "]:" return $ hang marker (writerTabStop opts) contents @@ -163,8 +163,8 @@ (nest (writerTabStop opts) $ vcat $ map text (lines str)) <> text "\n" blockToMarkdown opts (BlockQuote blocks) = do contents <- blockListToMarkdown opts blocks- let quotedContents = unlines $ map ("> " ++) $ lines $ render contents- return $ text quotedContents + return $ (vcat $ map (text . ("> " ++)) $ lines $ render contents) <> + text "\n" blockToMarkdown opts (Table caption aligns widths headers rows) = do caption' <- inlineListToMarkdown opts caption let caption'' = if null caption
tests/testsuite.native view
@@ -178,6 +178,8 @@ , OrderedList (1,DefaultStyle,DefaultDelim) [ [ Plain [Str "Nested",Str "."] ] ] ] ]+, Para [Str "Should",Space,Str "not",Space,Str "be",Space,Str "a",Space,Str "list",Space,Str "item:"]+, Para [Str "M",Str ".",Str "A",Str ".",Space,Str "2007"] , HorizontalRule , Header 1 [Str "Definition",Space,Str "Lists"] , Para [Str "Tight",Space,Str "using",Space,Str "spaces:"]
tests/testsuite.txt view
@@ -281,6 +281,10 @@ #. More. #. Nested. +Should not be a list item:++M.A. 2007+ * * * * * # Definition Lists
tests/writer.context view
@@ -399,6 +399,10 @@ \item Nested. \stopltxenum \stopltxenum+Should not be a list item:++M.A. 2007+ \thinrule \section{Definition Lists}
tests/writer.docbook view
@@ -642,6 +642,12 @@ </orderedlist> </listitem> </orderedlist>+ <para>+ Should not be a list item:+ </para>+ <para>+ M.A. 2007+ </para> </section> </section> <section>
tests/writer.html view
@@ -449,6 +449,10 @@ ></ol ></li ></ol+ ><p+ >Should not be a list item:</p+ ><p+ >M.A. 2007</p ><hr /><h1 id="definition-lists" >Definition Lists</h1
tests/writer.latex view
@@ -345,6 +345,10 @@ \item Nested. \end{enumerate} \end{enumerate}+Should not be a list item:++M.A. 2007+ \begin{center}\rule{3in}{0.4pt}\end{center} \section{Definition Lists}
tests/writer.man view
@@ -322,6 +322,10 @@ Nested\. .RE .PP+Should not be a list item:+.PP+M\.A\. 2007+.PP * * * * * .SH Definition Lists .PP
tests/writer.markdown view
@@ -284,6 +284,10 @@ 1. Nested. +Should not be a list item:++M.A. 2007+ * * * * *
tests/writer.native view
@@ -178,6 +178,8 @@ , OrderedList (1,DefaultStyle,DefaultDelim) [ [ Plain [Str "Nested",Str "."] ] ] ] ]+, Para [Str "Should",Space,Str "not",Space,Str "be",Space,Str "a",Space,Str "list",Space,Str "item:"]+, Para [Str "M",Str ".",Str "A",Str ".",Space,Str "2007"] , HorizontalRule , Header 1 [Str "Definition",Space,Str "Lists"] , Para [Str "Tight",Space,Str "using",Space,Str "spaces:"]
tests/writer.rst view
@@ -348,6 +348,10 @@ #. Nested. +Should not be a list item:++M.A. 2007+ -------------- Definition Lists
tests/writer.rtf view
@@ -157,6 +157,8 @@ {\pard \ql \f0 \sa0 \li360 \fi-360 1.\tx360\tab Autonumber.\par} {\pard \ql \f0 \sa0 \li360 \fi-360 2.\tx360\tab More.\par} {\pard \ql \f0 \sa0 \li720 \fi-360 a.\tx360\tab Nested.\sa180\sa180\par}+{\pard \ql \f0 \sa180 \li0 \fi0 Should not be a list item:\par}+{\pard \ql \f0 \sa180 \li0 \fi0 M.A. 2007\par} {\pard \qc \f0 \sa180 \li0 \fi0 \emdash\emdash\emdash\emdash\emdash\par} {\pard \ql \f0 \sa180 \li0 \fi0 \b \fs36 Definition Lists\par} {\pard \ql \f0 \sa180 \li0 \fi0 Tight using spaces:\par}
+ web/highlight.css view
@@ -0,0 +1,20 @@+/* Style definition file generated by highlight 2.4.8, http://www.andre-simon.de/ */++/* Highlighting theme definition: */++body.hl { background-color:#ffffff; }+pre.hl { color:#000000; background-color:#ffffff; font-size:10pt; font-family: monospace;}+.num { color:#000000; }+.esc { color:#bd8d8b; }+.str { color:#bd8d8b; }+.dstr { color:#bd8d8b; }+.slc { color:#ac2020; font-style:italic; }+.com { color:#ac2020; font-style:italic; }+.dir { color:#000000; }+.sym { color:#000000; }+.line { color:#555555; }+.kwa { color:#9c20ee; font-weight:bold; }+.kwb { color:#208920; }+.kwc { color:#0000ff; }+.kwd { color:#000000; }+