Skip to content

Commit 32e9f5c

Browse files
committed
Don't trim non-ASCII whitespace
1 parent 16ff08a commit 32e9f5c

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

lib/inlines.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -980,7 +980,11 @@ var parseInline = function(block) {
980980
// Parse string content in block into inline children,
981981
// using refmap to resolve references.
982982
var parseInlines = function(block) {
983-
this.subject = block._string_content.trim();
983+
// trim() removes non-ASCII whitespaces, vertical tab, form feed and so on.
984+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trim#return_value
985+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#white_space
986+
// Removes only ASCII tab and space.
987+
this.subject = block._string_content.replace(/^[\t \r\n]+|[\t \r\n]+$/g, "")
984988
this.pos = 0;
985989
this.delimiters = null;
986990
this.brackets = null;

test/regression.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,3 +518,22 @@ foo <!-- test --> more -->
518518
<p>foo <!-----></p>
519519
<p>foo <!-- test --> more --&gt;</p>
520520
````````````````````````````````
521+
522+
#261
523+
```````````````````````````````` example
524+
Vertical Tab
525+
526+
Form Feed
527+
528+
 全角スペース (U+3000) 全形空白 
529+
530+
 Em Space (U+2003) Em Space 
531+
532+
 NBSP (U+00A0) NBSP 
533+
.
534+
<p> Vertical Tab </p>
535+
<p> Form Feed </p>
536+
<p> 全角スペース (U+3000) 全形空白 </p>
537+
<p> Em Space (U+2003) Em Space </p>
538+
<p> NBSP (U+00A0) NBSP </p>
539+
````````````````````````````````

0 commit comments

Comments
 (0)