Beispiel #1
0
// Generate the html documentation and copy all necessary assets to the build directory
func DoThings(cfg *config.Config) error {
	var err error

	curwd, err := os.Getwd()
	if err != nil {
		log.Fatal(err)
	}
	err = os.Chdir(filepath.Join(cfg.Basedir(), "doc", "manual"))
	if err != nil {
		log.Fatal(err)
	}

	defer os.Chdir(curwd)

	md := MDDoc{}
	md.root = "doc"
	md.dest = filepath.Join(cfg.Builddir, "manual")
	md.basedir = "."
	md.changelog = parseChangelog(filepath.Join(cfg.Basedir(), "doc", "changelog.xml"))
	md.assets = filepath.Join(cfg.Basedir(), "assets")
	md.renderer = blackfriday.HtmlRenderer(0, "", "")
	md.Version = cfg.Publisherversion.String()

	funcMap := template.FuncMap{
		"rootDoc": md.rootDoc,
		"footer":  md.footerHTML,
		"assets":  md.getAssetsDir,
		"root":    md.getRootDir,
	}

	err = os.MkdirAll(md.dest, 0755)
	if err != nil {
		return err
	}

	// text.template because we trust the input...
	templates, err = template.New("").Funcs(funcMap).ParseFiles(filepath.Join(md.basedir, "templates", "main.html"))
	if err != nil {
		return err
	}

	err = filepath.Walk(md.root, md.generateHTMLDocs)
	if err != nil {
		return err
	}

	md.writeFeed("en")
	md.writeFeed("de")
	return nil
}
Beispiel #2
0
func toMarkdown(input string) string {
	htmlFlags := 0
	htmlFlags |= blackfriday.HTML_USE_XHTML
	htmlFlags |= blackfriday.HTML_SMARTYPANTS_FRACTIONS
	htmlFlags |= blackfriday.HTML_SMARTYPANTS_LATEX_DASHES

	renderer := blackfriday.HtmlRenderer(htmlFlags, "", "")

	extensions := 0
	extensions |= blackfriday.EXTENSION_NO_INTRA_EMPHASIS
	extensions |= blackfriday.EXTENSION_TABLES
	extensions |= blackfriday.EXTENSION_FENCED_CODE
	extensions |= blackfriday.EXTENSION_AUTOLINK
	extensions |= blackfriday.EXTENSION_STRIKETHROUGH
	extensions |= blackfriday.EXTENSION_SPACE_HEADERS
	extensions |= blackfriday.EXTENSION_HEADER_IDS

	b := blackfriday.Markdown([]byte(input), renderer, extensions)
	return string(b)

}