Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions packages/app-core/src/lib/markdown.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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('<h1 data-source-line="6">Visible</h1>')
expect(yaml).not.toContain('title: Hidden')
expect(yaml).not.toContain('<hr')

const toml = renderMarkdown('+++\ntitle = "Hidden"\n+++\n\nBody')
expect(toml).toContain('<p data-source-line="5">Body</p>')
expect(toml).not.toContain('title =')
})

it('sanitizes raw HTML and javascript URLs', () => {
const html = renderMarkdown(
[
Expand Down
26 changes: 25 additions & 1 deletion packages/app-core/src/styles/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down