Commit Graph
8853 Commits
Author SHA1 Message Date
John MacFarlane 7a569b9c8f Initialize some missing fields in pandoc-server.
writerEpubTitlePage, writerChunkTemplate, writerListTables.
2024-09-08 09:41:17 -07:00
John MacFarlane e589dd62d7 Docx writer: Support --number-offsets. 2024-09-08 08:29:23 -07:00
John MacFarlane bdcbb67168 T.P.Opp: Change default for optNumberOffset to [].
This behaves the same as `[0,0,0,0,0]`.
2024-09-08 08:29:23 -07:00
John MacFarlane 3e6eb1cde2 Text.Pandoc.Shared: add makeSectionsWithOffsets [API change].
This is like `makeSections` but has an additional parameter
specifying number offsets, for use with the `--number-offset` option.

Use `makeSectionsWithOffsets` in HTML writer instead of ad hoc
and inefficient number-adjusting code.

Clarify MANUAL.txt: the `--number-offset` option should only
directly affect numbering of the first section heading in
a document; subsequent headings will increment normally.
Fix test output for #5071 to reflect this.
2024-09-08 08:29:23 -07:00
John MacFarlane a27dad6f68 Add options to change table/figure caption positions.
+ Add command line options `--table-caption-position` and
  `--figure-caption-position`. These allow the user to specify whether
  to put captions above or below tables and figures, respectively.
  The following output formats are supported: HTML (and related such
  as EPUB), LaTeX (and Beamer), Docx, ODT/OpenDocument, Typst.

+ Text.Pandoc.Options: add `CaptionPosition` and new
  `WriterOptions` fields `writerFigureCaptionPosition` and
  `writerTableCaptionPosition` [API change].

+ Text.Pandoc.Opt: add `Opt` fields `optFigureCaptionPosition` and
  `optTableCaptionPosition` [API change].

+ Docx writer: make table/figure rendering sensitive to caption
  position settings.

+ OpenDocument writer: make table/figure rendering sensitive to
  caption position settings.

+ Typst writer/template: implement figure caption positions by
  triggering a show rule in the default template, which determines caption
  positions for figures and tables globally.

+ LaTeX writer: make table/figure rendering sensitive to caption
  position settings. Closes #5116.

+ HTML writer/template: make `<figcaption>` placement sensitive to caption
  position settings.  For tables, `<caption>` must be the first element,
  and positioning is determined by CSS, for here we set a variable
  which the default template is sensitive to.
2024-09-08 08:29:09 -07:00
John MacFarlane 74221a0ccb LaTeX reader: math environments don't have bracketed options.
We were checking for these, and that caused problems if the math
began with `[`.

Closes #10160.
2024-09-07 08:39:09 -07:00
John MacFarlane 7d672fccbd Markdown writer: make math sensitive to tex_math_gfm extension.
This means that in GFM output, the "new style" math will be used
by default, e.g.

    $`x=y`$

    ```math
    x = y
    ```

To defeat this and get the older behavior, namely

    $x=y$

    $$x=y$$

one could use `-t gfm-tex_math_gfm`.
See #9121.
2024-09-05 19:38:43 -07:00
John MacFarlane 89c0052fd6 HTML writer: don't add doc-biblioref role to every link...
in a citation; only to links to the bibliography. Closes #10156.
2024-09-05 13:38:43 -07:00
John MacFarlane 180d2b5a02 RTF reader: handle images inside shp contexts.
We look for the `pib` property and parse image data inside its value.

Closes #10145.
2024-09-03 22:19:04 -07:00
John MacFarlane b3d721b4ab Typst writer: don't include trailing semicolon after...
`@` style citations with suffixes.

Closes #10148.
2024-09-03 20:14:33 -07:00
John MacFarlane 6be41d1c62 ANSI writer: Remove Figure and Table labels and numbers. 2024-09-03 14:26:53 -07:00
John MacFarlane f048d8110e Text.Pandoc.Format: change formatFromFilePaths...
so that it is smarter about URLs.  URLs are parsed, and we take the
format from the path component, if present.

This means that `https://emacs.org/` will be treated as HTML, while
`https://emacs.org/sample.org` will be treated as Org.

Closes #10141.
2024-09-03 11:01:48 -07:00
John MacFarlane 6808788b21 HTML reader: only parse main element's contents (if present).
If main has an id or class, we include a div with that id or class;
otherwise just the contents.

Closes #10140.
2024-09-03 10:40:08 -07:00
John MacFarlane 76521b66e4 Replace some 'tail' with safe 'drop 1'. 2024-09-02 21:48:08 -07:00
John MacFarlane 826f7879a4 Change default --pdf-engine via HTML to WeasyPrint.
wkhtmltopdf is deprecated.  weasyprint is the easiest-to-install,
maintained alternative.  For better results, one might prefer
pagedjs-cli.

