Beispiel #1
0
func main() {
	html := flag.Bool("embed", false, "Embeds the converted DML in an HTML body before writing it out.")
	flag.Parse()
	inpath := ""
	outpath := ""
	if flag.NArg() < 2 {
		fmt.Println("Insufficient arguments.")
		return
	}

	inpath = flag.Arg(0)
	outpath = flag.Arg(1)

	file, err := ioutil.ReadFile(inpath)
	if err != nil {
		fmt.Println("Could not" + err.String())
	}
	output := ""
	if *html {
		output = dml.ToHTML(flag.Arg(0), string(file))
	} else {
		output = dml.ParseDoc(string(file))
	}

	ioutil.WriteFile(outpath, []byte(output), 0664)
}
Beispiel #2
0
func globalServe(params *web.Context, val string) string {
	cssPath := params.Params["style"]
	if len(cssPath) == 0 {
		cssPath = "default.css"
	} else {
		cssPath += ".css"
	}
	file, err := ioutil.ReadFile("/" + val)
	if err != nil {
		return "404: File not found: dml-g/" + val
	}
	if strings.HasSuffix(val, ".dml") {
		css, err := ioutil.ReadFile(contextDir + cssPath)
		if err == nil {
			return dml.ToHTMLCSS(val, string(file), string(css))
		}
		return dml.ToHTML(val, string(file))
	}
	return string(file)
}