all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* EWW/SHR Feature Request
@ 2014-03-21 15:44 T. V. Raman
  2014-03-21 16:48 ` Nicolas Richard
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: T. V. Raman @ 2014-03-21 15:44 UTC (permalink / raw)
  To: emacs-devel

Now that we have shr and eww, it would be nice to have a function
that takes an html string  and returns a formatted representation
(replete with properties etc.)  something like 
(shr-format-html-string html-string) -> Return: Formatted string
suitable for insertion into a buffer. 
-- 

-- 



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: EWW/SHR Feature Request
  2014-03-21 15:44 EWW/SHR Feature Request T. V. Raman
@ 2014-03-21 16:48 ` Nicolas Richard
  2014-03-21 18:04 ` Vibhav Pant
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Nicolas Richard @ 2014-03-21 16:48 UTC (permalink / raw)
  To: emacs-devel

"T. V. Raman" <raman@google.com> writes:

> Now that we have shr and eww, it would be nice to have a function
> that takes an html string  and returns a formatted representation
> (replete with properties etc.)  something like 
> (shr-format-html-string html-string) -> Return: Formatted string
> suitable for insertion into a buffer. 

Is it something like this ?

(let ((html-string  "<a href=\"http://www.gnu.org\">GNU website</a>"))
  (with-temp-buffer
    (insert html-string)
    (shr-render-region (point-min) (point-max))
    (buffer-string)))

(the html-string should in fact be a complete html doc, but libxml does
its best to turn bad html like the above into *something*.)

-- 
Nico.




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: EWW/SHR Feature Request
  2014-03-21 15:44 EWW/SHR Feature Request T. V. Raman
  2014-03-21 16:48 ` Nicolas Richard
@ 2014-03-21 18:04 ` Vibhav Pant
  2014-03-21 18:36   ` T.V Raman
  2014-03-22 10:22 ` Willem Rein Oudshoorn
  2016-07-14  2:44 ` raman
  3 siblings, 1 reply; 7+ messages in thread
From: Vibhav Pant @ 2014-03-21 18:04 UTC (permalink / raw)
  To: raman; +Cc: emacs-devel@gnu.org

On Fri, Mar 21, 2014 at 9:14 PM, T. V. Raman <raman@google.com> wrote:
> Now that we have shr and eww, it would be nice to have a function
> that takes an html string  and returns a formatted representation
> (replete with properties etc.)  something like
> (shr-format-html-string html-string) -> Return: Formatted string
> suitable for insertion into a buffer.

By formatted string, do you mean the entire content of the page to
which the address redirects too, or the webpage title?

-- 
Vibhav Pant
vibhavp@gmail.com



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: EWW/SHR Feature Request
  2014-03-21 18:04 ` Vibhav Pant
@ 2014-03-21 18:36   ` T.V Raman
  2014-03-21 21:03     ` Lars Magne Ingebrigtsen
  0 siblings, 1 reply; 7+ messages in thread
From: T.V Raman @ 2014-03-21 18:36 UTC (permalink / raw)
  To: vibhavp; +Cc: emacs-devel, raman

I mean the following:

(shr-format-html-string "<bo>Strong</b>")

Returns a string with the font face set to 'bold or whatever else
shr chooses to use.

Here is the code I have in emacspeak:
(defun emacspeak-webutils-html-string (html-string)
  "Return formatted string."
  (or (require 'shr) (error "Need  emacs 24.4"))
  (with-temp-buffer "*html-format*"
                    (setq buffer-undo-list t)
                    (insert html-string)
                    (shr-render-region  (point-min) (point-max))
                    (buffer-string)))


Vibhav Pant writes:
 > On Fri, Mar 21, 2014 at 9:14 PM, T. V. Raman <raman@google.com> wrote:
 > > Now that we have shr and eww, it would be nice to have a function
 > > that takes an html string  and returns a formatted representation
 > > (replete with properties etc.)  something like
 > > (shr-format-html-string html-string) -> Return: Formatted string
 > > suitable for insertion into a buffer.
 > 
 > By formatted string, do you mean the entire content of the page to
 > which the address redirects too, or the webpage title?
 > 
 > -- 
 > Vibhav Pant
 > vibhavp@gmail.com



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: EWW/SHR Feature Request
  2014-03-21 18:36   ` T.V Raman
