Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SILE Writer #6088

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
- Brent Yorgey
- Brian Leung
- Bryan O'Sullivan
- Caleb Maclennan
- Caleb McDaniel
- Caleb Mclennan
- Calvin Beck
Expand Down
67 changes: 51 additions & 16 deletions MANUAL.txt
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ header when requesting a document from a URL:
- `rtf` ([Rich Text Format])
- `texinfo` ([GNU Texinfo])
- `textile` ([Textile])
- `sile` ([SILE])
- `slideous` ([Slideous] HTML and JavaScript slide show)
- `slidy` ([Slidy] HTML and JavaScript slide show)
- `dzslides` ([DZSlides] HTML5 + JavaScript slide show)
Expand Down Expand Up @@ -477,6 +478,7 @@ header when requesting a document from a URL:
[MultiMarkdown]: https://fletcherpenney.net/multimarkdown/
[reStructuredText]: https://docutils.sourceforge.io/docs/ref/rst/introduction.html
[S5]: https://meyerweb.com/eric/tools/s5/
[SILE]: https://www.sile-typesetter.org/
[Slidy]: https://www.w3.org/Talks/Tools/Slidy2/
[Slideous]: https://goessner.net/articles/slideous/
[HTML]: https://www.w3.org/html/
Expand Down Expand Up @@ -1103,7 +1105,7 @@ header when requesting a document from a URL:
`--top-level-division=default`|`section`|`chapter`|`part`

: Treat top-level headings as the given division type in
LaTeX, ConTeXt, DocBook, and TEI output. The hierarchy
LaTeX, ConTeXt, SILE, DocBook, and TEI output. The hierarchy
order is part, chapter, then section; all headings are
shifted such that the top-level heading becomes the
specified type. The default behavior is to determine the
Expand All @@ -1118,7 +1120,7 @@ header when requesting a document from a URL:

`-N`, `--number-sections=[true|false]`

: Number section headings in LaTeX, ConTeXt, HTML, Docx, ms, or EPUB
: Number section headings in LaTeX, ConTeXt, SILE, HTML, Docx, ms, or EPUB
output. By default, sections are not numbered. Sections with class
`unnumbered` will never be numbered, even if `--number-sections`
is specified.
Expand Down Expand Up @@ -1445,8 +1447,8 @@ header when requesting a document from a URL:
: Use the specified engine when producing PDF output.
Valid values are `pdflatex`, `lualatex`, `xelatex`, `latexmk`,
`tectonic`, `wkhtmltopdf`, `weasyprint`, `pagedjs-cli`,
`prince`, `context`, `pdfroff`, and `typst`. If the engine is not in
your PATH, the full path of the engine may be specified here.
`prince`, `context`, `pdfroff`, `sile`, and `typst`. If the engine is not
in your PATH, the full path of the engine may be specified here.
If this option is not specified, pandoc uses the following
defaults depending on the output format specified using
`-t/--to`:
Expand All @@ -1459,6 +1461,7 @@ header when requesting a document from a URL:
see [print-css.rocks](https://print-css.rocks) for a good
introduction to PDF generation from HTML/CSS)
- `-t ms`: `pdfroff`
- `-t sile`: `sile`
- `-t typst`: `typst`

`--pdf-engine-opt=`*STRING*
Expand Down Expand Up @@ -2663,7 +2666,7 @@ Currently the following pipes are predefined:

`title`, `author`, `date`
: allow identification of basic aspects of the document. Included
in PDF metadata through LaTeX and ConTeXt. These can be set
in PDF metadata through LaTeX, ConTeXt, and SILE. These can be set
through a [pandoc title block][Extension: `pandoc_title_block`],
which allows for multiple authors, or through a
[YAML metadata block][Extension: `yaml_metadata_block`]:
Expand All @@ -2682,12 +2685,12 @@ Currently the following pipes are predefined:
is set by `pagetitle`, which is equal to `title` by default.

`subtitle`
: document subtitle, included in HTML, EPUB, LaTeX, ConTeXt, and docx
documents
: document subtitle, included in HTML, EPUB, LaTeX, ConTeXt, SILE,
and docx documents

