-
-
Notifications
You must be signed in to change notification settings - Fork 18
Load Content Late - Add IDs After Others Have Addd Theirs #81
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
Draft
ronalfy
wants to merge
14
commits into
mtoensing:master
Choose a base branch
from
DLXPlugins:fix/generateblocks
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Owner
|
I tested this and it looks good so far. Let me know when it is you final version. And thank you again! |
Owner
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.

Relates to #58, Resolves #79
Continues #75
This is a draft PR demonstrating loading late and adding SimpleTOC after content has been parsed.
Features of Running Late
Caveats of loading late:
simpletoc_skip_in_wrapper(defaultfalse). If this is enabled, it'll get all headlines, even in other blocks and shortcode output.This flowchart shows the logic.
Block and Original Content Output
This runs whenever the block is initially output to the frontend (content priority
10) or when it is server-side rendered.If the block is server-side rendered (in REST), then a sample TOC is generated from block content, but only the TOC is returned, not the content.
Content Prority 800 - Add IDs Late
This assumes a shortcode is present in the content, which we'll replace later. In this iteration of content parsing, we're adding IDs to any headlines that don't already have them and storing all headlines for later retrieval.
TOC Rendering
TOC rendering is after all other content has finished running, and returns a rendered TOC. If it's parsed on regular content, a shortcode will be present and replaced with the TOC HTML.
This render is also part of the block server-side rendering, which passes attributes and wrapper classes. If a TOC-only flag is set, then only the TOC HTML is returned, and not the full content. This is useful for server-side rendering.
Test Pattern
Here is the Test Pattern I used.