Skip to content

Commit

Permalink
Don't trim non-ASCII whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
tats-u committed Sep 23, 2024
1 parent 16ff08a commit 21d88d5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/inlines.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
13 changes: 13 additions & 0 deletions test/regression.txt
Original file line number Diff line number Diff line change
Expand Up @@ -518,3 +518,16 @@ foo <!-- test --> more -->
<p>foo <!-----></p>
<p>foo <!-- test --> more --&gt;</p>
````````````````````````````````

#261
```````````````````````````````` example
 全角スペース (U+3000) 全形空白 

 Em Space (U+2003) Em Space 

 NBSP (U+00A0) NBSP 
.
<p> 全角スペース (U+3000) 全形空白 </p>
<p> Em Space (U+2003) Em Space </p>
<p> NBSP (U+00A0) NBSP </p>
````````````````````````````````

0 comments on commit 21d88d5

Please sign in to comment.