From 32e9f5c15347b9b3b239a99f87b999ce3240e36c Mon Sep 17 00:00:00 2001 From: Tatsunori Uchino Date: Sun, 1 Sep 2024 14:46:59 +0900 Subject: [PATCH] Don't trim non-ASCII whitespace --- lib/inlines.js | 6 +++++- test/regression.txt | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/lib/inlines.js b/lib/inlines.js index 1ecf8eef..1f0cbb7c 100644 --- a/lib/inlines.js +++ b/lib/inlines.js @@ -980,7 +980,11 @@ var parseInline = function(block) { // Parse string content in block into inline children, // using refmap to resolve references. var parseInlines = function(block) { - this.subject = block._string_content.trim(); + // trim() removes non-ASCII whitespaces, vertical tab, form feed and so on. + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trim#return_value + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#white_space + // Removes only ASCII tab and space. + this.subject = block._string_content.replace(/^[\t \r\n]+|[\t \r\n]+$/g, "") this.pos = 0; this.delimiters = null; this.brackets = null; diff --git a/test/regression.txt b/test/regression.txt index 40630a7b..8f6ce88e 100644 --- a/test/regression.txt +++ b/test/regression.txt @@ -518,3 +518,22 @@ foo more -->

foo

foo more -->

```````````````````````````````` + +#261 +```````````````````````````````` example + Vertical Tab + + Form Feed + + 全角スペース (U+3000) 全形空白  + + Em Space (U+2003) Em Space  + + NBSP (U+00A0) NBSP  +. +

Vertical Tab

+

Form Feed

+

 全角スペース (U+3000) 全形空白 

+

 Em Space (U+2003) Em Space 

+

 NBSP (U+00A0) NBSP 

+````````````````````````````````