
Markdown Basic【免费下载链接】ynA highly extensible Markdown editor featuring version control, AI Copilot, document annotations, mind maps, document encryption, executable code snippets, chart embedding, HTML applets, plugins, and macro replacement. Its integrated sidebar terminal makes working with AI faster and more convenient.项目地址: https://gitcode.com/GitHub_Trending/yn/ynThis.markdownfile should be treated like Markdown in the editor and preview.firstsecondblockquote这份文档的全部意图都写在第二行注释里**“This .markdown file should be treated like Markdown in the editor and preview.”** 也就是说它的核心功能是作为回归测试用例验证带 .markdown 扩展名的文件在 Yank Note 的编辑器Editor和预览器Previewer中都会被当作 Markdown 渲染而不是被当作纯文本、代码或其他未知类型处理。 虽然内容仅包含三类基础语法——一级标题、有序列表、引用块但它恰好覆盖了 Markdown 语法中最常用的“标题/列表/引用”三类块级元素足够用来快速判断一个编辑器是否正确识别了 .markdown 文件类型。 ## 二、源码依据.markdown 如何被识别为 Markdown 文件 .markdown 被当作 Markdown 处理并非编辑器按文件名“猜”出来的而是由明确的扩展名白名单决定的。在 [src/share/misc.ts](https://link.gitcode.com/i/dac78e9a5835f4dd1a903a5a74d74006) 中定义了完整的 Markdown 扩展名常量 ts export const MARKDOWN_FILE_EXT .md export const MARKDOWN_X_FILE_EXT .mdx export const MARKDOWN_LONG_FILE_EXT .markdown export const ENCRYPTED_MARKDOWN_FILE_EXT .c.md对应的判定函数isMarkdownFile将.md、.mdx、.markdown三种后缀统一视为 Markdown 文档export function isMarkdownFile (path: string) { return path.endsWith(MARKDOWN_FILE_EXT) || path.endsWith(MARKDOWN_X_FILE_EXT) || path.endsWith(MARKDOWN_LONG_FILE_EXT) }从源码结构可以推断这一判定在多个关键场景被复用构成了“编辑器-预览器-检索”全链路对.markdown文件类型的统一认知编辑器在 MonacoEditor.vue 中打开文档时会检查isMarkdownFile(uri.path) currentModel.getLanguageId() ! markdown若文件属于 Markdown 家族且当前 Monaco 语言模型不是 markdown则将其切换为 markdown 语言模式从而获得语法高亮。预览器DefaultPreviewer.vue 通过isMarkdownFile(store.state.currentFile)决定是否显示默认 Markdown 预览面板。文件树TreeNode.vue 使用isMarkdownFile(itemNode)为 Markdown 文件施加type-md样式类并在重命名等交互中对 Markdown 文件做差异化处理。全局检索SearchPanel.vue 在全文搜索时用同一函数过滤出可检索的 Markdown 文档。此外仓库的扩展名支持列表 src/renderer/others/file-extensions.ts 中还收录了更广泛的 Markdown 变体后缀.md、.mdx、.markdown、.mdown、.mkdn、.mkd、.mdwn、.mdtxt、.mdtext且supported()函数对后缀做小写归一化处理因此TODO.MARKDOWN、README.Md这类大小写混写的文件名同样能被识别这一点由 file-extensions 测试 中的/notes/TODO.MD、/src/App.TSX用例印证。三、markdown-basic.markdown 中的三类基础语法详解以 markdown-basic.markdown 中的三类元素为起点结合仓库中更完整的语法测试文档 basic-syntax.md可以系统梳理 Yank Note 对基础 Markdown 语法的支持情况。3.1 标题Heading文档中的# Markdown Basic使用一级标题。Markdown 规范支持从#到######共六级标题对应 HTML 的h1至h6。在 basic-syntax.md 中六种级别全部给出了样例。需要注意当某个#前没有空行、或位于列表/引用等块内时解析结果可能不同建议标题前后保留空行以保证渲染正确。3.2 有序列表Ordered List1. first 2. secondMarkdown 的有序列表不要求序号连续多数渲染器包括 markdown-it都会按 1、2、3…… 自动编号basic-syntax.md 还演示了有序列表的嵌套子项以及“有序项内混排无序子项”的混合列表写法实现缩进式层级列表1. Ordered item - Unordered sub-item - Another sub-item 2. Another ordered item3.3 引用块Blockquote blockquote引用块以开头basic-syntax.md 展示了跨段落的引用以及最多三层的嵌套引用。引用块内部仍可使用其他 Markdown 语法如强调、列表这也是 Markdown 块级语法可递归解析的体现。3.4 从基础到完整一份完整的 Markdown 语法矩阵除上述三类元素外basic-syntax.md 覆盖了 Yank Note 支持的全部基础语法可作为编写.markdown文件的速查表语法类别示例写法说明段落连续多行文本空行分隔启用breaks时段落内换行也会渲染为换行斜体 / 粗体*text*、_text_、**text**、__text__星号与下划线两种风格均可斜体加粗***text***、___text___三者组合删除线~~text~~渲染为del行内链接[text](https://example.com)支持带 title 的写法text引用式链接[text][ref]配合[ref]: url便于复用与维护自动链接裸写https://example.com需启用linkify图片alt、引用式![alt][img]支持 title无序列表-、*、均可可多层嵌套分割线---、***、___需与上下文空行隔离行内代码code含反引号的代码用双反引号包裹缩进代码块每行缩进 4 空格CommonMark 传统写法围栏代码块语言包裹可指定javascript、python等语言以获得语法高亮转义\*、\#、\[、\反斜杠转义特殊字符硬换行行尾两个空格或行尾反斜杠触发br四、渲染原理.markdown 内容如何变成预览4.1 基于 markdown-it 的渲染管线Yank Note 的 Markdown 解析核心位于 src/renderer/services/markdown.ts。它创建了一个全局的 markdown-it 实例默认开启linkify自动链接、breaks软换行转为换行、html允许内联 HTMLexport const markdown Markdown({ linkify: true, breaks: true, html: true })【免费下载链接】ynA highly extensible Markdown editor featuring version control, AI Copilot, document annotations, mind maps, document encryption, executable code snippets, chart embedding, HTML applets, plugins, and macro replacement. Its integrated sidebar terminal makes working with AI faster and more convenient.项目地址: https://gitcode.com/GitHub_Trending/yn/yn创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考