Allow code blocks in posts

This commit is contained in:
silverpill 2022-01-28 00:31:10 +00:00
parent 3a33d057c0
commit 44e2fb1624
3 changed files with 5 additions and 4 deletions

View file

@ -586,7 +586,8 @@ export default class PostComponent extends Vue {
line-height: 1.5; line-height: 1.5;
padding: $block-inner-padding; padding: $block-inner-padding;
:deep(pre) { :deep(pre),
:deep(code) {
overflow-x: scroll; overflow-x: scroll;
} }

View file

@ -10,7 +10,7 @@ const markdown = new MarkdownIt({ linkify: true, breaks: true })
// Minimal renderer // Minimal renderer
const markdownLite = new MarkdownIt({ linkify: true, breaks: true }) const markdownLite = new MarkdownIt({ linkify: true, breaks: true })
.disable(["backticks", "emphasis", "strikethrough", "image"]) .disable(["emphasis", "strikethrough", "image"])
.use( .use(
MarkdownItLinkAttrs, MarkdownItLinkAttrs,
{ attrs: { target: "_blank", rel: "noopener" } }, { attrs: { target: "_blank", rel: "noopener" } },

View file

@ -3,8 +3,8 @@ import { renderMarkdownLite } from "@/utils/markdown"
describe("Render markdown", () => { describe("Render markdown", () => {
it("Render markdown lite", () => { it("Render markdown lite", () => {
const text = "test **bold** ~~strike~~ with `code` and https://example.com\nand a new line" const text = "test **bold** ~~strike~~ with `code`, <span>html</span> and https://example.com\nand a new line"
const html = renderMarkdownLite(text) const html = renderMarkdownLite(text)
expect(html).to.equal('test **bold** ~~strike~~ with `code` and <a href="https://example.com" target="_blank" rel="noopener">https://example.com</a><br>\nand a new line') expect(html).to.equal('test **bold** ~~strike~~ with <code>code</code>, &lt;span&gt;html&lt;/span&gt; and <a href="https://example.com" target="_blank" rel="noopener">https://example.com</a><br>\nand a new line')
}) })
}) })