Hi,
I have a filter that comes before GeSHi-filter. It replaces something with foo. But GeSHI-filter does not process it. These tags are untouched.
Why?
Is there some pre filtering happening before any other filter gets in touch?
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | process_added_code-521746-11.patch | 1.25 KB | deciphered |
Comments
Comment #1
soxofaan commentedGeshifilter uses a prepare phase, which captures the codeblocks to highlight and re-embeds them in [geshifilter-..] style containers. The processing only triggers on those [geshifilter-..] containers, not on the original <code> style tags.
So if your filter has no prepare phase, the pipeline is:
if you want your <code> tags to be captured by geshifilter, you should insert them in the prepare phase of your filter so the pipeline is:
Comment #2
soxofaan commented(setting issue status back to "active" to make it more visible)
Comment #3
Crashtest commentedThe problem is I'm using the Custom Filter module. So I have no influence on any preperation.
How do the [geshifilter-...] style containers look like?
Comment #4
soxofaan commentedThis is internal representation and you should not depend on how it works.
(It can change from release to release and depending on it makes your site very fragile.)
can you describe your use case in more depth? why are you using the Custom Filters module and not inserting code tags directly?
Comment #5
Crashtest commentedI was creating a Creole wiki style markup. And I wanted to make things consistent. So [code] didn't fit in the concept.
But it's not that important. It was just worth a try.
Comment #6
soxofaan commentedwhat is creole wiki style?
could this be related to #455564: Handling of tag style [[code]]?
Comment #7
Crashtest commentedIt's a wiki markup language. http://en.wikipedia.org/wiki/Creole_%28markup%29
Yes, it is some kind of related.
The prefiltering habbit of this module reduces a bit the interoperability with other modules resp. makes it more difficult. But I think there a very few cases, where interoperability is really needed.
Maybe this is more a flaw in the input filter system of drupal. Can you control the order in which the preperations of the input filters take place?
Comment #8
soxofaan commentedI still don't see how you want creole wiki style talk to geshifilter. How do you want your code blocks to look like in creole wiki style?
the prepare phase (not only for geshi filter, but all filters that use a prepare phase) is to avoid collisions between filters and by consequence integration is harder indeed. I agree though that the filter system in drupal could use some rethinking.
about the order: first the prepare phases of all filters are executed (in the configured order) and then the process phases.
If you have an input format with filter order:
- filter A
- filter B
- filter C
then the processing order is:
- filter A prepare
- filter B prepare
- filter C prepare
- filter A process
- filter B process
- filter C process
Comment #9
boombatower commentedIssue is long dead, please reopen if still relevant.
Comment #10
decipheredThis issue is still relevant, re-opening.
It is implied that the prepare callback is used to prevent conflicts of any other filters that wish to deal with code tags, but the prepare function converts all code tags so that no other filters would be able to deal with the tags unless additional code code tags where added by that filter or another filter post-geshi. This seems an unnecessary precaution, as simply using a process callback and weight adjustment would allow Geshi to handle all original code tags without missing any additional ones by other filters that are weighted intentionally to be handled by Geshi.
My personal use case is the Parsedown module, using github style code formatting, I want that code formatting to be handled by Geshi, and the current approach it can not do so.
The simplest workaround is to force the process callback to re-run the prepare callback, but it seems to be that just moving the prepare callback functionality into the process callback is the better solution.
Happy to discuss further, especially if someone can show reason why this should not be the case. Patch incoming.
Comment #11
decipheredPatch attached simply adds processing of extra <foo>..</foo> style code blocks, as these are likely the only ones that would get added via other filters. I did look as merging the prepare callback into the process callback, and had it 99% done, but the <?php .. ?> style code blocks where making it more complicated than I currently have time to get into.
Comment #12
yukare commentedIt is not better you just mimic the prepare function in your module and make it output the code that geshilfilter expect?
In drupal 8 i will create a service for other modules work with geshi, but i do not have plans to make this for 7.
Comment #13
yukare commentedIn your module use the function geshifilter_geshi_process() it will do sintax highlight, so you do not need to prepare the code to filter again by geshi. Closing this as outdate, please reopen if you still need this.