-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Image attributes #1806
Image attributes #1806
Conversation
markdown reader and all writers done except Docx, ODT, OpenDocument, RTF and Custom
Thank you got doing this, this kind of work it always very messy. I noticed a few changes from a quick glance which didn't seem to fit into the proposed changes. It's probably too late to change that now but it would be better in future to split them into separate commits. Also it seems like there were some errors on the build, can you see what's causing these? |
Sorry about the two unrelated changes (the one in The two ICML writer commits are already in a separate pull, but I needed to build on them for the image dimensions stuff. The build is failing only on those commits, but not the final one, or am I looking at the wrong place? |
I know this is intentional but I don't think that this is desirable. How difficult would it be to change? |
It's all about the The alternative would probably be to add attributes to links as well and doing so sooner rather than later, fixing #170. |
So is this pull mainly waiting for the other writers, or the question on how to handle links in the markdown reader or something else? |
+++ mb21 [Jan 28 15 12:59 ]:
I haven't really had time to look at it yet, and of course it's a complex issue, but it hasn't been forgotten about. |
This is a delicate change and there is still the outstanding issue I mentioned above? |
sure, just wanted to know whether this is still on track for 1.14. |
👍 |
2 similar comments
+1 |
+1 |
This was a somewhat messy patch, with several different changes mixed together. I've tried to separate them out a bit, changed I'm tempted to merge this now. It does seem a bit incomplete though -- it would make sense to add the Attr field to Link as well, so links and images behave similarly. |
Does this mean that the next release is going to be a 2.0? |
+++ Tim T.Y. Lin [Apr 02 15 21:59 ]:
Why would it? With this change we'd need to bump to 1.14, but not to 2, |
@jgm Sorry, I was thinking |
+++ Tim T.Y. Lin [Apr 02 15 22:48 ]:
Policy is to increment the minor version on breaking API changes: We incremented the minor version, e.g., when header attributes were I agree that this change could break existing filters. So, we might
and have the writers and readers treat it as an image with attributes. |
Another conservative approach (not requiring changes to pandoc-types) would be to overload the title field (which we already do to some extent for figures -- see how the writers treat a So, for example:
Pandoc could be trained to look for these attributes in the title and strip them out. |
@jgm I was actually toying with the overloaded title approach for Scholdoc, and I liked it quite a lot. Forgot why I didn't make it official yet; probably laziness on my part. I dug out my notes, here's what I listed as pros:
The obvious downside is that it's hacky, and that parsing for attrs in the title may become a bit ambiguous. The latter might be alleviated if the attrs must be in MDExtra-style curly braces. |
@timtylin - on reflection I'm against the hackish title overloading idea. This is Haskell after all; we should be making type information explicit. And think about how it would make it harder to write filters if the filters have to parse the title for image size attributes! The span overloading idea might still be worth considering, though. Note that the issue of markdown syntax and the issue of how this is represented in the Pandoc structure are separate issues. Some of your considerations are about the syntax, not the types (e.g. "looks good in existing processors"). Of course, it's entirely possible to overload the title in the MD syntax while representing the attributes separately in the Image type constructor. I don't think I'd favor that, though. |
@jgm Makes sense that I'm thinking more about the syntax, since I've already abandoned any notion of backwards-compatible AST in Scholdoc, so no need for hacks there :) I guess I'm just very interested in your philosophy w.r.t. these filter/writer-breaking type changes, i.e., whether you want to lump together breaking changes as much as possible or spread them out slowly. On a broader scope, the Pandoc ecosystem already has quite a long chain of things dangling precariously on each other: types, filters (modules for other languages), custom writers, and templates, that all needs some sort of version orchestration which isn't very visible at the moment. I don't know if it's a big problem yet, but some community effort in orchestrating all this might be prudent sooner than later. |
@jgm @timtylin I think the fact that this sort of change would break existing filters is more of an argument for working on the pandoc architecture than not making the change in the properly typed way. The changes to be made to pandoc would be
For example, the existing Image [Inlines] Target and this currently comes out as this json:
but we could create an Image AltText Target and then have this json:
This changes the way we access the content of the image from alt, (fname, title) = image['c'] to alt = image['c']['alt']
target = image['c']['target']
fname = target['fname']
title = target['title'] This way you avoid breaking filters when you make a change like this (adding attributes). It would also make writing filters easier and clearer as you'd no longer have to remember the order of the types, just their names. Of course this in itself would be a massive breaking change to pandoc-types but I think it would make the AST more robust in the future. |
Additional spans could change output rendering, and I believe in many cases, filters may need changing even when using span-wrapping approach. Since it'll be 1.14 anyway, might as well go all the way, I think. P.S. adding attributes to links sounds like a good idea. Images and links should handle pretty similarly, I believe. |
I think we need to discuss this on pandoc-discuss. I'll open up +++ Tim T.Y. Lin [Apr 03 15 00:38 ]:
|
A thought occurred to me, w.r.t. conservative extension using spans. While spans have meaning for many writers, we could add a new This will also potentially allow to use attributes with any block element with little penalty (if writers actually honor this is another matter), and simplify attribute parsing code somewhat (i.e. we could possibly add attribute parser to This would make |
Since this issue is closed, which issue can we also refer to ? |
the new pull is at #2351 |
Implemented image attributes as discussed in #261. (closes #261)
The changes to
pandoc-types
can be found in this pull request.All writers except the following have been properly adjusted:
Would be great if someone familiar with those formats could adjust the writers.
The README and markdown reader have been adjusted as well. I chose to avoid renaming an existing extension flag, but maybe it would be better to rename the existing
link_attributes
tommd_link_attributes
, and my newcommon_link_attributes
tolink_attributes
(or if you know of a better name than common, the basic syntax is shared by Markdown Extra, Kramdown and now Pandoc).