Closes #10142.
2024-09-02 21:36:49 -07:00
Evan Silberman 403271e244 Render tables in ANSI writer
This table renderer is pretty basic and uses minimal non-data ink. It
presently renders correctly in the presence of colspans but not
rowspans.  Code blocks in table cells are never syntax highlighted
because the present approach of using skylighting's ANSI output is
incompatible with the reflowing done by doclayout's block elements.
(i.e., you get terminal escapes littering your output). No attempt is
made to shrink table width below the available maximum.
2024-09-02 14:51:52 -07:00
Evan Silberman 314a85b150 Tweak code block output
Code blocks are indented four spaces. Unhighlighted code blocks are
colored red.

A quirk is that code blocks that are numbered (class numberLines) but
don't set a language get run through skylighting, but the code itself
isn't actually highlighted, so the default red style won't get applied
to them. This isn't reasonably solvable right now.
2024-09-02 11:09:10 -07:00
Evan Silberman 5803f1e071 Support numbered sections 2024-09-02 11:09:10 -07:00
Evan Silberman 485196e9cc Revamp display of headings
All headings at the document top-level are green. Headings inner to
structures like blockquotes and lists are not. H1 is bold and all caps.
H2 is bold. H3-H6 are italic. The design here is meant to be relatively
boring/simple and allow telling H1 and H2 apart from each other and from
the remaining heading levels.
2024-09-02 11:09:10 -07:00
Evan Silberman ddfd8de5ec Remove default 4-column margin 2024-09-02 11:09:10 -07:00
Evan Silberman bf38a1583c Improve display of figure captions 2024-09-02 11:09:10 -07:00
Evan Silberman c2ede57213 Underline links 2024-09-02 11:09:10 -07:00
Evan Silberman aabbda2fa2 Make the horizontal rule less whimsical 2024-09-02 11:09:10 -07:00
Evan Silberman ec9ec839c9 Hide DocLayout's link to avoid clashes 2024-09-02 11:08:13 -07:00
Evan Silberman d09477400f Introduce ANSI writer for formatted console output
The ANSI writer (-t ansi) outputs a document formatted with ANSI control
sequences for reading on the console.

Most Pandoc elements are supported and printed in a reasonable way, if
not always ideally. This version does no detection of terminal
capabilities nor does it fall back to different output styles for
less-capable terminals.

Some gory details:

- Title blocks are formatted with modest extravagance in --standalone
  mode.
