@@ -2,7 +2,6 @@ const path = require('path')
22const slash = require ( 'slash' )
33const fs = require ( 'fs' )
44const walk = require ( 'walk-sync' )
5- const matter = require ( '@github-docs/frontmatter' )
65const { zip } = require ( 'lodash' )
76const yaml = require ( 'js-yaml' )
87const languages = require ( '../../lib/languages' )
@@ -81,19 +80,19 @@ const versionLinkRegEx = /(?=^|[^\]]\s*)\[[^\]]+\](?::\n?[ \t]+|\s*\()(?:(?:http
8180const domainLinkRegex = / (? = ^ | [ ^ \] ] \s * ) \[ [ ^ \] ] + \] (?: : \n ? [ \t ] + | \s * \( ) (?: h t t p s ? : ) ? \/ \/ (?: h e l p | d o c s | d e v e l o p e r ) \. g i t h u b \. c o m (? ! \/ c h a n g e s \/ ) [ ^ ) \s ] * (?: \) | \s + | $ ) / gm
8281
8382// {{ site.data.example.pizza }}
84- const oldVariableRegex = / { { \s ? s i t e \. d a t a \. .* } } / g
83+ const oldVariableRegex = / { { \s * ?s i t e \. d a t a \. .* ? } } / g
8584
8685// - {{ octicon-plus }}
8786// - {{ octicon-plus An example label }}
8887//
89- const oldOcticonRegex = / { { \s ? o c t i c o n - ( [ a - z - ] + ) ( \s [ \w \s \d - ] + ) ? \s ? } } / g
88+ const oldOcticonRegex = / { { \s * ?o c t i c o n - ( [ a - z - ] + ) ( \s [ \w \s \d - ] + ) ? \s * ?} } / g
9089
9190// - {{#note}}
9291// - {{/note}}
9392// - {{ #warning }}
9493// - {{ /pizza }}
9594//
96- const oldExtendedMarkdownRegex = / { { \s ? [ # / ] [ a - z - ] + \s ? } } / g
95+ const oldExtendedMarkdownRegex = / { { \s * ?[ # / ] [ a - z - ] + \s * } } / g
9796
9897const relativeArticleLinkErrorText = 'Found unexpected relative article links:'
9998const languageLinkErrorText = 'Found article links with hard-coded language codes:'
@@ -125,10 +124,7 @@ describe('lint-files', () => {
125124 let content
126125
127126 beforeAll ( async ( ) => {
128- const fileContents = await fs . promises . readFile ( markdownAbsPath , 'utf8' )
129- const { content : bodyContent } = matter ( fileContents )
130-
131- content = bodyContent
127+ const content = await fs . promises . readFile ( markdownAbsPath , 'utf8' )
132128 } )
133129
134130 test ( 'relative URLs must start with "/"' , async ( ) => {
@@ -214,7 +210,7 @@ describe('lint-files', () => {
214210 const matches = ( content . match ( oldVariableRegex ) || [ ] )
215211 const matchesWithExample = matches . map ( match => {
216212 const example = match
217- . replace ( / { { \s ? s i t e \. d a t a \. ( [ a - z A - Z 0 - 9 - _ ] + (?: \. [ a - z A - Z 0 - 9 - _ ] + ) + ) \s * } } / g, '{% data $1 %}' )
213+ . replace ( / { { \s * ?s i t e \. d a t a \. ( [ a - z A - Z 0 - 9 - _ ] + (?: \. [ a - z A - Z 0 - 9 - _ ] + ) + ) \s * ? } } / g, '{% data $1 %}' )
218214 return `${ match } => ${ example } `
219215 } )
220216 const errorMessage = formatLinkError ( oldVariableErrorText , matchesWithExample )
@@ -229,7 +225,7 @@ describe('lint-files', () => {
229225
230226 test ( 'does not use old extended markdown syntax' , async ( ) => {
231227 Object . keys ( tags ) . forEach ( tag => {
232- const reg = new RegExp ( `{{\\s?[#|/]${ tag } ` , 'g' )
228+ const reg = new RegExp ( `{{\\s* ?[#|/]${ tag } ` , 'g' )
233229 if ( reg . test ( content ) ) {
234230 const matches = ( content . match ( oldExtendedMarkdownRegex ) ) || [ ]
235231 const tagMessage = oldExtendedMarkdownErrorText
@@ -334,7 +330,7 @@ describe('lint-files', () => {
334330 if ( valMatches . length > 0 ) {
335331 matches . push ( ...valMatches . map ( ( match ) => {
336332 const example = match
337- . replace ( / { { \s ? s i t e \. d a t a \. ( [ a - z A - Z 0 - 9 - _ ] + (?: \. [ a - z A - Z 0 - 9 - _ ] + ) + ) \s * } } / g, '{% data $1 %}' )
333+ . replace ( / { { \s * ?s i t e \. d a t a \. ( [ a - z A - Z 0 - 9 - _ ] + (?: \. [ a - z A - Z 0 - 9 - _ ] + ) + ) \s * ? } } / g, '{% data $1 %}' )
338334 return `Key "${ key } ": ${ match } => ${ example } `
339335 } ) )
340336 }
0 commit comments