Commit graph

3161 commits

Author SHA1 Message Date
John MacFarlane
60bf4a8bfb Improved warnings when image size can't be determined.
Closes #1834.
2015-05-09 23:56:53 -07:00
John MacFarlane
31b3f2ef88 ImageSize: Use runGetOrFail with binary 0.7+. 2015-05-09 22:28:49 -07:00
John MacFarlane
a60c65c4e9 ImageSize: make jpeg header parsing routines return Either.
See #1834.
2015-05-09 21:55:19 -07:00
John MacFarlane
6fe243abbd ImageSize: make imageSize return an Either, not a Maybe.
This will give us better error reporting options.
This is part of a fix for #1834.
2015-05-09 21:32:31 -07:00
John MacFarlane
7920a1a469 Revert "EPUB writer: stylesheet changes. Closes #2040."
This reverts commit 1c2951dfd9.

See #2040.

The semantics was too squishy.  `--css` takes a URL, but
for EPUB we need files that we can read.  I prefer keeping
the old system for now, with `--epub-stylesheet`.
2015-05-09 00:07:27 -07:00
John MacFarlane
1c2951dfd9 EPUB writer: stylesheet changes. Closes #2040.
* Allow `--css` to be used to specify stylesheets.
* Deprecated `--epub-stylesheet` and made it a synoynym of
  `--css`.
* If a code block with class "css" is given as contents of the
  `stylesheet` metadata field, use its literal code as contents of
  the epub stylesheet.  Otherwise, treat it as a filename and
  read the file.
* Note: `--css` and `stylesheet` in metadata are not compatible.
  `stylesheet` takes precedence.
2015-05-08 23:47:50 -07:00
John MacFarlane
472c1424ba Deal with deprecation warning in Custom. 2015-05-05 12:46:20 -07:00
John MacFarlane
d19a347fd5 UTF8: Better handling of bare CRs in input files.
Previously we just stripped them out; now we convert
other line ending styles to LF line endings.

Closes #2132.
2015-05-05 12:42:50 -07:00
John MacFarlane
1b44acf0c5 SelfContained: properly handle data URIs in css urls.
Also use a proper css parser (adds dependency on text-css).

Closes #2129.
2015-05-04 16:00:28 -07:00
John MacFarlane
64b1394fe2 Make sure a closing </div> doesn't get included in a defn list item.
Closes #2127.
2015-05-03 15:06:40 -07:00
John MacFarlane
8a77eb4c9c LaTeX writer: Add a \label in \hyperdef for Div, Span.
Otherwise links don't work.
2015-05-02 17:58:16 -07:00
John MacFarlane
f1aaad9e86 EPUB writer: Use plain writer for metadata dc: fields.
This gives better results when we have, e.g. multiple paragraphs.
Note that tags aren't allowed in these fields.

Closes #2121.
2015-05-01 22:36:38 -07:00
John MacFarlane
9b2f645e2a SelfContained: cssURLs no longer tries to fetch fragment URLs.
The current test is: does the URL start with a `#`?
Closes #2121.
2015-05-01 22:15:43 -07:00
Alfred Wechselberger
7031748a43 Added woff2 to MIME types 2015-04-29 14:10:30 -07:00
John MacFarlane
55b7afc674 HTML reader: Allow multiple colgroups in table.
Closes #2122.
2015-04-29 12:05:38 -07:00
John MacFarlane
7b27cc6758 EPUB writer: Remove linear=no from cover itemref.
Closes #1609.
2015-04-26 15:43:58 -07:00
John MacFarlane
d9d88e58e1 Fixed regression with lists inside defintiion lists.
This fixes a regression (not in any released version) on
things like

    hi
    :   - there

Closes #2098.
2015-04-26 11:27:47 -07:00
John MacFarlane
2793d986dc Merge pull request #2112 from lierdakil/issue2101
Custom Writer: Set foreign encoding to UTF-8
2015-04-26 11:16:50 -07:00
John MacFarlane
1868cb5e42 Updated copyright notices to -2015. Closes #2111. 2015-04-26 10:18:29 -07:00
Nikolay Yakimov
a0ec3e85ad Custom Writer: Set foreign encoding to UTF-8
Closes #2101, #1634

