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

Nested shortcode output being expanded unexpectedly #115

Closed
bobbingwide opened this Issue Dec 11, 2018 · 2 comments

Comments

Projects
None yet
1 participant
@bobbingwide
Copy link
Owner

bobbingwide commented Dec 11, 2018

Some shortcodes expand to produce output which appears to contain unexpanded shortcodes. e.g. [bw_code bw_archive] expands to become a link to the [bw_archive shortcode]. This is achieved by converting the Left Square Bracket ( LSB ) character [ to the HTML number [. Unfortunately there is WordPress logic that converts this HTML number back to a LSB. When the original shortcode is nested within another shortcode then we get unwanted expansion of the generated HTML.

Expected output

[bw_code bw_archive] should expand to a link to the bw_archive shortcode being displayed as [bw_archive].

Actual output

The `[bw_archive] shortcode is also expanded.

This problem now occurs in Block expansion. See bobbingwide/oik-blocks#2 (comment)

Proposed solution

Replace the original LSB with the HTML number wrapped in an empty span tag.
If this HTML number gets converted back to an LSB further shortcode expansion should be prevented since the output would now no longer parse as a shortcode. e.g. <span>[</span>.

This change needs to be made in bw_code_example_link.
I'm not sure about other instances where &#91; is used.

@bobbingwide bobbingwide self-assigned this Dec 11, 2018

@bobbingwide bobbingwide transferred this issue from bobbingwide/oik-clone Dec 11, 2018

@bobbingwide

This comment has been minimized.

Copy link
Owner

bobbingwide commented Dec 11, 2018

Another potential solution would be to change the space between the shortcode and the first parameter to &nbsp; This assumes that there will be a space to change.
It also assumes that this unexpected no-break space won't get converted back to a normal space character by some filter.
Note: The appearance of &nbsp; in shortcodes seems to be related to Gutenberg. I'm not aware of an issue. You can use the Code editor view to see these characters.

bobbingwide added a commit that referenced this issue Jan 5, 2019

@bobbingwide

This comment has been minimized.

Copy link
Owner

bobbingwide commented Jan 9, 2019

Does this also fix bobbingwide/oik-shortcodes#1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment