Commit graph

1939 commits

Author SHA1 Message Date
David Lazar
100f8df43e Haddock reader: derive Show for Token, making debugging easier. 2013-04-04 23:01:15 -07:00
John MacFarlane
7e4290561d LaTeX reader: Support \textasciitilde, \textasciicircum.
Closes #810.
2013-03-31 21:08:19 -07:00
John MacFarlane
72020f1773 Docx writer: Use Compact style for Plain block elements.
This differentiates between tight and loose lists.
Closes #775.
2013-03-30 22:11:00 -07:00
David Lazar
8663667788 Haddock reader: make clearer which production the comment refers to. 2013-03-29 11:43:49 -07:00
David Lazar
d2704c2af1 Haddock reader: add the "haskell" attribute to code blocks so they are
highlighted. We reasonably assume that code blocks in Haddock markup
wont be used for anything but Haskell code.
2013-03-29 10:35:06 -07:00
David Lazar
7424454ace Haddock reader: improved error reporting. 2013-03-29 10:22:11 -07:00
John MacFarlane
7cb8b60910 Parsing: Better error reporting in readWith.
- Specialize readWith to String input.
- On error have it print the line in which the error occurred,
  with a caret pointing to the column.
- This should help diagnose parsing problems in LaTeX especially.
2013-03-28 22:20:05 -07:00
John MacFarlane
30969974f0 Haddock writer: use 'text' builder instead of 'str'.
This articulates strings into Str, Space, allowing them to be
hard-wrapped intelligently by the writers.

