feat(电子公文): 修复标引布局与资源扫描
build.yaml / build (push) Successful in 50s

This commit is contained in:
xiaoqidun committed 2026-10-13 08:40:56 +08:00
1 parent 91e5b57e24
commit e91c30ca3c
5 files changed
+77 -36

No files matched your search

+34
View File
@@ -15,6 +15,7 @@
package ofdgo
import (
"bufio"
"bytes"
"context"
"encoding/xml"
@@ -39,6 +40,39 @@ type editorXMLPatch struct {
data []byte
}
// editorXMLPrefix 跳过UTF-8字节序标记和XML空白,探测后保留首个内容字节
// 入参: input 带缓冲的输入流,读取错误及取消信号由底层传递
// 返回: bool 是否以XML标记起始, error 读取错误
func editorXMLPrefix(input *bufio.Reader) (bool, error) {
header, err := input.Peek(3)
if err != nil && err != io.EOF {
return false, err
}
if bytes.Equal(header, []byte{0xef, 0xbb, 0xbf}) {
input.Discard(3)
}
for {
if _, err := input.Peek(1); err != nil {
if err == io.EOF {
return false, nil
}
return false, err
}
chunk, _ := input.Peek(input.Buffered())
count := 0
for count < len(chunk) {
switch chunk[count] {
case ' ', '\t', '\r', '\n':
count++
default:
input.Discard(count)
return chunk[count] == '<', nil
}
}
input.Discard(count)
}
}
// parseEditorXML 解析节点位置,保留命名空间、注释和原始格式
// 入参: data XML原文
// 返回: *editorXML 根节点, error 错误信息