diff options
author | Linus Groh <mail@linusgroh.de> | 2020-10-31 18:11:44 +0000 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-10-31 20:52:54 +0100 |
commit | 10c19d52078ea99705f3d255f3fa6d91ded9ed1b (patch) | |
tree | 060a3ab44758f2e85c22e7a153f94424ff63e7d7 | |
parent | e5ec4d35ea65bbab07b6226868a7a93a679158d0 (diff) | |
download | serenity-10c19d52078ea99705f3d255f3fa6d91ded9ed1b.zip |
LibMarkdown: Replace inline styles in HTML with CSS in <head>
-rw-r--r-- | Libraries/LibMarkdown/CodeBlock.cpp | 6 | ||||
-rw-r--r-- | Libraries/LibMarkdown/Document.cpp | 6 |
2 files changed, 8 insertions, 4 deletions
diff --git a/Libraries/LibMarkdown/CodeBlock.cpp b/Libraries/LibMarkdown/CodeBlock.cpp index b6501ad03c..dce8a19d67 100644 --- a/Libraries/LibMarkdown/CodeBlock.cpp +++ b/Libraries/LibMarkdown/CodeBlock.cpp @@ -55,10 +55,10 @@ String CodeBlock::render_to_html() const if (style.emph) builder.append("<i>"); - if (style_language.is_null()) - builder.append("<code style=\"white-space: pre;\">"); + if (style_language.is_empty()) + builder.append("<code>"); else - builder.appendf("<code style=\"white-space: pre;\" class=\"%s\">", style_language.characters()); + builder.appendff("<code class=\"{}\">", style_language); builder.append(escape_html_entities(m_code)); diff --git a/Libraries/LibMarkdown/Document.cpp b/Libraries/LibMarkdown/Document.cpp index 2bd283c920..f418923701 100644 --- a/Libraries/LibMarkdown/Document.cpp +++ b/Libraries/LibMarkdown/Document.cpp @@ -40,7 +40,11 @@ String Document::render_to_html() const builder.append("<!DOCTYPE html>\n"); builder.append("<html>\n"); - builder.append("<head></head>\n"); + builder.append("<head>\n"); + builder.append("<style>\n"); + builder.append("code { white-space: pre; }\n"); + builder.append("</style>\n"); + builder.append("</head>\n"); builder.append("<body>\n"); for (auto& block : m_blocks) { |