skeeto / impatient-mode

Impatient html mode. See your changes in the browser as you type
215 stars 19 forks source link

HTML-Rendering not working with certain HTML-modes (html-ts-mode) #39

Open m4xxed opened 11 months ago

m4xxed commented 11 months ago

Description

When opening the html-buffer in the browser, it is not rendered as expected from a correct html-buffer. Instead, it "rendered", e.g. showed the html-buffer as visible within Emacs (even the theming was duplicated).

To Reproduce

Emacs version: GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.38, cairo version 1.17.8) of 2023-09-21

html-code:

<!DOCTYPE html5>
<html>
  <title>Minimal Reproducible Example.</title>
  <body>
    <p>First paragraph</p>
    <p>Second paragraph</p>
  </body>
</html>

Configuration

(use-package impatient-mode)

I execute the following steps:

  1. open html-file in buffer
  2. M-x httpd-start
  3. M-x impatient-mode
  4. M-x imp-visit-buffer

Screenshots

Here it is, with html-ts-mode supplied by html-ts-mode.el:

image

And this is what I get when I switch to html-mode supplied by sgml-mode.el (and reenable impatient-mode again, because it drops when I switch major modes):

image

Additionals

I have also tested this with other modes derived from sgml-mode.el's html-mode, like mhtml-mode, where the buffer is rendered correctly in the browser.

Edit (possible solution)

It does work after I have changed imp-default-user-filters to the following:

(defcustom imp-default-user-filters '((mhtml-mode . nil)
                                      (html-mode . nil)
                                      (html-ts-mode . nil)
                                      (web-mode  . nil))
  "Alist indicating which filter should be used for which modes."
  :group 'impatient
  :type 'sexp)

I always thought that html-mode remaps to html-ts-mode, like most other modes do (I think), but it seems like this isn't the case here.

I have added this to my config, which solves it. Maybe this could become a default at some point?

(use-package impatient-mode
:config
(add-to-list 'imp-default-user-filters '(html-ts-mode . nil)))