From mboxrd@z Thu Jan 1 00:00:00 1970 From: tftorrey@tftorrey.com (T.F. Torrey) Subject: Re: Bug: New HTML exporter incorrect attributes Date: Sat, 23 Feb 2013 02:43:58 -0700 Message-ID: <87621j9xgh.fsf@lapcat.tftorrey.com> References: <87vc9khr8f.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([208.118.235.92]:59024) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U9BeW-0003il-0q for emacs-orgmode@gnu.org; Sat, 23 Feb 2013 04:44:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U9BeT-0004D0-CI for emacs-orgmode@gnu.org; Sat, 23 Feb 2013 04:44:19 -0500 Received: from mail-da0-f42.google.com ([209.85.210.42]:63433) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U9BeT-0004Cl-5x for emacs-orgmode@gnu.org; Sat, 23 Feb 2013 04:44:17 -0500 Received: by mail-da0-f42.google.com with SMTP id z17so742308dal.1 for ; Sat, 23 Feb 2013 01:44:15 -0800 (PST) In-Reply-To: <87vc9khr8f.fsf@gmail.com> (message from Nicolas Goaziou on Sat, 23 Feb 2013 00:18:56 +0100) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Nicolas Goaziou Cc: emacs-orgmode@gnu.org Hello, First, as always, thanks for the prompt reply. Nicolas Goaziou 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

, 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