Commit graph

8864 commits

Author SHA1 Message Date
John MacFarlane
f8e125f42d fillMediaBag: don't cause fatal error if resource not found.
Report warning instead and change image to its alt text.
2017-05-07 12:16:14 +02:00
John MacFarlane
af8860d26a Updated documentation for --extract-media. 2017-05-07 11:56:19 +02:00
John MacFarlane
400fe3188e Allow --extract-media to work with non-binary input formats.
If `--extract-media` is supplied with a non-binary input format,
pandoc will attempt to extract the contents of all linked images,
whether in local files, data: uris, or external uris.

They will be named based on the sha1 hash of the contents.

Closes #1583, #2289.

Notes:

- One thing that is slightly subideal with this commit is that
  identical resources will be downloaded multiple times.  To improve
  this we could have mediabag store an original filename/url +
  a new name.

- We might think about reusing some of this code, since more or less the
  same thing is done in the Docx, EPUB, PDF writers (with slight
  variations).
2017-05-07 11:45:33 +02:00
John MacFarlane
de0fd90051 Use fewer quickcheck tests for lua tests, to speed things up. 2017-05-07 11:45:06 +02:00
John MacFarlane
e15a4badff Simplify plumbing for document transformation. 2017-05-07 10:34:04 +02:00
John MacFarlane
82cc7fb0d4 Markdown reader: improved parsing of indented raw HTML blocks.
Previously we inadvertently interpreted indented HTML as
code blocks.  This was a regression.

We now seek to determine the indentation level of the contents
of an HTML block, and (optionally) skip that much indentation.

As a side effect, indentation may be stripped off of raw
HTML blocks, if `markdown_in_html_blocks` is used. This
is better than having things interpreted as indented code
blocks.

Closes #1841.
2017-05-06 22:56:16 +02:00
John MacFarlane
f20c89e243 LaTeX reader: Better handling of comments inside math environments.
This solves a problem with commented out `\end{eqnarray}` inside
an eqnarray (among other things).