- Strong, Emph, Underline, and Strikeout spans are all formatted
  accordingly using SGR codes (which will be silently ignored by
  terminals that don't support them).
- Headings have somewhat arbitrary styles applied to them that
  probably need immediate improvement.
- Blockquotes and all flavors of list look pretty good.
- Code spans are colored magenta-on-white, which on the author's
  terminal looks kind of like the pinkish treatment of code spans used
  by many stylesheets. This probably isn't a good final decision.
- Code blocks are formatted by Skylighting's formatANSI using standard
  writer options and included directly in the output. This has some
  issues; see code comments.
- Links are printed with OSC 8 to create hyperlinks and colored cyan.
  The author's terminal automatically adds a dotted-underline to OSC 8
  hyperlinks, but only colors them differently on command-mouseover.
  Setting an underlined style on links may be more broadly accessible.
  OSC 8 support is not checked for, so on terminals not supporting it or
  with support disabled, the link text will be colored but not do
  anything and the links will not be printed.
- Images are displayed as their alt text. Support for the Kitty and
  iTerm 2 inline image protocols is planned. Supporting other terminals
  by using Chafa (https://hpjansson.org/chafa/) to print sixels etc would
  be cool too but the author would have to do some FFI stuff and it would
  add a dependency to Pandoc.
- Tables are replaced with a useless placeholder. Table output using
  box-drawing characters is desired.
- Subscripts and Superscripts are just parenthesized when accurate Unicode
  representations aren't available. Because these span types could have
  all kinds of semantics, there's not an obvious thing to do with them.
- Simple math is translated to Pandoc inlines using existing
  functionality.  An ambitious person could look into emulating the
  console-mode math output of a computer algebra system, or rendering each
  display math element as an image with TeX or Typst and including it, or
  some other thing.
2024-09-02 11:08:13 -07:00
Evan Silberman 44bd58cb64 Expose formatANSI from skylighting-format-ansi
For use by the ANSI writer
2024-09-02 11:07:41 -07:00
Evan Silberman 3ca82f21b0 Hide Color type from DocLayout to avoid clash 2024-09-02 11:07:41 -07:00
Evan Silberman 1ed9692e74 Move to{Sub,Super}scriptInline to T.P.W.Shared 2024-09-02 11:07:41 -07:00
John MacFarlane 1393cda27d LaTeX reader: parse nested tabular environments.
Closes #4746.
2024-09-01 11:04:46 -07:00
John MacFarlane 4a3b002a63 HTML reader: read TeX annotation in mathml content if present.
KaTeX (and probably other tools that produce MathML from TeX)
includes an annotation tag with the original TeX; we extract this
if present instead of converting the MathML.

See #9971.
2024-09-01 10:19:41 -07:00
John MacFarlane 49e82f9a7f HTML reader: better handle KaTeX-generated math.
KaTeX emits the mathml followed by a span with an HTML fallback.
Previously pandoc was converting both.  We now ignore the HTML
fallback span, marked with class `katex-html`.

Closes #9971.
2024-08-31 10:17:00 -07:00
John MacFarlane 1a56865705 Markdown writer: avoid emitting markdown caption if...
...table has fallen back to raw HTML, which will then contain
a `<caption>` tag.

Closes #10094.
2024-08-29 11:15:20 -07:00
John MacFarlane a0bc3a574e RST reader: improve simple table support.
Multiline rows occur only when the *first* cell is empty; we were
previously treating lines with *any* empty cell as row continuations.

Closes #10093.

In addition, we no longer wrap multiline cells in Para if they
can be represented as Plain. This is consistent with docutils
behavior.
2024-08-29 10:41:52 -07:00
John MacFarlane 6c4691324f AsciiDoc writer: add link: prefix when needed.
AsciiDoc requires it except for http, https, irc, mailto, ftp schemes.

Closes #10105.
2024-08-23 12:20:43 -07:00
Albert Krewinkel db3febd0f1 Org reader: refactor, cleanup parser for raw block contents. 2024-08-08 18:27:45 +02:00
Albert Krewinkel b2755f77ba Org reader: fix parsing of src blocks with an -i flag.
Tabs are now preserved in the contents of *src* blocks if the the block
has the `-i` flag.

Fixes: #10071
2024-08-08 17:01:34 +02:00
John MacFarlane 1f093eab98 Asciidoc writer: preserve original base level.
We used to normalize so that the base level is always 1, but
asciidoc no longer seems to care about that, and the behavior
creates difficulties when we are converting fragments.

Closes #10062.
2024-08-06 20:07:27 -07:00
John MacFarlane 9bf112b9af LaTeX writer: preserve locator labels with --natbib.
In #9275 we made pandoc strip off locator labels (e.g. `p.`)
for natbib and biblatex output. In fact, this is only desirable
for biblatex.  natbib needs the locators to be preserved.

Closes #10057.
2024-08-06 15:16:24 -07:00
John MacFarlane 720aa87402 HTML writer: add data- when rendering label attribute.
Fixes #10048.
2024-08-01 08:41:00 -07:00
John MacFarlane 3d0faf6927 AsciiDoc writer: don't emit empty figure caption.
Closes #10047.
2024-08-01 08:06:45 -07:00
John MacFarlane a2cae348b9 VimWiki reader: remove partial functions. 2024-07-30 10:17:57 -07:00
John MacFarlane bc3eaf0724 Chunks: replace partial function tail with drop 1. 2024-07-30 09:52:56 -07:00
John MacFarlane d299328022 Allow --number-sections to take an optional true|false argument.
This was omitted when we allowed this for other boolean flags.
2024-07-27 21:01:00 -07:00
John MacFarlane 6c43c03398 Docx writer: fix regression with nested lists.
Closes #9994.  The bug affects e.g. ordered lists with bullet
sublists; after the sublist the top-level list reverts to bullets
instead of being properly numbered.

This regression was introduced in version 3.2.1 and was caused by
commit f5531f1.
2024-07-27 21:01:00 -07:00
John MacFarlane 9cdc99cb7d RTF reader: handle \*\shppict without dropping image.
Closes #10025.
2024-07-27 21:01:00 -07:00
John MacFarlane 8613aa39e8 BibTeX writer: ensure that "literal" names are enclosed in braces.
Closes #9987.
2024-07-15 18:23:20 +03:00
Albert Krewinkel 73ce302479 Harmonize maintainer email addresses in module headers. 2024-07-08 13:27:45 +02:00
John MacFarlane 36debf75a6 Typst reader: ignore 'pad' and just parse its body.
See #9958.
2024-07-06 23:25:49 -07:00
John MacFarlane b65006d3e6 Avoid 'head' in JATS reader, DocBook writer. 2024-07-03 22:26:51 -07:00
John MacFarlane c4cf6b2663 Haddock reader: Avoid use of 'head'. 2024-07-03 22:05:20 -07:00