aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers
AgeCommit message (Collapse)AuthorFilesLines
2007-08-28Performance improvements:fiddlosopher1-13/+11
+ Rearranged parsers in definition of 'inline' so that the most frequently used would (by and large) be tried first. + Removed some unneeded 'try's. + Removed tabchar parser, as whitespace handles tabs anyway. + All in all, these changes, together with the last two commits, cut almost in half the time it takes pandoc to parse a large test file. git-svn-id: https://pandoc.googlecode.com/svn/trunk@924 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-08-26Don't countfiddlosopher1-0/+1
p. 27 at the beginning of a line as an ordered list start, since it's most likely a page number. git-svn-id: https://pandoc.googlecode.com/svn/trunk@900 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-08-23Added new rule for enhanced markdown ordered lists: if the list markerfiddlosopher1-6/+9
is a capital letter followed by a period (including a single-letter capital roman numeral), then it must be followed by at least two spaces. The point of this is to avoid accidentally treating people's initials as list markers: a paragraph may begin: B. Russell was an English philosopher. and this shouldn't be treated as a list. Modified Markdown reader and README documentation. Added a test case. git-svn-id: https://pandoc.googlecode.com/svn/trunk@880 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-08-22Added a needed 'try' to listItem in Markdown reader.fiddlosopher1-1/+1
git-svn-id: https://pandoc.googlecode.com/svn/trunk@878 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-08-20Code cleanup in Markdown reader.fiddlosopher1-27/+18
git-svn-id: https://pandoc.googlecode.com/svn/trunk@877 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-08-20Changes to Markdown reader for better conformity to thefiddlosopher1-6/+12
Markdown test suite under --strict: + Removed check for a following setext header in endline. A full test is too inefficient (doubles benchmark time), and the substitute we had before is not 100% accurate. + Don't use Code elements for autolinks if --strict specified. git-svn-id: https://pandoc.googlecode.com/svn/trunk@876 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-08-19Refactor RST and Markdown readers using parseFromString.fiddlosopher2-28/+7
git-svn-id: https://pandoc.googlecode.com/svn/trunk@864 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-08-19Added a necessary "try" in definition of "para"fiddlosopher1-1/+2
(HTML reader). git-svn-id: https://pandoc.googlecode.com/svn/trunk@863 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-08-18Bug fixes in readers:fiddlosopher2-7/+20
+ LaTeX reader: skip anything after \end{document} + HTML reader: fixed bug skipping material after </html> -- previously, stuff at the end was skipped even if no </html> was present, which meant only part of the file would be parsed and no error issued + HTML reader: added new constant eitherBlockOrInline with elements that may count either as block-level or 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. git-svn-id: https://pandoc.googlecode.com/svn/trunk@862 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-08-18+ Fixed bug in markdown ordered list parsing. The problem wasfiddlosopher2-4/+6
that anyOrderedListStart did not check for a space following the ordered list marker. So, 'A.B. 2007' would be parsed as a list item, then fail because of the lack of space after 'A.' (required by orderedListStart). Resolves Issue #22. + Fixed a similar problem in RST reader. + Added regression test. git-svn-id: https://pandoc.googlecode.com/svn/trunk@861 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-08-15Cosmetic changes.fiddlosopher1-4/+3
git-svn-id: https://pandoc.googlecode.com/svn/trunk@851 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-08-15LaTeX reader: parse \texttt{} as code, as long as there'sfiddlosopher1-2/+9
nothing fancy inside. git-svn-id: https://pandoc.googlecode.com/svn/trunk@846 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-08-15Allow htmlComments as rawHtmlInline in HTML reader.fiddlosopher1-2/+3
git-svn-id: https://pandoc.googlecode.com/svn/trunk@844 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-08-15Major code cleanup in all modules. (Removed unneeded imports,fiddlosopher4-1070/+811
reformatted, etc.) More major changes are documented below: + Removed Text.Pandoc.ParserCombinators and moved all its definitions to Text.Pandoc.Shared. + In Text.Pandoc.Shared: - Removed unneeded 'try' in blanklines. - Removed endsWith function and rewrote functions to use isSuffixOf instead. - Added >>~ combinator. - Rewrote stripTrailingNewlines, removeLeadingSpaces. + Moved Text.Pandoc.Entities -> Text.Pandoc.CharacterReferences. - Removed unneeded functions charToEntity, charToNumericalEntity. - Renamed functions using proper terminology (character references, not entities). decodeEntities -> decodeCharacterReferences, characterEntity -> characterReference. - Moved escapeStringToXML to Docbook writer, which is the only thing that uses it. - Removed old entity parser in HTML and Markdown readers; replaced with new charRef parser in Text.Pandoc.Shared. + Fixed accent bug in Text.Pandoc.Readers.LaTeX: \^{} now correctly parses as a '^' character. + Text.Pandoc.ASCIIMathML is no longer an exported module. git-svn-id: https://pandoc.googlecode.com/svn/trunk@835 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-08-08Major change in the way ordered lists are handled:fiddlosopher4-70/+75
+ The changes are documented in README, under Lists. + The OrderedList block element now stores information about list number style, list number delimiter, and starting number. + The readers parse this information, when possible. + The writers use this information to style ordered lists. + Test suites have been changed accordingly. Motivation: It's often useful to start lists with numbers other than 1, and to have control over the style of the list. Added to Text.Pandoc.Shared: + camelCaseToHyphenated + toRomanNumeral + anyOrderedListMarker + orderedListMarker + orderedListMarkers Added to Text.Pandoc.ParserCombinators: + charsInBalanced' + withHorizDisplacement + romanNumeral RST writer: + Force blank line before lists, so that sublists will be handled correctly. LaTeX reader: + Fixed bug in parsing of footnotes containing multiple paragraphs, introduced by use of charsInBalanced. Fix: use charsInBalanced' instead. LaTeX header: + use mathletters option in ucs package, so that basic unicode Greek letters will work properly. git-svn-id: https://pandoc.googlecode.com/svn/trunk@834 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-08-03Added parsing for \url to LaTeX reader.fiddlosopher1-1/+6
git-svn-id: https://pandoc.googlecode.com/svn/trunk@833 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-07-28Changes to Markdown reader:fiddlosopher1-6/+7
+ added try to def of indentSpaces + in def of 'reference', check to make sure it's not a note reference first. git-svn-id: https://pandoc.googlecode.com/svn/trunk@827 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-07-28Removed examplep specific stuff in LaTeX reader.fiddlosopher1-13/+1
git-svn-id: https://pandoc.googlecode.com/svn/trunk@826 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-07-28Changes in LaTeX reader to accommodate Pandoc's own use offiddlosopher1-2/+23
examplep. git-svn-id: https://pandoc.googlecode.com/svn/trunk@818 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-07-28Make URLs and emails in autolinks appear as Code.fiddlosopher1-2/+2
git-svn-id: https://pandoc.googlecode.com/svn/trunk@810 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-07-23In HTML reader, filter Nulls in lists of blocks. (These canfiddlosopher1-2/+2
be caused by raw HTML when the parse-raw option isn't selected.) git-svn-id: https://pandoc.googlecode.com/svn/trunk@787 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-07-23Fixed bug in spanStrikeout: case was not exhaustive.fiddlosopher1-1/+1
git-svn-id: https://pandoc.googlecode.com/svn/trunk@786 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-07-23README: Removed the statement that the RST reader doesn't parsefiddlosopher1-0/+1
definition lists. HTML reader: Added failIfStrict to the definitionList parser, so definition lists will be passed through as raw HTML if --strict specified. git-svn-id: https://pandoc.googlecode.com/svn/trunk@783 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-07-23Added support for definition lists to RST reader.fiddlosopher1-1/+15
Added a relevant test to the test suite. git-svn-id: https://pandoc.googlecode.com/svn/trunk@782 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-07-23Added definition list support to HTML reader.fiddlosopher1-13/+32
Added a test for definition lists to the html-reader test suite. git-svn-id: https://pandoc.googlecode.com/svn/trunk@781 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-07-23Added support for definition lists to LaTeX reader.fiddlosopher1-11/+23
git-svn-id: https://pandoc.googlecode.com/svn/trunk@780 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-07-23Renamed parseFromStr -> parseFromString.fiddlosopher1-3/+3
git-svn-id: https://pandoc.googlecode.com/svn/trunk@779 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-07-22Superscript and Subscript support for RST reader.fiddlosopher1-8/+10
git-svn-id: https://pandoc.googlecode.com/svn/trunk@777 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-07-22Added a "try" to the end parser in enclosed (Text.Pandoc.ParserCombinators).fiddlosopher2-12/+15
This makes errors in its use less likely. Removed some now-unneeded try's in calling code. git-svn-id: https://pandoc.googlecode.com/svn/trunk@776 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-07-22Added subscript and superscript support to LaTeX reader.fiddlosopher1-1/+14
git-svn-id: https://pandoc.googlecode.com/svn/trunk@775 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-07-22LaTeX reader: Added clauses for tilde and caret.fiddlosopher1-2/+10
Tilde is \ensuremath{\sim}, and caret is \^{}, not \^ as before. git-svn-id: https://pandoc.googlecode.com/svn/trunk@764 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-07-22Removed an extra occurance of escapedChar in definitionfiddlosopher1-1/+0
of inline. git-svn-id: https://pandoc.googlecode.com/svn/trunk@762 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-07-22Added support for strikeout (\sout) to latexfiddlosopher1-3/+7
reader. (Thanks to Bradley Sif for the patch.) git-svn-id: https://pandoc.googlecode.com/svn/trunk@754 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-07-21Added support for Strikeout, Superscript, and Subscript tofiddlosopher1-1/+26
HTML reader. Thanks to Bradley Sif for the patch for Strikeout (Issue #18). git-svn-id: https://pandoc.googlecode.com/svn/trunk@753 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-07-21+ Added support for Strikeout, Superscript, andfiddlosopher1-82/+64
Subscript in markdown reader. + Also replaced constants like emphStart with literals. git-svn-id: https://pandoc.googlecode.com/svn/trunk@752 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-07-16Simplified inlinesInBalanced, using lookAhead.fiddlosopher1-5/+5
git-svn-id: https://pandoc.googlecode.com/svn/trunk@732 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-07-15Markdown reader: Added inlinesInBalanced parser combinator tofiddlosopher1-29/+24
unify treatment of embedded brackets in links and inline footnotes. Note that the solution adopted here causes one of John Gruber's markdown tests to fail: [with_underscore](/url/with_underscore) Here the whole phrase "underscore](/url/with" is treated as emphasized. The previous version of the markdown reader handled this the way Gruber's script handles it, but it ran into trouble on the following: [link with verbatim `]`](/url) where the inner ] was treated as the end of the reference link label. I don't see any good way to handle both cases in the framework of pandoc, so I choose to require an escape in the first example: [with\_underscore](/url/with_underscore) git-svn-id: https://pandoc.googlecode.com/svn/trunk@729 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-07-12HTML reader: haddock comment fix.fiddlosopher1-1/+1
git-svn-id: https://pandoc.googlecode.com/svn/trunk@690 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-07-09Markdown reader: Parse bracketed text in inline footnotes. Previously,fiddlosopher1-2/+10
"test^[my [note] contains brackets]" would yield a note with contents "my [note". Now it yields a note with contents "my [note] contains brackets". New function: inlinesInBrackets. Resolves Issue 14. git-svn-id: https://pandoc.googlecode.com/svn/trunk@665 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-07-09RST reader: Allow hyperlink target URIs to be split over multiplefiddlosopher1-10/+14
lines, and to start on the line after the reference. Resolves Issue 7. git-svn-id: https://pandoc.googlecode.com/svn/trunk@664 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-07-09Moved Text.ParserCombinators.Pandoc ->fiddlosopher4-4/+4
Text.Pandoc.ParserCombinators. This way, all the Pandoc modules are in one place. git-svn-id: https://pandoc.googlecode.com/svn/trunk@663 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-07-07Adjusted copyright notices to 2006-7; usefiddlosopher4-12/+12
real email address instead of lamely attempting to obfuscate. git-svn-id: https://pandoc.googlecode.com/svn/trunk@640 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-07-06Fixed bug in Markdown reader: links in footnotes were notfiddlosopher1-4/+10
being processed. Solution: three-stage parse. First, get all the reference keys and add information to state. Next, get all the notes and add information to state. (Reference keys may be needed at this stage.) Finally, parse everything else. git-svn-id: https://pandoc.googlecode.com/svn/trunk@625 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-05-10Require blankspace (but not multiple lines) between URL andfiddlosopher1-5/+6
title in links and reference keys. (Markdown reader.) git-svn-id: https://pandoc.googlecode.com/svn/trunk@599 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-05-03Changed definition list syntax in markdown reader and simplifiedfiddlosopher1-10/+9
the parsing code. A colon is now required before every block in a definition. This fixes a problem with the old syntax, in which the last block in the following was ambiguous between a regular paragraph in the definition and a code block following the definition list: term : definition is this code or more definition? git-svn-id: https://pandoc.googlecode.com/svn/trunk@589 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-04-22Resolved issue #10: instead of adding "\n\n" to thefiddlosopher2-2/+2
end of strings in Main, do it in readMarkdown and readRST. (Note: the point of this is to ensure that a block at the end of the file gets treated as if it has blank space after it, which is generally what is wanted.) git-svn-id: https://pandoc.googlecode.com/svn/trunk@588 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-04-10Extensive changes stemming from a rethinking of the Pandoc datafiddlosopher4-217/+172
structure. Key and Note blocks have been removed. Link and image URLs are now stored directly in Link and Image inlines, and note blocks are stored in Note inlines. This requires changes in both parsers and writers. Markdown and RST parsers need to extract data from key and note blocks and insert them into the relevant inline elements. Other parsers can be simplified, since there is no longer any need to construct separate key and note blocks. Markdown, RST, and HTML writers need to construct lists of notes; Markdown and RST writers need to construct lists of link references (when the --reference-links option is specified); and the RST writer needs to construct a list of image substitution references. All writers have been rewritten to use the State monad when state is required. This rewrite yields a small speed boost and considerably cleaner code. * Text/Pandoc/Definition.hs: + blocks: removed Key and Note + inlines: removed NoteRef, added Note + modified Target: there is no longer a 'Ref' target; all targets are explicit URL, title pairs * Text/Pandoc/Shared.hs: + Added 'Reference', 'isNoteBlock', 'isKeyBlock', 'isLineClump', used in some of the readers. + Removed 'generateReference', 'keyTable', 'replaceReferenceLinks', 'replaceRefLinksBlockList', along with some auxiliary functions used only by them. These are no longer needed, since reference links are resolved in the Markdown and RST readers. + Moved 'inTags', 'selfClosingTag', 'inTagsSimple', and 'inTagsIndented' to the Docbook writer, since that is now the only module that uses them. + Changed name of 'escapeSGMLString' to 'escapeStringForXML' + Added KeyTable and NoteTable types + Removed fields from ParserState; 'stateKeyBlocks', 'stateKeysUsed', 'stateNoteBlocks', 'stateNoteIdentifiers', 'stateInlineLinks'. Added 'stateKeys' and 'stateNotes'. + Added clause for Note to 'prettyBlock'. + Added 'writerNotes', 'writerReferenceLinks' fields to WriterOptions. * Text/Pandoc/Entities.hs: Renamed 'escapeSGMLChar' and 'escapeSGMLString' to 'escapeCharForXML' and 'escapeStringForXML' * Text/ParserCombinators/Pandoc.hs: Added lineClump parser: parses a raw line block up to and including following blank lines. * Main.hs: Replaced --inline-links with --reference-links. * README: + Documented --reference-links and removed description of --inline-links. + Added note that footnotes may occur anywhere in the document, but must be at the outer level, not embedded in block elements. * man/man1/pandoc.1, man/man1/html2markdown.1: Removed --inline-links option, added --reference-links option * Markdown and RST readers: + Rewrote to fit new Pandoc definition. Since there are no longer Note or Key blocks, all note and key blocks are parsed on a first pass through the document. Once tables of notes and keys have been constructed, the remaining parts of the document are reassembled and parsed. + Refactored link parsers. * LaTeX and HTML readers: Rewrote to fit new Pandoc definition. Since there are no longer Note or Key blocks, notes and references can be parsed in a single pass through the document. * RST, Markdown, and HTML writers: Rewrote using state monad new Pandoc and definition. State is used to hold lists of references footnotes to and be printed at the end of the document. * RTF and LaTeX writers: Rewrote using new Pandoc definition. (Because of the different treatment of footnotes, the "notes" parameter is no longer needed in the block and inline conversion functions.) * Docbook writer: + Moved the functions 'attributeList', 'inTags', 'selfClosingTag', 'inTagsSimple', 'inTagsIndented' from Text/Pandoc/Shared, since they are now used only by the Docbook writer. + Rewrote using new Pandoc definition. (Because of the different treatment of footnotes, the "notes" parameter is no longer needed in the block and inline conversion functions.) * Updated test suite * Throughout: old haskell98 module names replaced by hierarchical module names, e.g. List by Data.List. * debian/control: Include libghc6-xhtml-dev instead of libghc6-html-dev in "Build-Depends." * cabalize: + Remove haskell98 from BASE_DEPENDS (since now the new hierarchical module names are being used throughout) + Added mtl to BASE_DEPENDS (needed for state monad) + Removed html from GHC66_DEPENDS (not needed since xhtml is now used) git-svn-id: https://pandoc.googlecode.com/svn/trunk@580 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-03-17Removed Blank block element as unnecessary.fiddlosopher2-2/+2
git-svn-id: https://pandoc.googlecode.com/svn/trunk@578 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-03-17Consolidated 'text', 'special', and 'inline' into 'inline'.fiddlosopher1-8/+23
git-svn-id: https://pandoc.googlecode.com/svn/trunk@577 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-03-16Added trys to two list start routines. Reason:fiddlosopher1-4/+4
<|> only parses second parser when first hasn't consumed input. git-svn-id: https://pandoc.googlecode.com/svn/trunk@576 788f1e2b-df1e-0410-8736-df70ead52e1b