terminate content with new line
explicit option to show citation markers increment version output embedded images as links
This commit is contained in:
parent
81227fa2fb
commit
a29cb7bd9a
@ -11,6 +11,7 @@ html2gmi <flags>
|
|||||||
-c, --citationStart int Start citations from this index (default 1)
|
-c, --citationStart int Start citations from this index (default 1)
|
||||||
-i, --input string Input path. Otherwise uses stdin
|
-i, --input string Input path. Otherwise uses stdin
|
||||||
-l, --linkEmitFrequency int Emit gathered links through the document after this number of paragraphs (default 2)
|
-l, --linkEmitFrequency int Emit gathered links through the document after this number of paragraphs (default 2)
|
||||||
|
-m --citationMarkers Output citation style markers
|
||||||
-o, --output string Output path. Otherwise uses stdout
|
-o, --output string Output path. Otherwise uses stdout
|
||||||
-v, --version Find out what version of html2gmi you're running
|
-v, --version Find out what version of html2gmi you're running
|
||||||
|
|
||||||
|
17
html2gmi.go
17
html2gmi.go
@ -11,12 +11,13 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
var version = "0.2.1"
|
var version = "0.2.2"
|
||||||
|
|
||||||
var (
|
var (
|
||||||
output = flag.StringP("output", "o", "", "Output path. Otherwise uses stdout")
|
output = flag.StringP("output", "o", "", "Output path. Otherwise uses stdout")
|
||||||
input = flag.StringP("input", "i", "", "Input path. Otherwise uses stdin")
|
input = flag.StringP("input", "i", "", "Input path. Otherwise uses stdin")
|
||||||
citationStart = flag.IntP("citationStart", "c", 1, "Start citations from this index")
|
citationStart = flag.IntP("citationStart", "c", 1, "Start citations from this index")
|
||||||
|
citationMarkers = flag.BoolP("citationMarkers", "m", false, "Use footnote style citation markers")
|
||||||
linkEmitFrequency = flag.IntP("linkEmitFrequency", "l", 2, "Emit gathered links through the document after this number of paragraphs")
|
linkEmitFrequency = flag.IntP("linkEmitFrequency", "l", 2, "Emit gathered links through the document after this number of paragraphs")
|
||||||
verFlag = flag.BoolP("version", "v", false, "Find out what version of html2gmi you're running")
|
verFlag = flag.BoolP("version", "v", false, "Find out what version of html2gmi you're running")
|
||||||
)
|
)
|
||||||
@ -92,13 +93,25 @@ func main() {
|
|||||||
options.PrettyTables = true
|
options.PrettyTables = true
|
||||||
options.CitationStart = *citationStart
|
options.CitationStart = *citationStart
|
||||||
options.LinkEmitFrequency = *linkEmitFrequency
|
options.LinkEmitFrequency = *linkEmitFrequency
|
||||||
|
options.CitationMarkers = *citationMarkers
|
||||||
|
|
||||||
|
//use slightly nicer Unicode borders, otherwise can use +,|,-
|
||||||
|
options.PrettyTablesOptions.CenterSeparator = "┼"
|
||||||
|
options.PrettyTablesOptions.ColumnSeparator = "│"
|
||||||
|
options.PrettyTablesOptions.RowSeparator = "─"
|
||||||
|
|
||||||
|
//dont use an extra line to separate header from body, but
|
||||||
|
//do separate each row visually
|
||||||
|
options.PrettyTablesOptions.HeaderLine = false
|
||||||
|
options.PrettyTablesOptions.RowLine = true
|
||||||
|
|
||||||
text, err := html2gemini.FromString(inputHtml, *options)
|
text, err := html2gemini.FromString(inputHtml, *options)
|
||||||
|
|
||||||
check(err)
|
check(err)
|
||||||
|
|
||||||
//process the output
|
//process the output
|
||||||
if *output == "" {
|
if *output == "" {
|
||||||
fmt.Print(text)
|
fmt.Print(text + "\n") //terminate with a new line
|
||||||
} else {
|
} else {
|
||||||
//save to the specified output
|
//save to the specified output
|
||||||
gmiBytes := []byte(text)
|
gmiBytes := []byte(text)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user