Also factored out ByteString, since it's only used as an intermediate
representation.
2015-04-26 08:44:57 +03:00
John MacFarlane
e1d6be4e30 LaTeX reader: recognize \newpage as a block command. 2015-04-22 08:48:25 -07:00
John MacFarlane
2bca018201 Custom writer: use UTF-8 aware bytestring conversion.
This might help with #2101.
2015-04-21 22:50:58 -07:00
John MacFarlane
e9d7504bea Rewrote charsInBalancedBrackets.
This version should be a bit more efficient.

This doesn't help with #1735, however.
2015-04-19 17:04:33 -07:00
Nikolay Yakimov
e83968412e MD Reader: Fix links/footnotets after citations
Footnotes: check if '^' follows '['
Links: check if '[' or '(' follows ']'
Shorthand links: attempt to lazily parse suffix as referenceLink
2015-04-20 01:47:02 +03:00
John MacFarlane
1a69896d8f Revert "Merge pull request #1947 from mpickering/Fmonad"
Closes #2062.

This reverts commit c302bdcdbe, reversing
changes made to b983adf0d0.

Conflicts:
	src/Text/Pandoc/Parsing.hs
	src/Text/Pandoc/Readers/Markdown.hs
	src/Text/Pandoc/Readers/Org.hs
	src/Text/Pandoc/Readers/RST.hs
2015-04-18 19:00:32 -07:00
John MacFarlane
d20152e011 Markdown writer: improved escaping.
`<` should not be escaped as `\<`, for compatibility with
original Markdown.  We now escape `<` and `>` with entities.
Also, we now backslash-escape square brackets.

Closes #2086.
2015-04-18 10:58:50 -07:00
John MacFarlane
d3544dc6f7 Markdown definition lists: don't require indent for first line.
Previously the body of the definition (after the `:` or `~` marker)
needed to be in column 4.  This commit relaxes that requirement,
to better match the behavior of PHP Markdown Extra.  So, now
this is a valid definition list:

    foo
    : bar

This patch also helps resolve a potentially ambiguity with table
captions:

    foo

      : bar

      -----
      table
      -----

Is "bar" a definition, or the caption for the table?  We'll count
it as a caption for the table.

Closes #2087.
2015-04-18 10:13:32 -07:00
John MacFarlane
10e28ef750 More principled fix for #1820.
If the tag parses as a comment, we check to see if the
input starts with `<!--`. If not, it's bogus comment mode
and we fail htmlTag.

Includes test case.  Closes #1820.
2015-04-17 22:56:33 -07:00
John MacFarlane
764f677530 Merge branch 'latex-tightlist' of https://github.com/jlduran/pandoc into jlduran-latex-tightlist
Conflicts:
	data/templates
2015-04-17 19:23:13 -07:00
John MacFarlane
28ca8566ab Merge pull request #1954 from mcmtroffaes/feature/citekey-firstchar-alphanum
Allow digit as first character of a citation key.
2015-04-17 19:10:37 -07:00
John MacFarlane
44fcc5f96e Merge pull request #2079 from lierdakil/rst-normalize-headings
RST Writer: Normalize headings to sequential levels
2015-04-17 19:06:25 -07:00
John MacFarlane
fb143be038 Merge pull request #2092 from lierdakil/issue1909
MD Reader: Smart apostrophe after inline math
2015-04-17 18:55:35 -07:00
John MacFarlane
13b230a1b5 Fixed htmlTag in HTML reader.
Require that `<!` or `<?` be followed by nonspace.
This prevents `</ div>` from being parsed as a comment.

Closes #1820.
2015-04-17 18:35:49 -07:00
Nikolay Yakimov
4229cf2d92 MD Reader: Smart ' after inline math
Closes #1909.

Adds new parser combinator to Parsing.hs

`a <+?> b`

:   if a succeeds, applies b and mappends
    output (if any) to result of a. If b fails,
    it's just a, if a fails, whole expression fails.
