* eww: Feature request: Dont hard-wire shr-external-rendering-functions
@ 2015-05-18 15:45 raman
2015-12-24 16:35 ` Lars Ingebrigtsen
0 siblings, 1 reply; 2+ messages in thread
From: raman @ 2015-05-18 15:45 UTC (permalink / raw
To: emacs-devel
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)))))))
--
--
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: eww: Feature request: Dont hard-wire shr-external-rendering-functions
2015-05-18 15:45 eww: Feature request: Dont hard-wire shr-external-rendering-functions raman
@ 2015-12-24 16:35 ` Lars Ingebrigtsen
0 siblings, 0 replies; 2+ messages in thread
From: Lars Ingebrigtsen @ 2015-12-24 16:35 UTC (permalink / raw
To: raman; +Cc: emacs-devel
raman@google.com writes:
> 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 now changed how `shr-external-rendering-functions' is bound by eww
so that you can override any element you want.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-12-24 16:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-18 15:45 eww: Feature request: Dont hard-wire shr-external-rendering-functions raman
2015-12-24 16:35 ` Lars Ingebrigtsen
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.