add [youtube] tag support

This commit is contained in:
mappu 2018-04-02 15:57:24 +12:00
parent 6b41df964b
commit e0e30372ef
2 changed files with 7 additions and 0 deletions

View File

@ -61,6 +61,12 @@ func (this *BBCodeRenderer) bbcode(data string) string {
nil,
},
pregReplaceRule{
regexp.MustCompile(`(?si)\[youtube](.*?)\[/youtube\]`),
`<iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/${1}" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>`,
nil,
},
pregReplaceRule{regexp.MustCompile(`(?si)\[section=(.*?)](.*?)\[/section\]`), "", func(m []string) string {
return `<div class="section"><a class="sectionheader" href="javascript:;" onclick="ts(this);">` + m[1] + `</a><span style="display:none;">` + strings.TrimSpace(m[2]) + `</span></div>`
}},

View File

@ -33,6 +33,7 @@ func (this *WikiServer) routeFormatting(w http.ResponseWriter, r *http.Request)
content += `
<li>[code]fixed width[/code]</li>
<li>[section=header]content[/section]</li>
<li>[youtube]id[/youtube]</li>
<li>[html]raw html[/html]</li>
</ul>`