diff options
| author | Bruce Hill <bitbucket@bruce-hill.com> | 2018-01-26 20:20:12 -0800 |
|---|---|---|
| committer | Bruce Hill <bitbucket@bruce-hill.com> | 2018-01-26 20:20:38 -0800 |
| commit | 90c56d31352a0eeccd382ef5921baf3af4971040 (patch) | |
| tree | 5167eafb5785c94b48458b18b0454222ca70c749 /lib/text.nom | |
| parent | d5aa4e52983712f9f4c5b23528d0c2dab12b0b33 (diff) | |
Added a ton of tests for virtually all the functionality. Helped me find
and fix a lot of latent problems.
Diffstat (limited to 'lib/text.nom')
| -rw-r--r-- | lib/text.nom | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/text.nom b/lib/text.nom index cbd0b3f..cd424b9 100644 --- a/lib/text.nom +++ b/lib/text.nom @@ -13,14 +13,15 @@ action [%texts joined with %glue] parse [joined %texts, %texts joined] as: %texts joined with "" compile [capitalized %text, %text capitalized] to - {expr:"(\(%text as lua expr)):gsub('%l', string.upper, 1)"} + {expr:"((\(%text as lua expr)):gsub('%l', string.upper, 1))"} compile [%text with %sub instead of %patt, %text s/%patt/%sub] to {expr:"((\(%text as lua expr)):gsub(\(%patt as lua expr), \(%sub as lua expr)))"} -compile [indented %text, %text indented] to {expr:"\%text:gsub('\\n','\\n'..(' '))"} +# TODO: figure out whether indent/dedent should affect first line +compile [indented %text, %text indented] to {expr:"((\%text):gsub('\\n','\\n'..(' ')))"} compile [dedented %obj, %obj dedented] to {expr:"nomsu:dedent(\(%obj as lua expr))"} -compile [%text indented %n times] to {expr:"\%text:gsub('\\n','\\n'..(' '):rep(\%n))"} +compile [%text indented %n times] to {expr:"((\%text):gsub('\\n','\\n'..(' '):rep(\%n)))"} # Text literals lua> ".." @@ -31,7 +32,7 @@ lua> ".." }; for name, e in pairs(escapes) do local lua = "'"..e.."'"; - nomsu:define_compile_action(name, \(!! code location !!), function() return {expr=text}; end); + nomsu:define_compile_action(name, \(!! code location !!), function() return {expr=lua}; end); end local colors = { ["reset color"]="\\\\27[0m", bright="\\\\27[1m", dim="\\\\27[2m", underscore="\\\\27[4m", |
