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 // since we are a web editor, with line wrapping, that behavior
// in undesirable, so pre preserve newlines by just maiking // in undesirable, so pre preserve newlines by just maiking
// every new line two newlines (as long as we arent in a codeblock) // every new line two newlines (as long as we arent in a codeblock)
function preprocessMarkdown(doc: string) { // function preprocessMarkdown(doc: string) {
const lines = doc.split('\n'); // const lines = doc.split('\n');
let inCode = false; // let inCode = false;
let result: string[] = []; // let result: string[] = [];
for (let i = 0; i < lines.length; i++) { // for (let i = 0; i < lines.length; i++) {
const fullLine = lines[i]!; // const fullLine = lines[i]!;
const match = fullLine.match(/^( {0,3})(.*)/); // const match = fullLine.match(/^( {0,3})(.*)/);
const content = match?.[2] || ''; // const content = match?.[2] || '';
if (content.startsWith('```')) { // if (content.startsWith('```')) {
if (!inCode) { // if (!inCode) {
inCode = true; // inCode = true;
} else { // } else {
inCode = false; // inCode = false;
} // }
result.push(fullLine); // result.push(fullLine);
continue; // continue;
} // }
if (inCode) { // if (inCode) {
result.push(fullLine); // result.push(fullLine);
} else { // } else {
if (content.trim().length === 0) { // if (content.trim().length === 0) {
result.push(''); // result.push('');
} else { // } else {
if (result.length > 0 && result[result.length - 1] !== '') { // if (result.length > 0 && result[result.length - 1] !== '') {
result.push(''); // result.push('');
} // }
result.push(fullLine); // result.push(fullLine);
} // }
} // }
} // }
return result.join('\n'); // return result.join('\n');
} // }
const ast = computed(() => { const ast = computed(() => {
const mdast = $remark.parse(preprocessMarkdown(props.content)); const mdast = $remark.parse(props.content);
return $remark.runSync(mdast); return $remark.runSync(mdast);
}); });