From dc1c392a4d6adbba222bf3690b789e41b0610fc9 Mon Sep 17 00:00:00 2001 From: Alex Kocharin Date: Tue, 14 Feb 2017 20:39:03 +0300 Subject: [PATCH] Remove tabs at the beginning of the line in paragraphs --- lib/rules_inline/newline.js | 5 ++++- .../markdown-it/commonmark_extras.txt | 22 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/lib/rules_inline/newline.js b/lib/rules_inline/newline.js index d09e106..14aa42d 100644 --- a/lib/rules_inline/newline.js +++ b/lib/rules_inline/newline.js @@ -2,6 +2,9 @@ 'use strict'; +var isSpace = require('../common/utils').isSpace; + + module.exports = function newline(state, silent) { var pmax, max, pos = state.pos; @@ -32,7 +35,7 @@ module.exports = function newline(state, silent) { pos++; // skip heading spaces for next line - while (pos < max && state.src.charCodeAt(pos) === 0x20) { pos++; } + while (pos < max && isSpace(state.src.charCodeAt(pos))) { pos++; } state.pos = pos; return true; diff --git a/test/fixtures/markdown-it/commonmark_extras.txt b/test/fixtures/markdown-it/commonmark_extras.txt index 41181c9..76f6cc7 100644 --- a/test/fixtures/markdown-it/commonmark_extras.txt +++ b/test/fixtures/markdown-it/commonmark_extras.txt @@ -159,6 +159,28 @@ Info string in fenced code block can't contain marker used for the fence
. +Tabs should be stripped from the beginning of the line +. + foo + bar + baz +. +

foo +bar +baz

+. + +Tabs should not cause hardbreak, EOL tabs aren't stripped in commonmark 0.27 +. +foo1 +foo2 +bar +. +

foo1 +foo2
+bar

+. + Coverage. Directive can terminate paragraph. . a