-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TAS-172]π Add marked for markdown rendering (#1259)
* β Add marked for markdown rendering * π[_classId] Add <MarkDown> for rendering edition description * π¨ Fix lint warning * π Add a parent classId for markdown style * β Add DOMPurify to sanitize HTML * β Update functions package.json * π¨ Fix lint error * π Update package-lock.json * ποΈ Remove html in markdown * π Fix typo and double esacpe --------- Co-authored-by: William Chong <[email protected]>
- Loading branch information
1 parent
711d2fb
commit 8818eab
Showing
9 changed files
with
31,967 additions
and
41,536 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
.markdown-container h1 { | ||
font-size: 34px; | ||
font-weight: bold; | ||
} | ||
|
||
.markdown-container h2 { | ||
font-size: 28px; | ||
font-weight: bold; | ||
} | ||
|
||
.markdown-container h3 { | ||
font-size: 24px; | ||
font-weight: bold; | ||
} | ||
|
||
|
||
.markdown-container ul { | ||
list-style-type: disc; | ||
margin-left: 0.5em; | ||
} | ||
|
||
.markdown-container ul ul { | ||
list-style-type: circle; | ||
margin-left: 1em; | ||
} | ||
|
||
.markdown-container ol { | ||
list-style-type: decimal; | ||
} | ||
|
||
.markdown-container li { | ||
text-align: left; | ||
} | ||
|
||
.markdown-container a{ | ||
color: '#1e4a51'; | ||
} | ||
|
||
.markdown-container a:hover { | ||
color: '#1e4a51'; | ||
text-decoration: underline; | ||
} | ||
|
||
|
||
.markdown-container blockquote { | ||
margin: 1em 0; | ||
padding: 0.5em 1em; | ||
border-left: 4px solid #ccc; | ||
} | ||
|
||
|
||
.markdown-container strong { | ||
font-weight: bold; | ||
} | ||
|
||
.markdown-container em { | ||
font-style: italic; | ||
} | ||
|
||
|
||
.markdown-container pre { | ||
background-color: #f0f0f0; | ||
padding: 1em; | ||
overflow: auto; | ||
font-family: 'Courier New', Courier, monospace; | ||
} | ||
|
||
.markdown-container code { | ||
font-family: 'Courier New', Courier, monospace; | ||
} | ||
|
||
|
||
.markdown-container img { | ||
max-width: 100%; | ||
height: auto; | ||
} | ||
|
||
|
||
.markdown-container hr { | ||
border: none; | ||
border-bottom: 1px solid #ccc; | ||
margin: 1em 0; | ||
} | ||
|
||
.markdown-container p { | ||
font-size: 14px; | ||
font-weight: lighter; | ||
text-align: left; | ||
|
||
word-wrap: break-word; | ||
overflow-wrap: break-word; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<!-- eslint-disable vue/no-v-html --> | ||
<template> | ||
<div class="markdown-container" v-html="markdownToHtml" /> | ||
</template> | ||
|
||
<script> | ||
import { marked } from 'marked'; | ||
import DOMPurify from 'dompurify'; | ||
|
||
import { escapeHtml, unescapeHtml } from '@/util/misc'; | ||
|
||
export default { | ||
name: 'Markdown', | ||
props: { | ||
mdString: { | ||
type: String, | ||
default: '', | ||
}, | ||
}, | ||
computed: { | ||
markdownToHtml() { | ||
const text = escapeHtml(unescapeHtml(this.mdString)); | ||
const rawHtml = marked(text); | ||
return DOMPurify.sanitize(rawHtml); | ||
}, | ||
}, | ||
}; | ||
</script> | ||
|
||
<style> | ||
/* Import the custom styles for Markdown rendering */ | ||
@import '@/assets/css/markdownStyle.css'; | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.