astro-ghostcms/.pnpm-store/v3/files/e4/f49b84f33bf5477bd00126ebeb4...

49 lines
1.2 KiB
Plaintext
Raw Normal View History

2024-02-14 14:10:47 +00:00
/**
* @typedef {import('mdast').Parents} Parents
* @typedef {import('mdast').Strong} Strong
* @typedef {import('../types.js').Info} Info
* @typedef {import('../types.js').State} State
*/
import {checkStrong} from '../util/check-strong.js'
strong.peek = strongPeek
// To do: there are cases where emphasis cannot “form” depending on the
// previous or next character of sequences.
// Theres no way around that though, except for injecting zero-width stuff.
// Do we need to safeguard against that?
/**
* @param {Strong} node
* @param {Parents | undefined} _
* @param {State} state
* @param {Info} info
* @returns {string}
*/
export function strong(node, _, state, info) {
const marker = checkStrong(state)
const exit = state.enter('strong')
const tracker = state.createTracker(info)
let value = tracker.move(marker + marker)
value += tracker.move(
state.containerPhrasing(node, {
before: value,
after: marker,
...tracker.current()
})
)
value += tracker.move(marker + marker)
exit()
return value
}
/**
* @param {Strong} _
* @param {Parents | undefined} _1
* @param {State} state
* @returns {string}
*/
function strongPeek(_, _1, state) {
return state.options.strong || '*'
}