1
0
mirror of https://github.com/home-assistant/frontend.git synced 2025-12-20 02:38:53 +00:00

Fix markdown styles regression (#28202)

* Render markdown table in wrapper.

* Fix markdown styles

* Fix formatting
This commit is contained in:
Silas Krause
2025-11-28 07:28:57 +01:00
committed by GitHub
parent 4df8501b20
commit 6727ffaae0
2 changed files with 20 additions and 6 deletions

View File

@@ -88,8 +88,7 @@ export class HaMarkdown extends LitElement {
} }
ol, ol,
ul { ul {
list-style-position: inside; padding-inline-start: 1rem;
padding-inline-start: 0;
} }
li { li {
&:has(input[type="checkbox"]) { &:has(input[type="checkbox"]) {
@@ -140,16 +139,19 @@ export class HaMarkdown extends LitElement {
margin: var(--ha-space-4) 0; margin: var(--ha-space-4) 0;
} }
table { table {
border-collapse: collapse; border-collapse: var(--markdown-table-border-collapse, collapse);
display: block; }
overflow-x: auto; div:has(> table) {
overflow: auto;
} }
th { th {
text-align: start; text-align: start;
} }
td, td,
th { th {
border: 1px solid var(--markdown-table-border-color, transparent); border-width: var(--markdown-table-border-width, 1px);
border-style: var(--markdown-table-border-style, solid);
border-color: var(--markdown-table-border-color, var(--divider-color));
padding: 0.25em 0.5em; padding: 0.25em 0.5em;
} }
blockquote { blockquote {

View File

@@ -55,6 +55,18 @@ const renderMarkdown = async (
marked.setOptions(markedOptions); marked.setOptions(markedOptions);
marked.use({
renderer: {
table(...args) {
const defaultRenderer = new marked.Renderer();
// Wrap the table with block element because the property 'overflow'
// cannot be applied to elements of display type 'table'.
// https://www.w3.org/TR/css-overflow-3/#overflow-control
return `<div>${defaultRenderer.table.apply(this, args)}</div>`;
},
},
});
const tokens = marked.lexer(content); const tokens = marked.lexer(content);
return tokens.map((token) => return tokens.map((token) =>
filterXSS(marked.parser([token]), { filterXSS(marked.parser([token]), {