emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] * org-html.el (org-html-handle-links): add an alternate for inline images
@ 2011-04-19  8:34 Manuel Giraud
  2011-04-19  8:48 ` Jambunathan K
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Manuel Giraud @ 2011-04-19  8:34 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Manuel Giraud

---
 lisp/org-html.el |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/lisp/org-html.el b/lisp/org-html.el
index 5d53478..7a4564d 100644
--- a/lisp/org-html.el
+++ b/lisp/org-html.el
@@ -888,7 +888,8 @@ OPT-PLIST is the export options list."
 	  (if (string-match "^file:" desc)
 	      (setq desc (substring desc (match-end 0)))))
 	(setq desc (org-add-props
-		       (concat "<img src=\"" desc "\"/>")
+		       (concat "<img src=\"" desc "\" alt=\"" 
+			       (file-name-nondirectory desc) "\"/>")
 		       '(org-protected t))))
       (cond
        ((equal type "internal")
-- 
1.7.3.5

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

* Re: [PATCH] * org-html.el (org-html-handle-links): add an alternate for inline images
  2011-04-19  8:34 [PATCH] * org-html.el (org-html-handle-links): add an alternate for inline images Manuel Giraud
@ 2011-04-19  8:48 ` Jambunathan K
  2011-04-19  9:12   ` Manuel Giraud
  2011-04-19  9:22 ` [Accepted] " Bastien Guerry
  2011-04-19  9:22 ` [PATCH] " Bastien
  2 siblings, 1 reply; 9+ messages in thread
From: Jambunathan K @ 2011-04-19  8:48 UTC (permalink / raw)
  To: emacs-orgmode


Without alt validation fails, right?

Jambunathan K.


Manuel Giraud <manuel.giraud@univ-nantes.fr> writes:

> ---
>  lisp/org-html.el |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/lisp/org-html.el b/lisp/org-html.el
> index 5d53478..7a4564d 100644
> --- a/lisp/org-html.el
> +++ b/lisp/org-html.el
> @@ -888,7 +888,8 @@ OPT-PLIST is the export options list."
>  	  (if (string-match "^file:" desc)
>  	      (setq desc (substring desc (match-end 0)))))
>  	(setq desc (org-add-props
> -		       (concat "<img src=\"" desc "\"/>")
> +		       (concat "<img src=\"" desc "\" alt=\"" 
> +			       (file-name-nondirectory desc) "\"/>")
>  		       '(org-protected t))))
>        (cond
>         ((equal type "internal")

-- 

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

* Re: [PATCH] * org-html.el (org-html-handle-links): add an alternate for inline images
  2011-04-19  8:48 ` Jambunathan K
@ 2011-04-19  9:12   ` Manuel Giraud
  0 siblings, 0 replies; 9+ messages in thread
From: Manuel Giraud @ 2011-04-19  9:12 UTC (permalink / raw)
  To: Jambunathan K; +Cc: emacs-orgmode

Jambunathan K <kjambunathan@gmail.com> writes:

> Without alt validation fails, right?

Yes it fails. This is the point of this patch (should have said so).

-- 
Manuel Giraud

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

* [Accepted] * org-html.el (org-html-handle-links): add an alternate for inline images
  2011-04-19  8:34 [PATCH] * org-html.el (org-html-handle-links): add an alternate for inline images Manuel Giraud
  2011-04-19  8:48 ` Jambunathan K
@ 2011-04-19  9:22 ` Bastien Guerry
  2011-04-19  9:22 ` [PATCH] " Bastien
  2 siblings, 0 replies; 9+ messages in thread
From: Bastien Guerry @ 2011-04-19  9:22 UTC (permalink / raw)
  To: emacs-orgmode

