aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers/Markdown.hs
AgeCommit message (Collapse)AuthorFilesLines
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 thefiddlosopher1-1/+1
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 datafiddlosopher1-123/+94
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.fiddlosopher1-1/+1
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
2007-03-11Changes to Markdown reader relating to definition lists:fiddlosopher1-5/+11
+ fixed bug in indentSpaces (which didn't properly handle cases with mixed spaces and tabs) + rewrote definition list code to conform to new syntax + include definition lists in list block + failIfStrict on definition lists git-svn-id: https://pandoc.googlecode.com/svn/trunk@572 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-03-10Changed syntax of definition lists in Markdown parser:fiddlosopher1-6/+7
+ definition blocks must be indented throughout (not just in first line) + compact lists can be formed by leaving no blank line between a definition and the next term git-svn-id: https://pandoc.googlecode.com/svn/trunk@568 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-03-10Added parser for definition lists, derived from reStructuredTextfiddlosopher1-3/+32
syntax: term 1 Definition 1 Paragraph 2 of definition 1. term 2 There must be whitespace between entries. Any kind of block may serve as a definition, but the first line of each block must be indented. terms can contain any *inline* elements If you want to be lazy, you can just indent the first line of the definition block. git-svn-id: https://pandoc.googlecode.com/svn/trunk@566 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-03-09Change in ordered lists in Markdown reader:fiddlosopher1-6/+12
+ Lists may begin with lowercase letters only, and only 'a' through 'n'. Otherwise first initials and page references (e.g., p. 400) are too easily parsed as lists. + Numbers beginning list items must end with '.' (not ')', which is now allowed only after letters). NOTE: This change may cause documents to be parsed differently. Users should take care in upgrading. git-svn-id: https://pandoc.googlecode.com/svn/trunk@561 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-03-07More smart quote adjustments:fiddlosopher1-4/+2
+ remove support for all-caps contractions (too much potential for conflict with things like 'M. Mitterand') + add support for 'm as a contraction git-svn-id: https://pandoc.googlecode.com/svn/trunk@560 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-03-07Smart quote parsing in Markdown reader:fiddlosopher1-2/+4
treat ' followed by ll, re, ve, then a non-letter, as a contraction. (e.g. I've, you're, he'll) git-svn-id: https://pandoc.googlecode.com/svn/trunk@559 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-02-15Refactored str and strong in Markdown reader, for clarity.fiddlosopher1-5/+9
git-svn-id: https://pandoc.googlecode.com/svn/trunk@539 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-02-15Got rid of two unneeded 'getState's. Note thatfiddlosopher1-2/+1
lookAhead automatically saves and restores the state. git-svn-id: https://pandoc.googlecode.com/svn/trunk@538 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-02-15Use lookAhead parser for the "first pass" looking forfiddlosopher1-5/+3
reference keys in Markdown parser, instead of parsing normally, then using setInput to reset input. Slight performance improvement. git-svn-id: https://pandoc.googlecode.com/svn/trunk@536 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-02-15Removed followedBy' parser from Text/ParserCombinators/Pandoc,fiddlosopher1-5/+5
replacing it with the 'lookAhead' parser from Text/ParserCombinators/Parsec. git-svn-id: https://pandoc.googlecode.com/svn/trunk@535 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-02-12+ Added some needed "try"s before multicharacter parsers,fiddlosopher1-4/+4
especially in "option" contexts. + Removed the "try" from the "end" parser in "enclosed" (Text.Pandoc.Shared). Now "enclosed" behaves like "option", "manyTill", etc. git-svn-id: https://pandoc.googlecode.com/svn/trunk@527 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-01-28+ Simplified entity handling by removing stringToSGML from Entities.hs.fiddlosopher1-4/+4
It is no longer needed now that all entities are processed in the markdown and HTML readers. All calls to stringToSGML have been replaced by calls to encodeEntities. + Since inTag's attribute handling already encodes entities, calls to encodeEntities are no longer needed for attribute values, so they've been removed. + The HTML and Markdown readers now call decodeEntities on all raw strings (e.g. authors, dates, link titles), to ensure that no unprocessed entities are included in the native representation of the document. (In the HTML reader, most of this work is done by a change in extractAttributeName.) + The result is a small speed improvement (around 5% on my benchmark) and cleaner code. git-svn-id: https://pandoc.googlecode.com/svn/trunk@519 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-01-27Cleaned up handling of embedded quotes in link titles.fiddlosopher1-2/+1
Now these are stored as a '"' character, not as '&quot;'. The function escapeLinkTitle in the Markdown writer is unnecessary and was removed. Tests modified accordingly. git-svn-id: https://pandoc.googlecode.com/svn/trunk@517 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-01-27Changes in entity handling:fiddlosopher1-4/+9
+ Entities are parsed (and unicode characters returned) in both Markdown and HTML readers. + Parsers characterEntity, namedEntity, decimalEntity, hexEntity added to Entities.hs; these parse a string and return a unicode character. + Changed 'entity' parser in HTML reader to use the 'characterEntity' parser from Entities.hs. + Added new 'entity' parser to Markdown reader, and added '&' as a special character. Adjusted test suite accordingly since now we get 'Str "AT",Str "&",Str "T"' instead of 'Str "AT&T".. + stringToSGML moved to Entities.hs. escapeSGML removed as redundant, given encodeEntities. + stringToSGML, encodeEntities, and specialCharToEntity are given a boolean parameter that causes only numerical entities to be used. This is used in the docbook writer. The HTML writer uses named entities where possible, but not all docbook-consumers know about the named entities without special instructions, so it seems safer to use numerical entities there. + decodeEntities is rewritten in a way that avoids Text.Regex, using the new parsers. + charToEntity and charToNumericalEntity added to Entities.hs. + Moved specialCharToEntity from Shared.hs to Entities.hs. + Removed unneeded 'decodeEntities' from 'str' parser in HTML and Markdown readers. + Removed sgmlHexEntity, sgmlDecimalEntity, sgmlNamedEntity, and sgmlCharacterEntity from Shared.hs. + Modified Docbook writer so that it doesn't rely on Text.Regex for detecting "mailto" links. git-svn-id: https://pandoc.googlecode.com/svn/trunk@515 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-01-24Changed Markdown autoLink parsing to conform better tofiddlosopher1-6/+6
Markdown.pl's behavior. <google.com> is not treated as a link, but <http://google.com>, <ftp://google.com>, and <mailto:google@google.com> are. git-svn-id: https://pandoc.googlecode.com/svn/trunk@513 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-01-24Refactored markdown reader so that Text.Regex is not used.fiddlosopher1-14/+19
Replaced email regex test with a custom email autolink parser (autoLinkEmail). Also replaced 'selfClosingTag' with a custom function 'isSelfClosingTag'. git-svn-id: https://pandoc.googlecode.com/svn/trunk@511 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-01-24Fixed bug in smart quoting: recognize ' in contractions likefiddlosopher1-3/+7
"don't" as not beginning single quoted contexts. git-svn-id: https://pandoc.googlecode.com/svn/trunk@505 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-01-22Removed 'gsub' entirely and replaced its uses with 'substitute'.fiddlosopher1-1/+1
git-svn-id: https://pandoc.googlecode.com/svn/trunk@501 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-01-18Small bug fix to last change, and count "'S" as well as "'s" asfiddlosopher1-1/+1
possessive when followed by non-alphanumeric. git-svn-id: https://pandoc.googlecode.com/svn/trunk@499 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-01-18More tweaks to smart quote parsing: a ' is not a single quotefiddlosopher1-0/+1
start if followed by 's' and then a non-alphanumeric. (Yes, this is English-centric, I'm afraid. But it does help, and I can't think of a language in which 's' by itself is a word.) git-svn-id: https://pandoc.googlecode.com/svn/trunk@498 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-01-16Minor tweaks to smart quoting code.fiddlosopher1-4/+3
git-svn-id: https://pandoc.googlecode.com/svn/trunk@497 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-01-16Fixed bug in smart quote recognition: ' before ) or certainfiddlosopher1-3/+4
other punctuation must not be an open quote. git-svn-id: https://pandoc.googlecode.com/svn/trunk@496 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-01-16Fixed haddock documentation errors.fiddlosopher1-25/+25
git-svn-id: https://pandoc.googlecode.com/svn/trunk@495 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-01-15Added support for tables in markdown reader and in LaTeX,fiddlosopher1-8/+153
DocBook, and HTML writers. The syntax is documented in README. Tests have been added to the test suite. git-svn-id: https://pandoc.googlecode.com/svn/trunk@493 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-01-08+ Changed 'escapedChar' in Markdown reader so that only thefiddlosopher1-1/+8
characters Markdown escapes are escaped in strict mode. When not in strict mode, Pandoc allows all non-alphanumeric characters to be escaped. + Added documentation of backslash escapes to README. git-svn-id: https://pandoc.googlecode.com/svn/trunk@461 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-01-07Small improvements to indentSpaces. (Allow combinationsfiddlosopher1-1/+2
of spaces and tabs.) git-svn-id: https://pandoc.googlecode.com/svn/trunk@446 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-01-07Fixed performance problems with '--strict' option:fiddlosopher1-15/+17
+ Replaced skipEndline with "option ' ' newline" where possible. + Replaced "notFollowedBy' header" in definition of endline with a faster but equally accurate test for a folliwng header. + Removed check at the beginning of 'reference' for a noteStart: This is not needed, because note comes before referenceKey in the definition of block. + Replaced check for a following anyHtmlBlockTag in autoLink with a check for anyHtmlTag or anyHtmlEndTag. + Other small code cleanups. git-svn-id: https://pandoc.googlecode.com/svn/trunk@444 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-01-06Fixed bug in Markdown reader's handling of underscores and otherfiddlosopher1-8/+14
inline formatting markers inside reference labels: for example, in '[A_B]: /url/a_b', the material between underscores was being parsed as emphasized inlines. git-svn-id: https://pandoc.googlecode.com/svn/trunk@442 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-01-06Fixed serious performance problems with new Markdown reader:fiddlosopher1-13/+35
Instead of using lookahead to determine whether a single quote is an apostrophe, we now use state. Inside single quotes, a ' character won't be recognized as the beginning of a single quote. 'stateQuoteContext' has been added to keep track of this. git-svn-id: https://pandoc.googlecode.com/svn/trunk@437 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-01-06Merged changes from 'quotes' branch since r431. Smart typographyfiddlosopher1-12/+62
is now handled in the Markdown and LaTeX readers, rather than in the writers. The HTML writer has been rewritten to use the prettyprinting library. git-svn-id: https://pandoc.googlecode.com/svn/trunk@436 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-01-02Change 'HtmlEntities' module to 'Entities'. Adjusted callingfiddlosopher1-1/+1
code accordingly. git-svn-id: https://pandoc.googlecode.com/svn/trunk@395 788f1e2b-df1e-0410-8736-df70ead52e1b
2006-12-31Revised inline code parsing in Markdown reader to conform tofiddlosopher1-14/+6
Markdown.pl. Now any number of `'s can begin inline code, which will end with the same number of `'s. For example, to have two backticks as code, write ``` `` ``` git-svn-id: https://pandoc.googlecode.com/svn/trunk@360 788f1e2b-df1e-0410-8736-df70ead52e1b
2006-12-31Changed Markdown reader so that the first pass, in which a listfiddlosopher1-2/+3
of reference keys is made, is much faster. This gets us a big performance boost. git-svn-id: https://pandoc.googlecode.com/svn/trunk@353 788f1e2b-df1e-0410-8736-df70ead52e1b
2006-12-31Removed unneeded 'do' block from 'parseBlocks' definitionfiddlosopher1-3/+1
in Markdown reader. git-svn-id: https://pandoc.googlecode.com/svn/trunk@352 788f1e2b-df1e-0410-8736-df70ead52e1b
2006-12-30Merged 'strict' branch from r324. This adds a '--strict'fiddlosopher1-31/+123
option to pandoc, which forces it to stay as close as possible to official Markdown syntax. git-svn-id: https://pandoc.googlecode.com/svn/trunk@347 788f1e2b-df1e-0410-8736-df70ead52e1b
2006-12-21Fixed a serious bug in the Markdown reader (also affecting LaTeXfiddlosopher1-25/+22
and RST readers). The problem: these readers ran 'runParser' on processed chunks of text to handle embedded block lists in lists and quotation blocks. But then any changes made to the parser state in these chunks was lost, as the state is local to the parser. So, for example, footnotes didn't work in quotes or list items. The fix: instead of calling runParser on some raw text, use setInput to make it the input, then parse it, then use setInput to restore the input to what it was before. This is shorter and more elegant, and it fixes the problem. 'BlockQuoteContext' was also eliminated from ParserContext, as it isn't used anywhere. git-svn-id: https://pandoc.googlecode.com/svn/trunk@261 788f1e2b-df1e-0410-8736-df70ead52e1b
2006-12-20Added license text to top of source files.fiddlosopher1-0/+18
git-svn-id: https://pandoc.googlecode.com/svn/trunk@258 788f1e2b-df1e-0410-8736-df70ead52e1b
2006-12-20Changed 'stability' from 'provisional' to 'alpha'.fiddlosopher1-1/+1
git-svn-id: https://pandoc.googlecode.com/svn/trunk@257 788f1e2b-df1e-0410-8736-df70ead52e1b
2006-12-20Changed 'status' in comment headers from 'unstable' to 'provisional'fiddlosopher1-1/+1
(which seems to be the term that is used in this context). git-svn-id: https://pandoc.googlecode.com/svn/trunk@255 788f1e2b-df1e-0410-8736-df70ead52e1b
2006-12-20+ Added module data for haddock.fiddlosopher1-289/+312
+ Reformatted code consistently. git-svn-id: https://pandoc.googlecode.com/svn/trunk@252 788f1e2b-df1e-0410-8736-df70ead52e1b
2006-12-19+ Replaced 'comparing' combinator in markdown reader with 'compare'.fiddlosopher1-2/+1
'comparing' is from Data.Ord, which is not available in GHC 6.4. + Added line break after </li> in HTML footnote output, for easier inspection of the source. git-svn-id: https://pandoc.googlecode.com/svn/trunk@245 788f1e2b-df1e-0410-8736-df70ead52e1b
2006-12-19Fixed a minor mistake introduced in resolving conflicts from thefiddlosopher1-1/+0
merge. git-svn-id: https://pandoc.googlecode.com/svn/trunk@243 788f1e2b-df1e-0410-8736-df70ead52e1b
2006-12-19Merged changes to footnotes branch r219-r240.fiddlosopher1-6/+41
git-svn-id: https://pandoc.googlecode.com/svn/trunk@241 788f1e2b-df1e-0410-8736-df70ead52e1b