From 6f5d13289dd41dbb55d883ff8bff996e77b6daf9 Mon Sep 17 00:00:00 2001 From: "Mr.Hope" Date: Tue, 1 Mar 2022 18:44:06 +0800 Subject: [PATCH] feat(markdown): add aria-hidden for line-numbers (#731) --- .../__snapshots__/codePlugin.spec.ts.snap | 106 +++++++++--------- .../importCodePlugin.spec.ts.snap | 2 +- .../src/plugins/codePlugin/codePlugin.ts | 2 +- 3 files changed, 55 insertions(+), 55 deletions(-) diff --git a/packages/@vuepress/markdown/__tests__/plugins/__snapshots__/codePlugin.spec.ts.snap b/packages/@vuepress/markdown/__tests__/plugins/__snapshots__/codePlugin.spec.ts.snap index 178122b81f..507caab3d7 100644 --- a/packages/@vuepress/markdown/__tests__/plugins/__snapshots__/codePlugin.spec.ts.snap +++ b/packages/@vuepress/markdown/__tests__/plugins/__snapshots__/codePlugin.spec.ts.snap @@ -6,7 +6,7 @@ exports[`@vuepress/markdown > plugins > codePlugin :line-numbers / :no-line-numb
Raw text
 
-
1
+
Raw text
 
@@ -24,7 +24,7 @@ function bar () { return 1024 } -
1
2
3
4
5
+
const foo = 'foo'
 
@@ -54,7 +54,7 @@ function bar () {
     
 
 



-
1
2
3
4
5
+
const foo = 'foo'
 
@@ -72,11 +72,11 @@ function bar () {
 exports[`@vuepress/markdown > plugins > codePlugin :line-numbers / :no-line-numbers should work properly if \`lineNumbers\` is enabled by default 1`] = `
 
Raw text
 
-
1
+
Raw text
 
-
1
+
Raw text
 
@@ -87,7 +87,7 @@ function bar () { return 1024 }
-
1
2
3
4
5
+
const foo = 'foo'
 
@@ -95,7 +95,7 @@ function bar () {
   return 1024
 }
 
-
1
2
3
4
5
+
const foo = 'foo'
 
@@ -114,7 +114,7 @@ function bar () {
     
 
 



-
1
2
3
4
5
+
const foo = 'foo'
 
@@ -126,7 +126,7 @@ function bar () {
     
 
 



-
1
2
3
4
5
+
const foo = 'foo'
 
@@ -147,7 +147,7 @@ exports[`@vuepress/markdown > plugins > codePlugin :line-numbers / :no-line-numb
 
Raw text
 
-
1
+
Raw text
 
@@ -158,7 +158,7 @@ function bar () { return 1024 }
-
1
2
3
4
5
+
const foo = 'foo'
 
@@ -166,7 +166,7 @@ function bar () {
   return 1024
 }
 
-
1
2
3
4
5
+
const foo = 'foo'
 
@@ -185,7 +185,7 @@ function bar () {
     
 
 



-
1
2
3
4
5
+
const foo = 'foo'
 
@@ -197,7 +197,7 @@ function bar () {
     
 
 



-
1
2
3
4
5
+
const foo = 'foo'
 
@@ -215,15 +215,15 @@ function bar () {
 exports[`@vuepress/markdown > plugins > codePlugin :v-pre / :no-v-pre should work properly if \`vPre\` is disabled by default 1`] = `
 
Raw text
 
-
1
+
Raw text
 
-
1
+
Raw text
 
-
1
+
const foo = 'foo'
 
@@ -231,7 +231,7 @@ function bar () {
   return 1024
 }
 
-
1
2
3
4
5
+
const foo = 'foo'
 
@@ -239,7 +239,7 @@ function bar () {
   return 1024
 }
 
-
1
2
3
4
5
+
const foo = 'foo'
 
@@ -247,7 +247,7 @@ function bar () {
   return 1024
 }
 
-
1
2
3
4
5
+
const foo = 'foo'
 
@@ -259,7 +259,7 @@ function bar () {
     
 
 



-
1
2
3
4
5
+
const foo = 'foo'
 
@@ -271,7 +271,7 @@ function bar () {
     
 
 



-
1
2
3
4
5
+
const foo = 'foo'
 
@@ -283,22 +283,22 @@ function bar () {
     
 
 



-
1
2
3
4
5
+ `; exports[`@vuepress/markdown > plugins > codePlugin :v-pre / :no-v-pre should work properly if \`vPre\` is enabled by default 1`] = `
Raw text
 
-
1
+
Raw text
 
-
1
+
Raw text
 
-
1
+
const foo = 'foo'
 
@@ -306,7 +306,7 @@ function bar () {
   return 1024
 }
 
-
1
2
3
4
5
+
const foo = 'foo'
 
@@ -314,7 +314,7 @@ function bar () {
   return 1024
 }
 
-
1
2
3
4
5
+
const foo = 'foo'
 
@@ -322,7 +322,7 @@ function bar () {
   return 1024
 }
 
-
1
2
3
4
5
+
const foo = 'foo'
 
@@ -334,7 +334,7 @@ function bar () {
     
 
 



-
1
2
3
4
5
+
const foo = 'foo'
 
@@ -346,7 +346,7 @@ function bar () {
     
 
 



-
1
2
3
4
5
+
const foo = 'foo'
 
@@ -358,14 +358,14 @@ function bar () {
     
 
 



-
1
2
3
4
5
+ `; exports[`@vuepress/markdown > plugins > codePlugin plugin options should disable \`highlightLines\` 1`] = `
Raw text
 
-
1
+
const foo = 'foo'
 
@@ -373,7 +373,7 @@ function bar () {
   return 1024
 }
 
-
1
2
3
4
5
+
const foo = 'foo'
 
@@ -381,7 +381,7 @@ function bar () {
   return 1024
 }
 
-
1
2
3
4
5
+
const foo = 'foo'
 
@@ -393,7 +393,7 @@ const baz = () => {
   return 2048
 }
 
-
1
2
3
4
5
6
7
8
9
+
`; @@ -466,7 +466,7 @@ const baz = () => { exports[`@vuepress/markdown > plugins > codePlugin plugin options should disable \`vPre\` 1`] = `
Raw text
 
-
1
+
const foo = 'foo'
 
@@ -474,7 +474,7 @@ function bar () {
   return 1024
 }
 
-
1
2
3
4
5
+
const foo = 'foo'
 
@@ -486,7 +486,7 @@ function bar () {
     
 
 



-
1
2
3
4
5
+
const foo = 'foo'
 
@@ -505,7 +505,7 @@ const baz = () => {
     
 
 




-
1
2
3
4
5
6
7
8
9
+ `; @@ -519,7 +519,7 @@ function bar () { return 1024 }
-
1
2
3
4
5
+
const foo = 'foo'
 
@@ -531,7 +531,7 @@ function bar () {
     
 
 



-
1
2
3
4
5
+
const foo = 'foo'
 
@@ -550,14 +550,14 @@ const baz = () => {
     
 
 




-
1
2
3
4
5
6
7
8
9
+ `; exports[`@vuepress/markdown > plugins > codePlugin plugin options should process code fences with default options 1`] = `
Raw text
 
-
1
+
const foo = 'foo'
 
@@ -565,7 +565,7 @@ function bar () {
   return 1024
 }
 
-
1
2
3
4
5
+
const foo = 'foo'
 
@@ -577,7 +577,7 @@ function bar () {
     
 
 



-
1
2
3
4
5
+
const foo = 'foo'
 
@@ -596,14 +596,14 @@ const baz = () => {
     
 
 




-
1
2
3
4
5
6
7
8
9
+ `; exports[`@vuepress/markdown > plugins > codePlugin syntax highlighting should work if highlighted code is not wrapped with \`
\` 1`] = `
 
highlighted code: Raw text
 , lang: text
-
1
+
highlighted code: const foo = 'foo'
 
@@ -611,7 +611,7 @@ function bar () {
   return 1024
 }
 , lang: javascript
-
1
2
3
4
5
+
highlighted code: const foo: string = 'foo'
 
@@ -619,14 +619,14 @@ function bar (): number {
   return 1024
 }
 , lang: typescript
-
1
2
3
4
5
+
`; exports[`@vuepress/markdown > plugins > codePlugin syntax highlighting should work if highlighted code is wrapped with \`
\` 1`] = `
 
highlighted code: Raw text
 , lang: text
-
1
+
highlighted code: const foo = 'foo'
 
@@ -634,7 +634,7 @@ function bar () {
   return 1024
 }
 , lang: javascript
-
1
2
3
4
5
+
highlighted code: const foo: string = 'foo'
 
@@ -642,6 +642,6 @@ function bar (): number {
   return 1024
 }
 , lang: typescript
-
1
2
3
4
5
+
`; diff --git a/packages/@vuepress/markdown/__tests__/plugins/__snapshots__/importCodePlugin.spec.ts.snap b/packages/@vuepress/markdown/__tests__/plugins/__snapshots__/importCodePlugin.spec.ts.snap index 0ae37df79b..d557197e12 100644 --- a/packages/@vuepress/markdown/__tests__/plugins/__snapshots__/importCodePlugin.spec.ts.snap +++ b/packages/@vuepress/markdown/__tests__/plugins/__snapshots__/importCodePlugin.spec.ts.snap @@ -12,7 +12,7 @@ console.log('foo bar')
 
 

-
1
2
3
4
5
+
# msg
 
diff --git a/packages/@vuepress/markdown/src/plugins/codePlugin/codePlugin.ts b/packages/@vuepress/markdown/src/plugins/codePlugin/codePlugin.ts
index 03f109bb17..6a0c8b661f 100644
--- a/packages/@vuepress/markdown/src/plugins/codePlugin/codePlugin.ts
+++ b/packages/@vuepress/markdown/src/plugins/codePlugin/codePlugin.ts
@@ -112,7 +112,7 @@ export const codePlugin: PluginWithOptions = (
         .map((_, index) => `${index + 1}
`) .join('') - result = `${result}
${lineNumbersCode}
` + result = `${result}` } result = `