Commit graph

6687 commits

Author SHA1 Message Date
Wandmalfarbe
b7a3e385e7 Add additional listings languages. 2019-10-03 08:54:31 -07:00
John MacFarlane
18d11103f5 RST reader: don't strip final underscore from absolute URI.
Partially addresses #5763.
2019-09-29 13:01:00 -07:00
John MacFarlane
746c92a41a Raise error on unsupported extensions. Closes #4338.
+ An error is now raised if you try to specify (enable or
  disable) an extension that does not affect the given
  format, e.g. `docx+pipe_tables`.

+ The `--list-extensions[=FORMAT]` option now lists only
  extensions that affect the given FORMAT.

+ Text.Pandoc.Error: Add constructors `PandocUnknownReaderError`,
  `PandocUnknownWriterError`, `PandocUnsupportedExtensionError`.
  [API change]

+ Text.Pandoc.Extensions now exports `getAllExtensions`,
  which returns the extensions that affect a given format
  (whether enabled by default or not). [API change]

+ Text.Pandoc.Extensions: change type of `parseFormatSpec`
  from `Either ParseError (String, Extensions -> Extensions)`
  to `Either ParseError (String, [Extension], [Extension])`
  [API change].

+ Text.Pandoc.Readers: change type of `getReader` so it returns
  a value in the PandocMonad instance rather than an Either
  [API change].  Exceptions for unknown formats and unsupported
  extensions are now raised by this function and need not be handled by
  the calling function.

+ Text.Pandoc.Writers: change type of `getWriter` so it returns
  a value in the PandocMonad instance rather than an Either
  [API change].  Exceptions for unknown formats and unsupported
  extensions are now raised by this function and need not be handled by
  the calling function.
2019-09-29 11:43:17 -07:00
John MacFarlane
03d4e6b9ef More throwError in place of fail. 2019-09-28 14:45:38 -07:00
John MacFarlane
63a1e05dd1 Replace some more fails with throwErrors. 2019-09-28 13:42:37 -07:00
John MacFarlane
df74eea69a Use throwError instead of fail when appropriate. 2019-09-28 12:36:09 -07:00
John MacFarlane
c86691fb84 Use Prelude.fail to avoid ambiguity with fail from GHC.Base. 2019-09-28 11:56:51 -07:00
John MacFarlane
7d6783006a LogMessage: change UnknownExtension -> CouldNotDeduceFormat 2019-09-27 09:27:56 -07:00
Nils Carlson
8028de3322 odt: Add external option for native numbering
This adds an external options +native_numbering to the
ODT writer enabling enumeration of figures and tables in
ODT output.
2019-09-24 15:23:59 -07:00
Eigil Rischel
d42308129a LaTeX reader: Add 'tikzcd' to list of special environments.
This allows it to be processed by filters, in the same way that
one can do for 'tikzpicture'
2019-09-24 14:19:45 -07:00
John MacFarlane
f223196c35 Man writer: suppress non-absolute link URLs.
Motivation: in a man page there's not much use for relative URLs,
which you can't follow.  Absolute URLs are still useful.  We previously
suppressed relative URLs starting with '#' (purely internal links),
but it makes sense to go a bit farther.

Closes #5770.
2019-09-23 17:46:39 -07:00
John MacFarlane
9abed45879 RST reader: Fixed parsing of indented blocks.
We were requiring consistent indentation, but this
isn't required by RST, as long as each nonblank
line of the block has *some* indentation.

