Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions packages/site-kit/src/lib/markdown/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -719,11 +719,18 @@ function replace_blank_lines(html: string) {
}

const delimiter_substitutes = {
'---': ' ',
'+++': ' ',
':::': ' '
'---': ' ',
'+++': ' ',
':::': ' '
};

const delimiter_patterns = Object.fromEntries(
Object.entries(delimiter_substitutes).map(([key, substitute]) => [
key,
new RegExp(`${substitute}([^ ][^]+?)${substitute}`, 'g')
])
);

function highlight_spans(content: string, classname: string) {
return content
.split('\n')
Expand Down Expand Up @@ -878,13 +885,13 @@ async function syntax_highlight({
.replace(' tabindex="0"', '');

html = html
.replace(/ {13}([^ ][^]+?) {13}/g, (_, content) => {
.replace(delimiter_patterns['---'], (_, content) => {
return highlight_spans(content, 'highlight remove');
})
.replace(/ {11}([^ ][^]+?) {11}/g, (_, content) => {
.replace(delimiter_patterns['+++'], (_, content) => {
return highlight_spans(content, 'highlight add');
})
.replace(/ {9}([^ ][^]+?) {9}/g, (_, content) => {
.replace(delimiter_patterns[':::'], (_, content) => {
return highlight_spans(content, 'highlight');
});

Expand Down