docs, quote style, and wrapped list style

* add stuff to man page
* added quote styling with green + italic
* bullet list is now wrapped

(wrapping of paragraphs still inconsistent, don't know why)
This commit is contained in:
Hedy Li 2021-06-25 16:13:58 +08:00
parent 67766704b2
commit c0cab712f1
3 changed files with 35 additions and 5 deletions

View File

@ -7,7 +7,7 @@ gelim - a friendly line-mode gemini client
# SYNOPSIS
_gelim_ [FLAGS] [URL]
_gelim_ [OPTIONS] [URL]
# OPTIONS
@ -21,6 +21,10 @@ _gelim_ [FLAGS] [URL]
\--no-interactive, -I
don't enter the line-mode interface (useful for just wanting to view _URL_ then exit)
\--search , -s _string_
search _string_ with the search engine. this takes priority over _URL_ and --input (which means _URL_ and --input will be ignored if this flag is used)
# INTERFACE
just run _gelim_ and optionally provide a url. it will start the line-mode interface.
@ -31,6 +35,9 @@ at the prompt, you can directly enter a url, link index, or otherwise a command.
\help, h, ?
get help for the interface
\quit, exit, q, x
exit the program
\back, b
go to previous url in history
@ -39,3 +46,16 @@ at the prompt, you can directly enter a url, link index, or otherwise a command.
\history
print history
\reload, r
reload current page
\links, link, peek, l _number_
get link for link-index _number_ (what the link links to).
if no _number_ specified, it prints a list of all the links in the current page
\url, current, cur, u
print current url
\search, s _query_...
search _query_ with search engine

View File

@ -81,6 +81,7 @@ func printHelp() {
fmt.Println(" r reload")
fmt.Println(" l <index> peek at what a link would link to, supply no arguments to view all links")
fmt.Println(" s <query> search engine")
fmt.Println(" u, cur print current url")
}
// Pager uses `less` to display body
@ -228,6 +229,8 @@ func main() {
fmt.Println("todo :D")
case "s", "search":
search(strings.Join(args, " "))
case "u", "url", "cur", "current":
fmt.Println(u)
default:
if strings.Contains(cmd, ".") || strings.Contains(cmd, "/") {
// look like an URL

View File

@ -33,9 +33,10 @@ type Response struct {
var inputReader = readline.NewInstance()
var (
h1Style = color.New(color.Bold).Add(color.Underline).Add(color.FgYellow).SprintFunc()
h2Style = color.New(color.Bold).SprintFunc()
linkStyle = color.New(color.Underline).Add(color.FgBlue).SprintfFunc()
h1Style = color.New(color.Bold).Add(color.Underline).Add(color.FgYellow).SprintFunc()
h2Style = color.New(color.Bold).SprintFunc()
linkStyle = color.New(color.Underline).Add(color.FgBlue).SprintfFunc()
quoteStyle = color.New(color.FgGreen).Add(color.Italic).SprintFunc()
)
// GeminiParsedURL fetches u and displays the page
@ -160,8 +161,14 @@ func GeminiPage(body string, currentURL url.URL) string {
} else if preformatted {
page += line + "\n"
} else if strings.HasPrefix(line, "> ") { // not sure if whitespace after > is mandatory for this
// appending extra \n here because we want quote blocks to stand out
// with leading and trailing new lines to distinguish from paragraphs
// as well as making it clear that it's actually a quote block.
page += "\n" + quoteStyle(ansiwrap.WrapIndent(line, width, 0, 2)) + "\n\n"
} else if strings.HasPrefix(line, "* ") { // whitespace after * is mandatory
page += strings.Replace(line, "*", "•", 1) + "\n"
page += ansiwrap.WrapIndent(strings.Replace(line, "*", "•", 1), width, 0, 2) + "\n"
} else if strings.HasPrefix(line, "#") { // whitespace after #'s are optional for headings as per spec
page += ansiwrap.Wrap(h1Style(line), width) + "\n"