Skip to content

Commit 2428626

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

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-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: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,3 +518,31 @@ 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+
 NBSP (U+00A0) NBSP 
529+
530+
 Em Space (U+2003) Em Space 
531+
532+

Line Separator (U+2028) Line Separator

533+
534+

Paragraph Separator (U+2029) Paragraph Separator

535+
536+
 全角スペース (U+3000) 全形空白 
537+
538+
ZWNBSP (U+FEFF) ZWNBSP
539+
.
540+
<p> Vertical Tab </p>
541+
<p> Form Feed </p>
542+
<p> NBSP (U+00A0) NBSP </p>
543+
<p> Em Space (U+2003) Em Space </p>
544+
<p>
Line Separator (U+2028) Line Separator
</p>
545+
<p>
Paragraph Separator (U+2029) Paragraph Separator
</p>
546+
<p> 全角スペース (U+3000) 全形空白 </p>
547+
<p>ZWNBSP (U+FEFF) ZWNBSP</p>
548+
````````````````````````````````

0 commit comments

Comments
 (0)