-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
Make p tags optional for render-image to enable use of figure elements #10492
Labels
Milestone
Comments
Somewhat related #8362 |
bep
added a commit
to bep/hugo
that referenced
this issue
Dec 3, 2022
This both: * Removes any surrounding <p> nodes * And transfers any attributes from the surrounding <p> down to the image node Closes gohugoio#8362 Fixes gohugoio#10492
bep
added a commit
to bep/hugo
that referenced
this issue
Dec 3, 2022
This both: * Removes any surrounding paragraph nodes * And transfers any attributes from the surrounding paragraph down to the image node Closes gohugoio#8362 Fixes gohugoio#10492
bep
added a commit
to bep/hugo
that referenced
this issue
Dec 3, 2022
This both: * Removes any surrounding paragraph nodes * And transfers any attributes from the surrounding paragraph down to the image node Closes gohugoio#8362 Fixes gohugoio#10492
bep
added a commit
to bep/hugo
that referenced
this issue
Dec 4, 2022
* Removes any surrounding paragraph nodes * And transfers any attributes from the surrounding paragraph down to the image node * Adds a new IsBlock field to the link context passed to the render hooks, only set for images. IsBlock is set to true if the image's parent node has only one child. Closes gohugoio#8362 Fixes gohugoio#10492 Fixes gohugoio#10494
bep
added a commit
to bep/hugo
that referenced
this issue
Dec 4, 2022
* Removes any surrounding paragraph nodes * And transfers any attributes from the surrounding paragraph down to the image node * Adds a new IsBlock field to the link context passed to the render hooks, only set for images. IsBlock is set to true if `wrapStandAloneImageWithinParagraph = false` and the image's parent node has only one child. Closes gohugoio#8362 Fixes gohugoio#10492 Fixes gohugoio#10494
bep
added a commit
to bep/hugo
that referenced
this issue
Dec 5, 2022
* Removes any surrounding paragraph nodes * And transfers any attributes from the surrounding paragraph down to the image node * Adds IsBlock and Ordinal (zero based) field to the image context passed to the image render hooks IsBlock is set to true if `wrapStandAloneImageWithinParagraph = false` and the image's parent node has only one child. Closes gohugoio#8362 Fixes gohugoio#10492 Fixes gohugoio#10494 Fixes gohugoio#10501
bep
added a commit
that referenced
this issue
Dec 5, 2022
* Removes any surrounding paragraph nodes * And transfers any attributes from the surrounding paragraph down to the image node * Adds IsBlock and Ordinal (zero based) field to the image context passed to the image render hooks IsBlock is set to true if `wrapStandAloneImageWithinParagraph = false` and the image's parent node has only one child. Closes #8362 Fixes #10492 Fixes #10494 Fixes #10501
Amazing, look forward to testing it out. |
bep
added a commit
that referenced
this issue
Dec 5, 2022
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Hello!
I'd like a config option to turn off the wrapping of markdown images with p tags.
I wanted to give my perspective and experience dealing with the way it currently works as a new Hugo user with photography blogs.
There was some discussion here:
-->](#6748 (comment))
It came down to this (and was closed):
"In this issue's original example, the render hook for a markdown image was coded to return a figure. This seems like we are hijacking the render hook, asking it do something for which it was not designed."
I disagree.
An image is an image
When writing my markdown content I just want to be able to add an image.
Having the render hooks in hugo is awesome, I could make figure elements from my existing content files with a simple template, awesome. An image is now the same image but can have retina, webp, responsive versions.
I just get them wrapped in unwanted p tags.
Being able to override the p tag wrapping would be to:
Shortcodes are not the answer
the suggestion in the issue linked above was to use shortcodes
i) I have hundreds of articles with a few thousand images between them, swapping markdown image to shortcodes would have to be done programmatically or take weeks.
ii) the idea of having my content as markdown was to make it platform independent and it worked
iii) shortcodes don't show the content if you write with a markdown app with a preview
Coming from grav
I had the same issue in grav but there is a solution with a plugin which makes images into figure elements and it removes the p tags e.g.
-->](https://github.com/OleVik/grav-plugin-imgcaptions)
I don't think it can be just me with a need for this, trying to come up with a solution to match what I could do with grav I found people with solutions to strip p tags from images in other projects e.g. jekyll and wordpress
Workaround
I've spent quite some time trying to work around this.
This is what I came up with for a workaround (seemed simpler than some suggestions)
i) Since we get an unwanted
before the figure I close it immediately by starting the render hook with
And do the same idea at the end, finishing with
which gets wrapped in the unwanted
ii) I use a grunt task to remove /
\n?</p> from all the html files in the public folder
Thanks for your time.
The text was updated successfully, but these errors were encountered: