Hello, First, as always, thanks for the prompt reply.
Nicolas Goaziou <n.goaz...@gmail.com> writes: > Hello, > > tftor...@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