mirror of
https://github.com/gohugoio/hugo.git
synced 2024-07-05 00:32:03 +00:00
Support embedding <script> tags in markdown pages
This commit is contained in:
parent
7b7ce11787
commit
e0ea6b9955
|
@ -652,7 +652,6 @@ func (page *Page) Convert() error {
|
||||||
|
|
||||||
func markdownRender(content []byte) []byte {
|
func markdownRender(content []byte) []byte {
|
||||||
htmlFlags := 0
|
htmlFlags := 0
|
||||||
htmlFlags |= blackfriday.HTML_SKIP_SCRIPT
|
|
||||||
htmlFlags |= blackfriday.HTML_USE_XHTML
|
htmlFlags |= blackfriday.HTML_USE_XHTML
|
||||||
htmlFlags |= blackfriday.HTML_USE_SMARTYPANTS
|
htmlFlags |= blackfriday.HTML_USE_SMARTYPANTS
|
||||||
htmlFlags |= blackfriday.HTML_SMARTYPANTS_FRACTIONS
|
htmlFlags |= blackfriday.HTML_SMARTYPANTS_FRACTIONS
|
||||||
|
@ -672,7 +671,6 @@ func markdownRender(content []byte) []byte {
|
||||||
|
|
||||||
func markdownRenderWithTOC(content []byte) []byte {
|
func markdownRenderWithTOC(content []byte) []byte {
|
||||||
htmlFlags := 0
|
htmlFlags := 0
|
||||||
htmlFlags |= blackfriday.HTML_SKIP_SCRIPT
|
|
||||||
htmlFlags |= blackfriday.HTML_TOC
|
htmlFlags |= blackfriday.HTML_TOC
|
||||||
htmlFlags |= blackfriday.HTML_USE_XHTML
|
htmlFlags |= blackfriday.HTML_USE_XHTML
|
||||||
htmlFlags |= blackfriday.HTML_USE_SMARTYPANTS
|
htmlFlags |= blackfriday.HTML_USE_SMARTYPANTS
|
||||||
|
|
|
@ -118,6 +118,12 @@ Summary Next Line. {{% img src="/not/real" %}}.
|
||||||
More text here.
|
More text here.
|
||||||
|
|
||||||
Some more text
|
Some more text
|
||||||
|
`
|
||||||
|
|
||||||
|
SIMPLE_PAGE_WITH_EMBEDDED_SCRIPT = `---
|
||||||
|
title: Simple
|
||||||
|
---
|
||||||
|
<script type='text/javascript'>alert('the script tags are still there, right?');</script>
|
||||||
`
|
`
|
||||||
|
|
||||||
SIMPLE_PAGE_WITH_SUMMARY_DELIMITER_SAME_LINE = `---
|
SIMPLE_PAGE_WITH_SUMMARY_DELIMITER_SAME_LINE = `---
|
||||||
|
@ -340,6 +346,16 @@ func TestPageWithShortCodeInSummary(t *testing.T) {
|
||||||
checkPageLayout(t, p, "page/single.html", "single.html")
|
checkPageLayout(t, p, "page/single.html", "single.html")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestPageWithEmbeddedScriptTag(t *testing.T) {
|
||||||
|
p, _ := NewPage("simple.md")
|
||||||
|
err := p.ReadFrom(strings.NewReader(SIMPLE_PAGE_WITH_EMBEDDED_SCRIPT))
|
||||||
|
p.Convert()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Unable to create a page with frontmatter and body content: %s", err)
|
||||||
|
}
|
||||||
|
checkPageContent(t, p, "<script type='text/javascript'>alert('the script tags are still there, right?');</script>\n")
|
||||||
|
}
|
||||||
|
|
||||||
func TestTableOfContents(t *testing.T) {
|
func TestTableOfContents(t *testing.T) {
|
||||||
p, _ := NewPage("tocpage.md")
|
p, _ := NewPage("tocpage.md")
|
||||||
err := p.ReadFrom(strings.NewReader(PAGE_WITH_TOC))
|
err := p.ReadFrom(strings.NewReader(PAGE_WITH_TOC))
|
||||||
|
|
Loading…
Reference in a new issue