Skip to content

Commit b8f6703

Browse files
OmikhleiaDidier Willis
authored andcommitted
feat: Rely on highligher.sile for syntax highlighting in code blocks
1 parent fe329c3 commit b8f6703

File tree

9 files changed

+380
-79
lines changed

9 files changed

+380
-79
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ This is but an overview. For more details, please refer to the provided example
147147
- Definition lists
148148
- Horizontal dividers / thematic breaks (with provision for asterisms, dinkuses, pendants...)
149149
- Tables (and table captions)
150-
- Code blocks (with attributes)
150+
- Code blocks (with attributes, and syntax highlighting when supported)
151151
- Line blocks (with enhanced provision for poetry)
152152
- Raw inlines and raw blocks (escaping to SILE, in SIL language or Lua scripting)
153153
- Raw inline HTML convenience subset in Markdown

examples/markdown-sile-overview.dot

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ digraph G {
1818
}
1919

2020
sile [shape=doublecircle, color="#e8ccd7 ", style=filled, label="SILE"];
21-
21+
2222
pandoc [shape=doublecircle, color="#d0d0d0", style=filled, label="Pandoc", fontsize=12];
23-
23+
2424
ast [shape=note, label="Pandoc\nAST", color="#c0c0c0", fontsize=12];
2525

2626
doc -> sile [label="native path", fontsize=11]

examples/markdown-sile-schema.dot

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
11
digraph omikhleia {
2-
rankdir=RL;
2+
rankdir=RL;
3+
compound=true;
4+
edge [
5+
arrowhead="vee"
6+
];
37

48
subgraph cluster_couyards {
59
label = "couyards.sile";
610

711
couyards [shape=component,style=filled,fillcolor=aliceblue]
812
}
913

14+
subgraph cluster_piecharts {
15+
label = "piecharts.sile";
16+
17+
piecharts [shape=component,style=filled,fillcolor=aliceblue]
18+
}
19+
1020
subgraph cluster_ptable {
1121
label = "ptable.sile";
1222

@@ -18,9 +28,9 @@ digraph omikhleia {
1828

1929
embedders [shape=component,style=filled,fillcolor=aliceblue]
2030
dot [style=filled,fillcolor=aliceblue]
21-
31+
2232
embedders -> dot
23-
}
33+
}
2434

2535
subgraph cluster_textsubsuper {
2636
label = "textsubsuper.sile";
@@ -34,18 +44,26 @@ digraph omikhleia {
3444
smartquotes [shape=component,style=filled,fillcolor=aliceblue]
3545

3646
}
37-
47+
3848
subgraph cluster_labelrefs {
3949
label = "labelrefs.sile";
4050

4151
labelrefs [shape=component,style=filled,fillcolor=aliceblue]
4252
}
4353

54+
subgraph cluster_highlighter {
55+
label = "highlighter.sile";
56+
57+
highlighter [shape=component,style=filled,fillcolor=aliceblue]
58+
}
59+
4460
subgraph cluster_resilient {
4561
label = "resilient.sile";
4662

4763
book [shape=component,style=filled,fillcolor=aliceblue,label="resilient.book"]
4864
poetry [shape=component,style=filled,fillcolor=aliceblue,label="resilient.poetry"]
65+
defn [shape=component,style=filled,fillcolor=aliceblue,label="resilient.defn"]
66+
epigraph [shape=component,style=filled,fillcolor=aliceblue,label="resilient.epigraph"]
4967
}
5068

5169
subgraph cluster_markdown {
@@ -66,13 +84,14 @@ digraph omikhleia {
6684
mrkcmd -> ptable
6785
mrkcmd -> smartquotes
6886
mrkcmd -> textsubsuper
69-
mrkcmd -> poetry [style=dashed]
70-
mrkcmd -> book [style=dashed]
87+
mrkcmd -> highlighter
7188
mrkcmd -> couyards [style=dashed]
89+
mrkcmd -> piecharts [style=dashed]
7290
}
73-
91+
7492
mybook [shape = circle, label="Markdown\nfor\nSILE", fontsize="25"]
7593
mybook -> markdown
7694
mybook -> pandocast
7795
mybook -> djot
96+
mybook -> book [style=dashed, lhead=cluster_resilient]
7897
}

examples/sile-and-djot.dj

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,6 @@ Files in Graphviz DOT graph language (`.dot`) are supported and rendered as imag
346346

347347
![The *markdown.sile* ecosystem (simplified).](./markdown-sile-schema.dot){width="90%"}
348348

349-
This image is obtained with the following syntax.
350-
351349
{custom-style=CodeBlock}
352350
:::
353351
```
@@ -621,7 +619,7 @@ Here is an example illustrating the use of these attributes:
621619

622620
Other attributes are passed through to the underlying heading implementation, which might do something with them.[^djot-heading-level-mapping]
623621

624-
[^djot-heading-level-mapping]: The converter assumes it can map heading levels to SILE commands `part`, `chapter`, `section`, `subsection`, `subsubsection`.
622+
[^djot-heading-level-mapping]: The converter assumes it can map heading levels to commands `part`, `chapter`, `section`, `subsection`, `subsubsection`.
625623
It uses a very basic fallback if these are not found (or if the sectioning level gets past that point).
626624
Also note that parts are supported by the *resilient* book class as a level 0 heading, and are therefore only available when header shifting is applied (see §[](#djot-configuration)).
627625

@@ -931,7 +929,7 @@ In most cases, the content is rendered as verbatim text, with some exceptions de
931929

932930
#### Lua code blocks
933931

934-
Code blocks marked as being in the Lua language are rendered as verbatim text, with syntax highlighting.
932+
Code blocks are rendered as verbatim text, with syntax highlighting when possible.
935933
For instance, the following code block...
936934

937935
{custom-style=CodeBlock}
@@ -962,12 +960,12 @@ end
962960
^ An example of a syntax-highlighted Lua code snippet.
963961

964962

965-
This is a very naive approach to syntax-highlighting, until the converter possibly supports a more general solution.
963+
Syntax-highlighting is applied to languages recognized by Scintillua.
966964

967965
#### Rendered code blocks
968966

969967
If the converter knows how to render the content of a code block, it does so by default.
970-
The `render` attribute can be set to `false` to prevent this behavior, and enforce the content to be rendered as raw verbatim text.
968+
The `render` attribute can be set to `false` to prevent this behavior, and enforce the content to be rendered as raw verbatim text (possibly with syntax highlighting).
971969

972970
: Mardown and Djot code blocks
973971

0 commit comments

Comments
 (0)