Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ctxdoc: 匹配 l3doc 的展开类型修改 #700

Merged
merged 1 commit into from
Mar 7, 2024

Conversation

atxy-blip
Copy link
Contributor

今天编译文档时发现 \tl_replace_all:Non 的定义也消失了,粗略翻了一圈没能追溯到 l3kernel 中的修改时间,先凑合提交了一个补丁来让代码跑起来。

此外,关于 #678,为了向后兼容性还是把 e 型展开手动补上了。

如果有更好的改法请不吝赐教!

@muzimuzhi
Copy link
Contributor

l3kernel 没有提供过 \tl_replace_all:NnnNon 变体 (variant),是 xecjk.sty 里定义的。

\cs_generate_variant:Nn \tl_replace_all:Nnn { Nno }

我看了一下,ctex.pdf 是用 xelatex 编译的,于是变体缺失问题在 ctex-kit 项目内部没有触发。你是在其他引擎下使用 ctxdoc.cls 了吗?

此外,关于 #678,为了向后兼容性还是把 e 型展开手动补上了。

ctxdoc.cls 是一个 ctex-kit 内部使用的、非公开的文档类,我觉得没必要考虑向后兼容性。(ctxdoc.cls 使用 l3kernel 内部的 l3doc.cls 已经是不推荐的做法,ctex-kit 要承受相应的代价。)

The l3doc class was written as some internal hack to to provide some initial support for the documentation of the l3 kernel code. It was never meant (and still isn't) as a general purpose class even though people have used it as is given that it was around.
latex3/latex3#1497 (comment)

不论是 ctex-kit 本身还是其他使用了 ctxdoc.cls(不推荐这么做)的项目,编译文档时把老的 l3kernell3doc.clsl3kernel 的一部分,总是一起发版)和新的 ctxdoc.cls 搭配使用是错误的做法。

可以在 ctxdoc.cls 里(软性)要求 l3doc 的最低版本为 2023-10-10,见 latex3/latex3@007b309

-\LoadClass{l3doc}
+\LoadClass{l3doc}[2023-10-10]

@atxy-blip
Copy link
Contributor Author

xecjk.sty 里定义的

可是你引用的是 Nno 变体,实际上出现的是 Non,项目中也仅有 ctxdoc.cls 一处用到 orz

\tl_replace_all:Non \l__codedoc_tmpa_tl

你是在其他引擎下使用 ctxdoc.cls 了吗?

我提供基于一个我使用的文档的 MWE 来复现问题,保存文件名为t.dtx,是用 xelatex 进行编译的。

% \iffalse meta-comment
% !TeX program  = XeLaTeX
% !TeX encoding = UTF-8
%
%<*internal>
\begingroup
  \def\NameOfLaTeXe{LaTeX2e}
\expandafter\endgroup\ifx\NameOfLaTeXe\fmtname\else
\csname fi\endcsname
%</internal>
%
%<*install>
\input docstrip.tex
\keepsilent
\askforoverwritefalse

\preamble
Preamble text
\endpreamble

\generate{
  \usedir{tex/latex/\jobname}
    \file{\jobname.cls}               {\from{\jobname.dtx}{class}}
%<*internal>
  \usedir{source/latex/\jobname}
    \file{\jobname.ins}               {\from{\jobname.dtx}{install}}
%</internal>
}

\endbatchfile
%</install>
%
%<*internal>
\fi
%</internal>
%
%
%<*driver>
\ProvidesFile{t.dtx}
\documentclass[fontset=fandol, scheme=plain]{ctxdoc}
\ExplSyntaxOn
\cs_generate_variant:Nn \__codedoc_get_hyper_target:nN { x } ^^A patch for current version of ctex
\ExplSyntaxOff
\begin{document}
  \DocInput{t.dtx}
\end{document}
%</driver>
% \fi
%
% \begin{implementation}
%
% \begin{macro}{\foo}
%    \begin{macrocode}
\foo
%    \end{macrocode}
% \end{macro}
%
% \end{implementation}
%

我觉得没必要考虑向后兼容性

这一点我了解了,会在全部问题讨论完后统一改一下。

@muzimuzhi
Copy link
Contributor

xecjk.sty 里定义的

可是你引用的是 Nno 变体,实际上出现的是 Non,项目中也仅有 ctxdoc.cls 一处用到 orz

你说的对,我看错了。

l3kernel 2023-12-08 之前,l3doc.cls 定义并使用 \tl_replace_all:NnnNonNno variants。从 latex3/latex3@96a159e2 (Reduce variant-generation in l3doc, 2023-11-27) 开始,l3doc.cls 不再定义这两个 variants,改为使用 NVnNnV。(使用 V 而非 o 是 LaTeX Project 的 Joseph Wright 的倾向。V 更贴近一般编程语言(取值,_v_alue),V 也只比 o 慢一点点。我个人在意识得到时,会更倾向于 o。)

也许 ctxdoc.cls 也可以使用 \tl_replace_all:NVn.(V-type 和 N 类似,所以对应的参数不用加大括号。)

diff --git a/support/ctxdoc.cls b/support/ctxdoc.cls
index 2d476b0..56b7d01 100644
--- a/support/ctxdoc.cls
+++ b/support/ctxdoc.cls
@@ -295,8 +295,8 @@
       { \use:n }
       {
         \tl_set:Nn \l__codedoc_tmpa_tl {#1}
-        \tl_replace_all:Non \l__codedoc_tmpa_tl
-          { \c_catcode_other_space_tl }
+        \tl_replace_all:NVn \l__codedoc_tmpa_tl
+          \c_catcode_other_space_tl
           { \fontspec_visible_space: }
         \__codedoc_macroname_prefix:o \l__codedoc_tmpa_tl
         \__codedoc_macroname_suffix:N #2

@muzimuzhi muzimuzhi merged commit 37f7b8b into CTeX-org:master Mar 7, 2024
3 checks passed
@@ -28,7 +28,7 @@
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{l3doc}}
\PassOptionsToClass{a4paper,full}{l3doc}
\ProcessOptions
\LoadClass{l3doc}
\LoadClass{l3doc}[2023-10-10]
Copy link
Contributor

@muzimuzhi muzimuzhi Mar 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

太小的修改容易过度 review,比如「这个修改要不要作为单独的 commit」。是我的问题,不要像我一样纠结。

Update: 其实在发之前的评论时,我还纠结这里的日期是写(根据已知信息)兼容的最老的(2023-10-10)还是最新的(2024-02-20)。

atxy-blip added a commit to nju-lug/NJUThesis that referenced this pull request Mar 7, 2024
@muzimuzhi muzimuzhi changed the title ctxdoc: 补充丢失的展开类型 ctxdoc: 匹配 l3doc 的展开类型修改 Mar 7, 2024
stone-zeng added a commit to stone-zeng/fduthesis that referenced this pull request Dec 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants