"Manually" format text


I’d like to view man pages in Atom. So I have something that inserts the output of “man ls” into a buffer, and it uses some simple visual formatting: x followed by backspace followed by another x means a bold x, and underline followed by backspace followed by x means an underlined x.

(If two characters xy are bold, then that’s done by having x^Hxy^Hy where ^H is my representation of backspace.)

I have no idea how to go about formatting this. I think I can write a grammar that matches this kind of stuff, then assigns a scope, then I can define the right font properties. That’s okay, but I will have to hide every other character (and the backspace, too). And then I don’t think that searching for “ls” will find a bold “ls”…

So I will have to munge the text before inserting into the editor. But after munging, how do I tell Atom to make it bold? (Or underlined, or whatever.)


Could you convert the man page into Markdown? Then you could use the Markdown Preview to make it look pretty :sparkles:


I apologize – man ls was just an example. The real intent is to allow reading any man page. My system has 25,000 of them.

Or were you suggesting to automatically convert it into Markdown? Whee! That looks rather difficult.


Well, you could either convert the Groff source into Markdown … or you could use the groff utility to convert the man page into HTML and figure out how to display it in a preview window like the Markdown Preview package.


Yes – this is also a possible alternative. The Markdown Preview package has a view to display its preview, so now I’m trying to figure out how to make a view to display that HTML.

Are there other packages that display “random” HTML? It might be nice to study them.

Thanks a lot for the suggestion!


Well, there is the Mobile Preview package.


Well, it’s been a long while. Now there is https://github.com/kgrossjo/atom-man and it does display some HTML. But it’s not scrollable! I derived from ScrollView!

I think I should first make it scrollable, then I should allow the user to enter which manual page should be shown, then I should figure out how to make the HTML prettier.

But neither MobilePreview nor MarkdownPreview tell me how to make the content scrollable. Well. MobilePreview uses an iframe. But I think I don’t want to use an iframe. (But I’m not clear why not.)


Okay, thanks to ScrollView subclass does not scroll I know why it’s not scrollable. I needed to apply the style overflow: auto to my top-level div. My top-level div has a specific class, so I can just add a rule for that class in my stylesheet in the stylesheets directory.