-
Notifications
You must be signed in to change notification settings - Fork 20
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
[markdown]: shortcodes in posts should not be wrapped in <p> #126
Comments
Here's how I've worked around this for now: In Then in {
hook: 'shortcodes',
name: 'unwrapBlockShortcodes',
description: 'Looks for block level shortcodes and remove their surrounding paragraph tags',
priority: 99,
run: async ({ layoutHtml, shortcodes }) => {
const blockShortcodes = shortcodes.filter(shortcode => shortcode.block)
let newHtml = layoutHtml
blockShortcodes.forEach(({ shortcode }) => {
newHtml = newHtml
.replace(new RegExp(`<p>({{${shortcode}( .*)?/?}})(</p>)?`, 'g'), '$1')
.replace(new RegExp(`({{/${shortcode}}})</p>`, 'g'), '$1')
})
return {
layoutHtml: newHtml
}
},
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Elder.js' Markdown plugin wraps any shortcode placed on its own line in
<p></p>
, including any Svelte component called via{{svelteComponent name='...' /}}
. This creates invalid HTML if any non-inline tags are wrapped into<p>
. Elder.js' Markdown parser should remove thesetags from the resulting HTML.
The text was updated successfully, but these errors were encountered: