Re: [O] [PATCH] * org-html.el (org-html-handle-links): add an alternate for inline images

2011-04-20 Thread Manuel Giraud
Aankhen aank...@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



Re: [O] [PATCH] * org-html.el (org-html-handle-links): add an alternate for inline images

2011-04-20 Thread Aankhen
On Wed, Apr 20, 2011 at 13:39, Manuel Giraud
manuel.gir...@univ-nantes.fr wrote:
 Aankhen aank...@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-1span class=section-number-21/span Foo /h2
| div class=outline-text-2 id=text-1
|
| pimg 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



Re: [O] [PATCH] * org-html.el (org-html-handle-links): add an alternate for inline images

2011-04-20 Thread Manuel Giraud
Aankhen aank...@gmail.com writes:

 On Wed, Apr 20, 2011 at 13:39, Manuel Giraud
 manuel.gir...@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



[O] [PATCH] * org-html.el (org-html-handle-links): add an alternate for inline images

2011-04-19 Thread 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




Re: [O] [PATCH] * org-html.el (org-html-handle-links): add an alternate for inline images

2011-04-19 Thread Jambunathan K

Without alt validation fails, right?

Jambunathan K.


Manuel Giraud manuel.gir...@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)

-- 



Re: [O] [PATCH] * org-html.el (org-html-handle-links): add an alternate for inline images

2011-04-19 Thread Manuel Giraud
Jambunathan K kjambunat...@gmail.com writes:

 Without alt validation fails, right?

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

-- 
Manuel Giraud



Re: [O] [PATCH] * org-html.el (org-html-handle-links): add an alternate for inline images

2011-04-19 Thread Bastien
Applied, thanks.

Manuel Giraud manuel.gir...@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



Re: [O] [PATCH] * org-html.el (org-html-handle-links): add an alternate for inline images

2011-04-19 Thread Aankhen
Hi,

On Tue, Apr 19, 2011 at 14:52, Bastien b...@altern.org wrote:
 Applied, thanks.

 Manuel Giraud manuel.gir...@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