File tree Expand file tree Collapse file tree 3 files changed +12
-5
lines changed Expand file tree Collapse file tree 3 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -270,12 +270,16 @@ for (let l in lines) {
270
270
}
271
271
272
272
// 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 ) {
275
279
const regExp = / \( ( \. \. [ ^ ) ] + ) \) / g;
276
280
line = line . replace ( regExp , function ( match , group1 ) {
277
281
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 ) + ')' ;
279
283
} ) ;
280
284
}
281
285
Original file line number Diff line number Diff line change 10
10
< p > Definition of Foo.</ p >
11
11
</ section > </ section > < section > < h1 > Another Heading 2</ h1 >
12
12
< 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 >
14
15
< section > < h2 > Heading 3</ h2 >
15
16
< p > Text for first subsection</ p >
16
17
< p > [[RFC3986]]</ p >
Original file line number Diff line number Diff line change @@ -20,7 +20,9 @@ Definition of Foo.
20
20
21
21
Text for second section
22
22
23
- [ Relative link] ( ../examples/foo.yaml )
23
+ [ Relative link to example] ( ../examples/foo.yaml )
24
+
25
+ [ Relative link to something else] ( ../something/else )
24
26
25
27
### Heading 3
26
28
You can’t perform that action at this time.
0 commit comments