Commit Graph
1122 Commits
Author SHA1 Message Date
John MacFarlane 2b11ce9bab Update tests for previous commit (protecting phantomsection). 2025-03-15 11:14:36 -07:00
John MacFarlane 28eca1e41e Markdown reader: remove some misguided list fanciness.
Previously we tried to handle things like commented out list
items:

    - one
    <!--
    - two
    -->
    - three

and also things like:

    - one `and
    - two` and

But the code we added to handle these cases caused problems with
other, more straightforward things, like:

    - one
    - ```
      code
      ```
    - three

So we are rolling back all the fanciness, so that the markdown
parser now behaves more like the commonmark parser, in which
indicators of block-level structure always take priority over
indicators of inline structure.

Closes #9865. Closes #7778. See also #5628.
2025-03-14 15:07:16 -07:00
John MacFarlane b7d2c4815f Markdown reader: fixed escapedChar' parser.
It should not accept escaped newlines.
See #10672.
2025-03-07 14:28:10 -08:00
John MacFarlane e73b9ee1d8 Disable citations extension in writers if --citeproc is used.
Otherwise we get undesirable results, as the format's native
citation mechanism is used instead of (or in addition to) the
citeproc-generated citations. Closes #10662.
2025-03-05 13:24:05 -08:00
John MacFarlane 6c3e43dc57 LaTeX reader: better handle comments/whitespace in option lists and includes.
Closes #10659.
2025-03-04 15:00:37 -08:00
John MacFarlane ac79938043 Typst writer: better heuristics for escaping potential list markers.
Closes #10650.
2025-02-27 13:37:25 -08:00
John MacFarlane 3caf2b1e3a Revert "Docx reader and writer: support row heads."
This reverts commit cbe67b9602.

Word sets `w:firstColumn="1"` by default for tables.  You have to find
the Table Design tab and explicitly uncheck "First Column" to make this
go away.  In most cases, I don't think writers intend to designate
the first column as a row head, so this commit is going to produce
unexpected results.  In addition, because of the table normalization
done by pandoc-type's `tableWith`, any table containing a colspanned
cell in the left-hand column will get broken if the first column is
designated a row head.  For these reasons it seems best to revert this
change, which was made in response to #9495.

Closes #10627.
2025-02-19 10:02:50 -08:00
John MacFarlane bf1c17c883 Markdown reader: allow line break between URL and title of link.
Closes #10621.
2025-02-14 10:17:26 -08:00
John MacFarlane 54039e392d Update pandoc-citeproc-320a test.
See #10610.
2025-02-13 14:19:58 -08:00
John MacFarlane c21177b113 Smart quote parsing: ignore curly quotes.
Previously we tried to match curly quotes as well as straight
quotes, producing Quoted inlines.  But it seems better just to
assume that those who use curly quotes want them passed through
verbatim.

This also fixes an (unintended) bug whereby curly single left
quotes would sometimes be changed to single right quotes.

Closes #10610.
2025-02-13 13:58:53 -08:00
John MacFarlane 0fe6254535 Markdown writer: omit extra space after bullets.
We used to insert extra spaces to ensure that the content respected
the four-space rule.  That is not really necessary now, since pandoc's
markdown and most markdowns don't follow the four-space rule.

Those who want the old behavior can obtain it by using
`-t markdown+four_space_rule`.

Closes #7172.
2025-02-12 09:41:20 -08:00
John MacFarlane 49d154c769 Use babel options shorthands=off.
This has been fixed now in Babel for some time.  So we can now
get rid of the ugly code that disabled language-specific shorthands
(see e26d31d).

Closes #6817.
2025-02-10 13:22:33 -08:00
John MacFarlane 4948d27fee Remove selnolig-langs.
We now specify the language as a global option again, so we
no longer need to specify it when invoking selnolig.

See #9863.
2025-02-10 13:02:58 -08:00
John MacFarlane 9be0963327 LaTeX writer/template: Improve babel support.
Previously we used the `.ini` files for every language, but
for European languages these tend to provide inferior results
to the `.ldf` files used by classic Babel. Currently Babel
documentation recommends using the classic system for European
languages written in Latin and Cyrillic scripts and Vietnamese.
So the LaTeX writer and template now follow this guidance.

Main languages in the list of languages with good "classic" support
are added to global documentclass options and will be automatically
handled by Babel using the `.ldf` files.

If the main language is not in this list, the `babeloptions` variable
will be set to `provide=*`, which will cause support to be loaded from
the `.ini` file rather than an `.ldf`. So, for example, setting
`-V babeloptions=''` with a polytonic Greek document will cause the
`.ldf` support to be used instead of the `.ini`.

The default setting of this variable can be overwritten, but in most
cases the default should give good results.

Closes #8283.
2025-02-08 10:45:11 -08:00
Evan Silberman 97b36ecb77 Track wikilinks with a class instead of a title
Once upon a time the only metadata element for links in Pandoc's AST was
a title, and it was hijacked to track certain links as having originated
in the wikilink syntax. Now we have Attrs and we can use a class to
handle wikilinks instead.

