-
Notifications
You must be signed in to change notification settings - Fork 92
[221_2] 修复有框定理中的脚注不显示的问题 #3120
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
Open
MoonL79
wants to merge
7
commits into
main
Choose a base branch
from
cms/221_2/fix_theorem_footnote
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[221_2] 修复有框定理中的脚注不显示的问题 #3120
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| [221_2] 有框定理中的脚注不显示 | ||
|
|
||
| ## 如何测试 | ||
| ### 单元测试 | ||
| bin/test_only bridge_ornamented_rep_test | ||
| bin/test_only lazy_ornament_rep_test | ||
|
|
||
| ### 手动测试 | ||
| 测试项一:无框定理中的脚注正常显示 | ||
| 1. 新建或打开任意 tmu 文档 | ||
| 2. 插入一个定理环境,不勾选“加框” | ||
| 3. 在定理正文中输入一段文字,并插入一个脚注 | ||
| 4. 文档中应出现脚注上标,页面底部应正常显示脚注正文 | ||
|
|
||
| 测试项二:有框定理中的脚注正常显示 | ||
| 1. 新建或打开任意 tmu 文档 | ||
| 2. 插入一个定理环境,并勾选“加框” | ||
| 3. 在定理正文中输入一段文字,并插入一个脚注 | ||
| 4. 文档中应出现脚注上标,页面底部也应正常显示脚注正文 | ||
| 5. 脚注正文不应因为定理有边框而丢失 | ||
|
|
||
| 测试项三:切换有框和无框后脚注保持正常 | ||
| 1. 插入一个带脚注的定理环境,初始不勾选“加框” | ||
| 2. 确认脚注正文正常显示 | ||
| 3. 勾选“加框” | ||
| 4. 脚注正文应继续正常显示 | ||
| 5. 再取消“加框” | ||
| 6. 脚注正文仍应正常显示 | ||
|
|
||
| 测试项四:多个有框定理脚注编号连续 | ||
| 1. 在同一文档中插入两个勾选“加框”的定理环境 | ||
| 2. 在每个定理中各插入一个脚注 | ||
| 3. 两个脚注的上标编号应连续 | ||
| 4. 页面底部应按顺序显示两个脚注正文 | ||
|
|
||
| ## 2026/04/09 有框定理重新包装 page item 时保留脚注 float | ||
|
|
||
| ### What | ||
| 修复定理环境在启用“加框”后,定理内部脚注只显示上标、不显示脚注正文的问题。 | ||
|
|
||
| ### Why | ||
| 无框定理里的脚注本来是正常的,说明 `footnote` 宏本身没有问题。 | ||
| 问题出在“加框”路径上:有框定理会通过 `decorated` / `ornament` 将内部内容重新包装成外层内容。 | ||
| 在这个重包装过程中,框内正文虽然已经生成了脚注对应的页面插入对象 `fl`,但原实现只取了 box 和 spacing,没有把 `fl` 一起传递到外层 page item。 | ||
| 因此脚注上标仍然存在,而脚注正文在页面脚注区丢失。 | ||
|
|
||
| ### How | ||
| TeXmacs/packages/customize/theorem/framed-theorems.ts 中的有框定理最终走到 ornament 渲染路径 | ||
| TeXmacs/packages/environment/env-float.ts 中脚注正文通过 `<float|footnote|...>` 进入页面插入通道 | ||
| src/Typeset/Bridge/bridge_gui.cpp 中: | ||
| 1. 为 ornament 内部生成的 `array<page_item>` 增加 `fl` 收集逻辑 | ||
| 2. 在 `insert_ornament` 将外框内容重新插入段落时,把收集到的 `fl` 重新挂回外层 page item | ||
| src/Typeset/Line/lazy_gui.cpp 中同步补充 lazy ornament / art_box 路径,对内部 `fl` 进行收集并重新附着,避免不同渲染链行为不一致 | ||
|
|
||
| ### 备注 | ||
| 本次问题的根因不是脚注没有生成,而是有框定理在 ornament 层重新包装内容时,没有保留脚注对应的页面 float。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
116 changes: 116 additions & 0 deletions
116
tests/Typeset/Bridge/bridge_gui/bridge_ornamented_rep_test.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| /****************************************************************************** | ||
| * MODULE : bridge_ornamented_rep_test.cpp | ||
| * DESCRIPTION: Tests for footnote propagation in bridge_ornamented_rep | ||
| * COPYRIGHT : (C) 2026 Mingshen Chu | ||
| ******************************************************************************* | ||
| * This software falls under the GNU general public license version 3 or later. | ||
| * It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE | ||
| * in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>. | ||
| ******************************************************************************/ | ||
|
|
||
| #include "Boxes/construct.hpp" | ||
| #include "Line/lazy_paragraph.hpp" | ||
| #include "Line/lazy_vstream.hpp" | ||
| #include "Metafont/load_tex.hpp" | ||
| #include "base.hpp" | ||
| #include "data_cache.hpp" | ||
| #include "env.hpp" | ||
| #include "tm_sys_utils.hpp" | ||
| #include <QtTest/QtTest> | ||
| #include <moebius/drd/drd_std.hpp> | ||
|
|
||
| using namespace moebius; | ||
| using moebius::drd::std_drd; | ||
|
|
||
| static edit_env | ||
| create_test_env () { | ||
| drd_info drd ("none", std_drd); | ||
| hashmap<string, tree> h1 (UNINIT), h2 (UNINIT); | ||
| hashmap<string, tree> h3 (UNINIT), h4 (UNINIT); | ||
| hashmap<string, tree> h5 (UNINIT), h6 (UNINIT); | ||
| return edit_env (drd, "none", h1, h2, h3, h4, h5, h6); | ||
| } | ||
|
|
||
| static tree | ||
| create_ornament_with_footnote () { | ||
| tree footnote_body (DOCUMENT, 1); | ||
| footnote_body[0]= tree (CONCAT, "footnote body"); | ||
|
|
||
| tree paragraph (CONCAT); | ||
| paragraph << "boxed theorem body"; | ||
| paragraph << tree (FLOAT, "footnote", "", footnote_body); | ||
| paragraph << " continues"; | ||
|
|
||
| tree body (DOCUMENT, 1); | ||
| body[0]= paragraph; | ||
|
|
||
| return tree (ORNAMENT, body); | ||
| } | ||
|
|
||
| static bool | ||
| has_footnote (array<page_item> items) { | ||
| for (int i= 0; i < N (items); ++i) | ||
| for (int j= 0; j < N (items[i]->fl); ++j) { | ||
| lazy_vstream ins= (lazy_vstream) items[i]->fl[j]; | ||
| if (is_tuple (ins->channel, "footnote")) return true; | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| static array<lazy> | ||
| collect_attached_floats_for_test (array<page_item> items) { | ||
| array<lazy> fl; | ||
| for (int i= 0; i < N (items); ++i) | ||
| if (N (items[i]->fl) > 0) fl << items[i]->fl; | ||
| return fl; | ||
| } | ||
|
|
||
| class TestBridgeOrnamentedRep : public QObject { | ||
| Q_OBJECT | ||
|
|
||
| private slots: | ||
| void initTestCase () { | ||
| init_lolly (); | ||
| init_texmacs_home_path (); | ||
| cache_initialize (); | ||
| init_tex (); | ||
| } | ||
|
|
||
| void keeps_footnote_float (); | ||
| }; | ||
|
|
||
| void | ||
| TestBridgeOrnamentedRep::keeps_footnote_float () { | ||
| edit_env env= create_test_env (); | ||
| env->style_init_env (); | ||
| env->update (); | ||
|
|
||
| array<page_item> inner_items (1); | ||
| array<page_item> footnote_lines (1); | ||
| footnote_lines[0]= page_item (empty_box (path (0))); | ||
| array<lazy> fl (1); | ||
| fl[0] = lazy_vstream (path (0), tuple ("footnote"), footnote_lines, | ||
| stack_border ()); | ||
| inner_items[0]= page_item (empty_box (path (1)), fl); | ||
|
|
||
| array<lazy> ornament_fl= collect_attached_floats_for_test (inner_items); | ||
| QVERIFY (has_footnote (inner_items)); | ||
|
|
||
| lazy_paragraph par (env, path ()); | ||
| par->a << line_item (STD_ITEM, env->mode_op, empty_box (path (2)), | ||
| HYPH_INVALID); | ||
| par->format_paragraph (); | ||
|
|
||
| int i= N (par->sss->l) - 1; | ||
| while (i >= 0 && par->sss->l[i]->type == PAGE_CONTROL_ITEM) | ||
| i--; | ||
| QVERIFY (i >= 0); | ||
|
|
||
| par->sss->l[i]= copy (par->sss->l[i]); | ||
| par->sss->l[i]->fl << ornament_fl; | ||
|
|
||
| QVERIFY (has_footnote (par->sss->l)); | ||
| } | ||
|
|
||
| QTEST_MAIN (TestBridgeOrnamentedRep) | ||
| #include "bridge_ornamented_rep_test.moc" |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doxygen style comment in Chinese