diff options
author | Hans Hagen <pragma@wxs.nl> | 2010-05-18 10:57:00 +0200 |
---|---|---|
committer | Hans Hagen <pragma@wxs.nl> | 2010-05-18 10:57:00 +0200 |
commit | cf10a29d938a8fd2ad81f8034b53ee7409990169 (patch) | |
tree | 1c53e21b95e86196c426a4cdda48000c6174eb8e /tex/context/base/char-tex.lua | |
parent | 89f1dbd1efbc71e5a74d798142ae5275e6f097ff (diff) | |
download | context-cf10a29d938a8fd2ad81f8034b53ee7409990169.tar.gz |
beta 2010.05.18 10:57
Diffstat (limited to 'tex/context/base/char-tex.lua')
-rw-r--r-- | tex/context/base/char-tex.lua | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/tex/context/base/char-tex.lua b/tex/context/base/char-tex.lua index 3e726703a..ed9a244d7 100644 --- a/tex/context/base/char-tex.lua +++ b/tex/context/base/char-tex.lua @@ -66,10 +66,24 @@ local commands = (P('\\') * C(R("az","AZ")^1)) / remap_commands local convert_accents = Cs((accents + P(1))^0) local convert_commands = Cs((commands + P(1))^0) -function characters.tex.toutf(str) - if find(str,"\\") then - str = lpegmatch(convert_commands,str) - str = lpegmatch(convert_accents,str) +local no_l = P("{") / "" +local no_r = P("}") / "" + +local convert_accents_strip = Cs((no_l * accents * no_r + accents + P(1))^0) +local convert_commands_strip = Cs((no_l * commands * no_r + commands + P(1))^0) + +function characters.tex.toutf(str,strip) + if find(str,"\\") then -- we can start at teh found position + if strip then + str = lpegmatch(convert_commands_strip,str) + str = lpegmatch(convert_accents_strip,str) + else + str = lpegmatch(convert_commands,str) + str = lpegmatch(convert_accents,str) + end end return str end + +--~ print(characters.tex.toutf([[\"{e}]]),true) +--~ print(characters.tex.toutf([[{\"{e}}]],true)) |