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 authored and jgm committed Sep 23, 2024
1 parent cb2c230 commit f3145e8
Show file tree
Hide file tree
Showing 2 changed files with 33 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
28 changes: 28 additions & 0 deletions test/regression.txt
Original file line number Diff line number Diff line change
Expand Up @@ -518,3 +518,31 @@ foo <!-- test --> more -->
<p>foo <!-----></p>
<p>foo <!-- test --> more --&gt;</p>
````````````````````````````````

#261
```````````````````````````````` example
Vertical Tab

Form Feed

 NBSP (U+00A0) NBSP 

 Em Space (U+2003) Em Space 


Line Separator (U+2028) Line Separator



Paragraph Separator (U+2029) Paragraph Separator


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

ZWNBSP (U+FEFF) ZWNBSP
.
<p> Vertical Tab </p>
<p> Form Feed </p>
<p> NBSP (U+00A0) NBSP </p>
<p> Em Space (U+2003) Em Space </p>
<p>
Line Separator (U+2028) Line Separator
</p>
<p>
Paragraph Separator (U+2029) Paragraph Separator
</p>
<p> 全角スペース (U+3000) 全形空白 </p>
<p>ZWNBSP (U+FEFF) ZWNBSP</p>
````````````````````````````````

0 comments on commit f3145e8

Please sign in to comment.