Sublime Forum

Viewing web content in a Sublime Text tab

#1

I’d be very interested in having some way to view and navigate webpages in a Sublime Text tab. It would be more convenient than having to separately manage Sublime and my columns and a browser window when trying to view code and documentation side-by-side. I’d be happy with pretty much anything as long as it’s not cluttered raw HTML, and in fact it might even be nice to use Lynx to generate the content (a fully text-based browser), or something like it.

Is there a plugin for this? Would it be feasible to create such a plugin?

Thanks!

0 Likes

#2

It’s not possible as ST itself has no embedded web browser and the dev team won’t do that.

Maybe someone can play Lynx with Terminus. I don’t know.

0 Likes

#3

Well, evidently it is possible, since I took a couple of hours to make something very rough that does exactly this - loads a webpage from a URL and displays it in Sublime Text. It would be fantastic to have something better polished, though, since this is a quite quick and hackish solution to my problem.

https://pastebin.com/WhS2WE6y

0 Likes

#4

Sure, text-based is already possible. As for others, no. Some simple HTML can be rendered in ST but that’s really way to simple… and nowadays, more and more websites rely on JavaScript for rendering.

1 Like

#5

I stated my use case in the original post… I’m just trying to view documentation beside the code I’m editing without having to manage two different windows (Sublime and a separate browser), and a text-based view is completely adequate. The plugin I quickly wrote mangles tables and doesn’t know how to handle relative URLs, though, at least not at the moment. It would be great to know if there is a more polished plugin that can already handle this sort of thing.

0 Likes

#6

What documentation? Maybe someone has done that.

0 Likes

#7

Presently, I am trying to view x86-64 ISA documentation side-by-side with code that needs to generate x86-64 machine code. The plugin I wrote is proving to be a big help here. A similar plugin, but with more polish, would be an even bigger help.

0 Likes

#8

x86-64 ISA documentation

Sorry. No luck on my side. :frowning:

0 Likes

#9

Maybe the -dump switch for lynx can be useful? I failed to make it visit a HTTPS page though…


UPDATE:

All right, config lynx with FORCE_SSL_PROMPT:YES ignores SSL errors.
There are still quite lots of noises in the output but lynx accepts standard input (via -stdin) too.

[Clover@Clover-NB lynx-newssl-setup]$ echo "<tr><td>1</td><td>2</td></tr><tr><td>3</td></tr>" | ./lynx -dump --display_charset=utf-8 -stdin

   1 2
   3

So maybe

  1. Get the wanted parts of HTML source code via Python requests or something
  2. Pipe the HTML code to lynx and get the dumped text
  3. Further process the dumped text in Python if needed

I also find the following statement in a book.

image


By the way, bs4 (maybe quite helpful for handling HTML) is available for ST 3 as a dependency.

2 Likes