Requires coordinated changes to commonmark-hs.
2025-02-07 14:04:12 -08:00
Charles Tapley HoytandJez Cope 1eed55f391 Add CRediT roles to JATS
Enable annotating author roles using the Contribution Role Taxonomy
(CRediT) and export this information in conformant JATS

Closes #10152.

Co-Authored-By: Jez Cope <457628+jezcope@users.noreply.github.com>
2025-02-05 21:28:56 -08:00
John MacFarlane f72548a7c2 DocBook reader: Handle title inside orderedlist.
Also some other elements that allow title: blockquote,
calloutlist, etc.
Closes #10594.
2025-02-03 12:33:39 -08:00
John MacFarlane 1470b3a573 DocBook reader: better handle formalpara, example, and sidebar.
Include identifiers and titles in each case.

The code should be credited to @tombolano.

Closes #8666.
2025-02-01 17:04:38 -08:00
Evan Silberman d680ce0100 Handle <abbr> as a span-like inline
Closes #5793
2025-01-29 15:59:26 -06:00
silby 0be07a5e4d Test \{,re}newcommand arguments (#10573)
Closes #4470
2025-01-29 11:32:25 -08:00
Gordon Woodhull 220dde406b brace tables with typst:no-figure and typst:text attributes (#10563)
The combination of #9648 Typst property output and #9778
`typst:no-figure` can cause fonts to spill out of tables.

This is because setting Typst text properties across a table
requires `set text(...)` outside the table, and previously we
were relying on the figure to provide a scope.

This adds an extra `#{...}` when the table has class `typst:no-figure`
and also has `typst:text:*` attributes.
2025-01-24 10:48:03 -08:00
John MacFarlane 96d4f5be51 Citeproc: fix moving punctuation before citation notes.
This previously worked with regular citations, but not author-in-text
citations. Now it works with both.
2025-01-16 08:32:02 -08:00
silby 806dcb0849 Consume blanks after =encoding in pod reader (#10544)
The reader did not properly consume empty lines after =encoding commands,
which produced various incorrect parses depending on the content between
there and the next command.

Fixes #10537
2025-01-15 12:07:26 -08:00
John MacFarlane c79ef1270e Fix 9495 command test for windows. 2025-01-10 23:43:32 -08:00
John MacFarlane cbe67b9602 Docx reader and writer: support row heads.
Reader: When `w:tblLook` has `w:firstColumn` set (or an equivalent bit
mask), we set row heads = 1 in the AST.

Writer: set `w:firstColumn` in `w:tblLook` when there are row
heads. (Word only allows one, so this is triggered by any number
of row heads > 0.)

Closes #9495.
2025-01-10 22:50:17 -08:00
John MacFarlane 6051d62e56 Docx reader: read table styles as custom styles...
...when `styles` extension is enabled.  Closes #9603.

Also improve manual's coverage of custom styles.
2025-01-10 10:30:08 -08:00
John MacFarlane 968b0c13ee Typst writer: fix handling of pixel image dimensions.
These are now converted to inches as in the LaTeX writer.

Closes #9945.
2025-01-01 23:00:35 -08:00
John MacFarlane 01b54593cc AsciiDoc writer: improve escaping.
Closes #10385.
Closes #2337.
Closes #6424.
2024-12-28 19:43:23 -08:00
John MacFarlane 9fa4fa3c51 RST reader: fix handling of underscores.
Fixes a regression in 3.6 that caused problems parsing
text with underscores.

Closes #10497.
2024-12-27 19:38:56 -08:00
John MacFarlane 3c0982c893 MediaWiki reader: allow empty quoted attributes.
Closes #10490.
2024-12-23 10:36:09 -08:00
John MacFarlane e122ca04b0 MediaWiki reader: allow cells starting with +.
Closes #10491.
2024-12-23 10:27:13 -08:00
silby d064ad77a5 RST reader: handle explicit reference links (#10485)
This case was missed when changing the reference link strategy for RST
to allow a single pass.

Closes #10484.
2024-12-22 10:03:00 -08:00
John MacFarlane cfb9bd5cf3 Mediawiki writer: escape line-initial characters...
...that would otherwise be interpreted as list starts.

Closes #9700.
2024-12-20 10:31:43 -08:00
John MacFarlane 7cff3590bc Allow --shift-heading-level-by=-1 to work in djot...
...in the same way it works for other formats (with the top-level
heading being promoted to metadata title).  This needed special
treatment because of the way djot surrounds sections with Divs.

Closes #10459.
2024-12-19 15:14:31 -08:00
John MacFarlane 669c2b8f64 LaTeX reader: handle figure* environment as a figure.
Closes #10472.
2024-12-18 12:11:04 -08:00
John MacFarlane d5c9fe73b8 Textile reader: improve parsing of spans.
The span needs to be separated from its surroundings by spaces.
Also, a span can have attributes, which we now attach.

Closes #9878.
2024-12-17 23:38:41 -08:00
John MacFarlane 9acff9924f Textile reader: inline constructors don't trigger if closer...
...is preceded by whitespace.

Closes #10414.
2024-12-17 20:37:01 -08:00
Evan Silberman 13b3453009 Add mdoc reader
This change introduces a reader for mdoc, a roff-derived semantic markup
language for manual pages. The two relevant contemporary implementations
of mdoc for manual pages are mandoc (https://mandoc.bsd.lv/), which
implements the language from scratch in C, and groff
(https://www.gnu.org/software/groff/), which implements it as roff macros.

mdoc has a lot of semantics specific to technical manuals that aren't
representable in Pandoc's AST. I've taken a cue from the mandoc HTML
output and many mdoc elements are encoded as Codes or Spans with classes
named for the mdoc macro that produced them.

Much like web browsers with HTML, mandoc attempts to produce best-effort
output given all kinds of weird and crappy mdoc input. Part of the
reason it's able to do this is it uses a very accommodating parse tree
and stateful output routines specialized to the output mode, and when it
encounters some macro it wasn't expecting, it can easily give up on
whatever it was outputting and output something else. I've encoded as
much flexibility as I reasonably could into the mdoc reader here, but I
don't know how to be as flexible as mandoc.

This branch has been developed almost exclusively against mandoc's
documentation and implementation of mdoc as a reference, and the
real-world manual pages tested against are those from the OpenBSD base
system. Of ~3500 manuals in mdoc format shipped with a fresh OpenBSD
install, 17 cause the mdoc reader to exit with a parse error. Any
further chasing of edge cases is deferred to future work.

Many of the tests in test/Tests/Readers/Mdoc.hs are derived directly
from mandoc's extensive regression tests.

[API change] Adds readMdoc to the public API
2024-12-05 22:57:18 -08:00
Evan Silberman 126e3330b9 Parameterize Roff escaping
The existing lexRoff does some stuff I don't want to deal with in mdoc
just yet, like lexing tbl, and some stuff I won't do at all, like
handling macro and text string definitions and switching between modes.
Uses a typeclass with associated type families to reuse most of the
escaping code between Roff (i.e. man) and Mdoc.

Future work could improve on this so that more lexing code could be
shared between Man and Mdoc. Mdoc inherits Roff's surface syntax so
hypothetically it makes sense to lex it into tokens that make sense for
roff. But it happens that the Mdoc parser is much easier to build with
an Mdoc specific token stream. Some discussion in jgm/pandoc#10225 about
the rationale.

Adds a test for the roff \A escape, which I accidentally dropped support
for in an earlier iteration without anything complaining.
2024-12-05 22:57:18 -08:00
John MacFarlane fabfaabd81 MediaWiki reader: fix indented tables with caption.
Closes #10390.
2024-11-19 09:46:53 -08:00
Evan Silberman fdef25eb6e Respect empty LineBlock lines in plain writer
The plain writer behaved as a markdown variant with Ext_line_blocks
turned off, and so empty lines in a line block would get eliminated.
This is surprising, since if there's anything where the intent can be
preserved in plain text output it's empty lines.

It's still a bit surprising to have nbsps in plain text output, as in
the test, where the distinction doesn't really matter, but that'd be an
orthogonal change.
2024-11-11 16:00:47 -08:00
Andreas Deininger 17634be3f4 JATS writer: correct spelling of suppress attribute (#10350) 2024-11-04 10:07:20 -08:00
John MacFarlane d66f6e943b LaTeX reader: put minipage in specially marked Div.
Closes #10266.
2024-10-25 09:41:59 -07:00
John MacFarlane cd5dab1874 RST reader: implement option lists.
Closes #10318.
2024-10-23 17:26:46 -07:00
Albert Krewinkel 4c66bf2790 HTML writer: unwrap empty incremental divs
Divs are unwrapped if the only purpose of the div seems to be to control
whether lists are presented incrementally on slides.

Closes: #10328
2024-10-23 09:04:54 -07:00
John MacFarlane d1063860af Fix typo in test case. 2024-10-17 08:43:34 -07:00
John MacFarlane 012d22cd11 RST reader: handle block level substitutions. 2024-10-16 23:49:54 -07:00
John MacFarlane 019f5d1c9d RST reader: fix linked substitutions.
E.g. `|Python|_`.

Closes #6588.
2024-10-15 11:52:32 -07:00
John MacFarlane 300e18efba RST reader: support inline anchors.
Closes #9196.
2024-10-15 11:25:28 -07:00
John MacFarlane e9e1684c9e RST reader: explicit links define references.
For example, ``Go to `g`_ `g <www.example.com>`_.``
should produce two links to www.example.com.

Closes #5081.
2024-10-15 11:07:20 -07:00