I'm using Markdown with GeSHi filter.
GeSHi transforms <blockcode>...</blockcode> into something like [geshifilter-blockcode]...[/geshifilter-blockcode] for preparation. This is very bad in conjunction with Markdown (or other text-based markup-languages) since then it looks like a simple text, not like a code block. To counteract I've changed the GeSHi filter to use angle brackets instead of square brackets. Also I've made it so that <geshifilter> is wrapping. This way markdown takes it as a HTML tag and does not touch it's contents.
So this:
[geshifilter-blockcode]...[/geshifilter-blockcode]
is now this:
<geshifilter><blockcode>...</blockcode></geshifilter>
Why not simply rearrange my input filters?
- I want to add (plain text) syntax highlighting to Markdown code blocks (will post a patch soon).
- For comments I've made some changes to the marksmarty module to escape HTML tags properly. When GeSHi is prepared beforehand it would get escaped.
Why use <geshifilter> as a wrapper?
Because now you can simply whitelist the <geshifilter> tag. The changes I made to the marksmarty module take this into account and won't escape it and its contents. All other tags which are not whitelisted will be escaped.
I've added a patch of the small and straightforward changes.
Question:
Does this break compatibility with other filters I don't user? I could imagine that my changes will break GeSHi module when used in conjunction with the HTML filter.
If this is the case what shall I do? I recon I could put my changes into some regexp code inside the markdown module. Would that be a better place?
| Comment | File | Size | Author |
|---|---|---|---|
| prepare-wrapp-code.patch | 847 bytes | milianw |
Comments
Comment #1
soxofaan commentedFor clarity: you are talking about http://drupal.org/project/marksmarty ?
The usage of square brackets in the preparation pass is chosen to avoid conflicts with the standard HTML filter.
Because this filter is more used (it's the default filter that comes with Drupal) than the markdown filter, I don't think it is a good idea to change the square brackets back to angle brackets.
(More about the choice for square brackets: http://drupal.org/node/208635)
Also note that GeSHi filter is not the only filter that uses square brackets for delimiting and preparation (e.g. codefilter).
I think we need a different solution than your patch. e.g.:
* patching the Markdown filter to make it compatible with square bracket using filters
* adding an option to GeSHi filter to set the delimiter to square or angle brackets
P.S. Concerning your patch: please add the option -up when running diff in the future, see under "readability" at http://drupal.org/patch/create
Comment #2
milianw commentedYes I was talking about marksmarty.
And the GeSHi module seems to be the wrong place to implement this. I'll add it to marksmarty instead.
One question though:
Is there any possibility when inside the marksmarty module to know wether GeSHi is activated for `$module` ?
Thanks and great module btw.
Comment #3
soxofaan commentedI'm not sure if I understood your question correctly, but maybe this is what you're looking for:
http://api.drupal.org/api/function/module_exists
Comment #4
milianw commentedNo this is not very helpful. Let me try to explain:
I'm in Marksmarty module and give it an option to be GeSHi compliant. Now this GeSHi compliance mode only makes sense if I've activated GeSHi for the current `$format` as well. It would make the option even unnecessary! So I want to do the following (in meta-code):
Any ideas?
Comment #5
soxofaan commentedhttp://api.drupal.org/api/function/filter_list_format/5
usage example from the conflict detection of GeSHi filter: