Skip to content

Commit 3920e00

Browse files
committed
Fix rendering and styling of release notes with icons and improved markdown support
1 parent e839dbe commit 3920e00

1 file changed

Lines changed: 70 additions & 4 deletions

File tree

components/targets/ReleaseNotes.vue

Lines changed: 70 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,13 @@ const renderReleaseNotes = async () => {
3939
4040
// Release notes can contain untrusted content (e.g. PR titles for PR builds),
4141
// so sanitize the rendered HTML before it reaches v-html. The trusted
42-
// hardcoded markup below is applied after sanitization.
42+
// hardcoded markup below (alert icons) is applied after sanitization.
43+
//
44+
// Markdown block structure (paragraphs, headings, lists, blockquotes) is left
45+
// intact and styled with the scoped CSS below — only real `> ...` blockquotes
46+
// in the source render with the accent bar.
4347
const output = DOMPurify.sanitize(await marked(notes))
4448
releaseNotes.value = output
45-
.replaceAll('<p>', '<blockquote class="p-4 my-4 border-s-4 border-meshtastic release-notes-quote">')
46-
.replaceAll('</p>', '</blockquote>')
47-
.replaceAll('<br>', '')
4849
.replaceAll('[!CAUTION]', '<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6"><path stroke-linecap="round" stroke-linejoin="round" d="M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126ZM12 15.75h.007v.008H12v-.008Z" /></svg>')
4950
.replaceAll('[!IMPORTANT]', '<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6"><path stroke-linecap="round" stroke-linejoin="round" d="M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126ZM12 15.75h.007v.008H12v-.008Z" /></svg>')
5051
.replaceAll('[!WARNING]', '<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6"><path stroke-linecap="round" stroke-linejoin="round" d="M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126ZM12 15.75h.007v.008H12v-.008Z" /></svg>')
@@ -65,6 +66,71 @@ watch(
6566
scrollbar-gutter: stable both-edges;
6667
}
6768
69+
/* v-html content is not touched by Vue's scoped attribute, so :deep() is
70+
required to style the markdown that marked renders. */
71+
.release-notes-box :deep(h1),
72+
.release-notes-box :deep(h2),
73+
.release-notes-box :deep(h3) {
74+
font-weight: 600;
75+
line-height: 1.3;
76+
margin: 1.25rem 0 0.5rem;
77+
}
78+
79+
.release-notes-box :deep(h1) { font-size: 1.25rem; }
80+
.release-notes-box :deep(h2) { font-size: 1.125rem; }
81+
.release-notes-box :deep(h3) { font-size: 1rem; }
82+
83+
.release-notes-box :deep(p) {
84+
margin: 0.75rem 0;
85+
line-height: 1.6;
86+
}
87+
88+
.release-notes-box :deep(ul),
89+
.release-notes-box :deep(ol) {
90+
margin: 0.75rem 0;
91+
padding-left: 1.5rem;
92+
}
93+
94+
.release-notes-box :deep(ul) { list-style: disc; }
95+
.release-notes-box :deep(ol) { list-style: decimal; }
96+
.release-notes-box :deep(li) { margin: 0.25rem 0; }
97+
98+
.release-notes-box :deep(a) {
99+
color: #67ea94;
100+
text-decoration: underline;
101+
}
102+
103+
.release-notes-box :deep(code) {
104+
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
105+
font-size: 0.875em;
106+
padding: 0.1rem 0.3rem;
107+
border-radius: 0.25rem;
108+
background: rgba(255, 255, 255, 0.08);
109+
}
110+
111+
.release-notes-box :deep(pre) {
112+
margin: 0.75rem 0;
113+
padding: 0.75rem 1rem;
114+
border-radius: 0.5rem;
115+
overflow-x: auto;
116+
background: rgba(255, 255, 255, 0.05);
117+
}
118+
119+
.release-notes-box :deep(pre code) {
120+
padding: 0;
121+
background: none;
122+
}
123+
124+
/* Only real `> ...` blockquotes in the source get the accent bar. */
125+
.release-notes-box :deep(blockquote) {
126+
border-left: 4px solid #67ea94;
127+
padding: 0.5rem 1rem;
128+
margin: 1rem 0;
129+
}
130+
131+
.release-notes-box :deep(blockquote) > :first-child { margin-top: 0; }
132+
.release-notes-box :deep(blockquote) > :last-child { margin-bottom: 0; }
133+
68134
.release-notes-box::-webkit-scrollbar {
69135
width: 10px;
70136
}

0 commit comments

Comments
 (0)