help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

eww: Proper comment indentation in forum websites


From: James Thomas
Subject: eww: Proper comment indentation in forum websites
Date: Sat, 18 Feb 2023 15:29:34 +0530
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.1 (gnu/linux)

Someone was asking for this a while ago (can't find the post now - may
have been on reddit).

I whipped up the following for use with the reddit proxy teddit.net;
sharing in case anyone finds it useful:

(defun my/eww-tag-div (dom)
  (let ((display (cdr (assq 'display shr-stylesheet))))
    (if (or (equal display "inline")
            (equal display "inline-block"))
        (shr-generic dom)
      (shr-ensure-newline)
      ;; Modifications of the default function
      (let ((shr-indentation
             (if (string-prefix-p "comment " (dom-attr dom 'class))
                 (+ shr-indentation
                    (* 4 shr-table-separator-pixel-width))
               shr-indentation)))
        (shr-generic dom))
      (shr-ensure-newline))))

(setq shr-external-rendering-functions '((div . my/eww-tag-div)))

--



reply via email to

[Prev in Thread] Current Thread [Next in Thread]