* feature request: save LaTeX as title for ltxpng html images
@ 2010-03-26 15:01 Eric Schulte
2010-03-26 20:42 ` Carsten Dominik
0 siblings, 1 reply; 5+ messages in thread
From: Eric Schulte @ 2010-03-26 15:01 UTC (permalink / raw)
To: Org Mode
Hi,
HTML <img> tags allow both alternate text (rendered when the image can't
be rendered), as well as titles which show as tooltips on hover. I
wonder if it would be difficult to place the text latex used in
generating an image into these two fields. If not then I at least would
find it useful.
Thanks -- Eric
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: feature request: save LaTeX as title for ltxpng html images
2010-03-26 15:01 feature request: save LaTeX as title for ltxpng html images Eric Schulte
@ 2010-03-26 20:42 ` Carsten Dominik
2010-03-30 6:26 ` Eric Schulte
0 siblings, 1 reply; 5+ messages in thread
From: Carsten Dominik @ 2010-03-26 20:42 UTC (permalink / raw)
To: Eric Schulte; +Cc: Org Mode
On Mar 26, 2010, at 4:01 PM, Eric Schulte wrote:
> Hi,
>
> HTML <img> tags allow both alternate text (rendered when the image
> can't
> be rendered), as well as titles which show as tooltips on hover. I
> wonder if it would be difficult to place the text latex used in
> generating an image into these two fields. If not then I at least
> would
> find it useful.
It is not trivial, but not too hard either.
It is not trivial because Org first produces the images and inserts
org-style links. Later, in a second step, these links are replaced
(formatted for HTML).
One way to solve this is that `org-format-latex' will add this
information
as text properties to the link. Then later, when the HTML formatting
is done,
the text property could be retrieved and converted into the attributes
you are mentioning.
You have worked on org-format-latex before, I think this should be
relatively easy for you.
- Carsten
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: feature request: save LaTeX as title for ltxpng html images
2010-03-26 20:42 ` Carsten Dominik
@ 2010-03-30 6:26 ` Eric Schulte
2010-03-30 7:37 ` Carsten Dominik
0 siblings, 1 reply; 5+ messages in thread
From: Eric Schulte @ 2010-03-30 6:26 UTC (permalink / raw)
To: Carsten Dominik; +Cc: Org Mode
[-- Attachment #1: Type: text/plain, Size: 223 bytes --]
Hi,
The attached patch places the latex source into alt html image tags as
described below. I think it should be safe, in that I remove all "s
from inside of the alt string.
Thanks for the implementation advice -- Eric
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: ltx-src-alt.patch --]
[-- Type: text/x-diff, Size: 1401 bytes --]
diff --git a/lisp/org-html.el b/lisp/org-html.el
index b8925e7..2246daf 100644
--- a/lisp/org-html.el
+++ b/lisp/org-html.el
@@ -1529,7 +1529,8 @@ lang=\"%s\" xml:lang=\"%s\">
"Create image tag with source and attributes."
(save-match-data
(if (string-match "^ltxpng/" src)
- (format "<img src=\"%s\"/>" src)
+ (format "<img src=\"%s\" alt=\"%s\"/>"
+ src (org-find-text-property-in-string 'org-latex-src src))
(let* ((caption (org-find-text-property-in-string 'org-caption src))
(attr (org-find-text-property-in-string 'org-attributes src))
(label (org-find-text-property-in-string 'org-label src)))
Modified lisp/org.el
diff --git a/lisp/org.el b/lisp/org.el
index e30c49a..480e9f1 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -15183,7 +15183,12 @@ Some of the options can be changed using the variable
(push ov org-latex-fragment-image-overlays)
(goto-char end))
(delete-region beg end)
- (insert link))))))))
+ (let ((link-beg (point))
+ (link-end (progn (insert link) (point))))
+ (add-text-properties
+ link-beg link-end
+ (list 'org-latex-src
+ (replace-regexp-in-string "\"" "" txt)))))))))))
;; This function borrows from Ganesh Swami's latex2png.el
(defun org-create-formula-image (string tofile options buffer)
[-- Attachment #3: Type: text/plain, Size: 1014 bytes --]
Carsten Dominik <carsten.dominik@gmail.com> writes:
> On Mar 26, 2010, at 4:01 PM, Eric Schulte wrote:
>
>> Hi,
>>
>> HTML <img> tags allow both alternate text (rendered when the image
>> can't
>> be rendered), as well as titles which show as tooltips on hover. I
>> wonder if it would be difficult to place the text latex used in
>> generating an image into these two fields. If not then I at least
>> would
>> find it useful.
>
> It is not trivial, but not too hard either.
>
> It is not trivial because Org first produces the images and inserts
> org-style links. Later, in a second step, these links are replaced
> (formatted for HTML).
> One way to solve this is that `org-format-latex' will add this
> information
> as text properties to the link. Then later, when the HTML formatting
> is done,
> the text property could be retrieved and converted into the attributes
> you are mentioning.
>
> You have worked on org-format-latex before, I think this should be
> relatively easy for you.
>
> - Carsten
[-- Attachment #4: Type: text/plain, Size: 201 bytes --]
_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: feature request: save LaTeX as title for ltxpng html images
2010-03-30 6:26 ` Eric Schulte
@ 2010-03-30 7:37 ` Carsten Dominik
2010-03-31 16:24 ` Eric Schulte
0 siblings, 1 reply; 5+ messages in thread
From: Carsten Dominik @ 2010-03-30 7:37 UTC (permalink / raw)
To: Eric Schulte; +Cc: Org Mode
Hi Eric, looks good to me, please go ahead and apply this patch.
I would not have expected that this is such a compact change.
The only improvement I can see would be to use org-add-props to
put the properties on the link before inserting it and in this
way shave off a let form.
Thanks!
- Carsten
On Mar 30, 2010, at 8:26 AM, Eric Schulte wrote:
> Hi,
>
> The attached patch places the latex source into alt html image tags as
> described below. I think it should be safe, in that I remove all "s
> from inside of the alt string.
>
> Thanks for the implementation advice -- Eric
>
> diff --git a/lisp/org-html.el b/lisp/org-html.el
> index b8925e7..2246daf 100644
> --- a/lisp/org-html.el
> +++ b/lisp/org-html.el
> @@ -1529,7 +1529,8 @@ lang=\"%s\" xml:lang=\"%s\">
> "Create image tag with source and attributes."
> (save-match-data
> (if (string-match "^ltxpng/" src)
> - (format "<img src=\"%s\"/>" src)
> + (format "<img src=\"%s\" alt=\"%s\"/>"
> + src (org-find-text-property-in-string 'org-latex-
> src src))
> (let* ((caption (org-find-text-property-in-string 'org-caption
> src))
> (attr (org-find-text-property-in-string 'org-attributes src))
> (label (org-find-text-property-in-string 'org-label src)))
> Modified lisp/org.el
> diff --git a/lisp/org.el b/lisp/org.el
> index e30c49a..480e9f1 100644
> --- a/lisp/org.el
> +++ b/lisp/org.el
> @@ -15183,7 +15183,12 @@ Some of the options can be changed using
> the variable
> (push ov org-latex-fragment-image-overlays)
> (goto-char end))
> (delete-region beg end)
> - (insert link))))))))
> + (let ((link-beg (point))
> + (link-end (progn (insert link) (point))))
> + (add-text-properties
> + link-beg link-end
> + (list 'org-latex-src
> + (replace-regexp-in-string "\"" ""
> txt)))))))))))
>
> ;; This function borrows from Ganesh Swami's latex2png.el
> (defun org-create-formula-image (string tofile options buffer)
>
>
> Carsten Dominik <carsten.dominik@gmail.com> writes:
>
>> On Mar 26, 2010, at 4:01 PM, Eric Schulte wrote:
>>
>>> Hi,
>>>
>>> HTML <img> tags allow both alternate text (rendered when the image
>>> can't
>>> be rendered), as well as titles which show as tooltips on hover. I
>>> wonder if it would be difficult to place the text latex used in
>>> generating an image into these two fields. If not then I at least
>>> would
>>> find it useful.
>>
>> It is not trivial, but not too hard either.
>>
>> It is not trivial because Org first produces the images and inserts
>> org-style links. Later, in a second step, these links are replaced
>> (formatted for HTML).
>> One way to solve this is that `org-format-latex' will add this
>> information
>> as text properties to the link. Then later, when the HTML formatting
>> is done,
>> the text property could be retrieved and converted into the
>> attributes
>> you are mentioning.
>>
>> You have worked on org-format-latex before, I think this should be
>> relatively easy for you.
>>
>> - Carsten
- Carsten
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: feature request: save LaTeX as title for ltxpng html images
2010-03-30 7:37 ` Carsten Dominik
@ 2010-03-31 16:24 ` Eric Schulte
0 siblings, 0 replies; 5+ messages in thread
From: Eric Schulte @ 2010-03-31 16:24 UTC (permalink / raw)
To: Carsten Dominik; +Cc: Org Mode
Thanks, I've made your suggested change and applied the patch. -- Eric
Carsten Dominik <carsten.dominik@gmail.com> writes:
> Hi Eric, looks good to me, please go ahead and apply this patch.
>
> I would not have expected that this is such a compact change.
> The only improvement I can see would be to use org-add-props to
> put the properties on the link before inserting it and in this
> way shave off a let form.
>
> Thanks!
>
> - Carsten
> On Mar 30, 2010, at 8:26 AM, Eric Schulte wrote:
>
>> Hi,
>>
>> The attached patch places the latex source into alt html image tags as
>> described below. I think it should be safe, in that I remove all "s
>> from inside of the alt string.
>>
>> Thanks for the implementation advice -- Eric
>>
>> diff --git a/lisp/org-html.el b/lisp/org-html.el
>> index b8925e7..2246daf 100644
>> --- a/lisp/org-html.el
>> +++ b/lisp/org-html.el
>> @@ -1529,7 +1529,8 @@ lang=\"%s\" xml:lang=\"%s\">
>> "Create image tag with source and attributes."
>> (save-match-data
>> (if (string-match "^ltxpng/" src)
>> - (format "<img src=\"%s\"/>" src)
>> + (format "<img src=\"%s\" alt=\"%s\"/>"
>> + src (org-find-text-property-in-string 'org-latex-
>> src src))
>> (let* ((caption (org-find-text-property-in-string 'org-caption
>> src))
>> (attr (org-find-text-property-in-string 'org-attributes src))
>> (label (org-find-text-property-in-string 'org-label src)))
>> Modified lisp/org.el
>> diff --git a/lisp/org.el b/lisp/org.el
>> index e30c49a..480e9f1 100644
>> --- a/lisp/org.el
>> +++ b/lisp/org.el
>> @@ -15183,7 +15183,12 @@ Some of the options can be changed using
>> the variable
>> (push ov org-latex-fragment-image-overlays)
>> (goto-char end))
>> (delete-region beg end)
>> - (insert link))))))))
>> + (let ((link-beg (point))
>> + (link-end (progn (insert link) (point))))
>> + (add-text-properties
>> + link-beg link-end
>> + (list 'org-latex-src
>> + (replace-regexp-in-string "\"" ""
>> txt)))))))))))
>>
>> ;; This function borrows from Ganesh Swami's latex2png.el
>> (defun org-create-formula-image (string tofile options buffer)
>>
>>
>> Carsten Dominik <carsten.dominik@gmail.com> writes:
>>
>>> On Mar 26, 2010, at 4:01 PM, Eric Schulte wrote:
>>>
>>>> Hi,
>>>>
>>>> HTML <img> tags allow both alternate text (rendered when the image
>>>> can't
>>>> be rendered), as well as titles which show as tooltips on hover. I
>>>> wonder if it would be difficult to place the text latex used in
>>>> generating an image into these two fields. If not then I at least
>>>> would
>>>> find it useful.
>>>
>>> It is not trivial, but not too hard either.
>>>
>>> It is not trivial because Org first produces the images and inserts
>>> org-style links. Later, in a second step, these links are replaced
>>> (formatted for HTML).
>>> One way to solve this is that `org-format-latex' will add this
>>> information
>>> as text properties to the link. Then later, when the HTML formatting
>>> is done,
>>> the text property could be retrieved and converted into the
>>> attributes
>>> you are mentioning.
>>>
>>> You have worked on org-format-latex before, I think this should be
>>> relatively easy for you.
>>>
>>> - Carsten
>
> - Carsten
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-03-31 16:25 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-26 15:01 feature request: save LaTeX as title for ltxpng html images Eric Schulte
2010-03-26 20:42 ` Carsten Dominik
2010-03-30 6:26 ` Eric Schulte
2010-03-30 7:37 ` Carsten Dominik
2010-03-31 16:24 ` Eric Schulte
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).