Skip to content

Commit 38bef02

Browse files
authored
[19_4] 英文文档中支持中文内容正确断行 (#2362)
1 parent 6ea20ee commit 38bef02

File tree

3 files changed

+50
-1
lines changed

3 files changed

+50
-1
lines changed

TeXmacs/tests/tmu/19_4.tmu

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<TMU|<tuple|1.0.1|2.1.2>>
2+
3+
<style|<tuple|tmdoc|british>>
4+
5+
<\body>
6+
<tmdoc-title|Line break for Chinese Text in English Document>
7+
8+
<section|Bug Metadata>
9+
10+
<\itemize>
11+
<item>Reporter: 杨勇
12+
13+
<item>Mogan Editor Version: v1.1.1
14+
15+
<item>Fixed in Mogan Editor v1.1.2
16+
17+
<item>Issue: <slink|https://gitee.com/XmacsLabs/mogan/issues/I60WEJ>
18+
</itemize>
19+
20+
<section|Description>
21+
22+
我能吞下玻璃而不伤身体。我能吞下玻璃而不伤身体。我能吞下玻璃而不伤身体。我能吞下玻璃而不伤身体。我能吞下玻璃而不伤身体。
23+
24+
In Mogan v1.1.1, the above line does not wrap!
25+
26+
<tmdoc-copyright|2022|杨勇|Darcy Shen>
27+
28+
<tmdoc-license|Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License".>
29+
</body>
30+
31+
<\initial>
32+
<\collection>
33+
<associate|preamble|false>
34+
</collection>
35+
</initial>

devel/19_4.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# 19_4
2+
## 如何测试
3+
1. 打开`TeXmacs/tests/tmu/19_4.tmu`,里面的中文内容能够正常换行
4+
2. 打开`TeXmacs/tests/tmu/204_24.tmu`,将文档语言切换成英文之后,排版仍旧正确
5+
+ 老版本的异常行为:在标点符号后面会有很大的空白
6+
7+
## 2025/12/26 英文文档中支持中文内容正确断行

src/System/Language/text_language.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,20 @@ text_language_rep::advance (tree t, int& pos) {
8888
return &tp_normal_rep;
8989
}
9090

91-
if (s[pos] == '<') {
91+
if (s[pos] == '<' && !test (s, pos, "<#")) {
9292
while ((pos < N (s)) && (s[pos] != '>'))
9393
pos++;
9494
if (pos < N (s)) pos++;
9595
return &tp_normal_rep;
9696
}
9797

98+
if (s[pos] == '<' && test (s, pos, "<#")) {
99+
int start= pos;
100+
tm_char_forwards (s, pos);
101+
string c= s (start, pos);
102+
return &tp_cjk_normal_rep;
103+
}
104+
98105
pos++;
99106
return &tp_normal_rep;
100107
}

0 commit comments

Comments
 (0)