Repository navigation
Conversation
|
I checked this out and replaced the inline parser used in There are a lot of failures around emphasis parsing for example. I don't know if the new model can implement emphasis parsing according to the spec. In general I'd rather keep the existing logic as it's very close to what the JS reference implementation does and follows the spec. I might take a stab at making inline parsing extensible based on the current logic (can't promise a timeline though). |
|
Gotcha @robinst. It makes sense. Thanks for your thoughts on this. Do you think that makes sense put any effort into this idea? for instance, trying to see if matches with emphasis patterns for instance? or go by the original one? My time for the next weeks is not so good but I can try to help you somehow. |
|
Hey! I've taken some time to work on this and it's looking really good. I've opened a WIP PR here: #180 |
|
Closing this, see #177 (comment) |
Hey @robinst / @colinodell , bringing our discussion to here. (I'm committing this code partially for us to have some code to discuss over)
So, based on our initial thoughts in the other PR(#177) I came with this idea in this new PR to us discuss over and see if make senses. The main thing that made me (re)think to give a try in a new approach it was when I studied the InlineParser default impl and I noticed that to inject the idea about "priority extensible nodes" would mean redo the entire logic. Also, I saw better about the text patterns and I thought about how we could provide an extensible way without losing performance avoiding as much as possible regex needs. So I came with a new redesign idea. (totally understandable if it doesn't make senses ;) )
That said, I created a new InlineParser implementation following the @robinst recommendation such as 1. One character to trigger the node process; 2. One way to prioritize the winner nodes;
In high level the idea is based on some points:
InlineParserImpl: will run all characters from the line; Once noticed a special trigger character, it will start a watch process by the node which can have multiple watches based on the node setup (TextNodeIdentifierSetup)TextNodeIdentifierSetup: it will provide the text identifier logic, which is called for each character after being started by the InlineParser;NodePatternIdentifierpositionsReservedByNodePriority;positionsReservedByNodePriorityto check which nodes it was found;NodeCreatorfor that give node passing some metadata and the substring for each node found;Tring to put some more colors, the algorithm is:
In this idea, if the client wants to add a new Node configuration, they just need to create a
TextNodeIdentifierSetupand to add this one to the parser factory, using the priority property to override any pre-node setup if needed. (i.e:ImageLogoNodeSetup.javaand checkInlineParserNodeSetupFactory.java) (For sure that we can add a builder class or something else for this flow)Also, comparing the current way with the new one the performance is really close: (I set up just a few os nodes to be able to do this comparison)
Geez, such a huge blog text.. sorry folks. 😅 Thoughts? Ideas? Revert the code? :)
(I've put everything in a package apart to avoid impact the current code, but, if you want to see for example which tests are falling just replace the
Parser.getInlineParserFactory()by the new factoryInlineParserNodeSetupFactory)