Replies: 1 comment
-
Yep. pretty much. Hopefully we'll be able to accomplish most things with just making a plugin, but as you saw already, we need to raise an issue on BBob. Thank you doing it btw! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm writing this out, mainly for myself, because it helps me understand the structure of Bbob's processing, feel free to correct me if I say something off.
How Bbob processes inputs
Bbob has three main phases:
Parsing
In the parsing phase, Bbob, builds a branching array (tree) based off of a given input string. The way Bbob parses can be affected by options
The order of the array matches the sequence of characters in the input.
Rules for building the tree
[\n(normal space) or\[\n\[or[/followed by a continuous string of characters ending in](an unrecognized tag)The resulting branching array is then sent to the plugins.
Plugins
This is where we can add custom logic to editing the tree, without needing to modify Bbob core. Currently we send preset() and lineBreak() to execute here.
Rendering
The render walks through the tree, checking the content of each node and appending them to a string. If it recognizes a TagNode, it converts it to a string with a
<+tagName+tag attributes+>. Closing tags are built the same way but without tag attributes.Once the entire tree has been converted back to a string, the string is returned to whatever called for it.
Options:
I should also say that the behavior of the Parsing and Rendering phase can be controlled by options. Currently there only seems to be one available option:
stripTagswhich removes html tags from the tree (or maybe more? I haven't tested this one in detail)Edit: The choice of parser and render functions are also options that can be passed in. As well as three parsing options listed here: https://github.com/JiLiZART/BBob/tree/3bccca086f3be4f657ffa5724f62486342cc0933#parse-options-
Speed:
It looks like even through Bbob is a branching array, it still traverses the array linearly? I'm not sure we get any time saving factors from the tree structure. Each plugin we add will mean an extra round traversing the tree. This may be trivial, but I think it's something to keep an eye on over time.
Pull Request or Plugin?
So my thought is that in general:
If we want a change that affects the initial structure of the generated tree, like adding a new option, we need to make a pull request
If we just need to traverse and check nodes in the existing tree, then a plugin will be fine.
Beta Was this translation helpful? Give feedback.
All reactions