Commit Graph
861 Commits
Author SHA1 Message Date
John MacFarlane 26b25a4428 LaTeX writer: new method for ensuring images don't overflow.
Previously we relied on graphicx internals and made global
changes to Gin to force images to be resized if they exceed
textwidth.  This approach is brittle and caused problems
with `\includesvg` (see #9660).

The new approach uses a new macro `\pandocbounded` that is
now defined in the LaTeX template. (Thanks here to Falk Hanisch in
https://github.com/mrpiggi/svg/issues/60.)

The LaTeX writer has been changed to enclose `\includegraphics`
and `\includesvg` commands in this macro when they don't explicitly
specify a width or height.

In addition, the writer now adds `keepaspectratio` to the
`\includegraphics` or `\includesvg` options if `height` is specified
without width, or vice versa. Previously, this was set in the preamble
as a global option.

Compatibility issues:

- If custom templates are used with the new LaTeX writer, they will have
  to be updated to include the new `\pandocbounded` macro, or an error
  will be raised because of the undefined macro.

- Documents that specify explicit dimensions for an image may render
  differently, if the dimensions are greater than the line width or
  page height. Previously pandoc would shrink these images to fit,
  but the new behavior takes the specified dimensions literally.
  In addition, pandoc previously always enforced `keepaspectratio`,
  even when width and height were both specified, so images with
  width and height specified that do not conform to their intrinsic
  aspect ratio will appear differently.

Closes #9660.
2024-06-23 16:12:37 -07:00
John MacFarlane cd9753d4af LaTeX writer/template: specify language option for selnolig...
...and only include it if `english` or `german` is used.

Since 3d8f011, the babel language is not specified as a
class option any more; so now we need to explicitly specify
the language option when we load `selnolig`.  Only `german`
and `english` are valid, so we construct the variable
`selnolig-langs` in the writer and include `selnolig` if it
is nonempty.

This should restore proper ligature suppression when
lualatex is used.

Closes #9863. Supersedes #9864.

Thanks to @fkohrt for the initial fix.
2024-06-10 19:33:43 -07:00
John MacFarlane 8e227ab059 LaTeX template: put babel-lang in options to beamer.
This is required to make beamer use proper localized terms for
things like "Section." Closes #9868.
2024-06-10 08:57:05 -07:00
John MacFarlane 684668db1e Fix --toc-depth with beamer output.
Previously only top-level sections were ever included in the TOC,
regardless of the setting of `--toc-depth`.

Closes #9861.
2024-06-08 17:35:00 -07:00
John MacFarlane b9491ccbbc Support supplementary-material in metadata for jats_articlepublishing.
See #9818.
2024-06-03 09:37:35 -07:00
John MacFarlane 7abfec3d2c Fix typo in fix to template.typst. 2024-05-30 18:24:52 -06:00
John MacFarlane 0e92d9483c Typst template: use content rather than string...
...for title, author, date, email.

Fixes #9823 (escaped `\@` in rendered email).
Allows formatting in title, author, date, and email fields.
Since the PDF metadata requires a string, and typst only
converts the title to a string (not the authors), we use
a small function content-to-string to do this conversion.
Background: https://github.com/typst/typst/issues/2196
2024-05-30 12:00:48 -06:00
John MacFarlane 61bc9a0c47 ConTeXt template: remove \setupbackend[export=yes].
This doesn't seem necessary for what we're doing, and it causes a
crash due to a bug in ConTeXt.  Closes #9820.
2024-05-30 09:38:35 -06:00
John MacFarlane f874997f18 Fix abstract-title in openxml template. 2024-05-19 19:20:08 -07:00
John MacFarlane db559e100c Allow OpenXML templates to be used with docx.
The `--reference-doc` option allows customization of styles in docx
output, but it does not allow one to adjust the content of the output
(e.g., changing the order in which metadata, the table of contents,
and the body of the document are displayed), or adding boilerplate
text before or after the document body.  For these changes, one can
now use `--template` with an OpenXML template.  (See the default
`openxml` template for a sample.)

This patch also allows `--include-before-body` and
`--include-after-body` to be used with `docx` output.
The included files must be OpenXML fragments suitable for
inclusion in the document body.

Closes #8338 (`--include-before-body`, `--include-after-body`).

Closes #9069 (a custom template can be used to omit the
title page).

Closes #7256.

Closes #2928.
2024-05-19 13:09:21 -07:00
John MacFarlane c26211b0c9 Cleaned up Abstract Title and Subtitle in default reference docx.
Center Subtitle, remove color.
2024-05-18 10:50:07 -07:00
John MacFarlane dbef49050e texinfo template: add variables for filename and version 2024-05-15 17:42:41 -07:00
Mickaël Canouil fef5f2d94c Add subtitle to Typst template (#9747) 2024-05-12 09:39:27 -07:00
Guilhem Saurel bd8529257e LaTeX template: add titlegraphicoptions variable (#9207)
Including a title graphic on a beamer template might require some
options, like e.g. `height=1.5cm` to ensure some image will fit at its
place in a given template.
2024-05-02 09:35:29 -07:00
John MacFarlane 066d1ba7ef reference.docx: use current standard Word theme.
This includes using the sans-serif font Aptos instead of
the serif font Cambria.

See #7280.
2024-04-13 22:31:20 -07:00
John MacFarlane 14f69c60ef reference.docx: Remove duplicate DefaultParagraphFont in styles.xml. 2024-04-13 22:12:11 -07:00
John MacFarlane e0f37996b3 reference.docx: stay closer to Word's current defaults.
We use the default styles for headings and the title instead
of what pandoc was using.

See #7280.
2024-04-13 18:15:04 -07:00
John MacFarlane 604f541b0f Typst writer: support Typst 0.11 table features. (#9593)
* Typst writer: support Typst 0.11 table features.

- colspans
- rowspans
- cell alignment overrides
- relative column widths
- header and footer
- multiple table bodies with intermediate headers

Row heads are not yet supported.

The default typst template has been modified so that tables
don't have lines by default. As is standard with pandoc, we only
add a line under a header or over a footer. However, a different
default stroke pattern can easily be added in a template.

Closes #9588.
2024-03-20 14:25:08 -07:00
John MacFarlane 2514ad2531 Typst template: set table inset globally. 2024-03-16 10:26:14 -07:00
Oliver Fabel f20f74512c Fix block headings support for unnumbered paragraphs (#9542)
`block-headings: true` seems to break unnumbered paragraphs and subparagraphs. This is due to the fact, that the unnumbered version uses the star macros \paragraph* and \subparagraph*. See issue #6018 for details.
2024-03-09 08:46:27 -08:00
John MacFarlane 892bcca2c9 Korean translations: delete colon in translation for 'to'.
This was invalid YAML, and not desired anyway, since a colon
is added.
2024-03-03 10:14:25 -08:00
John MacFarlane 5877ec546d Replace polyfill provider in HTML templates.
The PR replaces polyfill.io with cdnjs.cloudflare.com/polyfill.
polyfill.io has been acquired by Funnull, and the service has
become unstable.

This is essentially a cleaned up version of PR #2384 by @SukkaW;
see the PR for more information.
2024-03-01 08:46:10 -08:00
John MacFarlane 8c42926cb2 Add djot reader and writer.
Djot is a light markup syntax (https://djot.net).

This patch adds djot as input and output formats.

API changes:

Add Text.Pandoc.Readers.Djot
Add Text.Pandoc.Writers.Djot
2024-02-13 23:10:42 -08:00
Lawrence Chonavel 7164a238dd ConTeXt template: support font fallback (#9361)
This uses the same YAML options as the LaTeX template.
2024-02-03 10:27:31 -08:00
Max Heller 74f4ae25d2 LaTeX writer: set font fallback for babel main font 2024-01-20 09:47:12 -08:00
lawcho 0110f59053 LaTeX template: support font fallback
* LuaLaTeX-specific (uses luaotfload)
* Configured in YAML metadata
* Sans/main/mono fonts have separate fallback chains
2024-01-19 17:41:27 -08:00
mh4ckt3mh4ckt1c4s dce7f7a6a8 Fix beamer highlighting 2024-01-05 22:26:49 -07:00
John MacFarlane b1a1f04168 ODT/opendocument writers: properly handle highlighting styles.
These styles were going into an office:styles element in content.xml,
but this is invalid.  Instead they must go in styles.xml. See #9287.

The variable `highlighting-styles` no longer has any effect on
the default opendocument template, and highlighting styles are
not included in opendocument output.
2023-12-26 22:12:44 -08:00
John MacFarlane 907b1192d1 Remove html5shiv from default HTML5 template.
I don't think we need to support IE < 9 any more!
2023-12-20 10:10:21 -08:00
Edwin Török 7e15ebb2ca reference.docx: fix validation error on w:bCs
```
  {
        "Description": "The element has unexpected child element 'http://schemas.openxmlformats.org/wordprocessingml/2006/main:bCs'.",
        "Path": {
            "NamespacesDefinitions": [
                "xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\""
            ],
            "Namespaces": {

            },
            "XPath": "/w:styles[1]/w:style[15]/w:rPr[1]",
            "PartUri": "/word/styles.xml"
        },
        "Id": "Sch_UnexpectedElementContentExpectingComplex",
        "ErrorType": "Schema"
    },
```

Signed-off-by: Edwin Török <edwin@etorok.net>
2023-12-17 10:07:10 -08:00
Edwin Török 9fba209004 reference.docx: fix validation error on w:b
From OOXMLValidator:
```
    {
        "Description": "The element has unexpected child element 'http://schemas.openxmlformats.org/wordprocessingml/2006/main:b'.",
        "Path": {
            "NamespacesDefinitions": [
                "xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\""
            ],
            "Namespaces": {

            },
            "XPath": "/w:styles[1]/w:style[9]/w:rPr[1]",
            "PartUri": "/word/styles.xml"
        },
        "Id": "Sch_UnexpectedElementContentExpectingComplex",
        "ErrorType": "Schema"
    },
```

Signed-off-by: Edwin Török <edwin@etorok.net>
2023-12-17 10:07:10 -08:00
Edwin Török 8fc8a857e2 reference.docx: fix validation error on doNotTrackMoves
```
{
        "Description": "The element has unexpected child element 'http://schemas.openxmlformats.org/wordprocessingml/2006/main:doNotTrackMoves'.",
        "Path": {
            "NamespacesDefinitions": [
                "xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\""
            ],
            "Namespaces": {

            },
            "XPath": "/w:settings[1]",
            "PartUri": "/word/settings.xml"
        },
        "Id": "Sch_UnexpectedElementContentExpectingComplex",
        "ErrorType": "Schema"
    }
```

According to `wml.xsd` the order is:
```
 <xsd:complexType name="CT_Settings">
    <xsd:sequence>
      <xsd:element name="doNotTrackMoves" type="CT_OnOff" minOccurs="0"/>
      [...]
      <xsd:element name="footnotePr" type="CT_FtnDocProps" minOccurs="0"/>
```

Signed-off-by: Edwin Török <edwin@etorok.net>
2023-12-17 10:07:10 -08:00
Edwin Török 7b5808292c reference.docx: fix validation error on cnfStyle
Error from OOXMLValidator:
```
  {
        "Description": "The required attribute 'val' is missing.",
        "Path": {
            "NamespacesDefinitions": [
                "xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\""
            ],
            "Namespaces": {

            },
            "XPath": "/w:document[1]/w:body[1]/w:tbl[1]/w:tr[1]/w:trPr[1]/w:cnfStyle[1]",
            "PartUri": "/word/document.xml"
        },
        "Id": "Sch_MissRequiredAttribute",
        "ErrorType": "Schema"
    },
```

This is a bitmask where the first bit means 'first row', which is set as
an attribute already.

Signed-off-by: Edwin Török <edwin@etorok.net>
2023-12-17 10:07:10 -08:00
Edwin Török f48fa9ac17 reference.docx: fix validation error on tblW
```
./tmp/document-pretty.xml:260: element tblW: Schemas validity error : Element '{http://schemas.openxmlformats.org/wordprocessingml/2006/main}tblW', attribute '{http://schemas.openxmlformats.org/wordprocessingml/2006/main}w': '0.0' is not a valid value of the union type '{http://schemas.openxmlformats.org/wordprocessingml/2006/main}ST_MeasurementOrPercent'.
```

See http://officeopenxml.com/WPtableWidth.php, there is a disagreement
here between standard versions on whether a `%` is required or not when
type=`pct`, but the default is 0 when omitted, so just delete this
entry.

Signed-off-by: Edwin Török <edwin@etorok.net>
2023-12-17 10:07:10 -08:00
Edwin Török 79204047a5 reference.docx: fix validation error on pStyle
There were 2 `pStyle` for `Abstract`:
```
./tmp/document-pretty.xml:47: element pStyle: Schemas validity error : Element '{http://schemas.openxmlformats.org/wordprocessingml/2006/main}pStyle': This element is not expected. Expected is one of ( {http://schemas.openxmlformats.org/wordprocessingml/2006/main}keepNext, {http://schemas.openxmlformats.org/wordprocessingml/2006/main}keepLines, {http://schemas.openxmlformats.org/wordprocessingml/2006/main}pageBreakBefore, {http://schemas.openxmlformats.org/wordprocessingml/2006/main}framePr, {http://schemas.openxmlformats.org/wordprocessingml/2006/main}widowControl, {http://schemas.openxmlformats.org/wordprocessingml/2006/main}numPr, {http://schemas.openxmlformats.org/wordprocessingml/2006/main}suppressLineNumbers, {http://schemas.openxmlformats.org/wordprocessingml/2006/main}pBdr, {http://schemas.openxmlformats.org/wordprocessingml/2006/main}shd, {http://schemas.openxmlformats.org/wordprocessingml/2006/main}tabs ).
```

Signed-off-by: Edwin Török <edwin@etorok.net>
2023-12-17 10:07:10 -08:00
Edwin Török b7e9a6e0a7 reference.docx: Fix validation error on tcBorders
According to `wml.xsd` the order must be:
```
<xsd:sequence>
      <xsd:element name="tcBorders" type="CT_TcBorders" minOccurs="0" maxOccurs="1"/>
      [...]
      <xsd:element name="vAlign" type="CT_VerticalJc" minOccurs="0"/>
```

Signed-off-by: Edwin Török <edwin@etorok.net>
2023-12-17 10:07:10 -08:00
Edwin Török c0febe86d5 reference.docx: fix validation error, remove extra >
There was an extra `>` which showed up as "character content" in the XML:
```
/tmp/styles-pretty.xml:113: element rPr: Schemas validity error : Element '{http://schemas.openxmlformats.org/wordprocessingml/2006/main}rPr': Character content other than whitespace is not allowed because the content type is 'element-only'.
```

Signed-off-by: Edwin Török <edwin@etorok.net>
2023-12-17 10:07:10 -08:00
Edwin Török 39b59af8c9 reference.docx: fix validation error on spacing
```
./tmp/styles-pretty.xml:111: element spacing: Schemas validity error : Element '{http://schemas.openxmlformats.org/wordprocessingml/2006/main}spacing': This element is not expected. Expected is one of ( {http://schemas.openxmlformats.org/wordprocessingml/2006/main}textDirection, {http://schemas.openxmlformats.org/wordprocessingml/2006/main}textAlignment, {http://schemas.openxmlformats.org/wordprocessingml/2006/main}textboxTightWrap, {http://schemas.openxmlformats.org/wordprocessingml/2006/main}outlineLvl, {http://schemas.openxmlformats.org/wordprocessingml/2006/main}divId, {http://schemas.openxmlformats.org/wordprocessingml/2006/main}cnfStyle, {http://schemas.openxmlformats.org/wordprocessingml/2006/main}pPrChange ).
```

According to `wml.xsd` `spacing` must be placed before `jc`:
```
 <xsd:sequence>
      <xsd:element name="spacing" type="CT_Spacing" minOccurs="0"/>
      [...]
      <xsd:element name="jc" type="CT_Jc" minOccurs="0"/>

```

Signed-off-by: Edwin Török <edwin@etorok.net>
2023-12-17 10:07:10 -08:00
Edwin Török 6a06f6f608 reference.docx: fix validation error on qFormat
```
./tmp/styles-pretty.xml:30: element qFormat: Schemas validity error : Element '{http://schemas.openxmlformats.org/wordprocessingml/2006/main}qFormat': This element is not expected. Expected is one of ( {http://schemas.openxmlformats.org/wordprocessingml/2006/main}rPr, {http://schemas.openxmlformats.org/wordprocessingml/2006/main}tblPr, {http://schemas.openxmlformats.org/wordprocessingml/2006/main}trPr, {http://schemas.openxmlformats.org/wordprocessingml/2006/main}tcPr, {http://schemas.openxmlformats.org/wordprocessingml/2006/main}tblStylePr ).
```

According to `wml.xsd` it must come before `pPr`:
```
<xsd:complexType name="CT_Style">
    <xsd:sequence>
      [...]
      <xsd:element name="qFormat" type="CT_OnOff" minOccurs="0"/>
      [...]
      <xsd:element name="pPr" type="CT_PPrGeneral" minOccurs="0" maxOccurs="1"/>
```

Signed-off-by: Edwin Török <edwin@etorok.net>
2023-12-17 10:07:10 -08:00
John MacFarlane ea9317c73d Typst template fixes. 2023-12-11 10:18:37 -08:00
John MacFarlane aa95770743 Typst writer: use quote for block quotes.
Remove custom definitiion of blockquote in default template.
2023-12-09 23:23:15 -08:00
John MacFarlane fb4cea44b9 Docx writer: Use different style for block quotes in notes.
Using "Footnote Block Text" for the style name, so it can be
given a different font size if footnotes are.

Closes #9243.
2023-12-08 13:34:33 -08:00
John MacFarlane 5bd301ef45 Typst writer/template: support --toc-depth as in other writers.
Closes #9242.
2023-12-07 14:39:21 -08:00
Ian Max Andolina e562d23bc7 Update default.typst to support csl (#9186)
Typst now supports CSL for its native citation engine, so pandoc
should use a specified `csl` style in the template, falling back to
`bibliographystyle` if `csl` is not specified.

https://typst.app/docs/reference/meta/bibliography/
2023-11-14 19:46:18 -08:00
John MacFarlane bb36f127e2 LaTeX template: include bookmark package unconditionally.
This package produces better PDF bookmarks than hyperref
and does it on the first pass.

As a consequence, we now default to running LaTeX only
once in producing a PDF (instead of twice). If a table
of contents is present, we still have to run three times
to get the page numbers.
2023-11-03 10:40:38 -07:00
John MacFarlane 196bf96932 epub.css: add styling for sup and sub.
Closes #9160.
2023-10-28 09:46:56 -07:00
priiduonu 67ea7cd253 Update et translation 2023-10-01 17:38:16 -04:00
Stephan Daus 11facf72cd Updated Norwegian language translation files
1) Renamed no.yaml (macrolanguage Norwegian) to nb.yaml (Norwegian Bokmål)
2) Created soft symbolic link from no.yaml pointing to nb.yaml.
2023-09-29 09:41:21 -07:00
samuel-weinhardt edbea270f5 Apply style to h6 2023-09-23 22:10:52 -07:00
samuel-weinhardt 957489de85 Format styles 2023-09-23 22:10:52 -07:00