`abstract`
: document summary, included in HTML, LaTeX, ConTeXt, AsciiDoc, and docx
documents
: document summary, included in HTML, LaTeX, ConTeXt, SILE, AsciiDoc,
and docx documents

`abstract-title`
: title of abstract, currently used only in HTML, EPUB, and docx.
Expand All @@ -2708,6 +2711,9 @@ Currently the following pipes are predefined:
`category`
: document category, included in docx and pptx metadata

`rights`
: rights string, included in SILE and EPUB metadata

Additionally,
any root-level string metadata, not included in ODT, docx
or pptx metadata is added as a *custom property*.
Expand Down Expand Up @@ -2737,7 +2743,8 @@ ODT or pptx.
tags (following the [BCP 47] standard), such as `en` or `en-GB`.
The [Language subtag lookup] tool can look up or verify these tags.
This affects most formats, and controls hyphenation in PDF output
when using LaTeX (through [`babel`] and [`polyglossia`]) or ConTeXt.
when using LaTeX (through [`babel`] and [`polyglossia`]), ConTeXt,
or SILE.

Use native pandoc [Divs and Spans] with the `lang` attribute to
switch the language:
Expand Down Expand Up @@ -3274,6 +3281,33 @@ Pandoc uses these variables when [creating a PDF] with ConTeXt.
[`setupinterlinespace`]: https://wiki.contextgarden.net/Command/setupinterlinespace
[`setuppagenumbering`]: https://wiki.contextgarden.net/Command/setuppagenumbering

### Variables for SILE

The following variables are placed appropriately in standalone SILE documents.

`classoption`
: options for document class; repeat for multiple options:

---
classoption:
- layout: yoko
...

`documentclass`
: document class: usually one of the standard classes, [`plain`], or [`book`].

`fontsize`
: font size for body text (e.g. `10pt`, `12pt`)

`links-as-notes`
: causes links to be printed as footnotes

`mainfont`, `sansfont`, `monofont`
: font families: take the name of any system font

`papersize`
: paper size, e.g. `letter`, `a4`

### Variables for `wkhtmltopdf`

Pandoc uses these variables when [creating a PDF] with [`wkhtmltopdf`].
Expand Down Expand Up @@ -3548,7 +3582,7 @@ another. A link to this section, for example, might look like this:
[heading identifiers](#heading-identifiers-in-html-latex-and-context).

Note, however, that this method of providing links to sections works
only in HTML, LaTeX, and ConTeXt formats.
only in HTML, LaTeX, ConTeXt, and SILE formats.

If the `--section-divs` option is specified, then each section will
be wrapped in a `section` (or a `div`, if `html4` was specified),
Expand Down Expand Up @@ -3949,7 +3983,7 @@ Note that although this syntax allows assignment of classes and key/value
attributes, writers generally don't use all of this information. Identifiers,
classes, and key/value attributes are used in HTML and HTML-based formats such
as EPUB and slidy. Identifiers are used for labels and link anchors in the
LaTeX, ConTeXt, Textile, Jira markup, and AsciiDoc writers.
LaTeX, ConTeXt, SILE, Textile, Jira markup, and AsciiDoc writers.

Headings with the class `unnumbered` will not be numbered, even if
`--number-sections` is specified. A single hyphen (`-`) in an attribute
Expand All @@ -3965,7 +3999,7 @@ is just the same as
If the `unlisted` class is present in addition to `unnumbered`,
the heading will not be included in a table of contents.
(Currently this feature is only implemented for certain
formats: those based on LaTeX and HTML, PowerPoint, and RTF.)
formats: those based on LaTeX, SILE, HTML, PowerPoint, and RTF.)

### Extension: `implicit_header_references` ###

