|
@ -6,7 +6,7 @@ var isSpace = require('../common/utils').isSpace; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = function newline(state, silent) { |
|
|
module.exports = function newline(state, silent) { |
|
|
var pmax, max, pos = state.pos; |
|
|
var pmax, max, ws, pos = state.pos; |
|
|
|
|
|
|
|
|
if (state.src.charCodeAt(pos) !== 0x0A/* \n */) { return false; } |
|
|
if (state.src.charCodeAt(pos) !== 0x0A/* \n */) { return false; } |
|
|
|
|
|
|
|
@ -20,7 +20,11 @@ module.exports = function newline(state, silent) { |
|
|
if (!silent) { |
|
|
if (!silent) { |
|
|
if (pmax >= 0 && state.pending.charCodeAt(pmax) === 0x20) { |
|
|
if (pmax >= 0 && state.pending.charCodeAt(pmax) === 0x20) { |
|
|
if (pmax >= 1 && state.pending.charCodeAt(pmax - 1) === 0x20) { |
|
|
if (pmax >= 1 && state.pending.charCodeAt(pmax - 1) === 0x20) { |
|
|
state.pending = state.pending.replace(/ +$/, ''); |
|
|
// Find whitespaces tail of pending chars.
|
|
|
|
|
|
ws = pmax - 1; |
|
|
|
|
|
while (ws >= 1 && state.pending.charCodeAt(ws - 1) === 0x20) ws--; |
|
|
|
|
|
|
|
|
|
|
|
state.pending = state.pending.slice(0, ws); |
|
|
state.push('hardbreak', 'br', 0); |
|
|
state.push('hardbreak', 'br', 0); |
|
|
} else { |
|
|
} else { |
|
|
state.pending = state.pending.slice(0, -1); |
|
|
state.pending = state.pending.slice(0, -1); |
|
|