[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
eww: Feature request: Dont hard-wire shr-external-rendering-functions
From: |
raman |
Subject: |
eww: Feature request: Dont hard-wire shr-external-rendering-functions |
Date: |
Mon, 18 May 2015 08:45:52 -0700 |
I have a feature request motivated by the need to "tag" portions of
the EWW rendered buffer with the tag-name of the sub-tree that
produced the rendering; this helps me then implement structured
navigation of the EWW buffer for Emacspeak.
I've achieved this for header tags etc via an advice on the relevant
shr-tag-<tagname> functions.
At present the <article> element is handled by shr-generic which is a defsubst
-- so advice wont work.
I implemented byself a simple emacspeak-eww-tag-article that does:
(defun emacspeak-eww-tag-article (dom)
"Tag article, then render."
(let ((start (point)))
(shr-generic dom)
(put-text-property start (point) 'article 'eww-tag)))
But at present, I have no way of telling EWW to add this to
shr-external-rendering-functions -- since that variable is let-bound in
eww-display-html --- I could probably still get away with advicing
shr-insert-document -- but I'd prefer a simpler solution:-)
Possibilities --
1. Implement shr-tag-article as above -- essentially rename
emacspeak-eww-tag-article to shr-tag-article -- and update the other shr
functions in the recursive descent walk of the HTML tree to set property
'eww-tag --
2. If this is overkill for mainstream Emacs users -- then perhaps allow
external packages to customize what list of rendering functions eww uses?
For completeness, here is how I generate the advice on the shr-tag-<name>
functions to emit the necessary eww-tag properties in the EWW rendered buffer:
(loop
for tag in
'(h1 h2 h3 div ; sectioning
ul ol dl ; Lists
li dt dd p ; block-level: bullets, paras
form blockquote ; block-level
a b it em span ; in-line
br hr ; separators
th tr table )
do
(eval
` (defadvice ,(intern (format "shr-tag-%s" tag)) (around emacspeak pre act
comp)
(let ((start (point)))
ad-do-it
(let ((start (if (char-equal (following-char) ?\n)
(min (point-max) (1+ start) )start))
(end (if (> (point) start) (1- (point)) (point))))
(put-text-property start end
(quote ,tag) 'eww-tag)
(when (memq (quote ,tag) '(h1 h2 h3))
(put-text-property start end 'h 'eww-tag)))))))
--
--
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- eww: Feature request: Dont hard-wire shr-external-rendering-functions,
raman <=