Compare commits
No commits in common. "master" and "v0.1.0" have entirely different histories.
28
main.go
28
main.go
|
@ -73,22 +73,10 @@ func highlight(w io.Writer, source, lexer, style string) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
/* HACK: If background color is white, set to a reasonable, light grey
|
|
||||||
* default. */
|
|
||||||
if s.Get(chroma.Background).Background.String() == "#ffffff" {
|
|
||||||
senr := s.Get(chroma.Background)
|
|
||||||
senr.Background = chroma.ParseColour("#f6f8fa");
|
|
||||||
s, err = s.Builder().AddEntry(chroma.Background, senr).Build();
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return f.Format(w, s, it)
|
return f.Format(w, s, it)
|
||||||
}
|
}
|
||||||
|
|
||||||
const Version = "0.1.3"
|
const Version = "0.1"
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
css := flag.String("css", "", "Path to a CSS import to include at the beginning of the output")
|
css := flag.String("css", "", "Path to a CSS import to include at the beginning of the output")
|
||||||
|
@ -119,7 +107,6 @@ func main() {
|
||||||
bs := bufio.NewScanner(r)
|
bs := bufio.NewScanner(r)
|
||||||
lang := ""
|
lang := ""
|
||||||
needCSS := false
|
needCSS := false
|
||||||
cmark, lookErr := exec.LookPath("cmark-gfm")
|
|
||||||
for bs.Scan() {
|
for bs.Scan() {
|
||||||
text := bs.Text()
|
text := bs.Text()
|
||||||
trimmed := strings.TrimSpace(text)
|
trimmed := strings.TrimSpace(text)
|
||||||
|
@ -142,12 +129,6 @@ func main() {
|
||||||
currentCodeBlock.WriteString(text)
|
currentCodeBlock.WriteString(text)
|
||||||
currentCodeBlock.WriteByte('\n')
|
currentCodeBlock.WriteByte('\n')
|
||||||
} else {
|
} else {
|
||||||
/* If cmark is not installed then discount will be used, and we have to
|
|
||||||
* do some encoding ourselves. */
|
|
||||||
if lookErr != nil {
|
|
||||||
text = strings.Replace(text, "\\<", "<", -1)
|
|
||||||
text = strings.Replace(text, "\\>", ">", -1)
|
|
||||||
}
|
|
||||||
out.WriteString(text)
|
out.WriteString(text)
|
||||||
out.WriteByte('\n')
|
out.WriteByte('\n')
|
||||||
}
|
}
|
||||||
|
@ -164,13 +145,12 @@ func main() {
|
||||||
checkError(writeErr, "writing data to temporary file")
|
checkError(writeErr, "writing data to temporary file")
|
||||||
// shell out to markdown because of
|
// shell out to markdown because of
|
||||||
// https://github.com/russross/blackfriday/issues/403
|
// https://github.com/russross/blackfriday/issues/403
|
||||||
var args []string
|
cmark, lookErr := exec.LookPath("cmark")
|
||||||
|
args := []string{cmark, "--unsafe", f.Name()}
|
||||||
if lookErr != nil {
|
if lookErr != nil {
|
||||||
cmark, lookErr = exec.LookPath("markdown")
|
cmark, lookErr = exec.LookPath("markdown")
|
||||||
checkError(lookErr, "finding markdown binary")
|
checkError(lookErr, "finding markdown binary")
|
||||||
args = []string{cmark, "-f", "smarty,pants", f.Name()}
|
args = []string{cmark, f.Name()}
|
||||||
} else {
|
|
||||||
args = []string{cmark, "--smart", "--unsafe", "--extension", "table", f.Name()}
|
|
||||||
}
|
}
|
||||||
execErr := localExec(cmark, args, []string{})
|
execErr := localExec(cmark, args, []string{})
|
||||||
checkError(execErr, "executing markdown binary")
|
checkError(execErr, "executing markdown binary")
|
||||||
|
|
Loading…
Reference in New Issue