-
-
Notifications
You must be signed in to change notification settings - Fork 104
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
Implement MiniMessage preprocessor and cleanup parsing #749
Conversation
allows the parser to infer message content from the ContextImpl that was passed to it, instead of relying on a redundant rich message parameter.
implements a preprocessor for minimessages: behaves exactly like a postprocessor like in existing versions, except the unary operator acts on the raw input strings prior to parsing
fixes StackOverflowError from escaping, introduced by 8671d4b
adds a unit test that checks if basic preprocessing is functional
fixes some issues with a lack of newlines, final keywords, and this-dots
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just the tiniest of nitpicks :p
text-minimessage/src/main/java/net/kyori/adventure/text/minimessage/MiniMessage.java
Outdated
Show resolved
Hide resolved
replace "end" with "start" in preprocessor javadoc
whoopsies, i guess that's what i get for copy & paste :D |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! :)
text-minimessage/src/main/java/net/kyori/adventure/text/minimessage/ContextImpl.java
Outdated
Show resolved
Hide resolved
moves the ContextImpl constructor's closing bracket to a new line Co-authored-by: Riley Park <[email protected]>
oh whoops sorry kezz didnt mean to press buttons |
Out of curiosity, what was your planned usecase for this pre-processing function? |
I believe the initial use-case for this was a preprocessor that word wraps the input prior to building the components — the discussion that led to this change is in the #adventure channel on the Kyori discord server |
This pull request combines two changes to MiniMessage, one internal and the other external.
On the user-facing side, a new feature is implemented: preprocessing. This is essentially exactly opposite to the existing post-processing in MiniMessage: it's simply a unary operator that is applied to every string input prior to deserialising it into a tree.
On the internal side, this also removes the explicit
richMessage
parameters from most MiniMessageParser methods, opting to instead deduce the value from ContextImpl where possible. A notable outlier here is the process of escaping tokens, where therichMessage
parameter is explicitly required for escaping to work.