This patch also fixes a bug with trailing spaces and newlines.
(See #806.)
2013-03-28 20:09:06 -07:00
John MacFarlane
38e35aaeda Allow simple tables to be printed as grid tables.
if other table options are disabled.

This means you can do

    pandoc -t markdown-pipe_tables-simple_tables-multiline_tables

and all tables will render as grid tables.
2013-03-28 17:34:54 -07:00
David Lazar
18459b95ba Add reader for Haddock markup based on Haddock's own lexer/parser. 2013-03-28 14:53:10 -07:00
John MacFarlane
ee0fc19bc5 Parsing: Further improvements to uri parser.
Don't treat punctuation before percent-encoding as final punctuation.
Don't treat '+' as final punctuation.
2013-03-28 11:33:01 -07:00
John MacFarlane
e81b87c2dc Mediawiki reader: Fixed | links inside table cells.
Improved attribute parsing.
2013-03-28 11:26:22 -07:00
John MacFarlane
998695001a Mediawiki reader: Fixed last commit. 2013-03-28 10:51:14 -07:00
John MacFarlane
48b23d491d MediaWiki reader: Correctly handle indented preformatted text
without preceding or following blank line.
2013-03-28 10:48:00 -07:00
John MacFarlane
099b4b7769 Mediawiki: Fixed regression for <ref>URL</ref>.
`<` is no longer allowed in URLs, according to the uri parser
in Text.Pandoc.Parsing.

Added a test case.
2013-03-28 09:54:02 -07:00
John MacFarlane
351b3e09c3 mediawiki reader: allow space before table rows. 2013-03-27 08:45:51 -07:00
John MacFarlane
ba1e74dcd7 Removed blaze_html_0_5 flag, require blaze-html >= 0.5.
Reason:  < 0.5 does not provide a monoid instance for Attribute,
which is now needed by the HTML writer.

Closes #803.
2013-03-26 11:38:50 -07:00
John MacFarlane
40f0a6dd66 SelfContained: handle src in embed, audio, source, input tags. 2013-03-26 08:45:25 -07:00
John MacFarlane
727645bc1f Shared: openURL now follows redirects.
Closes #701.
2013-03-26 08:32:02 -07:00
John MacFarlane
0ee54549af SelfContained: strip off fragment, query of relative URL
before treating as a filename.  This fixes `--self-contained`
when used with CSS files that include web fonts using the
method described here:

http://paulirish.com/2009/bulletproof-font-face-implementation-syntax/

Examples from reveal.js themes:

    "../../lib/font/league_gothic-webfont.eot?#iefix"
    "../../lib/font/league_gothic-webfont.svg#LeagueGothicRegular"

Closes #739.
2013-03-25 20:09:24 -07:00
John MacFarlane
b6f75f60d6 EPUB writer: Don't put blank title page in reading sequence.
Set linear="no" if no title block.
Addresses #797.
2013-03-24 23:06:44 -07:00
John MacFarlane
cb906e7512 EPUB writer: Add id="toc-title" to h1 in nav.xhtml.
Closes #799.
2013-03-24 22:41:00 -07:00
John MacFarlane
6217623d0a Added syntax for "pauses" in beamer or reaveljs slide shows.
This gives

    . . .

    a pause.
2013-03-24 21:03:04 -07:00
John MacFarlane
da1e38893a Reveal.js improvements.
Changed name to revealjs (from reveal_js).
Set revealjs-url template variable to 'reveal.js' by default.
2013-03-23 21:48:34 -04:00
John MacFarlane
2ec59935de reveal_js: nested vertical stacks used for hierarchical structure.
Variant of a patch from jamiefolson.
Results for more than one level of nesting may be odd.
Perhaps this needs revising.
2013-03-21 15:46:47 -07:00
John MacFarlane
5b424f881d Support incremental slide view for definition lists.
All slide formats supported.
Simplified some list code.
2013-03-21 15:21:53 -07:00
Jamie F. Olson
6b53a905c4 Added basic support for reveal.js.
Support unordered and ordered lists with "fragment" elements.

Modified by JGM to remove the --reveal_js-url command-line option.
Instead use -V reveal_js-url=... as with slidy and the other slide
formats.  Also cleaned up the list code in the HTML writer.
2013-03-21 14:54:17 -07:00
John MacFarlane
ff9af6c9e5 EPUB writer: Don't add dc:creator tags if present in epub metadata. 2013-03-20 13:10:03 -07:00
John MacFarlane
5b4d239b85 Added OPML template, tests.
Minor fixes to OPML writer.
Improved OPML reader tests.
2013-03-20 10:17:59 -07:00
John MacFarlane
a63c208d77 OPML reader: Type attributes are not case sensitive.
So, `type="link"` or `type="LINK"`.
2013-03-20 09:16:16 -07:00
John MacFarlane
69acb47a34 Added Text.Pandoc.Writers.OPML.
TODO:

* Document in README
* Add tests
* Add template (and add template to cabal file)
2013-03-19 22:49:44 -07:00
John MacFarlane
8aa6172380 Merge branch 'opml' 2013-03-19 20:23:48 -07:00
John MacFarlane
74d53f4347 Added Text.Pandoc.Readers.OPML, exporting readOPML.
The _note attribute is supported.  This is unofficial, but
used e.g. in OmniOutliner and supported by multimarkdown.
We treat the contents as markdown blocks under a section
header.

Added to documentation and tests.
2013-03-19 20:22:14 -07:00
John MacFarlane
d596b0db83 Docx writer: Fixed rendering of display math in lists.
In 1.11 and 1.11.1, display math in lists rendered as a new list
item.  Now it always appears centered, just as outside of lists,
and in proper display math style, no matter how far indented the
containing list item is.

Closes #784.
2013-03-18 19:31:48 -07:00
John MacFarlane
835deee58b Markdown writer: New approach for citations.
* Reverts 1.11 change that caused citations to be rendered as
  markdown citations, even if `--biblio` was specified, unless
  `citation` extension is disabled.  Now, formatted citations
  are always printed if `--biblio` was specified.  If you want to
  reformat markdown keeping pandoc markdown citations intact,
  just don't specify `--biblio`.

* Reverted now unnecessary changes to Text.Pandoc.Biblio adding the raw
  block to mark the bibliography, and to Text.Pandoc.Writers.Markdown
  to remove the bibliography if `citations` not specified.

* If the content of a `Cite` inline is a `RawInline "latex"`, which
  means that a LaTeX citation command was parsed and `--biblio` wasn't
  specified, then render it as a pandoc markdown citation.  This means
  that `pandoc -f latex -t markdown`, without `--biblio`, will convert
  LaTeX citation commands to pandoc markdown citations.
2013-03-17 10:33:54 -07:00
John MacFarlane
99f9126d72 Markdown writer: Omit bibliography when citations enabled.
In 1.11, citations would be rendered as pandoc markdown citations,
but the bibliography would still be printed.

We avoid that by adding a `RawBlock "pandoc" "references"` before
the references.  This allows the markdown writer to find the references
and strip them off when `citations` is enabled.
2013-03-17 09:57:27 -07:00
John MacFarlane
cae52ecc31 Revert "LaTeX reader: citation handling changes."
This reverts commit f7229b1473.
2013-03-17 08:48:29 -07:00
John MacFarlane
f8fec87f09 Fixed numbering mismatch between TOC and sections in HTML.
Also made `--number-offset` affect TOC numbering as well
as section numbering, as it should have all along.

Closes #789.
2013-03-16 14:48:37 -07:00
John MacFarlane
a1c0210dcd Fixed regression in ODT writer.
This was due to a change in the Show instance for
Text.Pandoc.Pretty.Doc, which led 1.11 to produce corrupt ODTs.

Closes #780.
2013-03-15 15:20:52 -07:00
John MacFarlane
db3d4113a2 Markdown reader: don't lose parentheses in URLs.
Added tests.  This fixes a regression from 1.10.x.  Closes #786.
2013-03-13 19:20:25 -07:00
John MacFarlane
d820eb2c47 Markdown reader: Handle unmatched double quotes in dialogues.
They do not generate a Quoted element; instead, the double quote
is just turned into a Str with a curly left quote.

This should satisfy the fiction writers.  Closes #99 (again).
2013-03-12 19:18:14 -07:00
John MacFarlane
54782c2af6 Fixed spacing bugs involving code block attributes.
Closes #763.
2013-03-11 20:45:27 -07:00
John MacFarlane
f7229b1473 LaTeX reader: citation handling changes.
Previously, a LaTeX citation would always be parsed as a Citation
element, with the raw LaTeX in the [Inline] part.

Now, the LaTeX citation is parsed as a Citation element only if
`--biblio` was specified (i.e. only if there is a nonempty set
of references in readerReferences).  Otherwise it is parsed as
raw LaTeX.

This will make it possible to simplify some things in the markdown
writer.  It also makes the LaTeX reader behave more like the Markdown
reader.
2013-03-09 10:33:25 -08:00
John MacFarlane
af7e97b9f5 Markdown writer: Render citations as pandoc-markdown citations.
Previously citations were rendered as citeproc-formatted citations
by default.  Now we render them as pandoc citations, e.g. `[@item1]`,
unless the `citations` extension is disabled.

If you still want formatted citations in your markdown output,
use `pandoc -t markdown-citations`.
2013-03-07 16:38:19 -08:00
John MacFarlane
48be39ae2a Support :number-lines: in RST code output. 2013-03-06 10:13:12 -08:00
John MacFarlane
f7d37c97bb LaTeX reader: Better support for Verbatim and minted environments.
Closes #763.
2013-03-06 09:58:47 -08:00
John MacFarlane
8b3a81e4dd LaTeX reader: Handle language attribute for lstlistings.
Convert it to a highlighting-kate language name.
2013-03-05 22:43:27 -08:00
John MacFarlane
3b63cb0903 Hide Text.Pandoc.Highlighting.
* Moved code for translating listings language names to
  highlighting-kate names and back from LaTeX reader to Highlighting.
* Text.Pandoc.Highlighting no longer exposed (API change)
* Text.Pandoc.Highlighting exports toListingsLang, fromListingsLang
2013-03-05 22:09:42 -08:00
John MacFarlane
3692e371a7 LaTeX reader: Read optional attributes in lstlisting environment.
We convert these to pandoc standard names, e.g. "numberLines"
for "numbers=left", "startFrom=100" from "firstnumber=100".

Still need to add code to convert the language names.
2013-03-04 09:50:11 -08:00
John MacFarlane
0bbee1bcf6 LaTeX writer: Support line numbering with --listings.
If "numberLines" class is present, we add "numbers=left";
if "startFrom" is present, we add "firstnumber=".

Partially addresses #763.
2013-03-04 09:31:31 -08:00
John MacFarlane
76c5ebf141 EPUB writer: Include html TOC even in epub2.
* The TOC is included in `<spine>`, but `linear` is set
  to `no` unless the `--toc` option is specified.
* Include `<guide>` element in OPF.
* This should allow the TOC to be useable in Kindles when
  converted with kindlegen.
* Results validate with epubcheck 3.0 for both epub and epub3
  output.
* Closes #773.
2013-03-03 08:42:45 -08:00
John MacFarlane
f4629df14a Markdown reader: attribute parsing improvements.
* Cleaned up parsing code.
* '-' in an attribute context = '.unnumbered'.  The point of this
  is to provide a way to specify unnumbered headers in non-English
  documents.
2013-03-02 21:08:33 -08:00
John MacFarlane
3ad68b2522 Check for tables before line blocks.
Otherwise some pipe tables get treated as line blocks.
2013-03-02 19:02:50 -08:00
John MacFarlane
1aff783095 Markdown reader: Allow spaces around borders in pipe tables.
Closes #772.
2013-03-02 18:59:50 -08:00
John MacFarlane
f449dfd55d LaTeX reader: Add "fig:" as title for images with captions.
This is needed for them to be rendered as figures.
Closes #766.
2013-03-01 12:22:01 -08:00
John MacFarlane
6611ec399c Textile writer: Removed an unused assignment. 2013-03-01 12:17:49 -08:00
John MacFarlane
649608d324 Markdown: allow ---- in angle-bracket autolinks.
The uri parser is designed for bare URIs.  In angle-bracket contexts,
we can be sure that we don't have trailing punctuation.  So
`<http://openclipart.org/detail/22566/lego-smiley----happy-by-pitr>`
should work now.

Closes #768.
2013-02-28 22:05:22 -08:00
John MacFarlane
abdaa96b03 Markdown writer: Use grid tables when needed, and if enabled.
Closes #740.
2013-02-28 20:22:28 -08:00
John MacFarlane
68c95f4857 Pretty: Fixed chomp so it works inside Prefixed elements. 2013-02-28 20:22:08 -08:00
John MacFarlane
0c4965847f Pretty: Better Show instance for debugging purposes. 2013-02-28 20:12:21 -08:00
John MacFarlane
0c9bb40403 Textile writer: Support header attributes. 2013-02-28 18:47:49 -08:00
John MacFarlane
6cfd2e8fa9 Docx writer: Better treatment of display math.
Display math inside a paragraph is now put in a separate
paragraph, so it will render properly (centered and without
extra blank lines around it).

Partially addresses #742.
2013-02-26 22:59:21 -08:00
John MacFarlane
52ee09608a LaTeX reader: Handle \caption for images in figures.
Closes #766.
2013-02-26 22:16:03 -08:00
John MacFarlane
3fca434737 Changed style names in reference docx.
FootnoteReference -> FootnoteRef.
Hyperlink -> Link.

Why?  Because the old names got changed by Word when the
reference.docx was edited.  I don't understand why, but this
fixes things.

Closes #414.
2013-02-26 22:01:47 -08:00
John MacFarlane
caed0df4a7 Docx writer: Create content types and document rels from scratch.
This fixes problems that arise when you edit the reference.docx
with Word.  Word tends to remove things from the `[Content_Types].xml`
and `word/_rels/document.xml.rels` files that are needed (e.g.
references to the `footnotes.xml` file and image default mime types).
So we regenerate these completely rather than taking them from
the `reference.docx`.

We also now encode mime types for each individual image rather
than using defaults.  This should allow us to handle a wider
range of image types.

This mostly addresses #414.  The only remaining issue I can see
is the issue of style IDs, which Word inexplicably changes in
some cases when the reference.docx is saved.  E.g.
`FootnoteReference` becomes `FootnoteReference1`.
2013-02-26 20:31:32 -08:00
John MacFarlane
c46eac5aea Refactoring in Docx writer. 2013-02-25 19:04:20 -08:00
John MacFarlane
cae409725f Docx writer: Handle PDF images. 2013-02-23 23:04:42 -08:00
John MacFarlane
588a49acf9 ImageSize: Added Pdf to ImageType.
So far we have no function to determine PDF's size.
2013-02-23 23:03:56 -08:00
John MacFarlane
dd48e06a4d EPUB writer: Improved behavior with --number-sections.
* Headers with "unnumbered" attribute are not numbered.
  (Nor do they cause an increment in running numbering.)
* Section numbers now work properly, even when there is
  material before the first numbered section.
2013-02-23 20:21:45 -08:00
John MacFarlane
ca6cb04509 EPUB writer: more transition.
Changed toChunks to toChapters.
2013-02-23 19:34:04 -08:00
John MacFarlane
9c40535c47 EPUB writer: Temporary step towards a better system for numbering.
With this change, `--number-sections` won't work.  This will
be fixed later.
2013-02-23 18:51:58 -08:00
John MacFarlane
8b8c8cfed9 HTML writer: fix case when writerNumberOffet is empty or short.
We add 0s to the end of the list if it's shorter than needed.
2013-02-23 18:51:33 -08:00
John MacFarlane
756c8d492a --number-from -> --number-offset
Also `writerNumberFrom` -> `writeNumberOffset`.
The offset is a list of numbers (0 by default).
These are added to the section, subsection, etc.
numbers that would have been generated automatically.
2013-02-23 18:11:05 -08:00
John MacFarlane
a7245b453c EPUB writer: Minor section numbering tweaks.
* If we need to add an initial section, make it unnumbered.
* Don't add extra space before unnumbered section titles in TOC.
2013-02-22 20:38:56 -08:00
John MacFarlane
a33828f375 EPUB writer: Use writerNumberFrom instead of ugly hack. 2013-02-22 19:45:39 -08:00
John MacFarlane
9b190ec3db Made HTML writer sensitive to writerNumberFrom. 2013-02-22 19:15:38 -08:00
John MacFarlane
8df380486c Added --number-from option and writerNumberFrom.
These still aren't hooked up to anything in the writers.
2013-02-21 21:40:06 -08:00
John MacFarlane
07e8cedf2b Make implicit_header_references work with explicit header ids.
(Markdown reader.)
2013-02-21 19:53:35 -08:00
John MacFarlane
7a97369d01 LaTeX reader: Don't emit empty paragraph.
See #761.
2013-02-20 13:01:50 -08:00
John MacFarlane
3f2dd98f45 LaTeX reader: Parse \section*, etc. as unnumbered sections. 2013-02-20 09:59:31 -08:00
John MacFarlane
83521c18e9 ConTeXt writer: now sensitive to 'unnumbered' class in headers.
In this case \title, \subject are used instead of \chapter,
\section.
2013-02-18 10:55:08 -08:00
John MacFarlane
5e9145bb62 Textile reader: Handle attributes on headers.
Includes `[lang]`, `(class #id)`, `{color:red}` styles.
2013-02-16 18:29:12 -08:00
John MacFarlane
8dd00b93e2 LaTeX writer: Omit lists with no items.
Otherwise we get LaTeX errors.
2013-02-16 17:47:45 -08:00
John MacFarlane
eca8c6043b EPUB writer: Fix section numbering.
Previously the numbering restarted from 1 in each chapter
(with `--number-sections`), though the numbers in the table
of contents were correct.

Note that this fix is a bit hackish and possibly fragile:
if the rendering of section numbers in HTML changes in the
future, it may break.  But it works, without needing
changes in other modules.
2013-02-16 17:36:39 -08:00
John MacFarlane
14b64ed46c HTML reader: Preserve all header attributes. 2013-02-16 17:01:44 -08:00
John MacFarlane
cc410a71b5 Allow & in emails (for entities).
Added tests for entities in titles and links.
Closes #723.
2013-02-15 23:02:17 -08:00
John MacFarlane
59764fa388 Parsing: uri, email: resolve entities.
A markdown link `<http://g&ouml;ogle.com>` should
be a link to http://göogle.com.
2013-02-15 22:39:49 -08:00
John MacFarlane
5491adbfdb Markdown reader: litChar now includes entities.
We no longer need to use fromEntities on titles.
2013-02-15 20:27:29 -08:00
John MacFarlane
11f7407445 LaTeX writer: Include unnumbered sections in TOC. 2013-02-15 19:23:51 -08:00
John MacFarlane
0d1fa0a763 Implemented "unnumbered" headers in LaTeX writer.
Starred variants of section commands used when header
has "unnumbered" class.
2013-02-14 19:50:11 -08:00
John MacFarlane
90f0dd15b6 HTML writer: Support header attributes.
Note:  The attributes go on the enclosing section or div
if `--section-divs` is specified.

Also fixed a regression (only now noticed) in html+lhs output.
Previously the bird tracks were being omitted.
2013-02-14 19:35:58 -08:00
John MacFarlane
cdee226586 hierarchicalize: Do not number section with class "unnumbered".
Unnumbered sections get [] for their section number.
So far only the HTML writer has been adjusted to be sensitive
to this.

If we keep this change, all the writers will need to be changed
either (a) to directly check for the "unnumbered" class, if they
do section numbering themselves, or (b) to check for a null section
number, if they use hierarchicalize.
2013-02-13 08:49:48 -08:00
John MacFarlane
a50b83266c HTML writer: Refactored adding attributes to html element. 2013-02-12 21:29:17 -08:00
John MacFarlane
5330e63421 Shared: Changed type of Element.
Sec now includes a field for Attr rather than just String
(the identifier).

Note, this is an API change.
2013-02-12 20:13:23 -08:00
John MacFarlane
a49ecc9fe7 Markdown reader: Fix title block parsing.
Now if mmd_title_blocks is specified, pandoc will parse a
MMD title block if it sees one, even if pandoc_title_blocks is enabled.
2013-02-12 19:55:37 -08:00
John MacFarlane
35cc1d99ca Markdown reader: Make backslash escape work in attributes. 2013-02-12 11:27:42 -08:00
John MacFarlane
ea9b7a4a52 Markdown reader: Fixed bug parsing key/value attributes.
Parsing failed if you had an unquoted attribute immediately
before the final '}'.
2013-02-12 11:20:36 -08:00
John MacFarlane
0e03962615 LaTeX reader: Parse \hrule as HorizontalRule.
Closes #746.
2013-02-11 17:39:52 -08:00
John MacFarlane
18d490bd38 Added markdown_github as input format. 2013-02-11 17:27:06 -08:00
John MacFarlane
3465ba2f61 UTF8: Strip off BOM if present.
Closes #743.
2013-02-08 09:45:25 -08:00