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

Allow nested shortcodes #2748

Open
wants to merge 2 commits into
base: next
Choose a base branch
from

Conversation

ARitz-Cracker
Copy link

Fixes #515

Hello, and Happy Christmas 🎄

This PR iterates on #2630 with the given feedback of not requiring the use of the markdown filter to execute nested shortcodes. Additionally, unlike the previous PR, nested nth invocation increments follows a more intuitive pattern.

Before:

  • 1
  • 2
    • 5
    • 6
      • 9
      • 10
    • 7
    • 8
  • 3
  • 4

After:

  • 1
  • 2
    • 3
    • 4
      • 5
      • 6
    • 7
    • 8
  • 9
  • 10

Sanity check:

Code changes

  • The shortcode parser has been changed to stop at the appropriate {% end %}, instead of the first-encountered {% end %}. (Thanks to Allow recursively nested shortcodes #1475)
  • A clonable shared ShortcodeInvocationCounter has been added
  • The markdown::shortcode::parser::Shortcode struct now has inner: Vec<Shortcode>
  • The markdown::shortcode::parser::parse_for_shortcodes function now also parses shortcode bodies
  • Added a flatten method to markdown::shortcode::parser::Shortcode which renders the inner-shortcodes into the shortcode body
  • The render method on markdown::shortcode::parser::Shortcode now calls flatten
  • Are you doing the PR on the next branch?

If the change is a new feature or adding to/changing an existing one:

  • Have you created/updated the relevant documentation page(s)?
    • As far as I'm aware, the documentation does not explicitly prohibit nested short-codes.

Let me know what you think!

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.

1 participant