Hi,
the footnotes.module offers exactly the functionality which I would like to use, but not with Filtered HTML or Full HTML; I tried to make it work with the PEAR Wiki Filter (http://drupal.org/project/pearwiki_filter) which offers support for a wide range of alternative markup syntax, e.g. MediaWiki or BBCode; I'm using MediaWiki syntax since this is as well a fast-to-type syntax as quite widely used.
E.g. in the order Footnotes (weight -6), PEAR Wiki Filter (0), Code filter (2), URL filter (8), neither "Footnotes" nor "Footnotes Textile style" is parsed in a completely usable way.
* In the node, "Footnotes" renders to <sup class="see_footnote" title="blah"><a href="#footnote1">1</a></sup> with an <div class="footnotes"><ol><li id="footnote1">blah </li></ol></div> at the bottom
* "Footnotes Textile style" renders to [1] with fn1. blah at the bottom of the node, where [1] is not linked the the footnote at the bottom. This might conflict with the Pear Wiki filter since tags like "[]" have their own meaning in MediaWiki syntax (however, even without active hyperlink this is better than nothing ;-).
With "Footnotes Textile style", a footnote can even include an URL, if "URL filter" has an heavier weight than "PEAR Wiki Filter"; then, the URL in the footnote's target at the bottom of the node becomes correctly hypertextified (an active hyperlink). However, I can't get the footnote in the node's body hypertextified.
Question 1: Is there a way around this, if I stick with MediaWiki syntax?
Question 2: Are there plans to offer a more flexible integration of the footnotes.module with alternative input formats (like the PEAR Wiki Filter, or Texy)?
Thanks & greetings,
-asb
Comments
Comment #1
hingo commentedHi
Even if the Footnotes module itself doesn't mind you using it together with some Wiki filter, in practice you should just use the type of Footnotes filter that matches the general markup style you are using. So, the correct solution would be to develop a third Footnotes style, compatible with wiki style. (Both for the Footnotes markup you write and what is output by the filter.) This is actually fairly simple to do, if you know basic php and preg_replace() you can start with copy pasting some code in the following 3 methods:
And as always, if you provide a patch, we will add it to the next release!
Comment #2
hingo commentedI've reviewed this and tried to see how it could be implemented.
Review
The PEAR Wiki Filter actually supports several markup styles: Mediawiki, TikiWiki, DokuWiki, Creole and BBCode.
I will skip Creole, as I understand it is not widespread. BBCode is a simple markup system used mainly in forums and I don't see a critical need for footnotes in it either. This leaves us with 3 wiki markup styles.
The Dokuwiki syntax defines markup for footnotes (http://wiki.splitbrain.org/wiki:syntax#footnotes) as does MediaWiki (http://meta.wikimedia.org/wiki/Help:Footnotes). TikiWiki doesn't seem to support footnotes, but it does have an api for arbitrary plugins (http://tikiwiki.org/tiki-index.php?page=PluginsList&bl) , which would be the right way to implement this for TikiWiki.
The problem, as far as I can see, is that none of the implementations in PEAR Text_Wiki_* actually support footnotes. (They are independent parsers that don't support the full syntaxes and all are also quite old it seems.)
Solutions
1) The right thing to do is obviously to go to the PEAR modules in question and add footnotes support to at least the MediaWiki and DocuWiki modules, in their respective syntaxes.
2) However, I do admit that at least the Textile variant in the Footnotes filter came to be simply because "Uh, I just want a simple hack that will support footnotes, I don't want to touch the Textile code itself." Therefore, I am sympathetic to the idea of Footnotes module supporting more markup styles.
Problems
The current style of Footnotes module is that the HTML variant reads a HTMLesque style of footnotes and outputs HTML. OTOH the Textile variant reads a footnote style similar to other Textile commands and outputs valid Textile syntax. (Which the Textile filter then makes into HTML.) In keeping with this strategy we should now implement 3 new variants for each of the MediaWiki, DocuWiki and TikiWiki syntaxes.
There is one problem with the above approach, that in creating the list of footnotes we are limited by the syntax of the variant we are using. Already now the Textile variant is not as cool as the HTML variant (the reference is not a link to the footnote, it is not as rich in CSS...). In particular, I don't see any of the above Wiki languages supporting links within the page (ie between the number in the main text and the footnote at the bottom). It seems that at best the Wiki languages support linking to headers only.
A smaller problem is of course just the need to support an ever growing list of syntaxes. This is not critical, but a drawback nevertheless.
Solution
It could be a better idea to restructure the Footnotes module as follows:
Example
Imagine some text that originally looks like this:
When user posts this text, the filters kicks in. First the Footnotes prepare operation shields the
<fn>tags. (See the time tag filter in http://api.drupal.org/api/HEAD/function/filter_example_filter)Note that the codes \xFE and \xFF are not really text, they are Unicode values that in real life are invisible.
Then the Wiki filter does it's job:
Note that a typical wiki filter may (or may not) strip away html tags (like
<b>) for security reasons. That's why<fn>had to be prepared.Now it is time to do the footnotes:
And after this HTML filter and HTML corrector may still do their jobs
PS
I've used some days of my vacation for maintenance of the Footnotes module. (And it's been great and I wish I could spend more time on it!) However, my vacation is now nearing its end so I just want to stress that the above review doesn't mean that I would actually have time to implement this any time soon. But this will probably be the next thing I implement whenever I have time to do that.
Comment #3
hingo commentedComment #4
wayland76 commentedJust to make things more difficult, the people who developed that wiki module are actually recommending that you go with the new flexifilters module, and they don't intend to upgrade to 6.x
http://drupal.org/project/flexifilter
HTH,
Comment #5
hingo commentedHi Wayland and thanks for keeping me updated.
While there has been no progress on this issue, I've kept my mind on it for a year now. I've tried to come up with various ways to best integrate with various wiki's. My conclusion is that only 2 options are good:
* Footnotes feature should be integrated with the various wiki-filters themselves. (As is the case with the real Mediawiki.) This is the best alternative as it allows for the best integration. However, this is obviously none of my business as the Footnotes maintainter.
* Implement a new Wiki-style Footnotes filter, just as we now have two, the Html and Textile style filters. This filter will accept footnotes with markup that fits into the wiki-style overall markup and outputs markup that is not html but rather something that one or more wiki filters will understand as input.
I've thought of various schemes to convert wiki-style input directly into html output, but this leads to all kinds of problems as to ordering of filters, so I am not considering them anymore.
So as a summary, I still intend to implement the second bullet point one day. As soon as #161217: URL filter breaks generated href tags is closed I guess.
Comment #6
hingo commentedI tried to Flexifilter, but it seems really really rudimentary and not ready for real use. It didn't support creating a simple bulleted list, and for some funny reason all links point to en.wikipedia.org.
I tried with the MediaWiki version of pearwiki_filter, which seems more usable. In fact you can use the current HTML filter just fine, the resulting HTML is passed throught the MediaWiki filter.
Re-reading the original question, it seems some of the new features are what asbdpl was asking for and by using the newest version of Footnotes, all should work fine. (Use the [fn]...[/fn] or ... version, not the Textile version.)
In particular, to get the URLs into links, replace Drupal's own URL filter with the "Better URL filter" that comes with Footnotes 6.x-2.x-dev version now.
Comment #7
Pushkar Gaikwad commentedIs there any work around for footnotes with mediawiki input format for 5.7 ? because I am certainly not able to use it
Comment #8
hingo commentedOh?
The http://ftp.drupal.org/files/projects/footnotes-6.x-2.x-dev.tar.gz version should be usable on 5.7, there is nothing 6.x specific in it. The [fn]...[/fn] style footnotes filter should work just fine with Mediawiki. If your experience is the opposite, please explain here.
Comment #9
Pushkar Gaikwad commentedhingo, you rocks! Working like a charm..
Comment #10
hingo commentedHeh. Thanks :-)