Skip to content

Commit b20e6bf

Browse files
fix: resolve HTML export frontmatter parsing and table styling (fixes #109)
1 parent 766e05d commit b20e6bf

2 files changed

Lines changed: 42 additions & 4 deletions

File tree

desktop-app/resources/js/script.js

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4295,8 +4295,9 @@ This is a fully client-side application. Your content never leaves your browser
42954295

42964296
exportHtml.addEventListener("click", function () {
42974297
try {
4298-
const markdown = markdownEditor.value;
4299-
const html = marked.parse(markdown);
4298+
const { frontmatter, body } = parseFrontmatter(markdownEditor.value);
4299+
const tableHtml = frontmatter ? renderFrontmatterTable(frontmatter) : '';
4300+
const html = tableHtml + marked.parse(body);
43004301
const sanitizedHtml = DOMPurify.sanitize(html, {
43014302
ADD_TAGS: ['mjx-container', 'input'],
43024303
ADD_ATTR: ['id', 'class', 'style', 'align', 'type', 'checked', 'disabled']
@@ -4395,6 +4396,24 @@ This is a fully client-side application. Your content never leaves your browser
43954396
.markdown-alert-caution { color: ${isDarkTheme ? "#f85149" : "#cf222e"}; border-left-color: ${isDarkTheme ? "#f85149" : "#cf222e"}; background-color: ${isDarkTheme ? "rgba(248, 81, 73, 0.18)" : "#ffebe9"}; }
43964397
.markdown-alert > *:not(.markdown-alert-title) { color: ${isDarkTheme ? "#c9d1d9" : "#24292e"}; }
43974398
4399+
.frontmatter-table {
4400+
width: 100%;
4401+
border-collapse: collapse;
4402+
margin-bottom: 24px;
4403+
font-size: 14px;
4404+
}
4405+
.frontmatter-table th,
4406+
.frontmatter-table td {
4407+
border: 1px solid ${isDarkTheme ? "#30363d" : "#e1e4e8"};
4408+
padding: 8px 12px;
4409+
text-align: left;
4410+
}
4411+
.frontmatter-table th {
4412+
font-weight: 600;
4413+
background-color: ${isDarkTheme ? "#161b22" : "#f6f8fa"};
4414+
width: 150px;
4415+
}
4416+
43984417
@media (max-width: 767px) {
43994418
.markdown-body {
44004419
padding: 15px;

script.js

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4295,8 +4295,9 @@ This is a fully client-side application. Your content never leaves your browser
42954295

42964296
exportHtml.addEventListener("click", function () {
42974297
try {
4298-
const markdown = markdownEditor.value;
4299-
const html = marked.parse(markdown);
4298+
const { frontmatter, body } = parseFrontmatter(markdownEditor.value);
4299+
const tableHtml = frontmatter ? renderFrontmatterTable(frontmatter) : '';
4300+
const html = tableHtml + marked.parse(body);
43004301
const sanitizedHtml = DOMPurify.sanitize(html, {
43014302
ADD_TAGS: ['mjx-container', 'input'],
43024303
ADD_ATTR: ['id', 'class', 'style', 'align', 'type', 'checked', 'disabled']
@@ -4395,6 +4396,24 @@ This is a fully client-side application. Your content never leaves your browser
43954396
.markdown-alert-caution { color: ${isDarkTheme ? "#f85149" : "#cf222e"}; border-left-color: ${isDarkTheme ? "#f85149" : "#cf222e"}; background-color: ${isDarkTheme ? "rgba(248, 81, 73, 0.18)" : "#ffebe9"}; }
43964397
.markdown-alert > *:not(.markdown-alert-title) { color: ${isDarkTheme ? "#c9d1d9" : "#24292e"}; }
43974398
4399+
.frontmatter-table {
4400+
width: 100%;
4401+
border-collapse: collapse;
4402+
margin-bottom: 24px;
4403+
font-size: 14px;
4404+
}
4405+
.frontmatter-table th,
4406+
.frontmatter-table td {
4407+
border: 1px solid ${isDarkTheme ? "#30363d" : "#e1e4e8"};
4408+
padding: 8px 12px;
4409+
text-align: left;
4410+
}
4411+
.frontmatter-table th {
4412+
font-weight: 600;
4413+
background-color: ${isDarkTheme ? "#161b22" : "#f6f8fa"};
4414+
width: 150px;
4415+
}
4416+
43984417
@media (max-width: 767px) {
43994418
.markdown-body {
44004419
padding: 15px;

0 commit comments

Comments
 (0)