1
1
run-lua
2
- ==================================================================
2
+ =======
3
3
4
4
Executes any Lua command in a ` lua ` XML processing instruction and
5
5
includes the result in the document.
6
6
7
7
Example:
8
8
9
9
``` markdown
10
- The fifth triangular number is <?lua return 1 + 2 + 3 + 4 + 5?>.
10
+ The number <?lua return 1 + 2 + 3 + 4 + 5?> is the fifth triangular number .
11
11
```
12
12
13
13
This yields
14
14
15
- > The fifth triangular number is 15.
15
+ > <div id =" output " >
16
+ >
17
+ > The number 15 is the fifth triangular number.
18
+ >
19
+ > </div >
16
20
17
- The value that' s returned by the Lua code is spliced back into the
21
+ The value that’ s returned by the Lua code is spliced back into the
18
22
document. The ` = ` character can be used as a shorthand for
19
23
` return ` when placed at the beginning of an expression.
20
24
21
25
``` xml
22
- <?lua =1 + 2 ?>
26
+ 1 + 2 = <?lua =1 + 2 ?>
23
27
```
24
28
29
+ <details >
30
+
31
+ Result:
32
+
33
+ > <div id =" output " >
34
+ >
35
+ > 1 + 2 = 3
36
+ >
37
+ > </div >
38
+
39
+ </details >
40
+
25
41
The filter tries to detect when the ` return ` has been omitted and
26
42
inserts it automatically in that case. Therefore, the above can be
27
43
shortened to
28
44
29
45
``` xml
30
- <?lua 1 + 2 ?>
46
+ 1 + 2 = <?lua 1 + 2 ?>
31
47
```
32
48
49
+ <details >
50
+
51
+ > <div id =" output " >
52
+ >
53
+ > 1 + 2 = 3
54
+ >
55
+ > </div >
56
+
57
+ </details >
58
+
33
59
Raw attributes syntax with format ` run-lua ` or ` runlua ` can be
34
60
used as an alternative to the processing-instructions-based
35
61
syntax.
36
62
37
63
For example,
38
64
39
- ````` markdown
40
- 𝜋 ≈ `math.pi`{=runlua}
41
- `````
65
+ ``` markdown
66
+ 𝜋 ≈ `math.pi`{=run-lua}
67
+
68
+ 𝜏 ≈ `2 * math.pi`{=runlua}
69
+ ```
42
70
43
71
yields
44
72
73
+ > <div id =" output " >
74
+ >
45
75
> 𝜋 ≈ 3.1415926535898
76
+ >
77
+ > 𝜏 ≈ 6.2831853071796
78
+ >
79
+ > </div >
46
80
47
- ** Note** that pandoc isn' t an XML processor, and the processing
81
+ ** Note** that pandoc isn’ t an XML processor, and the processing
48
82
instruction is terminated by a single ` > ` . Use the “raw attribute”
49
83
syntax if your code contains that character:
50
84
51
85
```{=runlua}
52
86
return 1 > 0 and 'all is well'
53
87
```
54
88
55
- [ CI badge ] : https://img.shields.io/github/actions/workflow/status/pandoc-ext/run-lua/ci.yaml?branch=main&logo=github
56
- [ CI workflow ] : https://github.com/pandoc-ext/run-lua/actions/workflows/ci.yaml
57
-
58
-
59
89
Usage
60
- ------------------------------------------------------------------
90
+ -----
61
91
62
92
The filter modifies the internal document representation; it can
63
93
be used with many publishing systems that are based on pandoc.
@@ -75,8 +105,8 @@ Users of Quarto can install this filter as an extension with
75
105
76
106
quarto install extension pandoc-ext/run-lua
77
107
78
- and use it by adding ` run-lua ` to the ` filters ` entry
79
- in their YAML header.
108
+ and use it by adding ` run-lua ` to the ` filters ` entry in their
109
+ YAML header.
80
110
81
111
``` yaml
82
112
---
@@ -100,7 +130,7 @@ output:
100
130
```
101
131
102
132
License
103
- ------------------------------------------------------------------
133
+ -------
104
134
105
135
This pandoc Lua filter is published under the MIT license, see
106
136
file ` LICENSE ` for details.
0 commit comments