Closes #3113.
2017-05-06 22:16:43 +02:00
schrieveslaach
ddf2524477 Fix keyval funtion: pandoc did not parse options in braces correctly.… (#3642)
* Fix keyval funtion: pandoc did not parse options in braces correctly. Additionally, dot, dash, and colon were no valid characters

* Add | as possible option value

* Improved code
2017-05-06 15:09:29 +02:00
John MacFarlane
f422000197 Small reformatting in MANUAL. 2017-05-06 15:01:54 +02:00
John MacFarlane
2f3d62cb86 ConTeXt template: improved font handling.
simplefonts is now obsolete in ConTeXt.

This patch comes from Pablo Rodríguez via jgm/pandoc-templates#247.
2017-05-06 14:58:32 +02:00
Albert Krewinkel
bf44b88522
Drop redundant import of sort
This was left in accidentally.
2017-05-06 11:32:38 +02:00
Albert Krewinkel
da8c153a68
Org reader: support macros
Closes: #3401
2017-05-06 11:00:32 +02:00
John MacFarlane
9f0a80457f Revert "SelfContained: special handling for css @import."
This reverts commit 89b3fcc8e0.
2017-05-05 23:23:49 +02:00
John MacFarlane
89b3fcc8e0 SelfContained: special handling for css @import.
We now avoid creating a data URI for the url under an
@import.
2017-05-05 23:03:31 +02:00
John MacFarlane
c1b45adda0 SelfContained: Handle url() inside material retrieved from url().
This can happen e.g. with an @import of a google web font.
(What is imported is some CSS which contains an url reference
to the font itself.)

Also, allow unescaped pipe (|) in URL.

This is intended to help with #3629, but it doesn't seem to
work.
2017-05-05 17:03:27 +02:00
John MacFarlane
1668998c46 Include backtick_code_blocks extension in mardkown_mmd.
Closes #3637.
2017-05-04 16:36:35 +02:00
Alexander Krotov
430e6be1f4 Muse writer: omit automatic header identifiers (#3633) 2017-05-04 11:36:52 +02:00
Albert Krewinkel
57cba3f1d5
Org reader: support table.el tables
Closes #3314
2017-05-03 22:43:34 +02:00
Albert Krewinkel
df23d96c89
Generalize tableWith, gridTableWith
The parsing functions `tableWith` and `gridTableWith` are generalized to
work with more parsers. The parser state only has to be an instance of
the `HasOptions` class instead of requiring a concrete type. Block
parsers are required to return blocks wrapped into a monad, as this
makes it possible to use parsers returning results wrapped in `Future`s.
2017-05-02 23:41:45 +02:00
David A Roberts
79855ef934 Markdown writer: better escaping for links (#3628)
Previously the Markdown writer would sometimes create links where there
were none in the source.  This is now avoided by selectively escaping bracket
characters when they occur in a place where a link might be created.

Closes #3619.
2017-05-03 12:19:45 +02:00
schrieveslaach
6e55e6837a LaTeX reader: Add support for tabularx environment (#3632) 2017-05-03 12:16:48 +02:00
Mauro Bieg
e02cfcdeac Markdown Writer: put space before reference link definitions
Fixes #3630 (#3631).

Previously the attributes in link reference definitions did not have a space preceding.
2017-05-03 12:13:25 +02:00
John MacFarlane
cd2551c16c Added PandocResourceNotFound error.
Use this instead of PandocIOError when a resource is not
found in path.

This improves the error message in this case, see #3629.
2017-05-02 16:00:04 +02:00
John MacFarlane
022d58e02a stack.yaml: use lts-8.12.
This should fix the build failure on travis.
2017-05-02 09:24:33 +02:00
David A Roberts
c0192132cf Markdown writer: Case-insensitive reference links. (#3616)
Ensure that we do not generate reference links
whose labels differ only by case.

Also allow implicit reference links when the link
text and label are identical up to case.

Closes #3615.
2017-05-02 09:00:37 +02:00
Alexander Krotov
5d529e30c7 FB2 writer: Add support for "lang" metadata (#3625) 2017-05-02 08:57:08 +02:00
Albert Krewinkel
ae21a8bb2a
Lua filter: fall-back to global filters when none is returned
The implicitly defined global filter (i.e. all element filtering
functions defined in the global lua environment) is used if no filter is
returned from a lua script. This allows to just write top-level
functions in order to define a lua filter. E.g

    function Emph(elem) return pandoc.Strong(elem.content) end
2017-04-30 17:06:54 +02:00
Albert Krewinkel
1afdccfa8c
Document lua filters 2017-04-30 15:55:45 +02:00
Albert Krewinkel
2e916b3abf
Lua module: simplify Attributes, rename to Attr
Attributes was written to behave much like a normal table, in order to
simplify working with it. However, all Attr containing elements were
changed to provide panflute-like accessors to Attr components, rendering
the previous approach unnecessary.
2017-04-30 11:50:09 +02:00
Albert Krewinkel
3362cb89d9
Lua module: make Header argument order consistent
Attributes are always passed as the last element, making it possible to
omit this argument.  Argument order for `Header` was wrong and is fixed.
2017-04-30 11:28:03 +02:00
Albert Krewinkel
01e8df2e53
Lua module: add example for usage of read 2017-04-30 11:24:48 +02:00
Albert Krewinkel
31caa616a9 Provide shared F monad functions for Markdown and Org readers
The `F` monads used for delayed evaluation of certain values in the
Markdown and Org readers are based on a shared data type capturing the
common pattern of both `F` types.
2017-04-30 10:59:20 +02:00
Alexander Krotov
97addc2a17 Add returnF to Text.Pandoc.Parsing 2017-04-30 10:59:20 +02:00
Alexander Krotov
540f3d49ef Org reader: Avoid creating nullMeta by applying setMeta directly 2017-04-30 10:58:19 +02:00
John MacFarlane
730796ee31 LaTeX writer: Fix problem with escaping in lstinline.
Previously the LaTeX writer created invalid LaTeX
when `--listings` was specified and a code span occured
inside emphasis or another construction.

This is because the characters `%{}\` must be escaped
in lstinline when the listinline occurs in another
command, otherwise they must not be escaped.

To deal with this, adoping Michael Kofler's suggestion,
we always wrap lstinline in a dummy command `\passthrough`,
now defined in the default template if `--listings` is
specified.  This way we can consistently escape the
special characters.

Closes #1629.
2017-04-29 11:05:44 +02:00
John MacFarlane
e76b672414 LaTeX writer: don't use lstinline it \item[..].
If you do, the contents of item disappear or are misplaced.
Use `\texttt` instead.

Closes #645.
2017-04-28 12:03:59 +02:00
Alexander Krotov
c346a8a7be Ms writer: make use of already defined render' (#3613) 2017-04-28 10:04:09 +02:00
Alexander Krotov
e97e9cd6a3 Muse writer: Do not reflow directives (#3614)
Directives at the beginning of documents cannot
span multiple lines so they must not be reflown.
2017-04-28 10:03:39 +02:00
Albert Krewinkel
24ef672132 Lua module: provide simple read format parser
A single `read` function parsing pandoc-supported formats is added to
the module. This is simpler and more convenient than the previous method
of exposing all reader functions individually.
2017-04-26 23:28:40 +02:00
Albert Krewinkel
c2567b2bd0 API change: move writer functions to Text.Pandoc.Writers
Writer helper functions were defined in the top-level Text.Pandoc
module. These functions are moved to the Writer submodule as to enable
reuse in other submodules.
2017-04-26 23:28:40 +02:00
Albert Krewinkel
0e107a305f API change: move reader functions to Text.Pandoc.Readers
Reader helper functions were defined in the top-level Text.Pandoc
module. These functions are moved to the Readers submodule as to enable
reuse in other submodules.
2017-04-26 23:28:40 +02:00
Albert Krewinkel
3ac23ab615 API change: move extension handling to Text.Pandoc.Extensions
Extension parsing and processing functions were defined in the top-level
Text.Pandoc module.  These functions are moved to the Extensions
submodule as to enable reuse in other submodules.
2017-04-26 23:28:40 +02:00
Albert Krewinkel
9cd20c9b8b Lua filter: allow filtering of meta data only 2017-04-26 23:28:40 +02:00
Albert Krewinkel
5416fb14ab Lua filter: allow natural access to meta elements
Meta elements that are treated as lua tables (i.e. MetaList,
MetaInlines, MetaBlocks, and MetaMap), are no longer wrapped in an
additional table but simply marked via a metatable.  This allows
treating those meta values just like normal tables, while still making
empty elements of those values distinguishable.
2017-04-26 23:28:40 +02:00
schrieveslaach
a29fa15a7b LaTeX reader: Add basic support for hyphenat package (#3603) 2017-04-26 12:05:13 +02:00
Alexander Krotov
256e3a6a5d Simplify linkText in Text.Pandoc.Readers.TWiki (#3605)
Avoid constructing list of one element ([B.str url]) just to flatten it
back with mconcat.
2017-04-26 12:04:28 +02:00
schrieveslaach
81548960d5 LaTeX reader: Add support for \vdots (#3607) 2017-04-26 12:03:07 +02:00
John MacFarlane
66b08391b3 HTML line block: Use class instead of style attribute.
We now issue `<div class="line-block">` and include a
default definition for `line-block` in the default
templates, instead of hard-coding a `style` on the
div.

Closes #1623.
2017-04-25 23:07:30 +02:00
John MacFarlane
ee160d7c4c LaTeX writer: fix error with line breaks after empty content.
LaTeX requires something before a line break, so we insert a
`~` if no printable content has yet been emitted.

Closes #2874.
2017-04-25 15:00:27 +02:00
John MacFarlane
d17f0dab84 LaTeX reader: better support for subfigure package.
A figure with two subfigures turns into two pandoc
figures; the subcaptions are used and the main caption
ignored, unless there are no subcaptions.

Closes #3577.
2017-04-24 23:39:14 +02:00