@@ -85,7 +85,20 @@ function preface(title,options) {
85
85
} ,
86
86
] ,
87
87
} ,
88
- ]
88
+ ] ,
89
+ //TODO: remove localBiblio once Specref PR https://github.com/tobie/specref/pulls/ralfhandl is merged
90
+ localBiblio : {
91
+ CommonMark : {
92
+ title : "CommonMark Spec" ,
93
+ href : "https://spec.commonmark.org/" ,
94
+ } ,
95
+ "CommonMark-0.27" : {
96
+ title : "CommonMark Spec Version 0.27" ,
97
+ href : "https://spec.commonmark.org/0.27/" ,
98
+ date : "2016-11-18" ,
99
+ authors : [ "John MacFarlane" ]
100
+ }
101
+ }
89
102
} ;
90
103
91
104
let preface = `<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><title>${ md . utils . escapeHtml ( title ) } </title>` ;
@@ -269,46 +282,55 @@ for (let l in lines) {
269
282
line = line . replace ( 'RFC [' , '[RFC' ) ;
270
283
line = line . replace ( '[Authorization header as defined in ' , 'Authorization header as defined in [' ) ;
271
284
line = line . replace ( '[JSON Pointer]' , 'JSON Pointer [RFC6901]' ) ; // only in 2.0.md
272
-
273
- //TODO: more "hidden" RFC references in older specs, for example
274
- // [media type range](https://tools.ietf.org/html/rfc7231#appendix-D)
275
- // [ABNF](https://tools.ietf.org/html/rfc5234)
276
-
277
- //TODO: unconventional references to RFCs in 3.0.4 and 3.1.1, for example
278
- // [RFC3986 §5.1.2 – 5.1.4](https://tools.ietf.org/html/rfc3986#section-5.1.2)
279
- // RFC6570 [mentions](https://www.rfc-editor.org/rfc/rfc6570.html#section-2.4.2)
280
- // [are not](https://datatracker.ietf.org/doc/html/rfc3986#appendix-A)
281
- // [special behavior](https://www.rfc-editor.org/rfc/rfc1866#section-8.2.1)
282
- // [RFC6570 considers to be _undefined_](https://datatracker.ietf.org/doc/html/rfc6570#section-2.3)
285
+ line = line . replace ( '[media type range](https://tools.ietf.org/html/rfc7231#appendix-D) ' , 'media type range, see [RFC7231](https://tools.ietf.org/html/rfc7231#appendix-D), ' ) ;
283
286
284
287
if ( line . indexOf ( '[RFC' ) >= 0 ) {
285
288
// also detect [RFC4648 §3.2] etc. in 3.0.4.md and 3.1.1.md
289
+ //TODO: TDC decision: fix in source markdown
286
290
line = line . replace ( / \[ R F C ? ( [ 0 - 9 ] { 1 , 5 } ) ( § [ 0 - 9 . - ] + ) ? \] / g, function ( match , group1 ) {
287
- // console.warn('Fixing RFC reference',match,group1);
291
+ //TODO: use string pattern with $1 instead of function
288
292
return '[[RFC' + group1 + ']]' ;
289
293
} ) ;
290
294
}
291
295
292
- //TODO: non-link mentions of RFCs in 3.0.4 and 3.1.1, for example
296
+ //TODO: TDC decision: fix unconventional references to RFCs in 3.0.4 and 3.1.1, for example
297
+ // [RFC3986 §5.1.2 – 5.1.4](https://tools.ietf.org/html/rfc3986#section-5.1.2)
298
+ // RFC6570 [mentions](https://www.rfc-editor.org/rfc/rfc6570.html#section-2.4.2)
299
+ // [are not](https://datatracker.ietf.org/doc/html/rfc3986#appendix-A)
300
+ // [special behavior](https://www.rfc-editor.org/rfc/rfc1866#section-8.2.1)
301
+ // [RFC6570 considers to be _undefined_](https://datatracker.ietf.org/doc/html/rfc6570#section-2.3)
302
+
303
+ //TODO: TDC decision: fix non-link mentions of RFCs etc. in 3.0.4 and 3.1.1, for example
293
304
// RFC3986's definition of [reserved](https://datatracker.ietf.org/doc/html/rfc3986#section-2.2)
294
305
295
306
// harmonize RFC URLs
296
- line = line . replace ( 'http://www.ietf.org/rfc/rfc2119.txt' , 'https://tools.ietf.org/html/rfc2119' ) ; // only in 2.0.md
307
+ //TODO: harmonize to https://www.rfc-editor.org/rfc/rfc*
308
+ line = line . replaceAll ( '](http://' , '](https://' ) ;
309
+ line = line . replace ( 'https://www.ietf.org/rfc/rfc2119.txt' , 'https://tools.ietf.org/html/rfc2119' ) ; // only in 2.0.md
297
310
line = line . replace ( / h t t p s : \/ \/ w w w .r f c - e d i t o r .o r g \/ r f c \/ r f c ( [ 0 - 9 ] { 1 , 5 } ) ( \. h t m l ) ? / g, 'https://tools.ietf.org/html/rfc$1' ) ;
298
311
line = line . replaceAll ( 'https://datatracker.ietf.org/doc/html/rfc' , 'https://tools.ietf.org/html/rfc' ) ;
299
- line = line . replaceAll ( 'http://tools.ietf.org' , 'https://tools.ietf.org' ) ;
300
312
301
- // handle url fragments in RFC links and construct section titles links as well as RFC links
313
+ // handle url fragments in RFC links and construct section links as well as RFC links
302
314
line = line . replace ( / \] \] \( h t t p s : \/ \/ t o o l s .i e t f .o r g \/ h t m l \/ r f c ( [ 0 - 9 ] { 1 , 5 } ) \/ ? ( \# [ ^ ) ] * ) ? \) / g, function ( match , rfcNumber , fragment ) {
303
315
if ( fragment ) {
304
316
// Extract section title from the fragment
305
317
let sectionTitle = fragment . replace ( '#' , '' ) . replace ( / - / g, ' ' ) ;
306
318
sectionTitle = sectionTitle . charAt ( 0 ) . toUpperCase ( ) + sectionTitle . slice ( 1 ) ; // Capitalize the first letter
319
+ //TODO: section links to https://www.rfc-editor.org/rfc/rfc* for newer RFCs (>= 8700)
307
320
return `]] [${ sectionTitle } ](https://datatracker.ietf.org/doc/html/rfc${ rfcNumber } ${ fragment } )` ;
308
321
} else {
309
322
return ']]' ;
310
323
}
311
324
} ) ;
325
+
326
+ // non-RFC references
327
+ line = line . replace ( '[ABNF](https://tools.ietf.org/html/rfc5234)' , '[[ABNF]]' ) ;
328
+ line = line . replace ( '[CommonMark 0.27](https://spec.commonmark.org/0.27/)' , '[[CommonMark-0.27]]' ) ;
329
+ line = line . replace ( '[CommonMark syntax](https://spec.commonmark.org/)' , '[[CommonMark]] syntax' ) ;
330
+ line = line . replace ( 'CommonMark markdown formatting' , '[[CommonMark]] markdown formatting' ) ;
331
+ line = line . replace ( 'consult http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4)' , 'consult [[html401]] [Section 17.13.4](http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4)' ) ;
332
+ //TODO
333
+ line = line . replace ( / Y A M L v e r s i o n \[ 1 \. 2 \] \( h t t p s : \/ \/ ( w w w \. ) ? y a m l \. o r g \/ s p e c \/ 1 \. 2 \/ s p e c \. h t m l \) / , '[[YAML]] version 1.2' ) ;
312
334
}
313
335
314
336
if ( ! inCodeBlock && line . indexOf ( '](../' ) >= 0 ) {
@@ -325,8 +347,6 @@ for (let l in lines) {
325
347
let delta = heading - prevHeading ;
326
348
if ( delta > 1 ) console . warn ( delta , line ) ;
327
349
if ( delta > 0 ) delta = 1 ;
328
- //if (delta<0) delta = -1;
329
- // if (Math.abs(delta)>1) console.warn(delta,line);
330
350
let prefix = '' ;
331
351
let newSection = '<section>' ;
332
352
if ( line . includes ( '## Version ' ) ) {
0 commit comments