From 21d88d53d7d9f857394077726d40bd54bfaebe64 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 | 13 +++++++++++++ 2 files changed, 18 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..9ad0580c 100644 --- a/test/regression.txt +++ b/test/regression.txt @@ -518,3 +518,16 @@ foo more -->

foo

foo more -->

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

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

+

 Em Space (U+2003) Em Space 

+

 NBSP (U+00A0) NBSP 

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