new -t option to toggle prettyTables (preformatted layout)

better rendering of tables in normal mode
remove borders on prettyTables
This commit is contained in:
Luke Emmet 2020-08-28 09:40:08 +01:00
parent ecff86bd27
commit fa5f0aac1b
2 changed files with 28 additions and 9 deletions

View File

@ -16,6 +16,7 @@ html2gmi <flags>
-n, --numberedLinks Number the links -n, --numberedLinks Number the links
-o, --output string Output path. Otherwise uses stdout -o, --output string Output path. Otherwise uses stdout
-e, --emitImagesAsLinks Emit links to included images -e, --emitImagesAsLinks Emit links to included images
-t, --prettyTables Pretty tables - works with most simple tables
-v, --version Find out what version of html2gmi you're running -v, --version Find out what version of html2gmi you're running
@ -29,8 +30,7 @@ html2gmi <flags>
* citationMarkers - use a numbered marker in the text to indicate the location of the citation, [1], [2] etc. * citationMarkers - use a numbered marker in the text to indicate the location of the citation, [1], [2] etc.
* numberedLinks - number the links with a reference number [1], [2] etc. Certain command line Gemini clients may automatically add these, in which case you can omit them. * numberedLinks - number the links with a reference number [1], [2] etc. Certain command line Gemini clients may automatically add these, in which case you can omit them.
* emitImagesAsLinks - add a link for every embedded image in addition to its placemarker * emitImagesAsLinks - add a link for every embedded image in addition to its placemarker
* prettyTables - tables will be displayed as preformatted content. Complex tables may not look perfect. Otherwise each table row is a new line.
Simple tables will be displayed as preformatted content. Complex tables may not look perfect.
You can pipe content in from other applications, for example utilities that download HTML from the web. You can pipe content in from other applications, for example utilities that download HTML from the web.
@ -55,7 +55,13 @@ go build github.com/LukeEmmet/html2gmi
# History # History
## 0.2.3 ## 0.2.5
* new -t flag to emit pretty tables (as preformatted content)
* improve table rendering when prettyTables is off
* don't use a border marker for preformatted tables
## 0.2.4
* option to toggle emitting links for embedded images * option to toggle emitting links for embedded images

View File

@ -11,7 +11,7 @@ import (
"os" "os"
) )
var version = "0.2.3" var version = "0.2.5"
var ( var (
output = flag.StringP("output", "o", "", "Output path. Otherwise uses stdout") output = flag.StringP("output", "o", "", "Output path. Otherwise uses stdout")
@ -19,6 +19,8 @@ var (
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") citationMarkers = flag.BoolP("citationMarkers", "m", false, "Use footnote style citation markers")
numberedLinks = flag.BoolP("numberedLinks", "n", false, "Number the links") numberedLinks = flag.BoolP("numberedLinks", "n", false, "Number the links")
prettyTables = flag.BoolP("prettyTables", "t", false, "Pretty tables - works with most simple tables")
emitImagesAsLinks = flag.BoolP("emitImagesAsLinks", "e", false, "Emit links to included images")
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")
) )
@ -90,22 +92,33 @@ func main() {
//convert html to gmi //convert html to gmi
options := html2gemini.NewOptions() options := html2gemini.NewOptions()
options.PrettyTables = true options.PrettyTables = *prettyTables
options.CitationStart = *citationStart options.CitationStart = *citationStart
options.LinkEmitFrequency = *linkEmitFrequency options.LinkEmitFrequency = *linkEmitFrequency
options.CitationMarkers = *citationMarkers options.CitationMarkers = *citationMarkers
options.NumberedLinks = *numberedLinks options.NumberedLinks = *numberedLinks
options.EmitImagesAsLinks = *emitImagesAsLinks
//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 //dont use an extra line to separate header from body, but
//do separate each row visually //do separate each row visually
options.PrettyTablesOptions.HeaderLine = false options.PrettyTablesOptions.HeaderLine = false
options.PrettyTablesOptions.RowLine = true options.PrettyTablesOptions.RowLine = true
//use slightly nicer Unicode borders, otherwise can use +,|,-
//options.PrettyTablesOptions.CenterSeparator = "┼"
//options.PrettyTablesOptions.ColumnSeparator = "│"
//options.PrettyTablesOptions.RowSeparator = "─"
//pretty tables option is somewhat experimental
//and the column positions not always correct
//so use invisible borders of spaces for now
options.PrettyTablesOptions.CenterSeparator = " "
options.PrettyTablesOptions.ColumnSeparator = " "
options.PrettyTablesOptions.RowSeparator = " "
text, err := html2gemini.FromString(inputHtml, *options) text, err := html2gemini.FromString(inputHtml, *options)
check(err) check(err)