MCPcopy
hub / github.com/typescript-cheatsheets/react / withHeadingContext

Function withHeadingContext

genReadme.mjs:93–97  ·  view source on GitHub ↗

* Adjusts the headings in the given `markdown` to be in a given heading context. * Headings must start in a line. * Preceding whitespace or any other character will result in the heading not being recognized. * * @example `withHeadingContext(2, '# Heading') === '### Heading'` * @param {number}

(relativeHeadingLevel, markdown)

Source from the content-addressed store, hash-verified

91 * @param {string} markdown
92 */
93function withHeadingContext(relativeHeadingLevel, markdown) {
94 return markdown.replaceAll(/^(#+)/gm, (match, markdownHeadingTokens) => {
95 return "#".repeat(markdownHeadingTokens.length + relativeHeadingLevel);
96 });
97}
98
99function generateContentForSection(options) {
100 const {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected