-
Notifications
You must be signed in to change notification settings - Fork 166
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
Possible to append to default filter chain? #407
Comments
Looked at the code more and realized you currently have to define your custom filters in the gollum-lib/lib/gollum-lib/markup.rb Line 159 in 1058d36
It might also be nice to allow implementors to stay out of the Gollum namespace like in my example above? |
I personally think it's neat to have all filters be part of the same namespace, but if the consensus is this is very counter intuitive I am happy to yield. :) Substantively it would only require modifying the line you quote, I think. Something like: filter_sym.is_a?(Class) ? fiter_sym.new(self) : Gollum::Filter.const_get(filter_sym).new(self) But my personal feeling is this complicates the code for a minimal gain in enduser-friendliness. Perhaps it's more important that we document clearly how to define a custom filter? |
Sorry @beporter, I just realized I never responded to this more verbosely. I do really like the example snippet you give and we would be open to considering a PR that makes something like that possible! If I see things correctly, that functionality would be independent of the namespace issue, no? Thanks for chipping in regardless! |
No worries on timing!
Quite similarly to you: I'm quite happy to do a PR, but no promises on timing. The nature of open source work is that sometimes it's months between good opportunities to meaningfully contribute. I have a gollum search plugin still sitting on the back burner too. 🤦♂️ |
Right, so there seem to be two options:
I'm alright with either approach, 1 means more flexibility for the end user, whereas 2 is less complex in our codebase. My own initial preference was for one, but I'm happy to yield. By the way, since the order of execution for the filters is important, I guess a typical usage would be something like: Gollum::Wiki::DEFAULT_FILTERS.insert(Gollum::Wiki::DEFAULT_FILTERS.rindex(:Code), My::CustomFilter) Maybe we could even come up with a more user friendly solution for that. And: absolutely understand about the timing! Thanks for taking the time to contribute. |
I've been digging around in the source code, looking for a way to append (or prepend) an additional filter to the default list.
gollum-lib/lib/gollum-lib/wiki.rb
Line 149 in 1058d36
But as far as I can tell, the only choice is to copy (and hardcode) the default list with my own filter added to it.
I suspect even converting the list to a constant would make this much more robust. Imagine this
wiki_options
:Would a PR for this be welcome? Do you have any modifications to the suggested code? Is there an alternative I'm not thinking of?
(Another option might be to expose methods like
def prepend_filter(filter)
on the Wiki class to manage the filter chain. This seems less than ideal though. An instance of the Wiki class isn't intended to be "manipulated" on a meta level but rather "used".)The text was updated successfully, but these errors were encountered: