Exemplo n.º 1
0
Arquivo: page.go Projeto: RoyRui/hugo
func renderBytes(content []byte, pagefmt string) []byte {
	switch pagefmt {
	default:
		return blackfriday.MarkdownCommon(content)
	case "markdown":
		return blackfriday.MarkdownCommon(content)
	case "rst":
		return []byte(getRstContent(content))
	}
}
Exemplo n.º 2
0
func (page *Page) convertMarkdown(lines io.Reader) {
	b := new(bytes.Buffer)
	b.ReadFrom(lines)
	content := string(blackfriday.MarkdownCommon(b.Bytes()))
	page.Content = template.HTML(content)
	page.Summary = template.HTML(TruncateWordsToWholeSentence(StripHTML(StripShortcodes(content)), summaryLength))
}
Exemplo n.º 3
0
func (page *Page) convertMarkdown(lines []string) {

	page.RawMarkdown = strings.Join(lines, "\n")
	content := string(blackfriday.MarkdownCommon([]byte(page.RawMarkdown)))
	page.Content = template.HTML(content)
	page.Summary = template.HTML(TruncateWordsToWholeSentence(StripHTML(StripShortcodes(content)), summaryLength))
}
Exemplo n.º 4
0
func (page *Page) convertMarkdown(lines io.Reader) {
	b := new(bytes.Buffer)
	b.ReadFrom(lines)
	content := b.Bytes()
	page.Content = template.HTML(string(blackfriday.MarkdownCommon(RemoveSummaryDivider(content))))
	summary := getSummaryString(content, "markdown")
	page.Summary = template.HTML(string(summary))
}
Exemplo n.º 5
0
func renderMarkdown(rw http.ResponseWriter, name string) error {
	data, err := ioutil.ReadFile(name)
	if err != nil {
		http.Error(rw, "Unable to read file", 500)
		return err
	}

	output := blackfriday.MarkdownCommon(data)
	Render.HTML(rw, 200, "slide", template.HTML(output))
	return nil
}
Exemplo n.º 6
0
func (p *Page) load() error {
	c, err := LoadConfig("config.json")
	if err != nil {
		return err
	}

	data, err := ioutil.ReadFile(p.File)
	if err != nil {
		return nil
	}

	p.HTML = string(blackfriday.MarkdownCommon(data))
	p.Title = c.Name()
	p.Author = c.Author()
	return nil
}