Commit Graph
17648 Commits
Author SHA1 Message Date
John MacFarlane 4cd5b38632 Use latest typst-hs. 2024-09-08 14:33:02 -07:00
John MacFarlane 9855cd98e1 Remove most uses of partial function 'head'. 2024-09-08 12:50:30 -07:00
John MacFarlane cf3a583bd4 Avoid use of partial function 'tail'. 2024-09-08 09:52:50 -07:00
John MacFarlane 477e235f6e pandoc-lua-engine: marshall list_tables, epub_title_page writer options. 2024-09-08 09:42:20 -07:00
John MacFarlane 7a569b9c8f Initialize some missing fields in pandoc-server.
writerEpubTitlePage, writerChunkTemplate, writerListTables.
2024-09-08 09:41:17 -07:00
John MacFarlane 25b9314472 Finishing touches on --link-images:
- Document in defaults file section of MANUAL.
- Add to pandoc-lua-engine writer option marshalling.
- Add to pandoc-server initialization of writer options.
2024-09-08 09:07:55 -07:00
John MacFarlane ca017b3c43 Document figure/table-caption-position in defaults files. 2024-09-08 08:57:26 -07:00
John MacFarlane 8e391ba599 Add to cli options seciton in CONTRIBUTING. 2024-09-08 08:55:49 -07:00
John MacFarlane 079af93d78 CONTRIBUTING.md: summarize steps for adding new cli option. 2024-09-08 08:52:29 -07:00
John MacFarlane 45da887ff7 Include accessors for new writer options 2024-09-08 08:52:23 -07:00
John MacFarlane 6be667625e pandoc-server: initialize caption position options 2024-09-08 08:52:10 -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 6d41c1b147 ANSI writer: add test for inline code. 2024-09-03 14:29:31 -07:00
John MacFarlane 6be41d1c62 ANSI writer: Remove Figure and Table labels and numbers. 2024-09-03 14:26:53 -07:00
John MacFarlane 9953f1d256 Add ansi writer tests. 2024-09-03 13:35:01 -07:00
John MacFarlane 9b62ddc24c Add ansi as output format in MANUAL.txt. 2024-09-03 13:18:23 -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 9821407262 Use dev doclayout, stack.yaml edition 2024-09-02 11:09:08 -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 5e5ce1fae4 Match writer.djot expected output to doclayout
For reasons not currently clear to me(!), the tip of doclayout consumes
the breaking space that is followed by nothing (i.e. the ignored raw
LaTeX inline). The tests of djoths itself still pass.
2024-09-02 11:08:13 -07:00
Evan Silberman c296c0fcfe Depend on newer dev doclayout 2024-09-02 11:08:12 -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
closeobserve 7a83cac6c3 chore: fix some comments 2024-08-29 21:23:17 -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