Patch 752 (http://patchwork.newartisans.com/patch/752/) is now "Accepted".

Maintainer comment: none

This relates to the following submission:

http://mid.gmane.org/%3C1303202089-27231-1-git-send-email-manuel.giraud%40univ-nantes.fr%3E

Here is the original message containing the patch:

> Content-Type: text/plain; charset="utf-8"
> MIME-Version: 1.0
> Content-Transfer-Encoding: 7bit
> Subject: [O] * org-html.el (org-html-handle-links): add an alternate for
> 	inline images
> Date: Tue, 19 Apr 2011 13:34:49 -0000
> From: Manuel Giraud <manuel.giraud@univ-nantes.fr>
> X-Patchwork-Id: 752
> Message-Id: <1303202089-27231-1-git-send-email-manuel.giraud@univ-nantes.fr>
> To: emacs-orgmode@gnu.org
> Cc: Manuel Giraud <manuel.giraud@univ-nantes.fr>
> 
> ---
>  lisp/org-html.el |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
> 
> 
> diff --git a/lisp/org-html.el b/lisp/org-html.el
> index 5d53478..7a4564d 100644
> --- a/lisp/org-html.el
> +++ b/lisp/org-html.el
> @@ -888,7 +888,8 @@ OPT-PLIST is the export options list."
>  	  (if (string-match "^file:" desc)
>  	      (setq desc (substring desc (match-end 0)))))
>  	(setq desc (org-add-props
> -		       (concat "<img src=\"" desc "\"/>")
> +		       (concat "<img src=\"" desc "\" alt=\"" 
> +			       (file-name-nondirectory desc) "\"/>")
>  		       '(org-protected t))))
>        (cond
>         ((equal type "internal")
> 

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

* Re: [PATCH] * org-html.el (org-html-handle-links): add an alternate for inline images
  2011-04-19  8:34 [PATCH] * org-html.el (org-html-handle-links): add an alternate for inline images Manuel Giraud
  2011-04-19  8:48 ` Jambunathan K
  2011-04-19  9:22 ` [Accepted] " Bastien Guerry
@ 2011-04-19  9:22 ` Bastien
  2011-04-19 21:08   ` Aankhen
  2 siblings, 1 reply; 9+ messages in thread
From: Bastien @ 2011-04-19  9:22 UTC (permalink / raw)
  To: Manuel Giraud; +Cc: emacs-orgmode

Applied, thanks.

Manuel Giraud <manuel.giraud@univ-nantes.fr> writes:

> ---
>  lisp/org-html.el |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/lisp/org-html.el b/lisp/org-html.el
> index 5d53478..7a4564d 100644
> --- a/lisp/org-html.el
> +++ b/lisp/org-html.el
> @@ -888,7 +888,8 @@ OPT-PLIST is the export options list."
>  	  (if (string-match "^file:" desc)
>  	      (setq desc (substring desc (match-end 0)))))
>  	(setq desc (org-add-props
> -		       (concat "<img src=\"" desc "\"/>")
> +		       (concat "<img src=\"" desc "\" alt=\"" 
> +			       (file-name-nondirectory desc) "\"/>")
>  		       '(org-protected t))))
>        (cond
>         ((equal type "internal")

-- 
 Bastien

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

* Re: [PATCH] * org-html.el (org-html-handle-links): add an alternate for inline images
  2011-04-19  9:22 ` [PATCH] " Bastien
@ 2011-04-19 21:08   ` Aankhen
  2011-04-20  8:09     ` Manuel Giraud
  0 siblings, 1 reply; 9+ messages in thread
From: Aankhen @ 2011-04-19 21:08 UTC (permalink / raw)
  To: Bastien, Manuel Giraud, Org-mode ml

Hi,

On Tue, Apr 19, 2011 at 14:52, Bastien <bzg@altern.org> wrote:
> Applied, thanks.
>
> Manuel Giraud <manuel.giraud@univ-nantes.fr> writes:
>
>> ---
>>  lisp/org-html.el |    3 ++-
>>  1 files changed, 2 insertions(+), 1 deletions(-)
>>
>> diff --git a/lisp/org-html.el b/lisp/org-html.el
>> index 5d53478..7a4564d 100644
>> --- a/lisp/org-html.el
>> +++ b/lisp/org-html.el
>> @@ -888,7 +888,8 @@ OPT-PLIST is the export options list."
>>         (if (string-match "^file:" desc)
>>             (setq desc (substring desc (match-end 0)))))
>>       (setq desc (org-add-props
>> -                    (concat "<img src=\"" desc "\"/>")
>> +                    (concat "<img src=\"" desc "\" alt=\""
>> +                            (file-name-nondirectory desc) "\"/>")
>>                      '(org-protected t))))
>>        (cond
>>         ((equal type "internal")

This might not be the best solution.  The purpose of the ‘alt’
attribute is to provide a textual alternative, which the file name
really isn’t.  It would be better to provide an empty value:

,----
| <img src="foo.png" alt=""/>
`----

I took a look at ‘org-html.el’ and changed the relevant line, but it
doesn’t seem to have any effect.  I think it’s being overriden by
‘org-export-html-format-image’, so I changed that as well.  Here’s the
resultant patch:

--8<---------------cut here---------------start------------->8---
diff --git a/lisp/org-html.el b/lisp/org-html.el
index 7a4564d..570d7d6 100644
--- a/lisp/org-html.el
+++ b/lisp/org-html.el
@@ -888,8 +888,7 @@ OPT-PLIST is the export options list."
          (if (string-match "^file:" desc)
              (setq desc (substring desc (match-end 0)))))
        (setq desc (org-add-props
-                      (concat "<img src=\"" desc "\" alt=\""
-                              (file-name-nondirectory desc) "\"/>")
+                      (concat "<img src=\"" desc "\" alt=\"\"/>")
                       '(org-protected t))))
       (cond
        ((equal type "internal")
@@ -1839,8 +1838,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\" alt=\"%s\"/>"
-                src (org-find-text-property-in-string 'org-latex-src src))
+       (format "<img src=\"%s\" alt=\"\"/>"
+                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)))
@@ -1855,7 +1854,7 @@ lang=\"%s\" xml:lang=\"%s\">
                src
                (if (string-match "\\<alt=" (or attr ""))
                    (concat " " attr )
-                 (concat " " attr " alt=\"" src "\"")))
+                 (concat " " attr " alt=\"\"")))
        (if caption
            (format "</p>%s
 </div>%s"
--8<---------------cut here---------------end--------------->8---

Aankhen

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

* Re: [PATCH] * org-html.el (org-html-handle-links): add an alternate for inline images
  2011-04-19 21:08   ` Aankhen
@ 2011-04-20  8:09     ` Manuel Giraud
  2011-04-20  9:10       ` Aankhen
  0 siblings, 1 reply; 9+ messages in thread
From: Manuel Giraud @ 2011-04-20  8:09 UTC (permalink / raw)
  To: Aankhen; +Cc: Bastien, Org-mode ml

Aankhen <aankhen@gmail.com> writes:

> This might not be the best solution.  The purpose of the ‘alt’
> attribute is to provide a textual alternative, which the file name
> really isn’t.  It would be better to provide an empty value:
>
> ,----
> | <img src="foo.png" alt=""/>
> `----

I knew it was not the best solution: all i wanted was to validate. But
an empty alt or maybe just "image" is fine by me too.

> I took a look at ‘org-html.el’ and changed the relevant line, but it
> doesn’t seem to have any effect.

I've tested my patch only on [[big_image.png][small_image.png]] kind of
link (maybe that's why).

> @@ -1839,8 +1838,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\" alt=\"%s\"/>"
> -                src (org-find-text-property-in-string 'org-latex-src src))
> +       (format "<img src=\"%s\" alt=\"\"/>"
> +                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)))
> @@ -1855,7 +1854,7 @@ lang=\"%s\" xml:lang=\"%s\">
>                 src
>                 (if (string-match "\\<alt=" (or attr ""))
>                     (concat " " attr )
> -                 (concat " " attr " alt=\"" src "\"")))
> +                 (concat " " attr " alt=\"\"")))
>         (if caption
>             (format "</p>%s
>  </div>%s"

Ok, those 2 last hunk should complete my patch I guess. But what I'd
really like is a way to set a alt as a user. Maybe something like this:

   [[big_image.png][small_image.png|my picture is cool]]

What you guys think? I'll look what i can do and try to make it work for
anykind of <img> tag that can be generated.

-- 
Manuel Giraud

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

* Re: [PATCH] * org-html.el (org-html-handle-links): add an alternate for inline images
  2011-04-20  8:09     ` Manuel Giraud
@ 2011-04-20  9:10       ` Aankhen
  2011-04-20  9:41         ` Manuel Giraud
  0 siblings, 1 reply; 9+ messages in thread
From: Aankhen @ 2011-04-20  9:10 UTC (permalink / raw)
  To: Manuel Giraud, Bastien, Org-mode ml

On Wed, Apr 20, 2011 at 13:39, Manuel Giraud
<manuel.giraud@univ-nantes.fr> wrote:
> Aankhen <aankhen@gmail.com> writes:
>
>> This might not be the best solution.  The purpose of the ‘alt’
>> attribute is to provide a textual alternative, which the file name
>> really isn’t.  It would be better to provide an empty value:
>>
>> [snip]
>
> I knew it was not the best solution: all i wanted was to validate. But
> an empty alt or maybe just "image" is fine by me too.

Fair enough. :-) ‘image’ would be about the same as the file name in
terms of useful alt text.

>> I took a look at ‘org-html.el’ and changed the relevant line, but it
>> doesn’t seem to have any effect.
>
> I've tested my patch only on [[big_image.png][small_image.png]] kind of
> link (maybe that's why).

Possibly—while I was hacking on it, I couldn’t quite pin down when it
had an effect and when it didn’t.

>> [snip]
>
> Ok, those 2 last hunk should complete my patch I guess. But what I'd
> really like is a way to set a alt as a user. Maybe something like this:
>
>   [[big_image.png][small_image.png|my picture is cool]]
>
> What you guys think? I'll look what i can do and try to make it work for
> anykind of <img> tag that can be generated.

Well, there /is/ a way to do that already, it’s just verbose:

,----[ Org ]
| * Foo
| #+ATTR_HTML: alt="The elusive foo in its native habitat."
| [[file:foo.png]]
`----

,----[ HTML ]
| <div id="outline-container-1" class="outline-2">
| <h2 id="sec-1"><span class="section-number-2">1</span> Foo </h2>
| <div class="outline-text-2" id="text-1">
|
| <p><img src="foo.png" alt="The elusive foo in its native habitat." />
| </p></div>
| </div>
`----

I’d suggest using the description part of the link as the alt text,
but then there’d be no way to provide the actual link text (or image,
as the case may be), so that’s a non-starter.

Aankhen

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

* Re: [PATCH] * org-html.el (org-html-handle-links): add an alternate for inline images
  2011-04-20  9:10       ` Aankhen
@ 2011-04-20  9:41         ` Manuel Giraud
  0 siblings, 0 replies; 9+ messages in thread
From: Manuel Giraud @ 2011-04-20  9:41 UTC (permalink / raw)
  To: Aankhen; +Cc: Bastien, Org-mode ml

Aankhen <aankhen@gmail.com> writes:

> On Wed, Apr 20, 2011 at 13:39, Manuel Giraud
> <manuel.giraud@univ-nantes.fr> wrote:
>
>> I knew it was not the best solution: all i wanted was to validate. But
>> an empty alt or maybe just "image" is fine by me too.
>
> Fair enough. :-) ‘image’ would be about the same as the file name in
> terms of useful alt text.

:-) and as useful as "" which is 5 bytes shorter: I think you've won
here.

> Well, there /is/ a way to do that already, it’s just verbose:
>
> ,----[ Org ]
> | * Foo
> | #+ATTR_HTML: alt="The elusive foo in its native habitat."
> | [[file:foo.png]]
> `----

Yes, discovered that in the doc just after posting my reply. But, this
doesn't work on [[big.jpg][small.jpg]] links as the alt attribute will
be placed in the anchor (which is wrong, AFAICT).

> I’d suggest using the description part of the link as the alt text,
> but then there’d be no way to provide the actual link text (or image,
> as the case may be), so that’s a non-starter.

Now, I'm looking into using the fragment part: less verbose and
hopefully it'll work for all kind of inline image.

-- 
Manuel Giraud

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

end of thread, other threads:[~2011-04-20  9:41 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-19  8:34 [PATCH] * org-html.el (org-html-handle-links): add an alternate for inline images Manuel Giraud
2011-04-19  8:48 ` Jambunathan K
2011-04-19  9:12   ` Manuel Giraud
2011-04-19  9:22 ` [Accepted] " Bastien Guerry
2011-04-19  9:22 ` [PATCH] " Bastien
2011-04-19 21:08   ` Aankhen
2011-04-20  8:09     ` Manuel Giraud
2011-04-20  9:10       ` Aankhen
2011-04-20  9:41         ` Manuel Giraud

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).