fix: resolve critical JavaScript syntax errors in md-render --edit
Fix broken edit mode that prevented content rendering due to: - Unescaped newline literals causing JavaScript string syntax errors - Inconsistent brace escaping in f-string templates - Template literal syntax issues with variable interpolation The edit mode now properly renders content AND provides editing capabilities. Also added html-inject-editing command for standalone HTML enhancement with graceful fallback options. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -574,35 +574,35 @@ class DocumentManager:
|
||||
const sections = content.querySelectorAll('.markitect-section-editable');
|
||||
let reconstructed = '';
|
||||
|
||||
sections.forEach(section => {
|
||||
sections.forEach(section => {{
|
||||
const tagName = section.tagName.toLowerCase();
|
||||
const text = section.textContent.trim();
|
||||
|
||||
if (tagName.startsWith('h')) {
|
||||
if (tagName.startsWith('h')) {{
|
||||
const level = parseInt(tagName.charAt(1));
|
||||
reconstructed += '#'.repeat(level) + ' ' + text + '\n\n';
|
||||
} else if (tagName === 'p') {
|
||||
reconstructed += text + '\n\n';
|
||||
} else if (tagName === 'blockquote') {
|
||||
reconstructed += '> ' + text + '\n\n';
|
||||
} else if (tagName === 'pre') {
|
||||
reconstructed += '```\n' + text + '\n```\n\n';
|
||||
} else if (tagName === 'ul') {
|
||||
reconstructed += '#'.repeat(level) + ' ' + text + '\\n\\n';
|
||||
}} else if (tagName === 'p') {{
|
||||
reconstructed += text + '\\n\\n';
|
||||
}} else if (tagName === 'blockquote') {{
|
||||
reconstructed += '> ' + text + '\\n\\n';
|
||||
}} else if (tagName === 'pre') {{
|
||||
reconstructed += '```\\n' + text + '\\n```\\n\\n';
|
||||
}} else if (tagName === 'ul') {{
|
||||
const items = section.querySelectorAll('li');
|
||||
items.forEach(item => {
|
||||
reconstructed += '- ' + item.textContent.trim() + '\n';
|
||||
});
|
||||
reconstructed += '\n';
|
||||
} else if (tagName === 'ol') {
|
||||
items.forEach(item => {{
|
||||
reconstructed += '- ' + item.textContent.trim() + '\\n';
|
||||
}});
|
||||
reconstructed += '\\n';
|
||||
}} else if (tagName === 'ol') {{
|
||||
const items = section.querySelectorAll('li');
|
||||
items.forEach((item, index) => {
|
||||
reconstructed += `${index + 1}. ` + item.textContent.trim() + '\n';
|
||||
});
|
||||
reconstructed += '\n';
|
||||
} else {
|
||||
reconstructed += text + '\n\n';
|
||||
}
|
||||
});
|
||||
items.forEach((item, index) => {{
|
||||
reconstructed += (index + 1) + '. ' + item.textContent.trim() + '\\n';
|
||||
}});
|
||||
reconstructed += '\\n';
|
||||
}} else {{
|
||||
reconstructed += text + '\\n\\n';
|
||||
}}
|
||||
}});
|
||||
|
||||
return reconstructed.trim();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user