better-html icon indicating copy to clipboard operation
better-html copied to clipboard

Replace "ast" gem with custom implementation

Open Forthoney opened this issue 2 years ago • 3 comments

The "ast" gem, a core dependency of better-html, is no longer actively maintained, with its most recent non-trivial commit happening nearly 3 years ago. Having crucial functionality of the gem be dependent on "ast" is unsustainable at best and dangerous at worst. Therefore, better-html should ideally move towards making its own AST class. It frankly does not utilize much of the features from the "ast" gem anyways, so writing a tailormade AST class for better-html should not be too challenging.

### Tasks

Forthoney avatar Nov 11 '23 03:11 Forthoney

Indeed, having a handcrafted AST will be more robust, organized and will allow for additional functionality to be built on top of better-html. We'd gladly accept a contribution!

vinistock avatar Nov 21 '23 14:11 vinistock

@vinistock A bit of bad news with a silver lining. Turns out the rewriting the AST class is not so simple because it is tightly coupled with the parser in two aspects. First is via the tokenizer of better-html. The second link through Whitequark's Parser that is used in small parts of the gem. I believe it is only used to provide test helpers for the gem users, but it is used nonetheless, and we must accomodate it at the moment.

My proposal is that this issue should be addressed as part of a larger refactor/rewrite that replaces Whitequark's parser with Prism. I understand that the Prism team is interested in finding gems that use non-canonical parsers, so I hope this information is of use to them.

Forthoney avatar Nov 30 '23 05:11 Forthoney

Agreed, we should definitely switch to using Prism. It might be a larger refactor, but if you're interested in taking a stab at it, I believe that's the right path forward.

vinistock avatar Nov 30 '23 14:11 vinistock