astro-ghostcms/.pnpm-store/v3/files/3e/f08ab1f7204f6b1c24d63733f93...

33 lines
791 B
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* @typedef {import('mdast').Break} Break
* @typedef {import('mdast').Parents} Parents
* @typedef {import('../types.js').Info} Info
* @typedef {import('../types.js').State} State
*/
import {patternInScope} from '../util/pattern-in-scope.js'
/**
* @param {Break} _
* @param {Parents | undefined} _1
* @param {State} state
* @param {Info} info
* @returns {string}
*/
export function hardBreak(_, _1, state, info) {
let index = -1
while (++index < state.unsafe.length) {
// If we cant put eols in this construct (setext headings, tables), use a
// space instead.
if (
state.unsafe[index].character === '\n' &&
patternInScope(state.stack, state.unsafe[index])
) {
return /[ \t]/.test(info.before) ? '' : ' '
}
}
return '\\\n'
}