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 srcset support? #205
Comments
That's not a bad idea. Though I wonder how such a filter function could look like, mostly what kind of return value would that be? |
I think the easiest solution would be to have a
The My tag handler could check for the tag name (if it is an image) and add the This would be extreme extensible for other tags and attributes. |
A function like this one is going to have problems manipulating things that do not have a one-to-one mapping to HTML (things such as code blocks( |
I'd love to have something generic, but it might not be necessary for this feature. What my intention was that you just generate the "tag" like you always do, but we have some saying in it before it is stringified. Can you elaborate a little bit about the problems you see with P.S. Having a parsed DOM like structure for markdown was always my dream. Is there already an issue for that? |
The problem with code blocks is that it really is two tags. While you could change the attributes on either one with your If we're going to rewrite every HTML-emitting code in PHP Markdown to use a custom handler like above, then we probably ought to do it in a way that does not lock you into emitting small variants of the current HTML structure. No, genericness is indeed not needed for this feature.
No, I don't think there's an issue for that. Feel free to create one. |
Actually, I think the context does not matter. Not because I don't need it for my feature, but more for the following reason: when you want to change something and you need the context, you should use the "DOM" like interface to modify it to your needs. If you just want to add an attribute to all elements of a type, or change a Both features together would perfectly cover both use cases. I have created #206 for the more advanced feature. |
@michelf I just reached the problem with the srcset again and was reminded of this issue. :) Given that the context would be a different feature for some other time, do you see any problem with the tag_handler itself? I know that it would not solve every problem, but it would solve the concrete example of a srcset, for this issue. |
Are you proposing a The generic solution I'm thinking about is to have an interface like this: interface MarkdownComposer {
function header($content, $level, $attributes);
function link($content, $href, $attributes);
function image($src, $attributes);
function codeBlock($content, $language, $attributes);
function paragraph($content, $attributes);
...
} and move the current HTML-generating code in those separate functions. Then you could set a custom object to the These functions represents Markdown concepts, not HTML tags, although in many cases they map one on one. Most of the work to get there is to disentangle the HTML-generating code from the rest of the logic, something that needs to be done with the |
I love your generic approach! |
As I stumbled on retina images again, is there anything I can do to help implement this? |
Well, I'm not working on this at the moment. So if you want feel free to go ahead, implement it, and make a pull request. I can answer questions too. |
I would not vote for this additional feature, simply because |
@michelf I'll try to find some time to look into this in the week after the next one. If I have questions, I'll let you know. Thanks! |
Hello,
are there an plans, ideas or best practices on how to use srcset within images?
I can see that it would be pretty hard to add this syntax to the markdown format, but maybe there could me some API extension that works like
url_filter_func
. Once an image is found, the API could define some (additional) attributes for the<img>
tag that is generated.Any ideas on this?
The text was updated successfully, but these errors were encountered: