aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Shared.hs
AgeCommit message (Collapse)AuthorFilesLines
2007-07-21Changes to functions for character escaping:fiddlosopher1-18/+17
+ Removed escapeCharAsString + Added escapeStringUsing + Changed backslashEscape to backslashEscapes, which now returns an association list of escapes to be passed to escapeStringUsing git-svn-id: https://pandoc.googlecode.com/svn/trunk@748 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-07-21Added Strikeout, Superscript, and Subscript tofiddlosopher1-8/+12
refsMatch function in Pandoc.Shared. git-svn-id: https://pandoc.googlecode.com/svn/trunk@742 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-07-19Added escapeCharAsString to Text.Pandoc.Shared.fiddlosopher1-0/+9
git-svn-id: https://pandoc.googlecode.com/svn/trunk@738 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-07-12Export NoteTable in Text.Pandoc.Shared.fiddlosopher1-0/+1
git-svn-id: https://pandoc.googlecode.com/svn/trunk@688 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-07-12Change to defaultWriterOptions: standalone is False by default.fiddlosopher1-1/+1
git-svn-id: https://pandoc.googlecode.com/svn/trunk@685 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-07-09Moved isHeaderBlock from Text.Pandoc.Writers.HTMLfiddlosopher1-0/+6
to Text.Pandoc.Shared. git-svn-id: https://pandoc.googlecode.com/svn/trunk@656 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-07-07Adjusted copyright notices to 2006-7; usefiddlosopher1-3/+3
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-07+ Introduced writerIgnoreNotes option in WriterOptions. This is neededfiddlosopher1-0/+25
for processing header blocks for a table of contents, since notes on headers should not appear in the TOC. Set default in Main.hs. + Moved Element, headerAtLeast, and hierarchicalize from Docbook writer to Text.Pandoc.Shared. This is because HTML writer now uses these in constructing a table of contents. git-svn-id: https://pandoc.googlecode.com/svn/trunk@633 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-07-07Added writerTableOfContents to WriterOptions, and added afiddlosopher1-11/+13
--table-of-contents/--toc command-line option to Main.hs. git-svn-id: https://pandoc.googlecode.com/svn/trunk@632 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-07-07Minor comment change.fiddlosopher1-1/+1
git-svn-id: https://pandoc.googlecode.com/svn/trunk@629 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-05-10Improved prettyprinting of definition lists.fiddlosopher1-3/+3
git-svn-id: https://pandoc.googlecode.com/svn/trunk@596 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-04-15Moved escape and nullBlock parsers from ParserCombinators/Pandocfiddlosopher1-3/+18
to Pandoc/Shared. Reason: ParserCombinators/Pandoc is for general-purpose parsers that don't require Pandoc.Definition. Also removed some unnecessary imports from Pandoc/Shared. git-svn-id: https://pandoc.googlecode.com/svn/trunk@584 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-04-13Added Table to prettyBlock in Shared.hs.fiddlosopher1-0/+7
git-svn-id: https://pandoc.googlecode.com/svn/trunk@582 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-04-10Extensive changes stemming from a rethinking of the Pandoc datafiddlosopher1-188/+39
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/+0
git-svn-id: https://pandoc.googlecode.com/svn/trunk@578 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-03-12Added clauses for DefinitionList and Table to replaceReferenceLinks infiddlosopher1-0/+8
Text/Pandoc/Shared.hs. This ensures that reference-style links inside tables and definition lists will be handled properly. git-svn-id: https://pandoc.googlecode.com/svn/trunk@575 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-03-12Simplified keyTable, using assumption that key blocks are notfiddlosopher1-20/+0
inside other block elements (an assumption that the Markdown reader uses in making its initial pass anyway). git-svn-id: https://pandoc.googlecode.com/svn/trunk@574 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-03-10Modified prettyPandoc to handle DefinitionList elements.fiddlosopher1-0/+4
git-svn-id: https://pandoc.googlecode.com/svn/trunk@565 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-03-03Added --inline-links option to force links in HTML to be parsedfiddlosopher1-0/+2
as inline links, rather than reference links. (Addresses Issue #4.) git-svn-id: https://pandoc.googlecode.com/svn/trunk@554 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-02-21Added defaultWriterOptions to Shared.hs.fiddlosopher1-0/+15
git-svn-id: https://pandoc.googlecode.com/svn/trunk@545 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-01-28Changed 'encodeEntities' to 'escapeSGMLString'.fiddlosopher1-3/+3
git-svn-id: https://pandoc.googlecode.com/svn/trunk@520 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-01-28+ Simplified entity handling by removing stringToSGML from Entities.hs.fiddlosopher1-3/+3
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-27More changes in entity handling: Instead of using entities for charactersfiddlosopher1-2/+2
above 128 in HTML and Docbook output, we now just use unicode. After all, we're declaring UTF-8 content in the header. This makes the HTML and docbook files produced by pandoc much more readable and editable. Changes to Entities.hs: + Removed specialCharToEntity + Added escapeSGMLChar (which just escapes the basic four, <>&") + Modified encodeEntities and stringToSGML to use escapeSGMLChar + Removed encodeEntitiesNumerical + Rewrote encodeEntities for better performance + Rewrote stringToSGML for better performance git-svn-id: https://pandoc.googlecode.com/svn/trunk@516 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-01-27Changes in entity handling:fiddlosopher1-55/+3
+ 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-24Rewrote functions in Text/Pandoc/Shared so as not to use Text.Regex,fiddlosopher1-28/+51
which does not support unicode: - escapePreservingRegex removed - stringToSGML rewritten using Parsec parser - new parsers for SGML character entities - escapeSGML rewritten using specialCharToEntity - new function specialCharToEntity git-svn-id: https://pandoc.googlecode.com/svn/trunk@514 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-01-24More smart quote bug fixes:fiddlosopher1-1/+3
+ LaTeX writer now handles consecutive quotes properly: for example, ``\,`hello'\,'' + LaTeX reader now parses '\,' as empty Str + normalizeSpaces function in Shared now removes empty Str elements + Modified tests accordingly git-svn-id: https://pandoc.googlecode.com/svn/trunk@506 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-01-22Removed 'gsub' entirely and replaced its uses with 'substitute'.fiddlosopher1-8/+0
git-svn-id: https://pandoc.googlecode.com/svn/trunk@501 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-01-22+ Added a 'substitute' function to Shared.hs. This is a genericfiddlosopher1-2/+12
list function that can be used to substitute one substring for another in a string, like 'gsub' except without regular expressions. + Use 'substitute' instead of 'gsub' in the LaTeX writer. This avoids what appears to be a bug in Text.Regex, whereby "\\^" matches "\350". There seems to be a slight speed improvement as well. (Note: If this works, it would be good to replace other uses of gsub that don't employ regexs with 'substitute'.) git-svn-id: https://pandoc.googlecode.com/svn/trunk@500 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-01-15Added support for tables in markdown reader and in LaTeX,fiddlosopher1-0/+11
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-06Fixed serious performance problems with new Markdown reader:fiddlosopher1-0/+9
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-68/+24
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-04Fixed small bug in consolidateList: added casefiddlosopher1-0/+1
for (Str a):Space:Space:rest. git-svn-id: https://pandoc.googlecode.com/svn/trunk@418 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-01-04Refactored SGML escaping functions and "in tag" functions tofiddlosopher1-3/+95
Text/Shared/Pandoc. (escapeSGML, stringToSGML, inTag, inTagSimple, inTagIndented, selfClosingTag) These can be used by both the HTML and Docbook writers. git-svn-id: https://pandoc.googlecode.com/svn/trunk@417 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-01-04+ Improved text wrapping algorithm in markdown, docbook, and RST writers.fiddlosopher1-5/+8
LineBreaks no longer cause ugly wrapping in Markdown output. + Replaced splitBySpace with the more general, polymorphic function splitBy (in Text/Pandoc/Shared). git-svn-id: https://pandoc.googlecode.com/svn/trunk@411 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
2007-01-01Merged changes from docbook branch since r363.fiddlosopher1-1/+2
git-svn-id: https://pandoc.googlecode.com/svn/trunk@386 788f1e2b-df1e-0410-8736-df70ead52e1b
2006-12-30Merged 'strict' branch from r324. This adds a '--strict'fiddlosopher1-4/+7
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-2/+1
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-104/+163
+ Reformatted code consistently. git-svn-id: https://pandoc.googlecode.com/svn/trunk@252 788f1e2b-df1e-0410-8736-df70ead52e1b
2006-12-19Merged changes to footnotes branch r219-r240.fiddlosopher1-11/+13
git-svn-id: https://pandoc.googlecode.com/svn/trunk@241 788f1e2b-df1e-0410-8736-df70ead52e1b
2006-12-18Changed '--smartypants' to '--smart' and adjusted documentationfiddlosopher1-1/+1
and symbols accordingly. git-svn-id: https://pandoc.googlecode.com/svn/trunk@224 788f1e2b-df1e-0410-8736-df70ead52e1b
2006-12-16Changed 'putStrLn' to 'putStr' in Main.hs, and modified somefiddlosopher1-1/+1
of the readers to make spacing at end of output more consistent. Modified tests accordingly. git-svn-id: https://pandoc.googlecode.com/svn/trunk@201 788f1e2b-df1e-0410-8736-df70ead52e1b
2006-11-26Pandoc bug fixes:fiddlosopher1-0/+5
+ LaTeX reader did not parse metadata correctly. Now the title, author, and date are parsed correctly, and everything else in the preamble is skipped. + Simplified parsing of LaTeX command arguments and options. The function commandArgs now returns a list of arguments OR options (in whatever order they appear). The brackets are included, and a new stripFirstAndLast function is provided to strip them off when needed. This fixes a problem in dealing with \newcommand, etc. + Added a "try" before "parser" in definition of notFollowedBy' combinator. Adjusted the code using this combinator accordingly. + Changed handling of code blocks. Previously, some readers allowed trailing newlines, while others stripped them. Now, all readers strip trailing newlines in code blocks; writers insert a newline at the end of code blocks as needed. + Changed test suite to reflect these changes. git-svn-id: https://pandoc.googlecode.com/svn/trunk@137 788f1e2b-df1e-0410-8736-df70ead52e1b
2006-11-08Fixed two small Haddock comment bugs in Shared.hs.fiddlosopher1-2/+4
git-svn-id: https://pandoc.googlecode.com/svn/trunk@87 788f1e2b-df1e-0410-8736-df70ead52e1b
2006-10-17initial importfiddlosopher1-0/+417
git-svn-id: https://pandoc.googlecode.com/svn/trunk@2 788f1e2b-df1e-0410-8736-df70ead52e1b