Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | 12x 224x 143x 143x 143x 858x 143x | import dynamic from "next/dynamic";
const Markdown = dynamic(() => import("components/MarkdownNoSSR"), {
ssr: false,
});
export default Markdown;
export function increaseMarkdownHeaderLevel(
source: string,
topHeaderLevel: number
) {
let convertedSource = source;
for (let i = 6; i >= 1; i--) {
//loop through each header level, and add extra # as necessary
//also put a ~ in front so we know that line is done
convertedSource = convertedSource.replace(
new RegExp(`^${"#".repeat(i)}`, "gm"),
`~${"#".repeat(Math.min(i + topHeaderLevel - 1, 6))}`
);
}
//take out the ~ markers (line start only)
return convertedSource.replace(/^~#/gm, "#");
}
|