2015-04-18 01:23:41 +03:00
Nikolay Yakimov
3f5d5a0a76 RST Writer: treat headings in block quotes, etc as rubrics 2015-04-16 12:12:00 +03:00
Nikolay Yakimov
2337ef68fc Docx Writer: Take TOC title from toc-title metadata field 2015-04-14 13:16:19 +03:00
Nikolay Yakimov
deb95d380e RST Writer: Normalize headings to sequential levels
This is pretty much required by docutils.
2015-04-13 20:45:40 +03:00
John MacFarlane
5ae48b7eaf Fixed warning. 2015-04-12 22:06:44 -07:00
John MacFarlane
0439f6f964 Fixed toc depth in RST writer.
Previously the depth was being rendered as a floating point
number with a decimal point.  Thanks to Nick Yakimov for
noticing this.
2015-04-12 22:06:44 -07:00
John MacFarlane
fee04fbee0 Merge pull request #2072 from lierdakil/latex-reader-cleanup
LaTeX Reader: Code cleanup
2015-04-12 21:39:08 -07:00
John MacFarlane
a9628d0745 Text.Pandoc.PDF: more comprehensible errors on image conversion.
Closes #2067.
EPS can't be supported without shelling out to something like
ImageMagick, but at least we can avoid mysterious error messages.

We now get:

    pandoc: Unable to convert `circle.eps' for use with pdflatex.
    ! Package pdftex.def Error: File `circle-eps-converted-to.pdf' not found.

which seems more straightforward.
2015-04-12 21:18:21 -07:00
Nikolay Yakimov
b92d49092f LaTeX Reader: Code cleanup 2015-04-12 14:50:38 +03:00
Nikolay Yakimov
b2ba922638 ODT Writer: Figure captions
Works pretty much the same as Word writer.

Following styles are used for figures:

Figure -- for figure with empty caption
FigureWithCaption (based on Figure) -- for figure with caption
FigureCaption (based on Caption) -- for figure captions

Also, TableCaption (based on Caption) is used for table captions.

We need FigureWithCaption to set keepWithNext, in order to keep caption
with figure.
2015-04-12 00:34:03 +03:00
John MacFarlane
5a33032560 Removed redundat import. 2015-04-07 23:26:20 -07:00
John MacFarlane
250fbef94d DocBook reader: look inside "info" elements for section titles.
Closes #1931.
2015-04-07 22:15:20 -07:00
John MacFarlane
28497d484e RST writer: better handling of raw latex inline.
We use `` :raw-latex:`...` `` and add a definition for this
role to the template.

