Skip to content

Commit

Permalink
xeCJK: 修复下划线中数学公式的错误处理
Browse files Browse the repository at this point in the history
closed #614
  • Loading branch information
qinglee committed Jul 27, 2022
1 parent f85a422 commit ad44c66
Showing 1 changed file with 41 additions and 16 deletions.
57 changes: 41 additions & 16 deletions xeCJK/xeCJK.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ Copyright and Licence
% \changes{v3.8.0}{2020/02/09}{清理过时的兼容性补丁代码。}
% \changes{v3.8.3}{2020/04/07}{删除 \texttt{\_nopar}。}
%
% \CheckSum{11005}
% \CheckSum{11033}
% \GetFileId{xeCJK.sty}
%
% \title{\bfseries\pkg{xeCJK} 宏包}
Expand Down Expand Up @@ -9262,7 +9262,7 @@ Copyright and Licence
% \begin{macrocode}
\cs_new_protected:Npn \xeCJK_ulem_word:nw #1 ~
{
\exp_after:wN \UL@start #1 ~
\@@_ulem_start:w #1 ~
\exp_after:wN \if_meaning:w \exp_after:wN \UL@end #1
\exp_after:wN \@@_ulem_end:
\else:
Expand Down Expand Up @@ -9290,6 +9290,8 @@ Copyright and Licence
\fi:
\xeCJK_ulem_word:nw \prg_do_nothing:
}
\cs_new_protected:Npn \@@_ulem_start:w
{ \exp_after:wN \UL@start }
\cs_set_eq:NN \UL@word \xeCJK_ulem_word:nw
% \end{macrocode}
% \end{macro}
Expand Down Expand Up @@ -9582,33 +9584,56 @@ Copyright and Licence
% \end{macrocode}
% \end{macro}
%
% \changes{v3.9.1}{2022/07/28}{修复下划线中数学公式的错误处理。}
%
% \begin{macro}{\@@_ulem_CJK_and_Boundary:w}
% \begin{macrocode}
\cs_new_protected:Npn \@@_ulem_CJK_and_Boundary:w
{
\xeCJK_if_ulem_patch:TF
{
\xeCJK_peek_catcode_ignore_spaces:NTF \c_math_toggle_token
{
\xeCJK_class_group_end: \UL@stop
\CJKecglue
\UL@start
}
{ \xeCJK_class_group_end: \CJKecglue }
{
\bool_if:NTF \l_@@_peek_ignore_spaces_bool
{
\xeCJK_class_group_end: \UL@stop
\UL@start { \xeCJK_make_node:n { CJK-space } }
}
{
\xeCJK_class_group_end: \UL@stop
\UL@start { \xeCJK_make_node:n { CJK } }
}
\xeCJK_make_group_tag:
{ \@@_ulem_peek_math:w }
{ \@@_ulem_group_end:n { CJK } }
}
}
{ \@@_ulem_CJK_and_Boundary:w }
}
\cs_new_protected:Npn \@@_ulem_group_end:n #1
{
\xeCJK_class_group_end: \UL@stop
\UL@start { \xeCJK_make_node:n {#1} }
\xeCJK_make_group_tag:
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_ulem_peek_math:w}
% 用于处理下划线中,汉字与 |$| 之间有空格的情况^^A
% \footnote{\url{https://github.com/CTeX-org/ctex-kit/issues/614}}。
% \begin{macrocode}
\cs_new_protected:Npn \@@_ulem_peek_math:w
{
\cs_set_eq:NN \@@_ulem_start:w \@@_ulem_exp_stop:w
\exp_after:wN \peek_after:Nw
\exp_after:wN \@@_ulem_peek_math_branches:w
\exp:w \exp_end_continue_f:w
}
\cs_new_protected:Npn \@@_ulem_peek_math_branches:w
{
\token_if_math_toggle:NTF \l_peek_token
{ \xeCJK_class_group_end: \CJKecglue }
{ \@@_ulem_group_end:n { CJK-space } }
}
\cs_new_protected:Npn \@@_ulem_exp_stop:w
{
\cs_if_eq:NNTF \UL@start \@empty
{ \exp_after:wN \exp_stop_f: }
{ \exp_after:wN \UL@start }
}
% \end{macrocode}
% \end{macro}
%
Expand Down

0 comments on commit ad44c66

Please sign in to comment.