From 153fbd89337d5d97765aedb71ee56128be39baeb Mon Sep 17 00:00:00 2001 From: greymoth <246701683+greymoth-jp@users.noreply.github.com> Date: Tue, 30 Jun 2026 22:41:49 +0900 Subject: [PATCH] Escape special characters in default value table cells A default value containing a pipe (e.g. `[sep="|"]` or a RegExp default such as `/a|b/`) was written raw into the Default column of the params and properties tables. The stray `|` splits the table row, so GFM drops the trailing Description cell and that row's description is lost. The sibling Type column already guards against this: union types use an escaped ` \| ` delimiter and type names pass through the escape helper in link.hbs. Run the default value through the same escape helper. escape() now returns non-string input unchanged so numeric and boolean defaults are preserved (it previously returned null, blanking them out). --- helpers/helpers.js | 2 +- partials/partial-cache.js | 2 +- partials/shared/value/defaultvalue.hbs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/helpers/helpers.js b/helpers/helpers.js index adceddf..a76f092 100644 --- a/helpers/helpers.js +++ b/helpers/helpers.js @@ -31,7 +31,7 @@ exports['json-stringify'] = JSON.stringify Escape special markdown characters */ function escape (input) { - if (typeof input !== 'string') return null + if (typeof input !== 'string') return input return input.replace(/([*|_])/g, '\\$1') } diff --git a/partials/partial-cache.js b/partials/partial-cache.js index b607a30..54ad88c 100644 --- a/partials/partial-cache.js +++ b/partials/partial-cache.js @@ -624,7 +624,7 @@ module.exports = [ ], [ 'defaultvalue', - '{{#unless (equal defaultvalue undefined)}}{{#if equals}} = {{/if}}{{#if (equal type.names.[0] "string")}}{{json-stringify defaultvalue}}{{else}}{{defaultvalue}}{{/if}}{{/unless}}' + '{{#unless (equal defaultvalue undefined)}}{{#if equals}} = {{/if}}{{#if (equal type.names.[0] "string")}}{{escape (json-stringify defaultvalue)}}{{else}}{{escape defaultvalue}}{{/if}}{{/unless}}' ], [ 'link', diff --git a/partials/shared/value/defaultvalue.hbs b/partials/shared/value/defaultvalue.hbs index e7791c6..b31f8d2 100644 --- a/partials/shared/value/defaultvalue.hbs +++ b/partials/shared/value/defaultvalue.hbs @@ -1 +1 @@ -{{#unless (equal defaultvalue undefined)}}{{#if equals}} = {{/if}}{{#if (equal type.names.[0] "string")}}{{json-stringify defaultvalue}}{{else}}{{defaultvalue}}{{/if}}{{/unless}} \ No newline at end of file +{{#unless (equal defaultvalue undefined)}}{{#if equals}} = {{/if}}{{#if (equal type.names.[0] "string")}}{{escape (json-stringify defaultvalue)}}{{else}}{{escape defaultvalue}}{{/if}}{{/unless}} \ No newline at end of file