英语 | русский
YFM 语法 linter
YFM (Yandex Flavored Markdown) 语法 linter 为 Diplodoc 平台设置自定义规则. 扩展 马克倒挂 带有YFM特定验证规则.
特征
- 自定义 YFM 规则 用于验证 YFM 特定语法
- 与 Markdownlint 合并 - 所有标准平分规则都可用
- 插件支持 - 与插件从
@diplodoc/transform(例如,term插件( 插件) - 可配置规则级别 - 错误、警告、信息或已禁用
- 源地图支持 - 液体模板处理后准确报告错误
安装
npm install @diplodoc/yfmlint
使用量
基本示例
import {yfmlint, log, LogLevels} from '@diplodoc/yfmlint';
const content = `# Title
[Link to missing file](./missing.md)
`;
const errors = await yfmlint(content, 'example.md', {
lintConfig: {
YFM003: LogLevels.ERROR, // Unreachable link
},
});
if (errors && errors.length > 0) {
log(errors, console);
}
带有插件
import {yfmlint} from '@diplodoc/yfmlint';
import termPlugin from '@diplodoc/transform/plugins/term';
const errors = await yfmlint(content, path, {
plugins: [termPlugin],
pluginOptions: {
// Plugin-specific options
},
lintConfig: {
YFM007: true, // Term used without definition
YFM009: 'warn', // Term definition not at end of file
},
});
配置
规则可以配置不同的日志级别 :
const lintConfig = {
// Boolean: true = warn, false = disabled
YFM001: true,
YFM002: false,
// String: log level name
YFM003: 'error',
YFM004: 'warn',
YFM005: 'info',
// Object: full configuration
YFM001: {
level: 'warn',
maximum: 120, // Custom parameter
},
};
文档
关于建筑、发展和贡献的详情,见 一般事务人员(其他职等)。 。 。 .
YFM 规则
这个软件包以自定义规则来扩展markdownlint用于YFM语法验证. 所有标准 马克倒挂规则 也可查阅.
YFM001 - 内含码行长度
标记 : line_length
别名 : inline-code-length
参数: maximum (默认:100)
验证内含代码跨度不超过最大长度. 用于防止超长的内置代码中断格式化 .
示例
`this is a very long inline code that exceeds the maximum length and will trigger YFM001`
YFM002 - 没有找到链接头
标记 : links
别名 : no-header-found-for-link
验证链接到目标文件中已存在的信头( 锁定) .
示例
[Link to non-existent header](./file.md#nonexistent)
YFM003 - 无法连接
标记 : links
别名 : unreachable-link
验证链接文件的存在和可访问性 。 检查 :
- 找不到文件
- 目录中缺少的文件
- 两项条件
示例
[Link to missing file](./missing.md)
YFM004 - 未关闭的表格
标记 : table
别名 : table-not-closed
验证 YFM 表格是否正确关闭 。 要求 table 插件从 @diplodoc/transform。 。 。 .
YFM005 - 标签列表未关闭
标记 : tab
别名 : tab-list-not-closed
验证 YFM 标签列表是否正确关闭 。 要求 tabs 插件从 @diplodoc/transform。 。 。 .
YFM006 - 术语定义重复
标记 : term
别名 : term-definition-duplicated
验证术语定义不重复。 要求 term 插件从 @diplodoc/transform。 。 。 .
示例
[term]: definition
[term]: another definition <!-- Error: duplicate definition -->
YFM007 - 无定义使用术语
标记 : term
别名 : term-used-without-definition
验证所有使用过的术语都有相应的定义. 要求 term 插件从 @diplodoc/transform。 。 。 .
示例
This uses [term] but no definition is provided.
YFM008 - 内定义不允许的术语
标记 : term
别名 : term-inside-definition-not-allowed
验证术语定义并不包含其他术语. 要求 term 插件从 @diplodoc/transform。 。 。 .
YFM009 - 文件结尾处没有术语定义
标记 : term
别名 : no-term-definition-in-content
验证所有术语定义都放在文件末尾。 要求 term 插件从 @diplodoc/transform。 。 。 .
示例
[term]: definition
Some content here <!-- Error: content after term definitions -->
[another-term]: another definition
YFM010 - 无法获取自动标题主播
标记 : titles
别名 : unreachable-autotitle-anchor
验证链接到自动标题主机的链接 .
示例
[Link to non-existent title](#nonexistent-title)
YFM011 - 最大 SVG 大小
标记 : image_svg
别名 : max-svg-size
验证SVG图像不超过最大尺寸限制. 需要图像处理插件 @diplodoc/transform。 。 。 .
YFM021 - 空自动向导锚
标记 : titles
别名 : empty-auto-heading-anchor
检测锁定插件所用的标题 @diplodoc/transform 无法生成非空自动锚。 该规则被报告为默认警告. 添加一个明确的锚使标题可以地址 .
锁定插件必须传递到 yfmlint() 为了这个规则的工作。 Diplodoc CLI和VS代码扩展已经提供了它.
无效 :
## 😀
修补 :
## 😀 {#emoji-section}
YFM024 - 空的快手标题锚
标记 : titles
别名 : empty-custom-heading-anchor
当最终标题属性块中的快手ID为空时警告,
例如 {# section-id} 或者说 {#}。其它处类似属性的文本不警告.
使用 {#section-id} 换句话说 有效条目周围的空格( E){ #section-id }, (中文(简体) ),
分类、引用值和任意布尔属性得到支持.
譬如说, {#id hidden}, (中文(简体) ), {#id data-x} 财务报告和审定财务报表 {#id custom-flag} 你不要警告我.
ID 之后的空字被解析为布尔属性;规则不猜测
作者是否打算使用多词ID或去除这些属性.
默认关卡是 战争,而不是错误;警告本身不会失败. 它可以通过通常的线粒体配置被禁用或被推广.
渲染倒回了自动锚,以进行空解析的ID.
需要锁定插件 @diplodoc/transform 4.78.6 或稍后时间。 。 。 .
将此插件传递给 yfmlint() 发送 YFM024 符号标记.
没有此标记的旧插件继续工作, 但无法发出此警告 .
YFM023 - 无效的能见度受众
标记 : directives
别名 : invalid-visibility-audience
验证 visibility 块选择一个被支持的听众。 规矩是
默认报告为错误,所以一个类型不能默默地隐藏已发布的内容.
有效性 :
:::visibility human
Human-only content.
:::
:::visibility agent
Agent-only content.
:::
无效 :
:::visibility agents
This block uses an unsupported plural value.
:::
YFM025 - 缺少本地链接主锚
别名: missing-local-anchor
Diplodoc CLI 语录,文档构建器,当本地链接指向已存在的页面时,在HTML构建过程中报告这种诊断,但其片段与该页面上的主锚不符. 它检查同页链接(#section)和链接到其他项目网页(guide.md#section),使用已实现的自动和明确的锚,包括从所包含文件中被锁定.
譬如说, [Section](guide.md#installation) 生产 YFM025 若为 guide.md 可达但无 installation 锚. 校正链接片段或将主机添加到目标页面中 。 缺少或无法访问的目标页面 YFM003 换句话说.
默认关卡是 warn,独立于 YFM002配置 CLI 项目的规则 .yfmlint 文件 :
log-levels:
YFM025: error # warn to report a warning, disabled to disable the check
关于数据流和构建者的责任,插件,和林特规则,参见 检查运行的地方。 。 。 .