Search code examples
htmlemacspreview

How can I change a buffer view in emacs to hide HTML tags


Like any conscientious emacs user I edit blog posts with it all the time using "It's All Text". However I'm often inserting HTML hrefs into my text and when I come to do my final proof read they tend to get in the way. Is there a mode I can toggle into that will hide these elements?

More generally are there any pointers on how to write a mode that modifies the actual buffer view while leaving the buffer contents untouched? Or does this just involve magic hacking with font-lock?


Solution

  • In html-mode you can use M-x sgml-tags-invisible to hide/show tags.

    You can also C-c C-v to run browse-url-of-buffer, which opens the current buffer (if buffer-file-name is not nil, that is, if it's a regular file) with your default browser. This works fine enough even with partial html blocks (i.e. without <html>, <body> etc.).