Skip to content

Commit

Permalink
remove \\ and inter-han spaces in title
Browse files Browse the repository at this point in the history
Close #265.
  • Loading branch information
stone-zeng committed Feb 12, 2023
1 parent 0769f06 commit c1f9e3e
Show file tree
Hide file tree
Showing 6 changed files with 143 additions and 35 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- 新增
- 新增 `acknowledgements` 环境 - [#253]
- 修复
- 删除论文标题中的 `\\` 和汉字间的空格 - [#264][#265]
- 在目录和书签中删除章标题中的 `\quad`
- 改用 `\DeclareDocumentCommand` 定义 `\newtheorem``\hypersetup` 以防冲突
- 优化
Expand Down Expand Up @@ -265,11 +266,13 @@
[#227]: https://github.com/stone-zeng/fduthesis/issues/227
[#229]: https://github.com/stone-zeng/fduthesis/issues/229
[#239]: https://github.com/stone-zeng/fduthesis/issues/239
[#265]: https://github.com/stone-zeng/fduthesis/issues/265

[#64]: https://github.com/stone-zeng/fduthesis/pull/64
[#233]: https://github.com/stone-zeng/fduthesis/pull/233

[#253]: https://github.com/stone-zeng/fduthesis/discussions/253
[#264]: https://github.com/stone-zeng/fduthesis/discussions/264

[ctex-kit#303]: https://github.com/CTeX-org/ctex-kit/issues/303
[ustctug/ustcthesis#223]: https://github.com/ustctug/ustcthesis/issues/223
Expand Down
46 changes: 38 additions & 8 deletions source/fduthesis.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -2830,13 +2830,14 @@ Copyright (C) 2017&ndash;2023 by Xiangdong Zeng <[email protected]>.
%
% \subsubsection{内部函数}
%
% \begin{macro}{\file_input:V,\int_to_arabic:v,\keys_define:nx}
% \begin{macro}{\file_input:V,\int_to_arabic:v,\keys_define:nx,\regex_replace_all:nnc}
% \begin{macro}[TF]{\tl_if_eq:Vn}
% \LaTeX3{} 函数变体。
% \begin{macrocode}
\cs_generate_variant:Nn \file_input:n { V }
\cs_generate_variant:Nn \int_to_arabic:n { v }
\cs_generate_variant:Nn \keys_define:nn { nx }
\cs_generate_variant:Nn \file_input:n { V }
\cs_generate_variant:Nn \int_to_arabic:n { v }
\cs_generate_variant:Nn \keys_define:nn { nx }
\cs_generate_variant:Nn \regex_replace_all:nnN { nnc }
\prg_generate_conditional_variant:Nnn \tl_if_eq:nn { Vn } { T, TF }
% \end{macrocode}
% \end{macro}
Expand Down Expand Up @@ -4595,6 +4596,35 @@ Copyright (C) 2017&ndash;2023 by Xiangdong Zeng <[email protected]>.
% \end{macrocode}
% \end{variable}
%
% \changes{v0.8a}{2023/02/12}{删除论文标题中的 \tn{\textbackslash} 和汉字间的空格。}
%
% \begin{variable}{\l_@@_info_title_sanitized_tl,
% \l_@@_info_title_en_sanitized_tl}
% 处理后的论文标题。
% \begin{macrocode}
\tl_new:N \l_@@_info_title_sanitized_tl
\tl_new:N \l_@@_info_title_en_sanitized_tl
% \end{macrocode}
% \end{variable}
%
% \begin{macro}{\@@_set_title:nn}
% 设置论文标题,并删除其中的 |\\| 和汉字间的空格。
% \begin{macrocode}
\cs_new_protected:Npn \@@_set_title:nn #1#2
{
\tl_set:cn { l_@@_info_ #1 _tl } {#2}
\tl_set:cn { l_@@_info_ #1 _sanitized_tl } {#2}
\tl_replace_all:cnn { l_@@_info_ #1 _sanitized_tl } { \\ } { ~ }
\regex_replace_all:nnc
{ \s+ } { \ }
{ l_@@_info_ #1 _sanitized_tl }
\regex_replace_all:nnc
{ ([\x{4e00}-\x{9fff}]) \s+ ([\x{4e00}-\x{9fff}]) } { \1 \2 }
{ l_@@_info_ #1 _sanitized_tl }
}
% \end{macrocode}
% \end{macro}
%
% 定义 |fdu/info| 键值类。
% \begin{macrocode}
\keys_define:nn { fdu / info }
Expand All @@ -4615,8 +4645,8 @@ Copyright (C) 2017&ndash;2023 by Xiangdong Zeng <[email protected]>.
% \begin{macro}{info/title,info/title*}
% 论文题目。以下带星号的项目均表示相应的英文字段。
% \begin{macrocode}
title .tl_set:N = \l_@@_info_title_tl,
title* .tl_set:N = \l_@@_info_title_en_tl,
title .code:n = { \@@_set_title:nn { title } {#1} },
title* .code:n = { \@@_set_title:nn { title_en } {#1} },
% \end{macrocode}
% \end{macro}
%
Expand Down Expand Up @@ -6060,12 +6090,12 @@ Copyright (C) 2017&ndash;2023 by Xiangdong Zeng <[email protected]>.
% 填写 PDF 元信息。
% \begin{macrocode}
%<*class>
pdftitle = \l_@@_info_title_tl,
pdftitle = \l_@@_info_title_sanitized_tl,
pdfauthor = \l_@@_info_author_tl,
pdfkeywords = \l_@@_info_keywords_clist,
%</class>
%<*class-en>
pdftitle = \l_@@_info_title_en_tl,
pdftitle = \l_@@_info_title_en_sanitized_tl,
pdfauthor = \l_@@_info_author_en_tl,
pdfkeywords = \l_@@_info_keywords_en_clist,
%</class-en>
Expand Down
47 changes: 37 additions & 10 deletions testfiles/01-internal.luatex.tlg
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,7 @@ l. ... }
l. ... }
============================================================
============================================================
TEST 2: Theorem define
============================================================
> Empty at present..
<recently read> }
l. ... }
============================================================
============================================================
TEST 3: Boxes in thesis cover
TEST 2: Boxes in thesis cover
============================================================
> \box...=
\hbox(8.14243+0.16862)x142.26378, direction TLT
Expand Down Expand Up @@ -382,7 +375,7 @@ l. ... }
l. ... }
============================================================
============================================================
TEST 4: Boxes in thesis cover (underfull)
TEST 3: Boxes in thesis cover (underfull)
============================================================
> \box...=
\hbox(19.0334+13.01155)x56.9055, direction TLT
Expand Down Expand Up @@ -478,8 +471,42 @@ l. ... }
l. ... }
============================================================
============================================================
TEST 5: Text width
TEST 4: Text width
============================================================
> \l_tmpa_dim=33.461pt.
> \l_tmpa_dim=48.18pt.
============================================================
============================================================
TEST 5: Sanitizing title
============================================================
> \l__fdu_info_title_tl=论文标题.
> \l__fdu_info_title_sanitized_tl=论文标题.
> \l__fdu_info_title_tl=论文 标题.
> \l__fdu_info_title_sanitized_tl=论文标题.
> \l__fdu_info_title_tl=论文\\标题.
> \l__fdu_info_title_sanitized_tl=论文标题.
> \l__fdu_info_title_tl=论文 \\ 标题.
> \l__fdu_info_title_sanitized_tl=论文标题.
> \l__fdu_info_title_tl=论文标题ABC.
> \l__fdu_info_title_sanitized_tl=论文标题ABC.
> \l__fdu_info_title_tl=论文标题 ABC.
> \l__fdu_info_title_sanitized_tl=论文标题 ABC.
> \l__fdu_info_title_tl=论文标题\\ABC.
> \l__fdu_info_title_sanitized_tl=论文标题 ABC.
> \l__fdu_info_title_tl=论文标题 \\ABC.
> \l__fdu_info_title_sanitized_tl=论文标题 ABC.
> \l__fdu_info_title_tl=论文标题\\ ABC.
> \l__fdu_info_title_sanitized_tl=论文标题 ABC.
> \l__fdu_info_title_tl=论文标题 \\ ABC.
> \l__fdu_info_title_sanitized_tl=论文标题 ABC.
> \l__fdu_info_title_tl=ABC DEF.
> \l__fdu_info_title_sanitized_tl=ABC DEF.
> \l__fdu_info_title_tl=ABC\\DEF.
> \l__fdu_info_title_sanitized_tl=ABC DEF.
> \l__fdu_info_title_tl=ABC \\DEF.
> \l__fdu_info_title_sanitized_tl=ABC DEF.
> \l__fdu_info_title_tl=ABC\\ DEF.
> \l__fdu_info_title_sanitized_tl=ABC DEF.
> \l__fdu_info_title_tl=ABC \\ DEF.
> \l__fdu_info_title_sanitized_tl=ABC DEF.
============================================================
32 changes: 27 additions & 5 deletions testfiles/01-internal.lvt
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,6 @@
\fdutest_footnote_number:nn { pifont-sans* } { 16 } % Overflow
}

\TEST { Theorem~ define }
{
\tl_show:n { Empty~ at~ present. }
}

\OMIT
\cs_new:Npn \fdutest_box:nnn #1#2#3
{
Expand Down Expand Up @@ -91,6 +86,33 @@
\dim_log:N \l_tmpa_dim
}

\TEST { Sanitizing~ title }
{
\clist_map_inline:nn
{
论文标题,
论文~标题,
论文\\标题,
论文~\\~标题,
论文标题ABC,
论文标题~ABC,
论文标题\\ABC,
论文标题~\\ABC,
论文标题\\~ABC,
论文标题~\\~ABC,
ABC~DEF,
ABC\\DEF,
ABC~\\DEF,
ABC\\~DEF,
ABC~\\~DEF,
}
{
\fdusetup { info / title = {#1} }
\tl_log:N \l__fdu_info_title_tl
\tl_log:N \l__fdu_info_title_sanitized_tl
}
}

\ExplSyntaxOff

\END
Expand Down
49 changes: 38 additions & 11 deletions testfiles/01-internal.tlg
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,7 @@ l. ... }
l. ... }
============================================================
============================================================
TEST 2: Theorem define
============================================================
> Empty at present..
<recently read> }
l. ... }
============================================================
============================================================
TEST 3: Boxes in thesis cover
TEST 2: Boxes in thesis cover
============================================================
> \box...=
\hbox(8.14243+0.16861)x142.26378
Expand Down Expand Up @@ -352,9 +345,9 @@ l. ... }
l. ... }
============================================================
============================================================
TEST 4: Boxes in thesis cover (underfull)
TEST 3: Boxes in thesis cover (underfull)
============================================================
Underfull \hbox (badness 10000) in paragraph at lines 84--84
Underfull \hbox (badness 10000) in paragraph at lines 79--79
[]\TU/FandolSong(0)/m/n/12.045 复 旦 大 学
\hbox(9.33487+1.96332)x56.9055, glue set 4.8821
.\hbox(0.0+0.0)x0.0
Expand Down Expand Up @@ -428,8 +421,42 @@ l. ... }
l. ... }
============================================================
============================================================
TEST 5: Text width
TEST 4: Text width
============================================================
> \l_tmpa_dim=33.461pt.
> \l_tmpa_dim=48.18pt.
============================================================
============================================================
TEST 5: Sanitizing title
============================================================
> \l__fdu_info_title_tl=论文标题.
> \l__fdu_info_title_sanitized_tl=论文标题.
> \l__fdu_info_title_tl=论文 标题.
> \l__fdu_info_title_sanitized_tl=论文标题.
> \l__fdu_info_title_tl=论文\\标题.
> \l__fdu_info_title_sanitized_tl=论文标题.
> \l__fdu_info_title_tl=论文 \\ 标题.
> \l__fdu_info_title_sanitized_tl=论文标题.
> \l__fdu_info_title_tl=论文标题ABC.
> \l__fdu_info_title_sanitized_tl=论文标题ABC.
> \l__fdu_info_title_tl=论文标题 ABC.
> \l__fdu_info_title_sanitized_tl=论文标题 ABC.
> \l__fdu_info_title_tl=论文标题\\ABC.
> \l__fdu_info_title_sanitized_tl=论文标题 ABC.
> \l__fdu_info_title_tl=论文标题 \\ABC.
> \l__fdu_info_title_sanitized_tl=论文标题 ABC.
> \l__fdu_info_title_tl=论文标题\\ ABC.
> \l__fdu_info_title_sanitized_tl=论文标题 ABC.
> \l__fdu_info_title_tl=论文标题 \\ ABC.
> \l__fdu_info_title_sanitized_tl=论文标题 ABC.
> \l__fdu_info_title_tl=ABC DEF.
> \l__fdu_info_title_sanitized_tl=ABC DEF.
> \l__fdu_info_title_tl=ABC\\DEF.
> \l__fdu_info_title_sanitized_tl=ABC DEF.
> \l__fdu_info_title_tl=ABC \\DEF.
> \l__fdu_info_title_sanitized_tl=ABC DEF.
> \l__fdu_info_title_tl=ABC\\ DEF.
> \l__fdu_info_title_sanitized_tl=ABC DEF.
> \l__fdu_info_title_tl=ABC \\ DEF.
> \l__fdu_info_title_sanitized_tl=ABC DEF.
============================================================
1 change: 0 additions & 1 deletion testfiles/support/luaotfload.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@

[run]
log-level = -1

0 comments on commit c1f9e3e

Please sign in to comment.