emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: tftorrey@tftorrey.com (T.F. Torrey)
To: Nicolas Goaziou <n.goaziou@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: Bug: New HTML exporter incorrect attributes
Date: Sat, 23 Feb 2013 02:43:58 -0700	[thread overview]
Message-ID: <87621j9xgh.fsf@lapcat.tftorrey.com> (raw)
In-Reply-To: <87vc9khr8f.fsf@gmail.com> (message from Nicolas Goaziou on Sat, 23 Feb 2013 00:18:56 +0100)

Hello,

First, as always, thanks for the prompt reply.

Nicolas Goaziou <n.goaziou@gmail.com> writes:

> Hello,
>
> tftorrey@tftorrey.com (T.F. Torrey) writes:
>
>> Where attributes have been assigned to an image in a paragraph, the new
>> exporter applies those attributes to both the image and a following
>> link.
>
> You don't assign attributes to an image in a paragraph, you assign
> attributes to the paragraph itself.

It would be nice if there actually was a way to assign an attribute to a
paragraph, so that the ATTR_HTML: class="XXX" syntax would export as <p
class="XXX">, but that is a different issue.

> For the time being, Org syntax
> doesn't allow to specify attributes per link object.

I think what you are saying is that the current intended behavior is for
whatever is specified by ATTR_HTML to apply to every image or link in
the paragraph.

> As a consequence, attributes will be assigned to every link within the
> paragraph.

Is this behavior helpful to anyone in any practical circumstances?

Moreover, this means that, not only does the new exporter fail where the
old one succeeded, the new one produces invalid HTML (anchors with
invalid attributes) in the use case I described (ATTR_HTML to apply to
an image beginning a paragraph which later has a link in it, which
happens several times in almost all my documents).

It seems to me that, whether the user is happy with the output or not,
the HTML exporter ought to produce valid HTML.

> A hack could be implemented in ox-html.el so only image links
> get these attributes, but it would be the same with multiple images
> within the same paragraph.

Again, I can't think of a practical situation where this would be
helpful.  If all the images and/or links had the same styling, simple
CSS would suffice, and there would be no need for the ATTR_HTML.

In my case, however, this would actually work.

I know that it is possible to style links using ATTR_HTML, but does
anyone actually do that in practice?  I don't think I ever have.  If no
one uses it, would it be missed?

> A proper solution to the problem would be to slightly change link
> syntax.

The link syntax change will be a welcome addition, though I understand
that it is not a high priority.

> Until then, you'll have to use workarounds (like, for example, writing
> the other link in raw HTML syntax within an export snippet).

Yes, a personal workaround would be to use the raw HTML syntax to mark
the image in my example.  This has the strong disadvantage, however, of
meaning the image doesn't appear at all when the document is exported to
other formats, and of requiring changes to all affected documents when
the syntax changes again.

A more general workaround that would help everyone affected would be to
temporarily modify ox-html.el so that attributes from ATTR_HTML only
apply to the *first* item in the paragraph.  This would have the
advantage of mimicking the behavior of the old exporter (thus not
breaking existing content) and of keeping images for other export
formats.  Of course, anyone relying on the ATTR_HTML to set attributes
for every image and/or link in a paragraph would have to adopt a
different workaround, but ... does anyone really do this?

In my case, rather than changing all my documents to use raw HTML for
the images, I will write a filter function that walks through the final
HTML and removes invalid and superfluous attributes from the anchor
tags.  This strikes me as a rather ugly hack, though.

It seems unlikely to me that this issue only comes up with the HTML
exporter.  Surely some documents with primary output formats of LaTeX or
OpenDocument have similar requirements.  I wonder how those export
backends handle situations like this.

Thanks again for your help and hard work.

Best regards,
Terry
-- 
T.F. Torrey

  reply	other threads:[~2013-02-23  9:44 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-22 22:23 Bug: New HTML exporter incorrect attributes T.F. Torrey
2013-02-22 23:18 ` Nicolas Goaziou
2013-02-23  9:43   ` T.F. Torrey [this message]
2013-02-23 10:16     ` Nicolas Goaziou
2013-02-24 20:27       ` Samuel Wales
2013-02-25  8:23         ` Nicolas Goaziou
2013-02-25 10:55       ` T.F. Torrey
2013-02-25 13:49         ` Nicolas Goaziou
2013-02-25 13:57           ` Vincent Beffara
2013-02-25 14:03             ` Nicolas Goaziou
2013-02-25 20:51           ` T.F. Torrey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87621j9xgh.fsf@lapcat.tftorrey.com \
    --to=tftorrey@tftorrey.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=n.goaziou@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).