troelskn / upflow

Flowing markdown upstream
http://troelskn.github.com/upflow/
33 stars 3 forks source link

Custom converter on initialization #1

Open NV opened 14 years ago

NV commented 14 years ago
upflow.attach(
    document.getElementById("canvas"),
    document.getElementById("content"),
    my_converter);

I want to set up my own converter on initialization.

Now I can do it by upflow.showdown = my_converter, but it will override converter for all instances of upflow. This is not good in case which is contain two different converters in one page (for example, Markdown and Textile).

I've tried patch upflow by myself with no luck. It was harder than I thought.

troelskn commented 14 years ago

I'm afraid that's probably going to be slightly more difficult than that. Even if the library was changed to make filters a property of canvas, rather than a global, there are other places where upflow assumes that it's working with markdown. Such as upflow.parseToTokens and upflow.roundTrip.

That said, I think it could be done with some refactoring. Do you have a javascript implementation of textile at hand?

NV commented 14 years ago

http://jrm.cc/extras/live-textile-preview.php