Created
February 10, 2022 23:08
-
-
Save vaidd4/adcd76cfb3f489b50e401661140bee82 to your computer and use it in GitHub Desktop.
Markdown to Html Converter - Basic command line tool using https://github.com/yuin/goldmark
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bufio" | |
"github.com/yuin/goldmark" | |
"os" | |
) | |
func main() { | |
scanner := bufio.NewScanner(os.Stdin) | |
for scanner.Scan() { | |
if err := goldmark.Convert(scanner.Bytes(), os.Stdout); err != nil { | |
panic(err) | |
} | |
} | |
if err := scanner.Err(); err != nil { | |
panic(err) | |
} | |
} | |
// Setup: go mod init goldmark-cli && go get github.com/yuin/goldmark | |
// Usage: ./goldmark-cli < readme.md > readme.html | |
// cat readme.md | ./goldmark-cli | <html-minifier> > readme.html |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment