1
+ import markdownIt from "markdown-it" ;
1
2
import markdownlint from "markdownlint" ;
2
- import yaml from ' js-yaml' ;
3
- import markdownlintGitHub from "@github/markdownlint-github" ;
3
+ import yaml from " js-yaml" ;
4
+ const markdownItFactory = ( ) => markdownIt ( { html : true } ) ;
4
5
5
6
export const validate = ( markdown , config ) => {
6
- const configObject = yaml . load ( config )
7
- return ( markdownlint
8
- . sync ( {
9
- strings : {
10
- content : markdown ,
11
- } ,
12
- config : config ? { default : false , ...configObject } : {
13
- default : false ,
14
- "no-default-alt-text" : true ,
15
- "no-alt-text" : true ,
16
- "no-empty-alt-text" : true ,
17
- } ,
18
- handleRuleFailures : true ,
19
- customRules : markdownlintGitHub ,
20
- } )
21
- . content ?. map ( ( error ) => {
22
- return `- ${ error . ruleDescription } at line ${ error . lineNumber } ` ;
23
- } ) ?? [ ] ) . join ( "\n" ) ;
24
- }
7
+ const configObject = yaml . load ( config ) ;
8
+ return (
9
+ markdownlint
10
+ . sync ( {
11
+ strings : {
12
+ content : markdown ,
13
+ } ,
14
+ config : config
15
+ ? { default : false , ...configObject }
16
+ : {
17
+ default : false ,
18
+ "no-default-alt-text" : true ,
19
+ "no-alt-text" : true ,
20
+ "no-empty-alt-text" : true ,
21
+ } ,
22
+ handleRuleFailures : true ,
23
+ markdownItFactory,
24
+ customRules : [ "@github/markdownlint-github" ] ,
25
+ } )
26
+ . content ?. map ( ( error ) => {
27
+ return `- ${ error . ruleDescription } at line ${ error . lineNumber } ` ;
28
+ } ) ?? [ ]
29
+ ) . join ( "\n" ) ;
30
+ } ;
0 commit comments