[latex3-commits] [latex3/latex3] main: Correct beahviour of implicit tokens in \text_purify:n (fixes #1208) (9d98dfb5a)
github at latex-project.org
github at latex-project.org
Thu May 18 22:57:10 CEST 2023
Repository : https://github.com/latex3/latex3
On branch : main
Link : https://github.com/latex3/latex3/commit/9d98dfb5a104c324478b4ac0ff0d0572e902a14d
>---------------------------------------------------------------
commit 9d98dfb5a104c324478b4ac0ff0d0572e902a14d
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date: Thu May 18 21:55:45 2023 +0100
Correct beahviour of implicit tokens in \text_purify:n (fixes #1208)
>---------------------------------------------------------------
9d98dfb5a104c324478b4ac0ff0d0572e902a14d
l3kernel/CHANGELOG.md | 1 +
l3kernel/l3text-purify.dtx | 22 +++++++++++--------
l3kernel/l3text.dtx | 8 ++++++-
l3kernel/testfiles/m3text004.luatex.tlg | 9 ++++++--
l3kernel/testfiles/m3text004.lvt | 39 +++++++++++++++++++++++++++++++++
l3kernel/testfiles/m3text004.ptex.tlg | 5 +++++
l3kernel/testfiles/m3text004.tlg | 9 ++++++--
l3kernel/testfiles/m3text004.uptex.tlg | 9 ++++++--
l3kernel/testfiles/m3text004.xetex.tlg | 9 ++++++--
9 files changed, 93 insertions(+), 18 deletions(-)
diff --git a/l3kernel/CHANGELOG.md b/l3kernel/CHANGELOG.md
index 365a3bd0c..171906676 100644
--- a/l3kernel/CHANGELOG.md
+++ b/l3kernel/CHANGELOG.md
@@ -15,6 +15,7 @@ this project uses date-based 'snapshot' version identifiers.
### Fixed
- Omit `0123456789` from URL escaping (issue \#838)
Leave implicit chars unchanged in `\text_expand:n` (fixes \#874)
+- Handlign of implicit chars in `\text_purify:n` (fixes \#1208)
## [2023-05-15]
diff --git a/l3kernel/l3text-purify.dtx b/l3kernel/l3text-purify.dtx
index e6c967ca0..e5db6a88d 100644
--- a/l3kernel/l3text-purify.dtx
+++ b/l3kernel/l3text-purify.dtx
@@ -271,20 +271,24 @@
{ \token_if_active_p:N #1 }
}
{
- \exp_args:Nv \@@_purify_replace:n
+ \exp_args:Nv \@@_purify_replace_auxi:n
{ l_@@_purify_ \token_to_str:N #1 _tl }
}
{
- \token_if_cs:NTF #1
- { \@@_purify_expand:N #1 }
- {
- \exp_args:Ne \@@_purify_store:n
- { \@@_token_to_explicit:N #1 }
- \@@_purify_loop:w
- }
+ \exp_args:Ne \@@_purify_replace_auxii:n
+ { \@@_token_to_explicit:N #1 }
+ }
+ }
+\cs_new:Npn \@@_purify_replace_auxi:n #1 { \@@_purify_loop:w #1 }
+\cs_new:Npn \@@_purify_replace_auxii:n #1
+ {
+ \token_if_cs:NTF #1
+ { \@@_purify_expand:N #1 }
+ {
+ \@@_purify_store:n {#1}
+ \@@_purify_loop:w
}
}
-\cs_new:Npn \@@_purify_replace:n #1 { \@@_purify_loop:w #1 }
\cs_new:Npn \@@_purify_expand:N #1
{
\str_if_eq:nnTF {#1} { \protect }
diff --git a/l3kernel/l3text.dtx b/l3kernel/l3text.dtx
index 72f67c9cd..d64d50b43 100644
--- a/l3kernel/l3text.dtx
+++ b/l3kernel/l3text.dtx
@@ -522,7 +522,13 @@
{ \token_if_mathchardef_p:N #1 }
{
\char_generate:nn {#1}
- { \char_value_catcode:n {#1} }
+ {
+ \if_int_compare:w \char_value_catcode:n {#1} = 10 \exp_stop_f:
+ 10
+ \else:
+ 12
+ \fi:
+ }
}
{#1}
}
diff --git a/l3kernel/testfiles/m3text004.luatex.tlg b/l3kernel/testfiles/m3text004.luatex.tlg
index afbb1475e..d2a054cb3 100644
--- a/l3kernel/testfiles/m3text004.luatex.tlg
+++ b/l3kernel/testfiles/m3text004.luatex.tlg
@@ -26,12 +26,17 @@ Opps not close token in $y = \sin \theta
$y=mx+c$ is an equation
============================================================
============================================================
-TEST 5: Letter-like commands
+TEST 5: Implicit tokens
+============================================================
+{}$&^^M#^_^^@ a*~%
+============================================================
+============================================================
+TEST 6: Letter-like commands
============================================================
^^c5^^e5^^e6^^f0^^dfł^^d8
============================================================
============================================================
-TEST 6: Accents
+TEST 7: Accents
============================================================
^^e4ĕi̋ǒu̇
^^f1r̨
diff --git a/l3kernel/testfiles/m3text004.lvt b/l3kernel/testfiles/m3text004.lvt
index 5a8083635..644d43b7e 100644
--- a/l3kernel/testfiles/m3text004.lvt
+++ b/l3kernel/testfiles/m3text004.lvt
@@ -46,6 +46,45 @@
\text_purify:n { \ensuremath { y = mx + c }~is~an~equation }
}
+\OMIT
+ \tex_chardef:D \tokenzero = `\\ % 0
+ \tex_chardef:D \tokeni = `\{ % 1
+ \tex_chardef:D \tokenii = `\} % 2
+ \tex_chardef:D \tokeniii = `\$% 3
+ \tex_chardef:D \tokeniv = `\& % 4
+ \tex_chardef:D \tokenv = `\^^M % 5
+ \tex_chardef:D \tokenvi = `\# % 6
+ \tex_chardef:D \tokenvii = `\^ % 7
+ \tex_chardef:D \tokenviii = `\_ % 8
+ \tex_chardef:D \tokenix = `\^^@ % 9
+ \tex_chardef:D \tokenx = `\ % 10
+ \tex_chardef:D \tokenxi = `\a % 11
+ \tex_chardef:D \tokenxii = `\* % 12
+ \tex_chardef:D \tokenxiii = `\~ % 13
+ \tex_chardef:D \tokenxiv = `\% % 14
+\TIMO
+
+\TESTEXP { Implicit~tokens }
+ {
+ \text_purify:n
+ {
+ \tokeni
+ \tokenii
+ \tokeniii
+ \tokeniv
+ \tokenv
+ \tokenvi
+ \tokenvii
+ \tokenviii
+ \tokenix
+ \tokenx
+ \tokenxi
+ \tokenxii
+ \tokenxiii
+ \tokenxiv
+ }
+ }
+
\sys_if_engine_ptex:T { \END }
\TESTEXP { Letter-like~commands }
diff --git a/l3kernel/testfiles/m3text004.ptex.tlg b/l3kernel/testfiles/m3text004.ptex.tlg
index 632ce1f8a..ce7eb5e57 100644
--- a/l3kernel/testfiles/m3text004.ptex.tlg
+++ b/l3kernel/testfiles/m3text004.ptex.tlg
@@ -25,3 +25,8 @@ Some text $y = \sin \theta $
Opps not close token in $y = \sin \theta
$y=mx+c$ is an equation
============================================================
+============================================================
+TEST 5: Implicit tokens
+============================================================
+{}$&^^M#^_^^@ a*~%
+============================================================
diff --git a/l3kernel/testfiles/m3text004.tlg b/l3kernel/testfiles/m3text004.tlg
index a7bcec9b4..c87cf72be 100644
--- a/l3kernel/testfiles/m3text004.tlg
+++ b/l3kernel/testfiles/m3text004.tlg
@@ -26,12 +26,17 @@ Opps not close token in $y = \sin \theta
$y=mx+c$ is an equation
============================================================
============================================================
-TEST 5: Letter-like commands
+TEST 5: Implicit tokens
+============================================================
+{}$&^^M#^_^^@ a*~%
+============================================================
+============================================================
+TEST 6: Letter-like commands
============================================================
^^c3^^85^^c3^^a5^^c3^^a6^^c3^^b0^^c3^^9f^^c5^^82^^c3^^98
============================================================
============================================================
-TEST 6: Accents
+TEST 7: Accents
============================================================
^^c3^^a4^^c4^^95i^^cc^^8b^^c7^^92u^^cc^^87
^^c3^^b1r^^cc^^a8
diff --git a/l3kernel/testfiles/m3text004.uptex.tlg b/l3kernel/testfiles/m3text004.uptex.tlg
index a7bcec9b4..c87cf72be 100644
--- a/l3kernel/testfiles/m3text004.uptex.tlg
+++ b/l3kernel/testfiles/m3text004.uptex.tlg
@@ -26,12 +26,17 @@ Opps not close token in $y = \sin \theta
$y=mx+c$ is an equation
============================================================
============================================================
-TEST 5: Letter-like commands
+TEST 5: Implicit tokens
+============================================================
+{}$&^^M#^_^^@ a*~%
+============================================================
+============================================================
+TEST 6: Letter-like commands
============================================================
^^c3^^85^^c3^^a5^^c3^^a6^^c3^^b0^^c3^^9f^^c5^^82^^c3^^98
============================================================
============================================================
-TEST 6: Accents
+TEST 7: Accents
============================================================
^^c3^^a4^^c4^^95i^^cc^^8b^^c7^^92u^^cc^^87
^^c3^^b1r^^cc^^a8
diff --git a/l3kernel/testfiles/m3text004.xetex.tlg b/l3kernel/testfiles/m3text004.xetex.tlg
index afbb1475e..d2a054cb3 100644
--- a/l3kernel/testfiles/m3text004.xetex.tlg
+++ b/l3kernel/testfiles/m3text004.xetex.tlg
@@ -26,12 +26,17 @@ Opps not close token in $y = \sin \theta
$y=mx+c$ is an equation
============================================================
============================================================
-TEST 5: Letter-like commands
+TEST 5: Implicit tokens
+============================================================
+{}$&^^M#^_^^@ a*~%
+============================================================
+============================================================
+TEST 6: Letter-like commands
============================================================
^^c5^^e5^^e6^^f0^^dfł^^d8
============================================================
============================================================
-TEST 6: Accents
+TEST 7: Accents
============================================================
^^e4ĕi̋ǒu̇
^^f1r̨
More information about the latex3-commits
mailing list.