You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: examples/sile-and-djot.dj
+35-18Lines changed: 35 additions & 18 deletions
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
> "Djot (/dʒɑt/) is a light markup syntax.
4
4
> It derives most of its features from commonmark, but it fixes a few things
5
-
> that make ommonmark's syntax complex and difficult to parse efficiently.
5
+
> that make commonmark's syntax complex and difficult to parse efficiently.
6
6
> It is also much fuller-featured (...)"
7
7
^ From the [Djot website](https://djot.net/).
8
8
@@ -36,7 +36,7 @@ The core concepts in Djot mirror those of Markdown, featuring inline and block e
36
36
37
37
All ASCII punctuation characters (even those that have no special meaning in Djot) may be "backslash-escaped."
38
38
Thus, `\*` is parsed and rendered as a literal \* character.
39
-
Backslashes before characters other than ASCII punctuation characters are just treated as literal backslashes, except before a newline, and a space (or a tab) character.
39
+
Backslashes before other characters are treated as literal backslashes, except before a newline, and a space (or a tab) character.
40
40
We will get back to this later.
41
41
42
42
: Inline elements
@@ -61,13 +61,13 @@ The core concepts in Djot mirror those of Markdown, featuring inline and block e
61
61
62
62
## Attributes
63
63
64
-
Actually, let's start with attributes, as they have the same general syntax for both inline and block elements.
64
+
Let's start with attributes, as they have the same general syntax for both inline and block elements.
65
65
66
66
Attributes are put inside curly braces.
67
-
On inline elements, attributes are placed immediately after the element they are attached to, with no intervening whitespace.
67
+
On inline elements, they are placed immediately after the element they are attached to, with no intervening whitespace.
68
68
They may contain line breaks, and may be "stacked," in which case they are combined.
69
69
70
-
To attach attributes to a block-level element, put the attributes on the line immediately before the block.
70
+
To attach attributes to a block-level element, put them on the line immediately before the block.
71
71
Block attributes have the same syntax as inline attributes, but they must fit on one line.
72
72
Repeated attribute specifiers can also be used, and the attributes accumulate.
73
73
@@ -76,19 +76,24 @@ Inside the curly braces, the following syntax is possible:
76
76
- `#foo` specifies an identifier, for referencing purposes.
77
77
78
78
An element may have only one identifier; if multiple identifiers are given, the last one is used.
79
+
Identifiers shall be unique.
79
80
80
81
- `.foo` specifies a class, for styling purposes.
81
82
82
83
Multiple classes may be given in this way.
83
84
84
85
- `key="value"` or `key=value` specifies a key-value attribute.
85
86
86
-
Quotes are not needed when the value consists entirely of ASCII alphanumeric characters or `_` or `:` or `-`. Backslash escapes may be used inside quoted values.
87
+
Quotes are not needed when the value consists of ASCII alphanumeric characters or `_` or `:` or `-`. Backslash escapes may be used inside quoted values.
87
88
88
89
- `?foo` and `!foo` specify a condition.
89
90
90
91
This is an extension specific to this converter, see §[](#djot-conditional-attributes).
91
92
93
+
- `:foo` and `:foo=value` specify an index entry.
94
+
95
+
This is an extension specific to this converter, see §[](#djot-index-entries-custom).
96
+
92
97
## Inline elements
93
98
94
99
### Spaces
@@ -226,7 +231,7 @@ You might notice a small difference between 2^10^{fake=false} and 2^10^{fake=tru
226
231
```
227
232
:::
228
233
229
-
There is another, likely more important, implication.
234
+
There is another, more important, implication.
230
235
This converter assumes that the content of a superscript or subscript consists of text, as it tries to use font features or text scaling techniques to render it.
231
236
232
237
[^djot-textsubsuper]: Refer to the *textsubsuper* package for details.
@@ -414,7 +419,6 @@ Another link to [the SILE website][sile].
414
419
[sile]: https://sile-typesetter.org/
415
420
416
421
The reference label should be defined somewhere in the document.
417
-
If the label is empty, then the link text is taken to be the reference label as well as the link text.
418
422
419
423
{#djot-cross-references}
420
424
#### Cross-references
@@ -1314,31 +1318,35 @@ This is SILE and Djot at their best{custom-style="strong"}!
1314
1318
That's a fairly contrived way to obtain a bold text, but you get the underlying general idea.
1315
1319
This is one of the ways to use SILE commands in Djot.
1316
1320
While you could invoke _any_ SILE command with this feature, we recommend, though, to restrict it to styling.
1317
-
Another more powerful way to leverage Djot with SILE’s full processing capabilities, and benefit from the best of both worlds, is to use the "raw" annotations, described in §[](#djot-raw-inlines) and §[](#djot-raw-blocks).
1321
+
Another more powerful way to leverage Djot with SILE’s full processing capabilities, and benefit from the best of both worlds, is to use the "raw" annotations, described in §[](#djot-raw-inlines) and §[](#djot-raw-blocks); or filters, discussed in §[](#djot-configuration).
1318
1322
1319
1323
1320
1324
### Templates and variable substitution
1321
1325
1322
1326
[^:pumpernickel:]: Herbert _"Froggie"_ Pumpernickel{.smallcaps .nobreak}
1323
1327
1324
1328
Let's now pretend that you are writing an essay about some fictitious :pumpernickel:.
1329
+
At this point, you know how to typeset that name in Djot syntax:
1325
1330
1326
-
From the previous sections, you know how to typeset that name in Djot syntax:
Herbert _"Froggie"_ Pumpernickel{.smallcaps .nobreak}
1335
+
```
1336
+
:::
1328
1337
1329
1338
So far, so good...
1330
1339
But your problem is that this long name will appear a lot of times.
1331
1340
Repeating it is tedious and error-prone.
1332
1341
Would you appreciate defining it as a replaceable variable going by a much simpler name?
1333
1342
1334
-
Well, Djot has the notion of a "symbol", a keyword surrounded by colon signs (§[](#djot-symbols)).
1335
-
Although it was initially provisioned for "emojis", the default interpretation is now left to the rendering engine.
1343
+
Djot has the notion of a "symbol", a keyword surrounded by colon signs (§[](#djot-symbols)).
1344
+
The interpretation of such symbols is left to the rendering engine.
1345
+
This converter uses them in non-conventional ways.
1336
1346
1337
-
This converter for SILE is focussed on producing print-quality books, where so-called emojis play little part.
1338
-
We are therefore going to use those symbols in a non-conventional way.
1339
1347
Back to our initial question, what if you could just type `:pumpernickel:` and have it automatically expanded?
1340
1348
1341
-
Since it's possible to have unused footnote definitions, let's craft one as shown hereafter, with its reference identifier being the same as our targeted variable.
1349
+
It’s possible to define footnotes without ever using them, so let's first craft one here, with same reference identifier as our target variable.
1342
1350
1343
1351
{custom-style=CodeBlock}
1344
1352
:::
@@ -1347,7 +1355,8 @@ Since it's possible to have unused footnote definitions, let's craft one as show
1347
1355
```
1348
1356
:::
1349
1357
1350
-
When encountering a symbol, this converter looks for such a footnote and expands its content.
1358
+
When encountering a symbol, the converter looks for such a footnote and expands its content.
1359
+
1351
1360
It works with inline elements as shown above, but also with full blocks, provided the symbol is the only element in a paragraph of its own.
1352
1361
Of course, these pseudo-footnotes[^djot-pseudo-footnotes] can in turn contain symbols, which get replaced too.
1353
1362
@@ -1441,11 +1450,11 @@ Optionally, an `indexed-⟨index⟩` attribute may be provided to define the tex
1441
1450
```
1442
1451
:::
1443
1452
1453
+
{#djot-index-entries-custom}
1444
1454
#### Shortcut syntax for indexing entries
1445
1455
1446
1456
The syntax above is fully valid Djot and thus portable to other converters.
1447
1457
However, it tends to be somewhat verbose and less than _lightweight_ in practice.
1448
-
1449
1458
For convenience, our Djot implementation also supports a more compact, non-standard syntax that is easier to type.
1450
1459
1451
1460
{custom-style=CodeBlock}
@@ -1494,3 +1503,11 @@ For document classes supporting it (in particular, the *resilient* book class),
1494
1503
\include[src=somefile.dj, shift_headings=-1]
1495
1504
```
1496
1505
:::
1506
+
1507
+
For developers, the converter also accepts a `filter` option, whose value is the name of a Lua script (with or without the `.lua` extension).
1508
+
This script is loaded in a sandboxed environment and must return a table of filters in the form expected by the **djot.lua** library.
1509
+
1510
+
Filters traverse the Djot AST and rewrite it, following the transformation rules you define.
1511
+
They can be useful to customize the conversion process in arbitrary ways --- adding features, modifying formatting, or transforming content structure in ways this converter doesn't provide out of the box.
1512
+
1513
+
In other terms, in addition to raw annotations, custom styles and programmatic symbols, filters are another way to adapt this converter to your specific needs.
Copy file name to clipboardExpand all lines: examples/sile-and-markdown.md
+8Lines changed: 8 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1311,6 +1311,14 @@ This is one of the ways to use SILE commands in Djot.
1311
1311
While you could invoke _any_ SILE command with this feature, we recommend, though, to restrict it to styling.
1312
1312
Another more powerful way to leverage Djot with SILE’s full processing capabilities, and benefit from the best of both worlds, is to use the "raw" annotations, described in §[](#markdown-raw-inlines) and §[](#markdown-raw-blocks).
1313
1313
1314
+
::: {custom-style=Difference}
1315
+
{height=1.3ex} **Main differences with Djot**
1316
+
1317
+
- Only works on divs and spans (versus almost any element in Djot).
1318
+
1319
+
:::
1320
+
1321
+
1314
1322
### Index entries
1315
1323
1316
1324
Markdown does not provide a built-in syntax for marking index entries within the text.
0 commit comments