Skip to content

Commit 164d4cc

Browse files
committed
escape link URI to prevent "$" from breaking MD
1 parent 5da6196 commit 164d4cc

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

docs/lib/JSONSchemaMarkdown.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ class JSONSchemaMarkdown {
538538
*/
539539
writeRef(ref, level) {
540540
if (this.notEmpty(ref)) {
541-
this.writeLine("$ref: [" + ref + "](" + this.refLink(ref) + ")", level);
541+
this.writeLine("$ref: [" + this.escapeLink(ref) + "](" + this.refLink(ref) + ")", level);
542542
}
543543
}
544544

@@ -769,6 +769,14 @@ class JSONSchemaMarkdown {
769769
error(error) {
770770
this.errors.push(error);
771771
}
772+
773+
/**
774+
* Escape string for MD link
775+
* @param {String} value
776+
*/
777+
escapeLink(value){
778+
return value.replace('$', '\\$'); //$ in [] breaks markdown
779+
}
772780
}
773781
;
774782

0 commit comments

Comments
 (0)