From bafa5a0739fe936a5be79ef91b2096e655542678 Mon Sep 17 00:00:00 2001 From: sloum Date: Thu, 17 Sep 2020 21:24:16 -0700 Subject: [PATCH 1/5] Solves the lynx lack of 404 issue --- http/http_render.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/http/http_render.go b/http/http_render.go index f68ee2d..58a8813 100644 --- a/http/http_render.go +++ b/http/http_render.go @@ -33,7 +33,7 @@ func Visit(webmode, url string, width int) (Page, error) { return Page{}, fmt.Errorf("Invalid webmode setting") } c, err := exec.Command(webmode, "-dump", w, fmt.Sprintf("%d", width), url).Output() - if err != nil { + if err != nil && c == nil { return Page{}, err } return parseLinks(string(c)), nil From 89095351a856ec9b999fb054b01dd7dffda61f60 Mon Sep 17 00:00:00 2001 From: sloum Date: Sat, 31 Oct 2020 22:05:27 -0700 Subject: [PATCH 2/5] Fixes help to take an optional action as a value to get syntax for a given command --- client.go | 10 +++++++++- cmdparse/parser.go | 4 ++-- help.go | 4 ++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/client.go b/client.go index c97e4b0..4bea3c6 100644 --- a/client.go +++ b/client.go @@ -344,7 +344,7 @@ func (c *client) simpleCommand(action string) { case "SEARCH": c.search("", "", "?") case "HELP", "?": - go c.Visit(helplocation) + c.Visit(helplocation) default: c.SetMessage(syntaxErrorMessage(action), true) c.DrawMessage() @@ -356,6 +356,14 @@ func (c *client) doCommand(action string, values []string) { case "C", "CHECK": c.displayConfigValue(values[0]) c.DrawMessage() + case "HELP", "?": + if val, ok := ERRS[values[0]]; ok { + c.SetMessage(val, false) + } else { + msg := fmt.Sprintf("%q is not a valid command; help syntax: %s", values[0], ERRS[action]) + c.SetMessage(msg, false) + } + c.DrawMessage() case "PURGE", "P": err := c.Certs.Purge(values[0]) if err != nil { diff --git a/cmdparse/parser.go b/cmdparse/parser.go index dc5870a..39e08ee 100644 --- a/cmdparse/parser.go +++ b/cmdparse/parser.go @@ -94,10 +94,10 @@ func (p *Parser) parseAction() (*Command, error) { case Value: cm.Target = t.val cm.Type = DOLINK - case Word: + case Word, Action: cm.Value = append(cm.Value, t.val) cm.Type = DO - case Action, Whitespace: + case Whitespace: return nil, fmt.Errorf("Found %q (%d), expected value", t.val, t.kind) } t = p.scan() diff --git a/help.go b/help.go index a9516f3..426d15f 100644 --- a/help.go +++ b/help.go @@ -23,6 +23,6 @@ var ERRS = map[string]string{ "SET": "`set [setting] [value]`", "W": "`w [target]`", "WRITE": "`write [target]`", - "?": "`?`", - "HELP": "`help`", + "?": "`? [[command]]`", + "HELP": "`help [[command]]`", } From 53de1b5662cc10e366ef048135cfb83bc47432a7 Mon Sep 17 00:00:00 2001 From: asdf Date: Sun, 1 Nov 2020 21:09:41 +1100 Subject: [PATCH 3/5] Minor correction to help text --- help.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/help.go b/help.go index 426d15f..ece82db 100644 --- a/help.go +++ b/help.go @@ -8,7 +8,7 @@ var ERRS = map[string]string{ "DELETE": "`delete [bookmark-id]`", "B": "`b [[bookmark-id]]`", "BOOKMARKS": "`bookmarks [[bookmark-id]]`", - "C": "`c [link_id]` or `check [setting]`", + "C": "`c [link_id]` or `c [setting]`", "CHECK": "`check [link_id]` or `check [setting]`", "H": "`h`", "HOME": "`home`", From 4f166ca61a7e7fc970349346987ccfe825d70e57 Mon Sep 17 00:00:00 2001 From: sloum Date: Sun, 1 Nov 2020 06:01:17 -0800 Subject: [PATCH 4/5] Adds a prefix string to help output --- client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client.go b/client.go index 4bea3c6..d6844ff 100644 --- a/client.go +++ b/client.go @@ -358,7 +358,7 @@ func (c *client) doCommand(action string, values []string) { c.DrawMessage() case "HELP", "?": if val, ok := ERRS[values[0]]; ok { - c.SetMessage(val, false) + c.SetMessage("Usage: " + val, false) } else { msg := fmt.Sprintf("%q is not a valid command; help syntax: %s", values[0], ERRS[action]) c.SetMessage(msg, false) From 388218a5b677ee1c798e6f94c6fd1bbbe2e306e5 Mon Sep 17 00:00:00 2001 From: asdf Date: Thu, 5 Nov 2020 21:17:19 +1100 Subject: [PATCH 5/5] Initial support for some unicode line endings --- page.go | 4 ++-- page_test.go | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/page.go b/page.go index ad44ab2..890f018 100644 --- a/page.go +++ b/page.go @@ -91,8 +91,8 @@ func (p *Page) WrapContent(width int, color bool) { } continue } - if ch == '\n' { - content.WriteRune(ch) + if ch == '\n' || ch == '\u0085' || ch == '\u2028' || ch == '\u2029' { + content.WriteRune('\n') counter = 0 } else if ch == '\t' { if counter+4 < width { diff --git a/page_test.go b/page_test.go index ef41a80..b5e8f94 100644 --- a/page_test.go +++ b/page_test.go @@ -61,6 +61,26 @@ func Test_WrapContent_Wrapped_Line_Length(t *testing.T) { false, }, }, + { + "Unicode line endings that should not wrap", + "LF\u000A" + + "CR+LF\u000D\u000A" + + "NEL\u0085" + + "LS\u2028" + + "PS\u2029", + []string{ + "LF", + "CR+LF", + "NEL", + "LS", + "PS", + "", + }, + args{ + 10, + false, + }, + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) {