Пример #1
0
func (h markdownHandler) PageConvert(p *Page, t tpl.Template) HandledResult {
	p.ProcessShortcodes(t)

	tmpContent, tmpTableOfContents := helpers.ExtractTOC(p.renderContent(helpers.RemoveSummaryDivider(p.rawContent)))

	if len(p.contentShortCodes) > 0 {
		replaced, err := replaceShortcodeTokensInsources(shortcodePlaceholderPrefix, p.contentShortCodes,
			tmpContent, tmpTableOfContents)
		if err != nil {
			jww.FATAL.Printf("Fail to replace shortcode tokens in %s:\n%s", p.BaseFileName(), err.Error())
			return HandledResult{err: err}
		}
		tmpContent = replaced[0]
		tmpTableOfContents = replaced[1]
	}

	p.Content = helpers.BytesToHTML(tmpContent)
	p.TableOfContents = helpers.BytesToHTML(tmpTableOfContents)

	return HandledResult{err: nil}
}
Пример #2
0
func (h htmlHandler) PageConvert(p *Page, t tpl.Template) HandledResult {
	p.ProcessShortcodes(t)
	var content []byte
	var err error

	if len(p.contentShortCodes) > 0 {
		content, err = replaceShortcodeTokens(p.rawContent, shortcodePlaceholderPrefix, p.contentShortCodes)

		if err != nil {
			jww.FATAL.Printf("Fail to replace shortcode tokens in %s:\n%s", p.BaseFileName(), err.Error())
			return HandledResult{err: err}
		}
	} else {
		content = p.rawContent
	}

	p.Content = helpers.BytesToHTML(content)
	return HandledResult{err: nil}
}