File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -270,12 +270,16 @@ for (let l in lines) {
270270 }
271271
272272 // fix relative links (to examples)
273- //TODO: adjust when moving examples to a different repo
274- if ( ! inCodeBlock && line . indexOf ( '](../' ) >= 0 ) {
273+ if ( ! inCodeBlock && line . indexOf ( '](../examples/' ) >= 0 ) {
274+ line = line . replace ( / \( \. \. \/ e x a m p l e s \/ ( [ ^ ) ] + ) \) / g, function ( match , group1 ) {
275+ //TODO: group1 = group1.replace('.yaml','.html');
276+ return `(https://learn.openapis.org/examples/${ group1 } )` ;
277+ } )
278+ } else if ( ! inCodeBlock && line . indexOf ( '](../' ) >= 0 ) {
275279 const regExp = / \( ( \. \. [ ^ ) ] + ) \) / g;
276280 line = line . replace ( regExp , function ( match , group1 ) {
277281 console . warn ( 'Fixing relative link' , group1 , line ) ;
278- return '(' + url . resolve ( 'https://github.com/OAI/OpenAPI-Specification/tree/master /versions/foo' , group1 ) + ')' ;
282+ return '(' + url . resolve ( 'https://github.com/OAI/OpenAPI-Specification/tree/main /versions/foo' , group1 ) + ')' ;
279283 } ) ;
280284 }
281285
Original file line number Diff line number Diff line change 1010< p > Definition of Foo.</ p >
1111</ section > </ section > < section > < h1 > Another Heading 2</ h1 >
1212< p > Text for second section</ p >
13- < p > < a href ="https://github.com/OAI/OpenAPI-Specification/tree/master/examples/foo.yaml "> Relative link</ a > </ p >
13+ < p > < a href ="https://learn.openapis.org/examples/foo.yaml "> Relative link to example</ a > </ p >
14+ < p > < a href ="https://github.com/OAI/OpenAPI-Specification/tree/main/something/else "> Relative link to something else</ a > </ p >
1415< section > < h2 > Heading 3</ h2 >
1516< p > Text for first subsection</ p >
1617< p > [[RFC3986]]</ p >
Original file line number Diff line number Diff line change @@ -20,7 +20,9 @@ Definition of Foo.
2020
2121Text for second section
2222
23- [ Relative link] ( ../examples/foo.yaml )
23+ [ Relative link to example] ( ../examples/foo.yaml )
24+
25+ [ Relative link to something else] ( ../something/else )
2426
2527### Heading 3
2628
You can’t perform that action at this time.
0 commit comments