Expand Down Expand Up @@ -4124,7 +4158,7 @@ Here `mycode` is an identifier, `haskell` and `numberLines` are
classes, and `startFrom` is an attribute with value `100`. Some
output formats can use this information to do syntax
highlighting. Currently, the only output formats that use this
information are HTML, LaTeX, Docx, Ms, and PowerPoint. If
information are HTML, LaTeX, SILE, Docx, Ms, and PowerPoint. If
highlighting is supported for your output format and language,
then the code block above will appear highlighted, with numbered
lines. (To see which languages are supported, type `pandoc
Expand Down Expand Up @@ -5533,7 +5567,7 @@ or
[Introduction]: #introduction

Internal links are currently supported for HTML formats (including
HTML slide shows and EPUB), LaTeX, and ConTeXt.
HTML slide shows and EPUB), LaTeX, ConTeXt, and SILE.

## Images

Expand Down Expand Up @@ -5610,9 +5644,10 @@ For example:
(If you're using a custom template, you need to configure `graphicx`
as in the default template.)
- ConTeXt: `\externalfigure[file.jpg][width=0.5\textwidth]`
- SILE: `\img[src=file.jpg][width=50%lw]`
- Some output formats have a notion of a class
([ConTeXt](https://wiki.contextgarden.net/Using_Graphics#Multiple_Image_Settings))
or a unique identifier (LaTeX `\caption`), or both (HTML).
or a unique identifier (LaTeX `\caption`), or both (HTML, SILE).
- When no `width` or `height` attributes are specified, the fallback
is to look at the image resolution and the dpi metadata embedded in
the image file.
Expand Down
68 changes: 68 additions & 0 deletions data/templates/default.sile
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
\begin[$if(papersize)$papersize=$papersize$,$endif$class=$documentclass$$if(classoptions)$,$classoptions$$endif$]{document}
\use[module=packages.pandoc]
$if(lang)$
\language[main=$lang$]
\font[language=$lang$]
$endif$
$if(langscript)$
\font[script=$langscript$]
$endif$
$if(mainfont)$
\font[family=$mainfont$]
$endif$
$if(fontsize)$
\font[size=$fontsize$]
$endif$
\begin{lua}
local base = require("packages.base")
local package = pl.class(base)
package._name = "pandoc_document"
function package:registerCommands ()
$if(links-as-notes)$
self:registerCommand("href", function(options, content)
SILE.call("url", options, content)
SILE.call("footnote", options, content)
end)
$else$
self:registerCommand("href", function(options, content)
SILE.call("url", options, content)
end)
$endif$
end
return package
\end{lua}
$for(include)$
\script[src=$include$]
$endfor$
$for(script)$
\script[src=$script$]
$endfor$
\set[parameter=linebreak.emergencyStretch,value=1em]
$if(sansfont)$
\define[command=book:chapterfont]{\font[family=$sansfont$,weight=800,size=20pt]{\process}}
\define[command=book:sectionfont]{\font[family=$sansfont$,weight=800]{\process}}
$endif$
$if(monofont)$
\define[command=verbatim:font]{\font[family=$monofont$]}
$endif$
$if(title)$
\title{$title$}
$endif$
$if(subtitle)$
\subtitle{$subtitle$}
$endif$
$if(author)$
\author{$author$}
$endif$
$if(rights)$
\rights{$rights$}
$endif$
$if(date)$
\date{$date$}
$endif$
$body$
$for(include-after)$
$include-after$
\script[src=$include-after$]
$endfor$
\end{document}
6 changes: 6 additions & 0 deletions pandoc.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ description: Pandoc is a Haskell library for converting from one markup
- Ebook formats (EPUB v2 and v3, FB2)
- Documentation formats (GNU TexInfo, Haddock)
- Roff formats (man, ms)
- SILE
- TeX formats (LaTeX, ConTeXt)
- Typst
- XML formats (DocBook 4 and 5, JATS, TEI Simple, OpenDocument)
Expand Down Expand Up @@ -72,6 +73,7 @@ data-files:
data/templates/default.bibtex
data/templates/default.biblatex
data/templates/default.context
data/templates/default.sile
data/templates/default.texinfo
data/templates/default.jira
data/templates/default.man
Expand Down Expand Up @@ -616,6 +618,7 @@ library
Text.Pandoc.Writers.LaTeX,
Text.Pandoc.Writers.ConTeXt,
Text.Pandoc.Writers.Djot,
Text.Pandoc.Writers.SILE,
Text.Pandoc.Writers.Typst,
Text.Pandoc.Writers.OpenDocument,
Text.Pandoc.Writers.Texinfo,
Expand Down Expand Up @@ -750,6 +753,7 @@ library
Text.Pandoc.Writers.Markdown.Types,
Text.Pandoc.Writers.Markdown.Inline,
Text.Pandoc.Writers.Roff,
Text.Pandoc.Writers.SILE.Types,
Text.Pandoc.Writers.Blaze,
Text.Pandoc.Writers.Powerpoint.Presentation,
Text.Pandoc.Writers.Powerpoint.Output,
Expand Down Expand Up @@ -834,6 +838,7 @@ test-suite test-pandoc
Tests.Readers.DokuWiki
Tests.Writers.Native
Tests.Writers.ConTeXt
Tests.Writers.SILE
Tests.Writers.DocBook
Tests.Writers.HTML
Tests.Writers.JATS
Expand All @@ -845,6 +850,7 @@ test-suite test-pandoc
Tests.Writers.LaTeX
Tests.Writers.Docx
Tests.Writers.RST
Tests.Writers.SILE
Tests.Writers.TEI
Tests.Writers.Markua
Tests.Writers.Muse
Expand Down
1 change: 1 addition & 0 deletions src/Text/Pandoc/App/CommandLineOptions.hs
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ engines = map ("html",) htmlEngines ++
map ("latex",) latexEngines ++
map ("beamer",) latexEngines ++
[ ("ms", "pdfroff")
, ("sile", "sile")
, ("typst", "typst")
, ("context", "context")
]
Expand Down
3 changes: 3 additions & 0 deletions src/Text/Pandoc/Extensions.hs
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,9 @@ getDefaultExtensions "epub" = extensionsFromList
Ext_epub_html_exts]
getDefaultExtensions "epub2" = getDefaultExtensions "epub"
getDefaultExtensions "epub3" = getDefaultExtensions "epub"
getDefaultExtensions "sile" = extensionsFromList
[Ext_smart,
Ext_auto_identifiers]
getDefaultExtensions "latex" = extensionsFromList
[Ext_smart,
Ext_latex_macros,
Expand Down
1 change: 1 addition & 0 deletions src/Text/Pandoc/Format.hs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ formatFromFilePath x =
".rst" -> defFlavor "rst"
".rtf" -> defFlavor "rtf"
".s5" -> defFlavor "s5"
".sil" -> defFlavor "sile"
".t2t" -> defFlavor "t2t"
".tei" -> defFlavor "tei"
".tex" -> defFlavor "latex"
Expand Down
6 changes: 6 additions & 0 deletions src/Text/Pandoc/PDF.hs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ makePDF program pdfargs writer opts doc =
source <- writer opts doc
verbosity <- getVerbosity
liftIO $ toPdfViaTempFile verbosity program pdfargs mkOutArgs source
"sile" -> do
let mkOutArgs f = ["-o", f]
source <- writer opts doc
verbosity <- getVerbosity
liftIO $
toPdfViaTempFile verbosity program pdfargs mkOutArgs source
"typst" -> do
source <- writer opts doc
verbosity <- getVerbosity
Expand Down
3 changes: 3 additions & 0 deletions src/Text/Pandoc/Writers.hs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ module Text.Pandoc.Writers
, writeRTF
, writeRevealJs
, writeS5
, writeSILE
, writeSlideous
, writeSlidy
, writeTEI
Expand Down Expand Up @@ -124,6 +125,7 @@ import Text.Pandoc.Writers.Org
import Text.Pandoc.Writers.Powerpoint
import Text.Pandoc.Writers.RST
import Text.Pandoc.Writers.RTF
import Text.Pandoc.Writers.SILE
import Text.Pandoc.Writers.TEI
import Text.Pandoc.Writers.Texinfo
import Text.Pandoc.Writers.Textile
Expand Down Expand Up @@ -169,6 +171,7 @@ writers = [
,("latex" , TextWriter writeLaTeX)
,("beamer" , TextWriter writeBeamer)
,("context" , TextWriter writeConTeXt)
,("sile" , TextWriter writeSILE)
,("texinfo" , TextWriter writeTexinfo)
,("man" , TextWriter writeMan)
,("ms" , TextWriter writeMs)
Expand Down
Loading
Loading