Skip to content

Commit

Permalink
Merge pull request #112 from Omikhleia/more-generic-logic
Browse files Browse the repository at this point in the history
More generic handling of code blocks, divs, etc.
  • Loading branch information
Omikhleia authored Feb 28, 2024
2 parents 6707e98 + 157088b commit 45b99ea
Show file tree
Hide file tree
Showing 20 changed files with 3,426 additions and 1,038 deletions.
114 changes: 50 additions & 64 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@
[![Luacheck](https://img.shields.io/github/actions/workflow/status/Omikhleia/markdown.sile/luacheck.yml?branch=main&label=Luacheck&logo=Lua)](https://github.com/Omikhleia/markdown.sile/actions?workflow=Luacheck)
[![Luarocks](https://img.shields.io/luarocks/v/Omikhleia/markdown.sile?label=Luarocks&logo=Lua)](https://luarocks.org/modules/Omikhleia/markdown.sile)

This collection of modules for the [SILE](https://github.com/sile-typesetter/sile) typesetting
system provides a complete redesign of its former native Markdown support, with
a great set of Pandoc-like extensions and plenty of extra goodies.
This collection of modules for the [SILE](https://github.com/sile-typesetter/sile) typesetting system provides a complete redesign of its former native Markdown support, with a great set of Pandoc-like extensions and plenty of extra goodies.

- **markdown** inputter and package: native support of Markdown files.
- **pandocast** inputter and package: native support of Pandoc JSON AST files.
- **djot** inputter and package: native support of Djot files.
- **pandocast** inputter and package: native support of Pandoc JSON AST files.

For casual readers, this collection notably aims at easily converting Markdown or Djot documents to print-quality PDFs.

Expand All @@ -23,23 +21,21 @@ Installation relies on the **luarocks** package manager.

To install the latest version, you may use the provided “rockspec”:

```
```shell
luarocks install markdown.sile
```

(Refer to the SILE manual for more detailed 3rd-party package installation information.)

## Usage

Basic usage is described just below. A more complete PDF version of the documentation (but not
necessarily the latest, see also further below for generating it from the sources) should be
available [HERE](https://drive.google.com/file/d/19VfSMmfBIZwr43U-W842IkSE349wdgZb/view?usp=sharing), or in our [Calaméo bookshelf](https://www.calameo.com/accounts/7349338).
Basic usage is described just below. A more complete PDF version of the documentation (but not necessarily the latest, see also further below for generating it from the sources) should be available [HERE](https://drive.google.com/file/d/19VfSMmfBIZwr43U-W842IkSE349wdgZb/view?usp=sharing), or in our [Calaméo bookshelf](https://www.calameo.com/accounts/7349338).

### Native Markdown package

From command line:

```
```shell
sile -u inputters.markdown somefile.md
```

Expand All @@ -61,38 +57,14 @@ Some **Markdown** content
\end{raw}
```

### Pandoc AST alternative package

_Prerequisites:_ The [LuaJSON](https://github.com/harningt/luajson) module must be installed and available to your SILE environment.
This topic is not covered here.

First, using the appropriate version of Pandoc, convert your file to a JSON AST:

```
pandoc -t json somefile.md -f markdown -o somefile.pandoc
```

Then, from command line:

```
sile -u inputters.pandocast somefile.pandoc
```

Or from SIL documents:

```
\use[module=packages.pandocast]
\include[src=somefile.pandoc]
```

### Native Djot package

[Djot](https://djot.net/) is a fairly recent “light markup syntax” derived from Markdown, fixing most of its complex syntax pitfalls, and also extending it on various aspects.
Since many concepts are similar, it felt rather natural to include it too in this collection, so that authors interested in Markdown can give it a try.

From command line:

```
```shell
sile -u inputters.djot somefile.dj
```

Expand All @@ -114,56 +86,71 @@ Some *Djot* content
\end{raw}
```

## Generating the documentation
### Pandoc AST alternative package

The example documentation/showcase in this repository additionally requires the `autodoc` package, so you may generate a PDF from it with as follows:
_Prerequisites:_ The [LuaJSON](https://github.com/harningt/luajson) module must be installed and available to your SILE environment.
This topic is not covered here.

```
sile -u inputters.markdown -u packages.autodoc examples/sile-and-markdown.md
First, using the appropriate version of Pandoc, convert your file to a JSON AST:

```shell
pandoc -t json somefile.md -f markdown -o somefile.pandoc
```

It assumes a default font, so a few things might not render as expected, and uses SILE's standard book class.
Then, from command line:

**Recommended:** For even best results (in this writer's biased opinion), provided you have installed the [resilient](https://github.com/Omikhleia/resilient.sile) collection of classes and packages:
```shell
sile -u inputters.pandocast somefile.pandoc
```

Or from SIL documents:

```
\use[module=packages.pandocast]
\include[src=somefile.pandoc]
```

## Generating the documentation

The example documentation/showcase in this repository needs the [resilient](https://github.com/Omikhleia/resilient.sile) collection of classes and packages to be installed.

To generate the PDF documentation from the sources, you may then use the following command:

```shell
sile -u inputters.silm examples/sile-and-markdown-manual.silm
```

The latter SIL “wrapper” document also loads extra packages before switching to Markdown, and defines additional commands and styles.
Moreover, it includes additional chapters, showcasing other advanced topics and cool use cases.
Needed fonts are Libertinus Serif, Symbola and Zallman Caps.

## Supported features

This is but an overview. For more details, please refer to the provided example Markdown document,
which also serves as documentation, showcase and reference guide.
This is but an overview. For more details, please refer to the provided example Markdown document, which also serves as documentation, showcase and reference guide.

- Standard Markdown and Djot typesetting (italic, bold, code, etc.)
- Standard Markdown and Djot typesetting (emphases, strong emphasis, code, etc.)
- Smart typography (quotes, apostrophes, ellipsis, dashes, etc.) with Markdown extensions (prime marks)
- Headers and header attributes
- Horizontal dividers (a.k.a. horizontal rules, with provision for asterisms, dinkuses, pendants...)
- Images (and image attributes, e.g. dimensions)
- TeX-like math
- Strikeout (a.k.a. deletions), etc.
- Subscript and superscript
- Footnotes (both regular and inline syntax support)
- Fenced code blocks (with attributes)
- Bracketed spans and fenced divs (with provisions for language change, custom styles, etc.)
- Underlines
- Hard line breaks and non-breaking spaces
- Underline, strikethrough, highlight, deletion, insertion (with provisions for custom styling)
- Small caps
- Spans (with provisions for language change, custom styles, etc.)
- Subscript and superscript
- Images (and image attributes, e.g. dimensions)
- Links (with special provisions for advanced cross-references)
- Footnotes
- TeX-like math
- Headers and header attributes
- Divs (with provisions for language change, custom styles, etc.)
- Lists
- Standard ordered lists and bulleted lists
- Fancy lists
- Task lists (GFM-like syntax)
- Definition lists
- Pipe tables (and table captions)
- Horizontal dividers / thematic breaks (with provision for asterisms, dinkuses, pendants...)
- Tables (and table captions)
- Code blocks (with attributes)
- Line blocks (with enhanced provision for poetry)
- Hard line breaks
- Raw attributes (escaping to inline SILE or Lua scripting)
- Raw inlines and raw blocks (escaping to SILE, in SIL language or Lua scripting)
- Raw inline HTML convenience subset in Markdown
- Advanced use of symbols in Djot (variable substitution and templating)
- Advanced use of symbols in Djot (variable substitution ,and templating)
- Advanced configuration (e.g. Markdown variants, headings shifting, etc.)

## Use with the resilient collection
Expand All @@ -176,7 +163,7 @@ Then, you can automatically benefit from a few advanced features.
Conversion from command-line just requires to load a resilient class, and optionally
the poetry package. For instance:

```
```shell
sile -c resilient.book -u inputters.markdown -u packages.resilient.poetry somefile.md
```

Expand Down Expand Up @@ -205,7 +192,6 @@ when these packages all reach a stable state.
Additional thanks to:

- Simon Cozens, _et al._ concerned, for the early attempts at using lunamark with SILE.
- Vít Novotný, for the good work on lunamark, and the impressive [witiko/markdown](https://github.com/Witiko/markdown)
package for (La)TeX - a great source of inspiration and a goal of excellence.
- Caleb Maclennan, for his early work on a Pandoc-to-SILE converter which, though on different grounds,
indirectly gave me the idea of the “pandocast” alternative approach.
- Vít Novotný, for the good work on lunamark, and the impressive [witiko/markdown](https://github.com/Witiko/markdown) package for (La)TeX - a great source of inspiration and a goal of excellence.
- Caleb Maclennan, for his early work on a Pandoc-to-SILE converter which, though on different grounds, indirectly gave me the idea of the “pandocast” alternative approach.
- John MacFarlane, for the Djot and Markdown libraries which empowers this module.
12 changes: 12 additions & 0 deletions examples/data-pie.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Players,Games,Points,Ties,Aces
Albert,10,3,1
Bertrand,20,6,5
Charly,15,11
Diane,25,,2
Elisabeth,29
Fabrice,6,,4
Gerard,12
Herbert,30,7
Ian,5,,3,40
John,25,,,30
Theo,22,5,,25
Loading

0 comments on commit 45b99ea

Please sign in to comment.