size: 1004 B
| 1 | Capitalize text: |
| 2 | |
| 3 | ``` |
| 4 | *Hello* world `code` |
| 5 | ! |
| 6 | return { |
| 7 | str = function(e) |
| 8 | e.text = e.text:upper() |
| 9 | end |
| 10 | } |
| 11 | . |
| 12 | <p><strong>HELLO</strong> WORLD <code>code</code></p> |
| 13 | ``` |
| 14 | |
| 15 | Capitalize text inside emphasis only: |
| 16 | |
| 17 | ``` |
| 18 | _Hello *world*_ outside |
| 19 | ! |
| 20 | local capitalize = 0 |
| 21 | return { |
| 22 | emph = { |
| 23 | enter = function(e) |
| 24 | capitalize = capitalize + 1 |
| 25 | end, |
| 26 | exit = function(e) |
| 27 | capitalize = capitalize - 1 |
| 28 | end, |
| 29 | }, |
| 30 | str = function(e) |
| 31 | if capitalize > 0 then |
| 32 | e.text = e.text:upper() |
| 33 | end |
| 34 | end |
| 35 | } |
| 36 | . |
| 37 | <p><em>HELLO <strong>WORLD</strong></em> outside</p> |
| 38 | ``` |
| 39 | |
| 40 | Capitalize text except in footnotes: |
| 41 | |
| 42 | ``` a |
| 43 | Hello[^1]. |
| 44 | |
| 45 | [^1]: This is a note. |
| 46 | ! |
| 47 | return { |
| 48 | str = function(e) |
| 49 | e.text = e.text:upper() |
| 50 | end, |
| 51 | footnote = { |
| 52 | enter = function(e) |
| 53 | return true -- prevent traversing into children |
| 54 | end |
| 55 | } |
| 56 | } |
| 57 | . |
| 58 | doc |
| 59 | para |
| 60 | str text="HELLO" |
| 61 | footnote_reference text="1" |
| 62 | str text="." |
| 63 | footnotes |
| 64 | ["1"] = |
| 65 | footnote |
| 66 | para |
| 67 | str text="This is a note." |
| 68 | ``` |