[IPython-dev] Right to left markdown in IPython (1.0)

Ronen Abravanel ronena at gmail.com
Mon Aug 26 08:59:07 EDT 2013


Works, thanks!

But only combining with my previews hack ("my" code to alter the preloaded
page and Matthias' to handle new-generated content.




On Mon, Aug 26, 2013 at 10:57 AM, Matthias BUSSONNIER <
bussonniermatthias at gmail.com> wrote:

>
> Le 25 août 2013 à 22:11, Ronen Abravanel a écrit :
>
> > The issue itself is general, but all the response are about editing,
> which seems for me less important then display.  My 'extension' tries to
> solve the display part.
> >
> > Markdown dose not define any behavior for RTL text, and all I found
> online is some hacks (like the one I used). Real solution will be to extend
> markdown (marked?) both for implicit Right-to-left (like bidiweb is doing)
> and explicit (invent some 'set RTL' mark?). But that's seems for me event
> outside the scope of IPython.
> >
>
>
> Yes extending marked is outside of scope of IPython.
>
> Sadly we don't trigger even on markdown rendering. You can open an issue
> on github about that.
>
> the current rendering code is the following :
>
>
> MarkdownCell.prototype.render = function () {
>         if (this.rendered === false) {
>             var text = this.get_text();
>             var math = null;
>             if (text === "") { text = this.placeholder; }
>             var text_and_math = IPython.mathjaxutils.remove_math(text);
>             text = text_and_math[0];
>             math = text_and_math[1];
>             var html = marked.parser(marked.lexer(text));
>             html = $(IPython.mathjaxutils.replace_math(html, math));
>             // links in markdown cells should open in new tabs
>             html.find("a[href]").not('[href^="#"]').attr("target",
> "_blank");
>             try {
>                 this.set_rendered(html);
>             } catch (e) {
>                 console.log("Error running Javascript in Markdown:");
>                 console.log(e);
>                 this.set_rendered($("<div/>").addClass("js-error").html(
>                     "Error rendering Markdown!<br/>" + e.toString())
>                 );
>             }
>             this.element.find('div.text_cell_input').hide();
>             this.element.find("div.text_cell_render").show();
>             this.typeset()
>             this.rendered = true;
>         }
>     };
>
> I can give you the **bad** advice to monkey patch
> MarkdownCell.prototype.render
>
> to be the following + what you need to handle RTL.
> It is **only** a temporary solution that **will** break later.
>
>
> In custom js that would look ilke  :
>
> IPython.MarkdownCell.prototype.render = function () {
>         if (this.rendered === false) {
>             … same as above
>             this.typeset()
>
>             // triger even and/or bidiweb.style('.rendered_html *');
>             // or anly the `html` DOM above for speed.
>             // if you are greedy.
>             this.rendered = true;
>         }
>     };
>
>
> --
> M
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20130826/f74301db/attachment.html>


More information about the IPython-dev mailing list