News for hackers. Stuff that matters.
Re:Vim.wasm by tomjakubowski on Wednesday April 24, 2019 @10:57PM (#19744626)
Does anyone know if lynx plans on supporting wasm? I'd like to try this editor in a terminal.
Re:Vim.wasm by bla3 on Thursday April 25, 2019 @07:31AM (#19746963)
You might be on to something here. I could see this editor working really well in a terminal environment.
Re:Vim.wasm by sagartewari01 on Thursday April 25, 2019 @10:17AM (#19748359)
You could try running it in neovim terminals.
Re:Vim.wasm by halter73 on Thursday April 25, 2019 @01:25AM (#19745275)
At this point, the easier route to getting a text-based browser to support something like this would be creating a new one based on WebKit/Blink.

It would probably need to get the engine to draw to a fake screen buffer and run an OCR algorithm over that. And even if the OCR and layout worked well, there would be a lot other work necessary to get reasonable text based interactivity, though that's probably partially solved by projects like Vimium. Some interactions like dragging would likely never be supported.

Not easy at all, but somehow more reasonable than updating lynx to support all of today's new technologies. I wonder if anyone's already tried something like it.

Re:Vim.wasm by tombh on Thursday April 25, 2019 @01:44AM (#19745367)
I did! See brow.sh

It uses Firefox as a backend so can in fact run Wasm. However it doesn't use OCR, it uses the DOM to get precise coordinates for text nodes, this recreating a pure text representation of the page, using nothing but spaces and carriage returns for "formatting".

Re:Vim.wasm by colordrops on Thursday April 25, 2019 @12:13PM (#19749605)
The vim browser demo uses pixels drawn to canvas though.
Re:Vim.wasm by halter73 on Thursday April 25, 2019 @01:40AM (#19745356)
I just found Browsh[1] which seems to be basically this but with Gecko. It seems they don't need to do OCR which makes sense thinking about it more. Cool stuff. Haven't gotten to try it yet.

[1] https://www.brow.sh/

Re:Vim.wasm by aasasd on Thursday April 25, 2019 @05:54AM (#19746501)
> OCR

Hey, dial back the blasphemy there. HTML is not PDF, it's usually made from text in the first place.

I'd guess you could force all text to use a monospace font, with fixed measures and line-height, and limit the width of the page. Then mostly dump the resulting text arrangement into the terminal.

Now, layouts from the various elements and CSS are probably a lot trickier, but snapping all margins and padding to multiples of a symbol's size should go a long way.

It seems that this could even be embedded at different levels in the browser: the layout engine or just the user's JS. (If JS can obtain the exact layout of text lines and elements―likely not, though, especially in forms. Maybe via devtools.)

Re:Vim.wasm by _pmf_ on Thursday April 25, 2019 @05:55AM (#19746511)
> HTML is not PDF, it's usually made from text in the first place.

I don't know, man. Most websites would be smaller if they were replaced by a HD video of someone reading the contents.

Re:Vim.wasm by jsjohnst on Thursday April 25, 2019 @08:31AM (#19747335)
> Hey, dial back the blasphemy there. HTML is not PDF, it's usually made from text in the first place.

Hey, dial back the blasphemy there. PDF is not an image, it’s usually[0] made from text in the first place.

As someone who has a bunch of experience both creating and parsing PDFs, it’s definitely very doable to extract the text content and render it in a similar way on a terminal. Yes, parsing the PDF format is much more painful than average HTML, but these days there’s libraries commonly available to assist.

[0] unless the PDF is a famous redacted DOJ document, then it’s a poorly scanned collection of image crammed into a PDF container.

Re:Vim.wasm by 42yeah on Wednesday April 24, 2019 @11:20PM (#19744694)
How about this in emacs www mode?
Re:Vim.wasm by TazeTSchnitzel on Thursday April 25, 2019 @06:03AM (#19746542)
It would need to have its HTTP code gutted and replaced with something that uses JS's XMLHttpRequest or the request API, but I think that's all you'd need to change.
Re:Vim.wasm by MuffinFlavored on Thursday April 25, 2019 @10:45AM (#19748675)
Or write a C function called http_request, refactor all of Lynx to use just this one function, and then do something like

    #if PLATFORM === 'WASM'
    then
      fetch()
    else
      the actual sockets and stuff
    end
Re:Vim.wasm by TazeTSchnitzel on Thursday April 25, 2019 @04:43PM (#19752338)
It would not be that simple, but yes.
Re:Vim.wasm by tempodox on Thursday April 25, 2019 @07:49AM (#19747055)
What's a terminal? Every kid knows that anything that doesn't run in a browser can't be software.
Re:Vim.wasm by ianai on Thursday April 25, 2019 @08:15AM (#19747227)
Definitely doesn’t scale.
Re:Vim.wasm by tempodox on Thursday April 25, 2019 @09:42AM (#19747948)
Oops, I forgot the /s at the end of my comment.
Re:Vim.wasm by ianai on Thursday April 25, 2019 @07:25PM (#19753467)
So did I.
Re:Vim.wasm by tomaskafka on Friday April 26, 2019 @01:17AM (#19755021)
You mean lynx.wasm?