You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/docs-builder/src/parse.spec.ts
+45Lines changed: 45 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -275,4 +275,49 @@ there
275
275
'Unresolved reference-style link found for lang=en link=[This is a link][unknown_ref]'
276
276
)
277
277
})
278
+
279
+
it('should throw an error if invalid link syntax is detected',()=>{
280
+
constlinks=`\
281
+
This is a valid normal link: [page](https://climateinteractive.org)
282
+
283
+
This is a valid reference-style link: [page][ref]
284
+
285
+
This is an invalid normal link: [page] (https://climateinteractive.org)
286
+
287
+
This is an invalid reference-style link: [page] [ref]
288
+
`
289
+
290
+
constmd=`\
291
+
# <!-- section:section_1 -->Section 1
292
+
293
+
<!-- begin-def:block_1 -->
294
+
295
+
${links}
296
+
297
+
<!-- end-def -->
298
+
299
+
[ref]: https://climateinteractive.org
300
+
`
301
+
302
+
functionexpectedMsg(lang: string){
303
+
constlangPart=lang==='en' ? '' : `lang=${lang} `
304
+
return`\
305
+
Detected invalid link syntax:
306
+
[page] (https://climateinteractive.org)
307
+
[page] [ref]
308
+
To fix, ensure there are no spaces between link text and link url/reference, for example: [text](url) or [text][ref] (${langPart}page=page_1.md scope=section_1)`
309
+
}
310
+
311
+
// Verify that an error is thrown if the English content contains invalid link syntax
0 commit comments