Skip to content
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

Auto-generate preconfigured class attributes #355

Open
wants to merge 1 commit into
base: lib
Choose a base branch
from

Conversation

fleonce
Copy link

@fleonce fleonce commented Jul 8, 2021

From my understanding it is currently impossible to let the Markdown library generate class attributes in the html output. While it would be possible to include those after the text has been generated via regex replace, it is much easier to configure the Markdown object beforehand, e.g. if you want all images in the output to have the "control-img" class.

I dont know if this is rather a thing I would only need for my specific use-case or if there is more interest in this, I created a pull-request for it.

In my use-case, I generate forum article html content from Markdown source files, inside of the general php generated html content. This exposes me to the following problem:

If I include images in the Markdown, there is currently no possibility to control their width and height, although there is a pull request open for this exact issue. I believe allowing class attributes to be added to generated html tags to use them in css styling purposes would make things quite a bit easier.

I currently did only include attribute generation for html tags a and img, however if accepted I can of course add support for the other tags generated as well.

@michelf
Copy link
Owner

michelf commented Jul 9, 2021

I don't understand why you'd want to put the same class names on every image. If all the images need the same style applied to them, isn't it already easy to target them with a CSS selector targeting an ancestor with a specific class? Like div.post img { width: 100% } Am I missing something?

On the implementation side, I think this won't work with special attributes in the MarkdownExtra parser.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants