Beispiel #1
0
func cliMarkdownToPDF(c *cli.Context) {

	if c.String("template") == "" {
		log.Fatal("Please specify a template file to parse with the --template or -t flag.")
	}

	if c.String("output") == "" {
		log.Fatal("Please specify an output file to write to with the --output or -o flag.")
	}

	contents := c.String("template")
	parameters := c.String("parameters")
	output := c.String("output")

	lmd.MarkdownToPDF(contents, parameters, output)
}
func TestLegalToRenderingToPDF(t *testing.T) {
	fmt.Println(CLR_B, "\n\tTesting Rendering to PDF\n", CLR_N)

	testFile := filepath.Join(".", "spec", "00.load_write_no_action.md")

	// make a temp file
	tempFile, tempFileErr := ioutil.TempFile(os.TempDir(), "lmd-test-")
	if tempFileErr != nil {
		t.Error(tempFileErr)
	}
	defer os.Remove(tempFile.Name())

	// dowit
	lmd.MarkdownToPDF(testFile, "", tempFile.Name())

	// read the tempfile
	iMadeThisFile := lmd.ReadAFile(tempFile.Name())

	if iMadeThisFile == "" {
		t.Error("Did not create a pdf.")
	}
}