Commit graph

6699 commits

Author SHA1 Message Date
John MacFarlane
da070bea47 Use typeMismatch. 2019-10-07 00:04:47 -07:00
John MacFarlane
6e537aeda8 T.P.App.Opt: custom FromJSON instance for LineEnding.
So either CRLF or crlf will work.
2019-10-06 23:48:34 -07:00
John MacFarlane
3ef0cdd8f9 Opt: Change optHighlightStyle to a Maybe String instead of Maybe Style.
Do the parsing/loading of themes later, after option parsing.
2019-10-06 23:15:52 -07:00
John MacFarlane
5f8254c4b9 Code cleanup 2019-10-06 22:26:26 -07:00
John MacFarlane
fcfdc8210f Text.Pandoc.App.Opt: Remove optBaseHeaderLevel from Opt.
We now just use optShiftHeadingLevelBy, to avoid redundancy.
2019-10-06 21:31:28 -07:00
John MacFarlane
cf1703396c Text.Pandoc.App.Opt: Change optShiftHeadingLevel to optShiftHeadingLevelBy...
to match the option.
2019-10-06 16:55:12 -07:00
John MacFarlane
2e35eafd12 Text.Pandoc.App.Opt: more convenient To/FromJSON instances.
Make the field names like `strip-empty-paragraphs` rather
than `optStripEmptyParagraphs`.
2019-10-06 16:25:05 -07:00
Alexander Krotov
6898445548 hlint Muse writer 2019-10-04 18:29:00 +03:00
Alexander Krotov
701ae8634e hlint FB2 reader 2019-10-04 18:28:45 +03:00
Alexander Krotov
8efc677368 Fix all hlint warnings in Muse reader 2019-10-04 18:22:05 +03:00
John MacFarlane
638c2ed460 Fix compiler warnings on ghc 8.8. 2019-10-04 07:20:51 -07:00
John MacFarlane
7caaa3d5d6 Minor ghc 8.8 fixups. 2019-10-03 22:41:24 -07:00
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