-
Notifications
You must be signed in to change notification settings - Fork 3
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
[Breaking Changes] attribute-based node protection #107
Draft
zkamvar
wants to merge
40
commits into
main
Choose a base branch
from
fix-105-unprotect
base: main
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 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
I've modified the escape-text function escape text based on wether or not it exists in an escapable range. This commit implements a proof of concept that protects the first escapable character and will not pass check.
In this version, we no longer need to split nodes in order to protect them if we also want them to be continuous. I've taken the XSL template "escape-text" and modified it so that it takes in three new parameters: 1. `pos`..........the position of the current character 2. `protect.pos`..a space-separated list of starting positions for protection 3. `protect.end`..a space-separated list of ending positions for protection I've also added three new helper templates to handle list contents: `peek` returns the top of the list, `trim` trims off the first element of the list (or returns the value if it's not a list), and `adjust-range` trims a list depending on if the current value is within range. There's a lot of printing here because I wasn't too confident with debugging, but based on my test in inst/extdata/xml_protect.xml, it produces results correctly.
I had initially found a tokenize template and had contacted the author about license information (she gave permission): <https://exslt.github.io/str/functions/tokenize/str.tokenize.template.xsl.html> When I was working with it, I found that the function exists as part of libxml because it bundles EXSLT functions, which allows me to do this easier and more efficient by tracking and modifying a single index instead of a pair of strings.
This will address #105
…into fix-105-unprotect
The square bracket _should_ be escaped since it's outside of the protected range.
This begins to address limitations of the attribute-based protection by providing a way to separate and rejoin nodes that were previously split.
The previous iteration was not quite correct because it had assumed that the sourcepos would match up exactly with the protection ranges, but these were two separate numbers. This does the following: 1. when a protected range spans the entire node, then it is labeled "asis" 2. `split_sourcepos()` now reflects the actual end of the sourcepos instead of the computed end 3. an awkward catch for single nodes in `join_split_nodes()` is now eliminated 4. `join_split_nodes()` no longer re-comuputes the protected ranges from the sourcepos
This allows us to search for internal nodes using their identities
This was referenced May 8, 2024
Merged
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.
As discussed in #105 (comment), since I have some time on my hands, I wanted to give this a go.
This shifts that paradigm from splitting nodes that need protection to one where we would use attributes to tell us where the protection needs to be applied.
Not Ready to Merge
I'm not quite ready to merge this yet because this has ripple effects for both {babeldown} as it explicitly relies on
asis
andcurly
nodes to be separated out to avoid them entering the translation fieldsand {pegboard} as the link transformation routines (from Jekyll -> pandoc) explicitly assume that the
asis
nodes existas shown in the documentation fix_links.R#L38-L48: