File tree 4 files changed +67
-0
lines changed
4 files changed +67
-0
lines changed Original file line number Diff line number Diff line change @@ -172,6 +172,11 @@ function addMetadata(hast, mdast) {
172
172
}
173
173
}
174
174
175
+ const html = select ( 'html' , hast ) ;
176
+ if ( html . properties ?. lang ) {
177
+ meta . set ( text ( 'html-lang' ) , text ( html . properties . lang ) ) ;
178
+ }
179
+
175
180
if ( meta . size ) {
176
181
mdast . children . push ( toGridTable ( 'Metadata' , Array . from ( meta . entries ( ) ) ) ) ;
177
182
}
Original file line number Diff line number Diff line change
1
+ < html lang ="en-US ">
2
+
3
+ < head >
4
+ < meta property ="og:type " content ="product ">
5
+ < meta property ="og:image " content ="/meta-image.png ">
6
+ < meta property ="product:availability " content ="In stock ">
7
+ < meta property ="product:price.amount " content ="3 ">
8
+ < meta property ="product:price.currency " content ="USD ">
9
+ < meta property ="invalid " content ="foo ">
10
+ < meta property ="og:ignored " content ="bar ">
11
+ < meta name ="twitter:card " content ="summary_large_image ">
12
+ < meta name ="twitter:label1 " content ="Price ">
13
+ < meta name ="twitter:data1 " content ="$3 ">
14
+ < meta name ="twitter:label2 " content ="Availability ">
15
+ < meta name ="twitter:data2 " content ="In stock ">
16
+ < meta name ="twitter:image " content ="/meta-image.png ">
17
+ </ head >
18
+
19
+ < body >
20
+ < main >
21
+ < div >
22
+ < h1 > Hello, World.</ h1 >
23
+ </ div >
24
+ </ main >
25
+ </ body >
26
+
27
+ </ html >
Original file line number Diff line number Diff line change
1
+ # Hello, World.
2
+
3
+ +------------------------------------------------+
4
+ | Metadata |
5
+ +------------------------+-----------------------+
6
+ | og: type | product |
7
+ +------------------------+-----------------------+
8
+ | og: image | ![ ] [ image0 ] |
9
+ +------------------------+-----------------------+
10
+ | product: availability | In stock |
11
+ +------------------------+-----------------------+
12
+ | product: price .amount | 3 |
13
+ +------------------------+-----------------------+
14
+ | product: price .currency | USD |
15
+ +------------------------+-----------------------+
16
+ | twitter: card | summary\_ large\_ image |
17
+ +------------------------+-----------------------+
18
+ | twitter: label1 | Price |
19
+ +------------------------+-----------------------+
20
+ | twitter: data1 | $3 |
21
+ +------------------------+-----------------------+
22
+ | twitter: label2 | Availability |
23
+ +------------------------+-----------------------+
24
+ | twitter: data2 | In stock |
25
+ +------------------------+-----------------------+
26
+ | twitter: image | ![ ] [ image0 ] |
27
+ +------------------------+-----------------------+
28
+ | html-lang | en-US |
29
+ +------------------------+-----------------------+
30
+
31
+ [ image0 ] : /meta-image.png
Original file line number Diff line number Diff line change @@ -112,6 +112,10 @@ describe('html2md Tests', () => {
112
112
it ( 'convert a document with meta names and properties correctly' , async ( ) => {
113
113
await test ( 'meta-tags' ) ;
114
114
} ) ;
115
+
116
+ it ( 'convert a document with html lang correctly' , async ( ) => {
117
+ await test ( 'meta-tags-htmllang' ) ;
118
+ } ) ;
115
119
} ) ;
116
120
117
121
describe ( 'className to block type tests' , ( ) => {
You can’t perform that action at this time.
0 commit comments