Closes #1961.
2015-04-07 22:07:38 -07:00
Julien Cretel
b28c846018 Markdown Reader: eliminate common subexpressions 2015-04-07 13:46:32 +01:00
John MacFarlane
b29a8a5516 EPUB writer: Take TOC title from toc-title metadata field. 2015-04-02 21:28:55 -07:00
John MacFarlane
8d39d03d05 Added "noProof" to docx syntax highlighting SourceCode style. 2015-04-01 15:21:55 -07:00
John MacFarlane
9a79538ac9 Merge pull request #2042 from lierdakil/issue1866
LaTeX Reader: check for block-level newcommand aliases in blockCommand
2015-03-31 09:44:15 -07:00
Nikolay Yakimov
f1eb1ab9cf Latex Reader: Block commands code cleanup 2015-03-31 14:32:42 +03:00
John MacFarlane
2b2f7fe15e Merge pull request #2035 from lierdakil/issue2031
Docx Writer/Reference: Add keepNext to objects w/ captions
2015-03-30 20:30:15 -07:00
John MacFarlane
ccb828894b Added CommonMark writer.
Added `Text.Pandoc.Writers.CommonMark`, exporting
`writeCommonMark`.
2015-03-29 23:42:42 -07:00
Nikolay Yakimov
6a0d500f99 Latex Reader: Guard against para starting with inline macro 2015-03-30 06:42:15 +03:00
Nikolay Yakimov
f3e8274d04 LaTeX Reader: check for block-level newcommand aliases in blockCommand 2015-03-30 05:37:00 +03:00
John MacFarlane
34c6ff1f60 Merge pull request #2038 from lierdakil/docx-hyphen-settings
Docx Writer: Copy hyphenation settings from reference.docx
2015-03-29 09:58:45 -07:00
John MacFarlane
91128aac99 Merge pull request #2037 from lierdakil/issue458
Docx Writer: support for --toc option
2015-03-29 09:47:49 -07:00
Matthew Pickering
f3aa03ee86 Docx Writer: Filter out illegal XML characters
Fixes #1992
2015-03-29 13:38:52 +01:00
Nikolay Yakimov
4d1e85a09e Docx Writer: Place toc after abstract, rather than before 2015-03-29 13:46:34 +03:00
Nikolay Yakimov
6ba37909fe Docx Writer: Copy hyphenation settings from reference.docx 2015-03-29 12:24:17 +03:00
Nikolay Yakimov
5ab839a187 Docx Writer: Initial support for --toc option (issue #458)
Creates a "dirty" TOC at the beginning of document, before abstract
2015-03-29 09:03:33 +03:00
Nikolay Yakimov
69d5085c11 Docx Writer: Add a style to figure images
Figures with empty captions use style "Figure"

Figures with nonempty captions use style "Figure with Caption", which is
based on "Figure", and additionally has keepNext set.
2015-03-29 08:02:18 +03:00
John MacFarlane
2d2e4c9ab2 Merge branch 'master' of https://github.com/rootzlevel/pandoc into rootzlevel-master
Conflicts:
	src/Text/Pandoc/Readers/Org.hs
2015-03-28 21:09:38 -07:00
John MacFarlane
8c6ad05ad3 Updated code example in Text.Pandoc. 2015-03-28 13:37:18 -07:00
John MacFarlane
6a3a04c428 Merge branch 'errortype' of https://github.com/mpickering/pandoc into mpickering-errortype
Conflicts:
	benchmark/benchmark-pandoc.hs
	src/Text/Pandoc/Readers/Markdown.hs
	src/Text/Pandoc/Readers/Org.hs
	src/Text/Pandoc/Readers/RST.hs
	tests/Tests/Readers/LaTeX.hs
2015-03-28 12:12:48 -07:00
Nikolay Yakimov
5f7639a0d6 Markdown Reader: Require nonempty value in mmd title block
`many1Till` will gobble up newline, and then whole following line will
match, so I had to use guard here.
2015-03-28 07:07:03 +03:00
Nikolay Yakimov
7091002966 Markdown Reader: Req. " " after key in mmd title block
Require space after key-value delimiter colon in mmd title block.
Issue #2026
Amend: parsec's `spaces` include newlines, but we don't want that. Had
to make custom `spaceNoNewline` parser here
2015-03-28 07:05:02 +03:00
Nikolay Yakimov
6960b2a4cc Markdown Reader: Disable meta exts for meta values
Disable all metadata block extensions when parsing metadata field
values. Issue #2026
2015-03-28 02:53:33 +03:00
Nikolay Yakimov
d09b7593f6 Docx Writer: Fix StyleMap
I've messed up badly with it, so it didn't work properly most of the
time. At the plus side, fallback mechanic is working wonderfully.
2015-03-24 19:24:29 +03:00
John MacFarlane
75a2a7ba69 Allow pipe tables with header but no body.
Closes #2017.
2015-03-23 20:26:56 -07:00
Matthew Pickering
65d67dcb51 Fix accidently usage of list monad instance 2015-03-23 00:14:02 +00:00
Matthew Pickering
84d6703ea7 Add missing import 2015-03-22 23:31:08 +00:00
Matthew Pickering
4ce6471c12 Factor out "returnState" into Parsing module 2015-03-22 21:47:28 +00:00
Matthew Pickering
9e150dd7cf HLint changes 2015-03-22 21:47:28 +00:00
Matthew Pickering
17b317268b Remove F Monad from Markdown reader 2015-03-22 21:47:28 +00:00
Matthew Pickering
7690e1d17f Generalise signature of addWarning 2015-03-22 20:11:30 +00:00
Matthew Pickering
9ca34cc9a9 Add check to see whether in a footnote to ParserState (to avoid circular footnotes) 2015-03-22 20:11:30 +00:00
Matthew Pickering
de093b4e6e Remove F monad from Parsing 2015-03-22 20:11:30 +00:00
Matthew Pickering
5dc902cbcc Changed parseWithWarnings to the more general returnWarnings parser transformer 2015-03-22 20:11:30 +00:00
Matthew Pickering
f6419a2691 Remove F monad from Org Reader. 2015-03-22 20:11:29 +00:00
Matthew Pickering
8271fb574e Added generalize function which can be used to lift specialised parsers.
Monad m => Parsec s st a -> Parsec T s st m a
2015-03-22 18:57:36 +00:00
John MacFarlane
b983adf0d0 Markdown writer: fixes for GHC 7.10. 2015-03-19 11:48:05 -07:00
Shahbaz Youssefi
e952d6633f Derive from Data and Typeable for libpandoc
This commit derives a few types from Data and Typeable used by
libpandoc.

Requires corresponding pull-request for Highlighting-Kate:

    https://github.com/jgm/highlighting-kate/pull/64

Signed-off-by: Shahbaz Youssefi <ShabbyX@gmail.com>
2015-03-19 17:07:18 +01:00
John MacFarlane
0a82e7e4b1 Fixed a compiler warning. 2015-03-17 17:06:19 -07:00
John MacFarlane
e0d234e54d Added CommonMark reader using cmark (libcmark bindings).
- Added commonmark as an input format.
- Added `Text.Pandoc.Readers.CommonMark.readCommonMark`.
- For now, we use the markdown writer to generate benchmark
  text for the CommonMark reader.  We can change this when we
  get a writer.
2015-03-17 16:15:57 -07:00
John MacFarlane
619b2e8ca2 Merge pull request #1968 from lierdakil/issue1607
Fixes for multiple docx writer style bugs.
2015-03-16 12:02:40 -07:00
Tom Leese
3dba66bf5d Replace occurrences of 'Github' with 'GitHub'
The website is called 'GitHub' afterall.
2015-03-16 09:28:45 +00:00
John MacFarlane
fcf1cd2f31 AsciiDoc writer: avoid wrapping after list marker.
Closes #1858.
2015-03-15 15:43:05 -07:00
John MacFarlane
451019290b AsciiDoc writer: insert some needed blank lines.
Closes #1860.
2015-03-15 14:48:01 -07:00
John MacFarlane
0deb7c507d Merge pull request #1989 from zudov/shortcut_ref_link_pr
Support shortcut reference links in markdown writer
2015-03-15 11:58:30 -07:00
John MacFarlane
967c13560e Really fix #1394.
This closes #1394, which actually wasn't fixed by the earlier commit.
This ensures that lists in speaker notes don't add "fragment" classes,
which can cause additional keypresses to be needed to advance a slide.
2015-03-14 23:32:35 -07:00
John MacFarlane
3b962a5277 Properly gobble spaces after \\.
Closes #2007.
2015-03-14 23:12:04 -07:00
John MacFarlane
348b383731 LaTeX reader: allow block content in \title{}.
Closes #2001.
2015-03-14 23:11:04 -07:00
Konstantin Zudov
b9f77ed03d Support shortcut reference links in markdown writer
Issue #1977

Most markdown processors support the [shortcut format] for reference links.
Pandoc's markdown reader parsed this shortcuts unoptionally.
Pandoc's markdown writer (with --reference-links option) never shortcutted links.

This commit adds an extension `shortcut_reference_links`. The extension is
enabled by default for those markdown flavors that support reading shortcut
reference links, namely:

    - pandoc
    - strict pandoc
    - github flavoured
    - PHPmarkdown

If extension is enabled, reader parses the shortcuts in the same way as
it preveously did. Otherwise it would parse them as normal text.

If extension is enabled, writer outputs shortcut reference links unless
doing so would cause problems (see test cases in `tests/Tests/Writers/Markdown.hs`).
2015-03-10 20:32:24 +02:00
Craig S. Bosma
513221f822 Org reader: add support for smart punctuation 2015-03-09 07:11:53 -05:00
Mathias Schenner
12bf0ff3e5 LaTeX reader: allow non-empty colsep in tables
The `tabular` environment allows non-empty column separators
with the "@{...}" syntax. Previously, pandoc would fail to
parse tables if a non-empty colsep was present. With this
commit, these separators are still ignored, but the table gets
parsed. A test case is included.
2015-03-08 15:47:39 +01:00
Mathias Schenner
1e3ef0e36f LaTeX reader: allow valign argument in tables
The `tabular` environment takes an optional parameter for
vertical alignment. Previously, pandoc would fail to parse
tables if this parameter was present. With this commit,
the parameter is still ignored, but the table gets
parsed. A test case is included.
2015-03-08 15:39:18 +01:00
John MacFarlane
efdc1691fa LaTeX reader: ignore options in \lstinline.
Rather than raising a parse error.  Closes #1997.
2015-03-07 19:58:49 -08:00
Nikolay Yakimov
c0c9b313e6 Docx Writer: set firstRow information in tables 2015-03-08 04:42:23 +03:00
John MacFarlane
0b42eb5f58 MediaWiki writer: spaces to underscores in wikilink URL.
This mimics MediaWiki itself.  Closes #1982.
2015-03-07 10:58:56 -08:00