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
+ Result:
30
+
31
+ > <div id =" output " >
32
+ >
33
+ > 1 + 2 = 3
34
+ >
35
+ > </div >
36
+
25
37
The filter tries to detect when the ` return ` has been omitted and
26
38
inserts it automatically in that case. Therefore, the above can be
27
39
shortened to
28
40
29
41
``` xml
30
- <?lua 1 + 2 ?>
42
+ 1 + 2 = <?lua 1 + 2 ?>
31
43
```
32
44
45
+ > <div id =" output " >
46
+ >
47
+ > 1 + 2 = 3
48
+ >
49
+ > </div >
50
+
33
51
Raw attributes syntax with format ` run-lua ` or ` runlua ` can be
34
52
used as an alternative to the processing-instructions-based
35
53
syntax.
36
54
37
55
For example,
38
56
39
- ````` markdown
40
- 𝜋 ≈ `math.pi`{=runlua}
41
- `````
57
+ ``` markdown
58
+ 𝜋 ≈ `math.pi`{=run-lua}
59
+
60
+ 𝜏 ≈ `2 * math.pi`{=runlua}
61
+ ```
42
62
43
63
yields
44
64
65
+ > <div id =" output " >
66
+ >
45
67
> 𝜋 ≈ 3.1415926535898
68
+ >
69
+ > 𝜏 ≈ 6.2831853071796
70
+ >
71
+ > </div >
46
72
47
- ** Note** that pandoc isn' t an XML processor, and the processing
73
+ ** Note** that pandoc isn’ t an XML processor, and the processing
48
74
instruction is terminated by a single ` > ` . Use the “raw attribute”
49
75
syntax if your code contains that character:
50
76
51
77
```{=runlua}
52
78
return 1 > 0 and 'all is well'
53
79
```
54
80
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
81
Usage
60
- ------------------------------------------------------------------
82
+ -----
61
83
62
84
The filter modifies the internal document representation; it can
63
85
be used with many publishing systems that are based on pandoc.
@@ -75,8 +97,8 @@ Users of Quarto can install this filter as an extension with
75
97
76
98
quarto install extension pandoc-ext/run-lua
77
99
78
- and use it by adding ` run-lua ` to the ` filters ` entry
79
- in their YAML header.
100
+ and use it by adding ` run-lua ` to the ` filters ` entry in their
101
+ YAML header.
80
102
81
103
``` yaml
82
104
---
@@ -100,7 +122,7 @@ output:
100
122
```
101
123
102
124
License
103
- ------------------------------------------------------------------
125
+ -------
104
126
105
127
This pandoc Lua filter is published under the MIT license, see
106
128
file ` LICENSE ` for details.
0 commit comments