sirthias / pegdown

A pure-Java Markdown processor based on a parboiled PEG parser supporting a number of extensions
http://pegdown.org
Apache License 2.0
1.29k stars 217 forks source link

The current plugin mechanism doesn't allow much code reuse #137

Open nberthet opened 10 years ago

nberthet commented 10 years ago

I've been struggling to understand how exactly to reuse all utilities from Parser.

I tried to subclass Parser in order to add a bunch of rules that would depends heavily on existing utility methods, but, due to the way parboiled works and the presence of protected/package methods in Parser makes it nearly impossible to subclass. The only way is to copy whatever contains reference to unaccessible types in the subclass. Clearly not a great option...

On the other hand, using the plugin class forces me to copy most of the utility from Parser to my plugin class, which doesn't feel much better.

By simply changing those 3 ~ 4 inner classes to have a public scope would greatly help to extend the current rule set.