Beispiel #1
0
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))
	}
}
Beispiel #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))
}
Beispiel #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))
}
Beispiel #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))
}
Beispiel #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
}
Beispiel #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
}