CMB / edbrowse

A command-line editor and web browser.
Other
340 stars 31 forks source link

Is it possible to let edbrowse load web pages with an external program? #86

Open mglh opened 1 year ago

mglh commented 1 year ago

I would like to use edbrowse in conjunction with rdrview.

Setting edbrowse as browser for rdrview with rdrview -B edbrowse works for the first page loaded, where the page is loaded by rdrview, but not for pages opened from that one in edbrowse, since they are loaded by edbrowse itself, bypassing rdrview.

David-Apps commented 1 year ago

I have not used rdrview. If I have understood things correctly,

rdrview -H

reads HTML code from standard input and writes transformed HTML code to standard output. If this is correct, something like this should work in edbrowse:

b https://www.example.com/ ub W !rdrview -H b

If this works, you could create an edbrowse function in your configuration file to use rdrview on demand. For example:

function+rv { ub W !rdrview -H b }

The W !filter-command feature is quite new.

CMB commented 1 year ago

I made some slight modifications to the rv function proposed by David:

function+rv {
db0
ub
W !rdrview -H -T 'title,body' -u "$EB_BASE"
b
!echo rdrview render done
db1
}

My command will include the title in the output, and I often want that, especially when I save versions of pages after running them through readability converters. I also pass along the base URL to rdrview, because if you don't, relative links are going to be messed up. Finally I temporarily set debug level to 0 so that you don't see a bunch of number spam as the buffer is unbrowsed, filtered, and rebrowsed. I don't know what the old debug level was, so it gets set back to the default of 1.

Do either of these functions solve your need satisfactorily?

eklhad commented 1 year ago

I don't know what the old debug level was, so it gets set back to the default of 1.

Just to be technical ... settings are changed locally, to the function, and resurrect when the function is done. So you don't need to set db1 and probably shouldn't.

Karl Dahlke

CMB commented 1 year ago

That's nice to know about debug levels and functions.

Another problem with rv is that filtering the buffer will flag the buffer as changed. So in my latest version, I've used bw to remove that flag.

function+rv {
db0
ub
    W !rdrview -H -T 'title,body' -u "$EB_BASE"
b
!echo rdrview render done
bw
}
WeNeedNothingMediaCorp commented 4 months ago

To anyone else finding W returns ?, it should actually be lowercase w.

edit: I was incorrectly running this in browse mode. Disregard.

eklhad commented 4 months ago

I did a quick scan for W through the usersguide, didn't see anything I thought was wrong. Perhaps you have some examples. w !command and W !command are both correct and do different things. w and W in the email client are both correct and do different things. !command and ! command (with a space) are both correct in ed and in edbrowse and do the same thing so I have no preference.

Karl Dahlke

WeNeedNothingMediaCorp commented 4 months ago

Hi Karl. Mentioned in the other issue, (this issue we are talking on now was just an example of where I noted your examples in the wild that seem to be wrong casing). This thread seems to be about using a shell command filter in browse mode which upper case W didn't seem to work for me, but lowercase did.

In the user guide line 660 and 661 has W uppercase, which I believe is incorrect in that context:

'a,'bW !command : run a range of lines through a shell command and replace them W !sort : sort the lines in the buffer

Great work btw. Excited about some potential contributions I have in mind.

WeNeedNothingMediaCorp commented 4 months ago

@eklhad apologies. I was wrong on this issue. I see where my mistake was now.