Closes #5753.
2019-09-22 12:01:45 -07:00
Nikolay Yakimov
9b6ee81c19 [Docx Writer] Re-use Readers.Docx.Parse for StyleMap (#5766)
* [Docx Parser] Move style-parsing-specific code to a new module

* [Docx Writer] Re-use Readers.Docx.Parse.Styles for StyleMap

* [Docx Writer] Move Readers.Docx.StyleMap to Writers.Docx.StyleMap

It's never used outside of writer code, so it makes more sense to scope it under writers really.
2019-09-22 12:00:35 -07:00
John MacFarlane
d247e9f72e Make plain output plainer.
Previously we used the following Project Gutenberg conventions
for plain output:

- extra space before and after level 1 and 2 headings
- all-caps for strong emphasis `LIKE THIS`
- underscores surrounding regular emphasis `_like this_`

This commit makes `plain` output plainer. Strong and Emph
inlines are rendered without special formatting.  Headings
are also rendered without special formatting, and with only
one blank line following.

To restore the former behavior, use `-t plain+gutenberg`.

API change: Add `Ext_gutenberg` constructor to `Extension`.

See #5741.
2019-09-22 11:33:09 -07:00
John MacFarlane
b64410ff9c Use HsYAML-0.2.0.0
Most of this is due to @vijayphoenix (#5704), but it
needed some revisions to integrate with current
master, and to use the released HsYAML.

Closes #5704.
2019-09-22 10:38:15 -07:00
Nikolay Yakimov
14b00517ae [Docx Writer] Consistently use style names, not style ids
Styles that this change affects: paragraph styles: Author, Abstract,
Compact, Figure, Captioned Figure, Image Caption, First Paragraph,
Source Code, Table Caption, Definition, Definition Term; character
styles: Verbatim Char, token styles (those with names ending in Tok)
2019-09-21 11:37:21 -07:00
Nikolay Yakimov
4a5e389f21 [Docx Writer] Code clean-up
Reduce code duplication, remove redundant brackets
2019-09-21 11:18:47 -07:00
Nikolay Yakimov
c113ca6717 [Docx Reader] Use style names, not ids, for assigning semantic meaning
Motivating issues: #5523, #5052, #5074

Style name comparisons are case-insensitive, since those are
case-insensitive in Word.

w:styleId will be used as style name if w:name is missing (this should
only happen for malformed docx and is kept as a fallback to avoid
failing altogether on malformed documents)

Block quote detection code moved from Docx.Parser to Readers.Docx

Code styles, i.e. "Source Code" and "Verbatim Char" now honor style
inheritance

Docx Reader now honours "Compact" style (used in Pandoc-generated docx).
The side-effect is that "Compact" style no longer shows up in
docx+styles output. Styles inherited from "Compact" will still
show up.

Removed obsolete list-item style from divsToKeep. That didn't
really do anything for a while now.

Add newtypes to differentiate between style names, ids, and
different style types (that is, paragraph and character styles)

Since docx style names can have spaces in them, and pandoc-markdown
classes can't, anywhere when style name is used as a class name,
spaces are replaced with ASCII dashes `-`.

Get rid of extraneous intermediate types, carrying styleId information.
Instead, styleId is saved with other style data.

Use RunStyle for inline style definitions only (lacking styleId and styleName);
for Character Styles use CharStyle type (which is basicaly RunStyle with styleId
and StyleName bolted onto it).
2019-09-21 11:18:15 -07:00
Nikolay Yakimov
fd14ad5261 [Docx Reader] Code clean-up
Reduce code duplication, remove redundant brackets, use newtype instead of data where appropriate
2019-09-21 11:18:15 -07:00
John MacFarlane
7b879f867c Changes to Slides to be more flexible with Div structure.
Previously if you had

```
::: #foo
c
:::
```

slide level would be 1, not 2.
2019-09-20 23:15:41 -07:00
Ben Steinberg
7389919bb4 Preserve built-in styles in DOCX with custom style (#5670)
This commit prevents custom styles on divs and spans from overriding
styles on certain elements inside them, like headings, blockquotes,
and links. On those elements, the "native" style is required for the
element to display correctly. This change also allows nesting of
custom styles; in order to do so, it removes the default "Compact"
style applied to Plain blocks, except when inside a table.
2019-09-20 22:13:29 -07:00
John MacFarlane
6d4b35dfaf Bug fixes to EPUB chapter splitting. 2019-09-20 17:20:36 -07:00
John MacFarlane
fb93954a26 MediaWiki: skip optional {{table}} template.
See https://en.wikipedia.org/wiki/Template:Table

Closes #5757.
2019-09-19 23:38:48 -07:00
John MacFarlane
d6b6000217 Clarify warning for missing title.
Closes #5760.
2019-09-19 22:40:43 -07:00
John MacFarlane
3a97e5b310 EPUB writer: make --epub-chapter-level work again.
It was temporarily broken by the latest change to chapter
splitting code.
2019-09-19 18:38:02 -07:00
John MacFarlane
8408e58474 EPUB writer: improve splitting into chapters.
+ Use makeSection from T.P.Shared.  This deals better with
  embedded divs. (Closes #5761.)

+ Remove chapter-title class from chapter h1, for now.
  (Reverts one change made earlier; we may revisit this
  in light of #5749.)

+ Avoid issuing warning multiple times when title not set (see #5760).
2019-09-19 18:17:23 -07:00
John MacFarlane
5a85789185 Remove admonition-title remnants.
Completes 8e01ccb41d
2019-09-19 16:09:38 -07:00
John MacFarlane
c42542428c LaTeX writer: use \hspace{0pt} for 0-width space U+200B.
Closes #5756.
2019-09-18 13:27:02 -07:00
John MacFarlane
297afd0aa9 PDF: Fix test for Cygwin. See #5451. 2019-09-16 08:30:57 -07:00
John MacFarlane
5d1a58b3d8 Add chapter-title class to EPUB chapter title h1 elements.
See #5269.
2019-09-14 11:44:11 -07:00
John MacFarlane
47358831a4 EPUB toChapters: don't treat "refs" Div specially.
This should make toChapters work better if there are
Divs around sections.
2019-09-14 11:36:21 -07:00
John MacFarlane
65f73de28a Better message for PandocShouldNeverHappenError. 2019-09-12 08:50:12 -07:00
John MacFarlane
4f909c626c Change exit codes.
It's good practice not to use codes 1-2 for user errors.
Also, we used 65 for two different errors.

- PandocAppError was 1, is now 4
- PandocOptionError was 2, is now 6
- PandocMakePDFError was 65, is now 66
2019-09-12 08:46:38 -07:00
John MacFarlane
88dc6fac5d Add --shift-heading-level-by option.
Deprecate --base-heading-level.

The new option does everything the old one does, but also
allows negative shifts.  It also promotes the document
metadata (if not null) to a level-1 heading with a +1 shift,
and demotes an initial level-1 heading to document metadata
with a -1 shift. This supports converting documents that
use an initial level-1 heading for the document title.

Closes #5615.
2019-09-10 23:16:13 -07:00
John MacFarlane
a64b3ab61f Pass value of --dpi to rsvg-convert...
when converting SVG to PDF in the process of creating a PDF.

Closes #5721.
2019-09-10 21:17:51 -07:00
John MacFarlane
4778d03473 LaTeX reader: Fix parsing of optional arguments that contain braced text.
Closes #5740.
2019-09-09 21:33:16 -07:00
John MacFarlane
8696725cd9 Add -L option as shortcut for --lua-filter. 2019-09-08 22:37:38 -07:00
Brian Leung
0558ea9836 Org reader: modify handling of example blocks. (#5717)
* Org reader: allow the `-i` switch to ignore leading spaces.

* Org reader: handle awkwardly-aligned code blocks within lists.

Code blocks in Org lists must have their #+BEGIN_ aligned in a
reasonable way, but their other components can be positioned otherwise.
2019-09-08 22:34:10 -07:00
John MacFarlane
9f984ff26a Replace Element and makeHierarchical with makeSections.
Text.Pandoc.Shared:

+ Remove `Element` type [API change]
+ Remove `makeHierarchicalize` [API change]
+ Add `makeSections` [API change]
+ Export `deLink` [API change]

Now that we have Divs, we can use them to represent the structure
of sections, and we don't need a special Element type.
`makeSections` reorganizes a block list, adding Divs with
class `section` around sections, and adding numbering
if needed.

This change also fixes some longstanding issues recognizing
section structure when the document contains Divs.
Closes #3057, see also #997.

All writers have been changed to use `makeSections`.
Note that in the process we have reverted the change
c1d058aeb1
made in response to #5168, which I'm not completely
sure was a good idea.

Lua modules have also been adjusted accordingly.
Existing lua filters that use `hierarchicalize` will
need to be rewritten to use `make_sections`.
2019-09-08 22:20:19 -07:00
John MacFarlane
1ccff3339d Revert changes to hierarchicalizeWithIds.
Revert "hierarchicalize: ensure that sections get ids..."
This reverts commit 212406a61d.

Revert "Improve detection of headings in Divs by hierarchicalize."
This reverts commit 6e2cfd6c97.

Revert "Shared.hierarchicalize: improve handling of div and section structure."
This reverts commit 345b33762e.
2019-09-08 21:56:42 -07:00
Mauro Bieg
d96a5629bc Emit warning on -f latex -o out.pdf (#5736)
add UnusualConversion to LogMessage [API change]
2019-09-08 16:03:13 -07:00
John MacFarlane
212406a61d hierarchicalize: ensure that sections get ids...
even if they're in divs.  Improves #3057.
2019-09-06 09:05:52 -07:00
John MacFarlane
6e2cfd6c97 Improve detection of headings in Divs by hierarchicalize.
The structure

```
<h1>one</h1>
<div>
<h1>two</h1>
</div>
```

should create two coordinate sections, not a section with
a subsection.  Now it does.

Extends #3057.
2019-09-06 08:44:59 -07:00
John MacFarlane
345b33762e Shared.hierarchicalize: improve handling of div and section structure.
Previously Divs were opaque to hierarchicalize, so headings
inside divs didn't get into the table of contents, for
example (#3057).

Now hierarchicalize treats Divs as sections when appropriate.
For example, these structures both yield a section and a
subsection:

``` html
<div>
<h1>one</h1>
<div>
<h2>two</h2>
</div>
</div>
```
``` html
<div>
<h1>one</h1>
<div>
<h1>two</h1>
</div>
</div>
```

Note that

``` html
<h1>one</h1>
<div>
<h2>two</h2>
</div>
<h1>three</h1>
```

gets parsed as the structure

    one
      two
    three

which may not always be desirable.

Closes #3057.
2019-09-05 22:37:13 -07:00
John MacFarlane
0534258780 Roff reader: Better support for 'while'. 2019-09-05 21:13:50 -07:00
John MacFarlane
75f6af5c12 Roff reader: improve handling of groups. 2019-09-05 07:01:31 -07:00
John MacFarlane
0e31483d43 asciidoc writer: don't include + in code blocks for regular asciidoc.
This is asciidoctor-specific.

Amends 98ee6ca289.
2019-09-04 14:57:22 -07:00
John MacFarlane
e7b8728ad2 Roff reader: Fix problem parsing comments before macro. 2019-09-04 10:55:56 -07:00
John MacFarlane
4967fd4208 Roff reader: more improvements in parsing conditionals. 2019-09-04 10:02:49 -07:00
John MacFarlane
e4cca4cf67 Roff readers: better parsing of groups.
We now allow groups where the closing `\\}` isn't at the
beginning of a line.

Closes #5410.
2019-09-04 09:24:42 -07:00