From f5a124b0845b0854f76c23bcf303b6c335ae6d39 Mon Sep 17 00:00:00 2001 From: lifegpc Date: Fri, 26 Sep 2025 13:13:36 +0800 Subject: [PATCH] Fix fixed formatter handle of scn special tokens --- src/format/fixed.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/format/fixed.rs b/src/format/fixed.rs index e336d90..ac487a7 100644 --- a/src/format/fixed.rs +++ b/src/format/fixed.rs @@ -573,6 +573,27 @@ impl FixedFormatter { result.push_str(grapheme); + #[cfg(feature = "kirikiri")] + if self.is_scn() { + if grapheme == "#" { + i += 1; + while i < vec.len() && vec[i] != ";" { + result.push_str(vec[i]); + i += 1; + } + if i < vec.len() { + result.push_str(vec[i]); + i += 1; + } + continue; + } + if grapheme == "%" && i + 1 < vec.len() && vec[i + 1] == "r" { + result.push('r'); + i += 2; + continue; + } + } + if self.is_circus() { if grapheme == "@" { is_command = true; @@ -797,6 +818,10 @@ fn test_format() { scn_formatter.format("%test;[ruby]测[test]试打断。"), "%test;[ruby]测[test]试打\n断。" ); + assert_eq!( + scn_formatter.format("%f$ハート$;#00ffadd6;♥%r打断测试"), + "%f$ハート$;#00ffadd6;♥%r打断\n测试" + ) } #[cfg(feature = "jieba")] {