You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
501 B
20 lines
501 B
module.exports = hardBreak |
|
|
|
var patternInScope = require('../util/pattern-in-scope') |
|
|
|
function hardBreak(node, _, context, safe) { |
|
var index = -1 |
|
|
|
while (++index < context.unsafe.length) { |
|
// If we can’t put eols in this construct (setext headings, tables), use a |
|
// space instead. |
|
if ( |
|
context.unsafe[index].character === '\n' && |
|
patternInScope(context.stack, context.unsafe[index]) |
|
) { |
|
return /[ \t]/.test(safe.before) ? '' : ' ' |
|
} |
|
} |
|
|
|
return '\\\n' |
|
}
|
|
|