feat: 为 XML 格式笔记添加富文本样式保留(颜色、粗体、斜体、下划线、缩进)#164
Open
0x00000003 wants to merge 1 commit into
Open
Conversation
…c, underline, indent) when converting Youdao Note XML to Markdown
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
改动说明
新增
note2md.py模块,专门处理有道云笔记 XML 格式的富文本转换。原有
XmlElementConvert.convert_para_func对<para>节点直接取纯文本,<inline-styles>中的颜色、加粗、斜体、下划线、删除线、字号、缩进等样式信息完全丢失。本次改动通过解析<inline-styles>节点,将样式还原为内嵌 HTML span 标签的 Markdown,在 Obsidian/Typora 中均可正确渲染。包含功能
<span style="color/background-color"><strong><em><u><s><span style="font-size"><div style="margin-left">测试结果
python3 test/test.py运行结果:10 个用例通过。剩余 1 个用例
test_get_dir_id失败,原因是pull.py中_get_ydnote_dir_id的错误消息已更新为包含目录名称(有道云笔记指定目录不存在:「{}」),但测试文件仍期待旧消息(有道云笔记指定顶层目录不存在),属于测试用例未同步更新的遗留问题,与本次改动无关。