From f499740f3ecdccebf53aaefaa1946cde8f52cd15 Mon Sep 17 00:00:00 2001 From: Da Shen Date: Thu, 14 May 2026 09:17:14 +0800 Subject: [PATCH] =?UTF-8?q?[0118]=20=E9=A6=96=E8=A1=8C=E7=BC=A9=E8=BF=9B?= =?UTF-8?q?=E5=9C=A8=E8=8A=82=E3=80=81=E4=BB=A3=E7=A0=81=E5=9D=97=E3=80=81?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E5=90=8E=E7=94=9F=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在样式语言中新增开关 indent-after-block,控制节、代码块、列表等 结构后的段落是否保留首行缩进。 - generic 等样式默认关闭(保持现有行为) - article 样式默认开启 - 用户可在导言区通过 手动覆盖 Co-Authored-By: Claude Opus 4.7 --- .../customize/algorithm/framed-program.ts | 2 +- .../customize/algorithm/modern-program.ts | 2 +- .../packages/customize/list/compact-list.ts | 2 +- TeXmacs/packages/environment/env-program.ts | 2 +- TeXmacs/packages/section/section-base.ts | 2 +- TeXmacs/packages/standard/std-list.ts | 4 +- TeXmacs/packages/standard/std-markup.ts | 2 + TeXmacs/styles/article.ts | 2 + devel/0118.md | 46 +++++++++++++++++++ 9 files changed, 57 insertions(+), 7 deletions(-) create mode 100644 devel/0118.md diff --git a/TeXmacs/packages/customize/algorithm/framed-program.ts b/TeXmacs/packages/customize/algorithm/framed-program.ts index 23275534b6..658f92d5dd 100644 --- a/TeXmacs/packages/customize/algorithm/framed-program.ts +++ b/TeXmacs/packages/customize/algorithm/framed-program.ts @@ -105,7 +105,7 @@ > - <\surround||> + <\surround||||>> <\framed-quoted> <\with|par-first|0fn|par-par-sep|0fn|item-hsep|> <\framed-code> diff --git a/TeXmacs/packages/customize/algorithm/modern-program.ts b/TeXmacs/packages/customize/algorithm/modern-program.ts index 05ef802df7..7bbfd39310 100644 --- a/TeXmacs/packages/customize/algorithm/modern-program.ts +++ b/TeXmacs/packages/customize/algorithm/modern-program.ts @@ -45,7 +45,7 @@ - <\surround||> + <\surround||||>> <\padded*> <\indent> <\with|par-first|0fn|par-par-sep|0fn|item-hsep||numbered-offset|> diff --git a/TeXmacs/packages/customize/list/compact-list.ts b/TeXmacs/packages/customize/list/compact-list.ts index 6c568a68be..21b7ea54f1 100644 --- a/TeXmacs/packages/customize/list/compact-list.ts +++ b/TeXmacs/packages/customize/list/compact-list.ts @@ -34,7 +34,7 @@ <\padded-normal||> <\indent-left|> - ||> + |||>|> > diff --git a/TeXmacs/packages/environment/env-program.ts b/TeXmacs/packages/environment/env-program.ts index f7735e784d..75879aa7e5 100644 --- a/TeXmacs/packages/environment/env-program.ts +++ b/TeXmacs/packages/environment/env-program.ts @@ -32,7 +32,7 @@ - <\surround||> + <\surround||||>> <\padded*> <\indent> <\with|par-first|0fn|par-par-sep|0fn|item-hsep||numbered-offset|> diff --git a/TeXmacs/packages/section/section-base.ts b/TeXmacs/packages/section/section-base.ts index 24033ad224..e068f0758a 100644 --- a/TeXmacs/packages/section/section-base.ts +++ b/TeXmacs/packages/section/section-base.ts @@ -106,7 +106,7 @@ - >> + ||>>> >> diff --git a/TeXmacs/packages/standard/std-list.ts b/TeXmacs/packages/standard/std-list.ts index 8aba826978..6d54f0a04c 100644 --- a/TeXmacs/packages/standard/std-list.ts +++ b/TeXmacs/packages/standard/std-list.ts @@ -109,7 +109,7 @@ <\padded-normal||> <\indent-left|> - ||> + |||>|> > @@ -249,7 +249,7 @@ <\with|item*|> <\padded-normal||> - ||> + |||>|> > diff --git a/TeXmacs/packages/standard/std-markup.ts b/TeXmacs/packages/standard/std-markup.ts index a0099e0c29..abeb93386d 100644 --- a/TeXmacs/packages/standard/std-markup.ts +++ b/TeXmacs/packages/standard/std-markup.ts @@ -665,6 +665,8 @@ + + > diff --git a/TeXmacs/styles/article.ts b/TeXmacs/styles/article.ts index e8c2ff1aa2..c993b56fab 100644 --- a/TeXmacs/styles/article.ts +++ b/TeXmacs/styles/article.ts @@ -27,6 +27,8 @@ + + \; diff --git a/devel/0118.md b/devel/0118.md new file mode 100644 index 0000000000..420e13d563 --- /dev/null +++ b/devel/0118.md @@ -0,0 +1,46 @@ +# [0118] 首行缩进在节、代码块、列表后生效 + +## 相关文档 +- [dddd.md](dddd.md) - 任务文档模板 + +## 任务相关的代码文件 +- `TeXmacs/packages/standard/std-markup.ts` - 定义新开关变量 `indent-after-block` +- `TeXmacs/packages/section/section-base.ts` - 节标题后的首行缩进控制 +- `TeXmacs/packages/standard/std-list.ts` - 列表环境(含 `description-paragraphs`)后的首行缩进控制 +- `TeXmacs/packages/customize/list/compact-list.ts` - 紧凑列表环境后的首行缩进控制 +- `TeXmacs/packages/environment/env-program.ts` - 代码块后的首行缩进控制 +- `TeXmacs/packages/customize/algorithm/framed-program.ts` - 带框算法代码块后的首行缩进控制 +- `TeXmacs/packages/customize/algorithm/modern-program.ts` - 现代算法代码块后的首行缩进控制 +- `TeXmacs/styles/article.ts` - article 样式默认开启 + +## 如何测试 + +### 非确定性测试(文档验证) +1. 新建 article 文档,加载 `indent-paragraphs` 包 +2. 在节标题后输入段落,观察首行是否缩进 +3. 在代码块后输入段落,观察首行是否缩进 +4. 在有序/无序列表后输入段落,观察首行是否缩进 +5. 新建 generic 文档,重复上述步骤,确认首行不缩进(保持旧行为) + +## 如何提交 + +```bash +xmake b tests && xmake r tests +``` + +## What +在样式语言中新增开关 `indent-after-block`,控制节、代码块、列表等结构后的段落是否保留首行缩进。 + +- generic 等样式默认关闭(保持现有行为) +- article 样式默认开启 +- 用户可在导言区通过 `` 手动覆盖 + +## Why +目前首行缩进在节、小节、代码块、有序列表等结构后默认被显式抑制(``),这与 LaTeX article 等主流排版引擎的行为不一致。很多论文排版场景需要这些结构后的段落也能正常首行缩进。 + +## How +1. 在 `std-markup.ts` 中定义新变量 `indent-after-block`,默认值为 `false` +2. 修改 `section-base.ts` 中的 `sectional-no-indent`,使其仅在 `indent-after-block` 为 `false` 时发射 `` +3. 修改 `std-list.ts` 中的 `render-list`,使其尾部 `` 受开关控制 +4. 修改 `env-program.ts` 中的 `render-code`,使其尾部 `` 受开关控制 +5. 在 `article.ts` 中设置 ``,使 article 样式默认开启该特性