@ 2014-03-21 21:03     ` Lars Magne Ingebrigtsen
  0 siblings, 0 replies; 7+ messages in thread
From: Lars Magne Ingebrigtsen @ 2014-03-21 21:03 UTC (permalink / raw)
  To: T.V Raman; +Cc: vibhavp, emacs-devel

raman@google.com (T.V Raman) writes:

>   (with-temp-buffer "*html-format*"
>                     (setq buffer-undo-list t)
>                     (insert html-string)
>                     (shr-render-region  (point-min) (point-max))
>                     (buffer-string)))

Note that `with-temp-buffer' doesn't take a buffer name as a parameter,
so the "*html-format*" string isn't used.  And there is no undo in the
temporary buffers,  so the whole thing just devolves to

(with-temp-buffer
  (insert html-string)
  (shr-render-region (point-min) (point-max))
  (buffer-string))

and I'm not sure that's enough to warrant a function...

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: EWW/SHR Feature Request
  2014-03-21 15:44 EWW/SHR Feature Request T. V. Raman
  2014-03-21 16:48 ` Nicolas Richard
  2014-03-21 18:04 ` Vibhav Pant
@ 2014-03-22 10:22 ` Willem Rein Oudshoorn
  2016-07-14  2:44 ` raman
  3 siblings, 0 replies; 7+ messages in thread
From: Willem Rein Oudshoorn @ 2014-03-22 10:22 UTC (permalink / raw)
  To: emacs-devel

"T. V. Raman" <raman@google.com> writes:

> Now that we have shr and eww, it would be nice to have a function
> that takes an html string  and returns a formatted representation
> (replete with properties etc.)  something like 
> (shr-format-html-string html-string) -> Return: Formatted string
> suitable for insertion into a buffer. 

I have been using this function for a while


(defun salesforce-insert-html (html)
  "Insert at current point, the 'rendered' HTML."
  (when html
    (shr-insert-document
     (with-temp-buffer
       (insert html)
       (libxml-parse-html-region (point-min) (point-max))))))


Wim Oudshoorn




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: EWW/SHR Feature Request
  2014-03-21 15:44 EWW/SHR Feature Request T. V. Raman
                   ` (2 preceding siblings ...)
  2014-03-22 10:22 ` Willem Rein Oudshoorn
@ 2016-07-14  2:44 ` raman
  3 siblings, 0 replies; 7+ messages in thread
From: raman @ 2016-07-14  2:44 UTC (permalink / raw)
  To: emacs-devel

Following up to myself:

For now I solved my use-case by advising 
eww-browse-with-external-browser -- that function is presently called by
EWW for content-types matching  
eww-use-external-browser-for-content-type 
the default value of that var is 
"\\`\\(video/\\|audio/\\|application/ogg\\)"
i.e. video/audio types, and those were the types  I wanted to handle
 within Emacs.

Longer term, there are two ways we could go:

1. EWW already has functions for handling PDF, img types etc. -- we
could set EWW up to handle  audio/video via a user configurable
function, with the default handing off  to  a full-blown browser as now.

2. The other alternative would be to process the user's mailcap file,
but that might not be ideal because in general  most users will want the
.mailcap file to govern their primary browser's behavior.
-- 



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2016-07-14  2:44 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-21 15:44 EWW/SHR Feature Request T. V. Raman
2014-03-21 16:48 ` Nicolas Richard
2014-03-21 18:04 ` Vibhav Pant
2014-03-21 18:36   ` T.V Raman
2014-03-21 21:03     ` Lars Magne Ingebrigtsen
2014-03-22 10:22 ` Willem Rein Oudshoorn
2016-07-14  2:44 ` raman

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.