diff --git a/packages/app-core/src/lib/markdown.test.ts b/packages/app-core/src/lib/markdown.test.ts index 85b7bfd4..24e7e2b0 100644 --- a/packages/app-core/src/lib/markdown.test.ts +++ b/packages/app-core/src/lib/markdown.test.ts @@ -4,6 +4,17 @@ import { describe, expect, it } from 'vitest' import { renderMarkdown } from './markdown' describe('renderMarkdown', () => { + it('hides leading YAML/TOML frontmatter in preview output', () => { + const yaml = renderMarkdown('---\ntitle: Hidden\ntags: [a, b]\n---\n\n# Visible') + expect(yaml).toContain('

Visible

') + expect(yaml).not.toContain('title: Hidden') + expect(yaml).not.toContain('Body

') + expect(toml).not.toContain('title =') + }) + it('sanitizes raw HTML and javascript URLs', () => { const html = renderMarkdown( [ diff --git a/packages/app-core/src/styles/index.css b/packages/app-core/src/styles/index.css index 891b05d0..c8a19fa6 100644 --- a/packages/app-core/src/styles/index.css +++ b/packages/app-core/src/styles/index.css @@ -2065,9 +2065,33 @@ html[data-completed-task-style="gray-strikethrough"] .cm-editor .cm-task-done * border-left: 1px solid rgb(var(--z-grey-0) / 0.13); border-right: 1px solid rgb(var(--z-grey-0) / 0.13); } -.cm-editor .cm-frontmatter-line :is(.tok-meta, .tok-string, .tok-keyword, .tok-atom) { +.cm-editor .cm-frontmatter-line + :is( + .tok-meta, + .tok-string, + .tok-keyword, + .tok-atom, + .tok-heading, + .tok-heading1, + .tok-heading2, + .tok-heading3, + .tok-heading4, + .tok-heading5, + .tok-heading6 + ) { color: inherit; } +/* Without a blank line before the closing `---`, CodeMirror's markdown parser + * can tokenize the previous frontmatter line as a setext heading. The metadata + * card owns frontmatter presentation, so suppress body heading typography here. */ +.cm-editor .cm-frontmatter-line + :is(.tok-heading, .tok-heading1, .tok-heading2, .tok-heading3, .tok-heading4, .tok-heading5, .tok-heading6) { + font-size: inherit; + font-weight: inherit; + line-height: inherit; + text-transform: none; + letter-spacing: 0; +} /* The key (before the `:`) is a muted label; the value keeps the normal color. */ .cm-editor .cm-frontmatter-key, .cm-editor .cm-frontmatter-key :is(.tok-meta, .tok-string, .tok-keyword, .tok-atom) {