revert: no longer preprocess markdown to make singlenewlines double, breaks table rendering

This commit is contained in:
Zoe
2026-02-28 17:20:58 -06:00
parent a2891e0461
commit 82ab72dae3
+33 -33
View File
@@ -21,47 +21,47 @@ const { $remark } = useNuxtApp();
// since we are a web editor, with line wrapping, that behavior
// in undesirable, so pre preserve newlines by just maiking
// every new line two newlines (as long as we arent in a codeblock)
function preprocessMarkdown(doc: string) {
const lines = doc.split('\n');
let inCode = false;
let result: string[] = [];
// function preprocessMarkdown(doc: string) {
// const lines = doc.split('\n');
// let inCode = false;
// let result: string[] = [];
for (let i = 0; i < lines.length; i++) {
const fullLine = lines[i]!;
// for (let i = 0; i < lines.length; i++) {
// const fullLine = lines[i]!;
const match = fullLine.match(/^( {0,3})(.*)/);
const content = match?.[2] || '';
// const match = fullLine.match(/^( {0,3})(.*)/);
// const content = match?.[2] || '';
if (content.startsWith('```')) {
if (!inCode) {
inCode = true;
} else {
inCode = false;
}
result.push(fullLine);
continue;
}
// if (content.startsWith('```')) {
// if (!inCode) {
// inCode = true;
// } else {
// inCode = false;
// }
// result.push(fullLine);
// continue;
// }
if (inCode) {
result.push(fullLine);
} else {
if (content.trim().length === 0) {
result.push('');
} else {
if (result.length > 0 && result[result.length - 1] !== '') {
result.push('');
}
result.push(fullLine);
}
}
}
// if (inCode) {
// result.push(fullLine);
// } else {
// if (content.trim().length === 0) {
// result.push('');
// } else {
// if (result.length > 0 && result[result.length - 1] !== '') {
// result.push('');
// }
// result.push(fullLine);
// }
// }
// }
return result.join('\n');
}
// return result.join('\n');
// }
const ast = computed(() => {
const mdast = $remark.parse(preprocessMarkdown(props.content));
const mdast = $remark.parse(props.content);
return $remark.runSync(mdast);
});