Snoopy1866 / RTFTools-For-SAS

RTF 文件小工具
https://snoopy1866.github.io/RTFTools-For-SAS/
GNU Affero General Public License v3.0
3 stars 1 forks source link

[bug] %ReadRTF \super\nosupersub 之间的字符被删除 #26

Closed Snoopy1866 closed 5 months ago

Snoopy1866 commented 5 months ago

例如,RTF 文件含有下述控制字:

\super[1]\nosupersub

%ReadRTF 读取后会将有实际意义的字符 [1] 也一并删除,这并不是期望的结果。

Snoopy1866 commented 5 months ago

单独处理 \super 这个控制字,改用以下正则表达式捕获有意义的字符串:

\{?\\super\s+((?:\\[\\\{\}]|[^\\\{\}])+)\}?

image

构建正则替换表达式:

reg_rtf_del_ctrl_id_4 = prxparse("s/(?:&reg_ctrl_4)\s*/$1/o");

进行单独替换:

context_raw = prxchange(reg_rtf_del_ctrl_id_4, -1, strip(context_raw));