File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ---
2+ id : doc3
3+ title : Document 3
4+ ---
5+
6+ ### Existing Docs
7+
8+ - [ doc1] [ doc1 ]
9+ - [ doc2] [ doc2 ]
10+
11+ ### Non-existing Docs
12+
13+ - [ hahaha] [ hahaha ]
14+
15+ ## Repeating Docs
16+
17+ - [ doc1] [ doc1 ]
18+ - [ doc2] [ doc2 ]
19+
20+ ## Do not replace this
21+ ``` md
22+ ![ image1] [ image1 ]
23+ ```
24+
25+ ``` js
26+ const doc1 = foo ();
27+ console .log (" [image2][image2]" );
28+ const testStr = ` ![image3][image3]` ;
29+ ```
30+
31+ [ doc1 ] : doc1.md
32+ [ doc2 ] : ./doc2.md
33+ [ hahaha ] : hahaha.md
34+ [ image1 ] : assets/image1.png
35+ [ image2 ] : assets/image2.jpg
36+ [ image3 ] : assets/image3.gif
Original file line number Diff line number Diff line change @@ -50,8 +50,14 @@ const doc2 = fs.readFileSync(
5050 'utf8' ,
5151) ;
5252
53+ const doc3 = fs . readFileSync (
54+ path . join ( __dirname , '__fixtures__' , 'doc3.md' ) ,
55+ 'utf8' ,
56+ ) ;
57+
5358const rawContent1 = metadataUtils . extractMetadata ( doc1 ) . rawContent ;
5459const rawContent2 = metadataUtils . extractMetadata ( doc2 ) . rawContent ;
60+ const rawContent3 = metadataUtils . extractMetadata ( doc3 ) . rawContent ;
5561
5662describe ( 'mdToHtmlify' , ( ) => {
5763 const mdToHtml = metadataUtils . mdToHtml ( Metadata , '/' ) ;
@@ -77,6 +83,17 @@ describe('mdToHtmlify', () => {
7783 expect ( content2 ) . toMatchSnapshot ( ) ;
7884 expect ( content2 ) . not . toEqual ( rawContent2 ) ;
7985 } ) ;
86+
87+ test ( 'transforms reference links' , ( ) => {
88+ const content3 = docs . mdToHtmlify (
89+ rawContent3 ,
90+ mdToHtml ,
91+ Metadata [ 'en-doc3' ] ,
92+ ) ;
93+ expect ( content3 ) . toContain ( '/docs/en/next/' ) ;
94+ expect ( content3 ) . toMatchSnapshot ( ) ;
95+ expect ( content3 ) . not . toEqual ( rawContent3 ) ;
96+ } )
8097} ) ;
8198
8299describe ( 'getFile' , ( ) => {
You can’t perform that action at this time.
0 commit comments