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

Matthias BUSSONNIER bussonniermatthias@gmail....
Mon Aug 26 02:57:57 CDT 2013

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 {
            } catch (e) {
                console.log("Error running Javascript in Markdown:");
                    "Error rendering Markdown!<br/>" + e.toString())
            this.rendered = true;

I can give you the **bad** advice to monkey patch 

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

	    // triger even and/or bidiweb.style('.rendered_html *');
	    // or anly the `html` DOM above for speed.
            // if you are greedy.
            this.rendered = true;


More information about the IPython-dev mailing list