<div dir="ltr">And now on github:<br><a href="https://github.com/ronenabr/ipython_bidi_markdown">https://github.com/ronenabr/ipython_bidi_markdown</a><br><br></div><div class="gmail_extra"><br><br><div class="gmail_quote">

On Mon, Aug 26, 2013 at 3:59 PM, Ronen Abravanel <span dir="ltr"><<a href="mailto:ronena@gmail.com" target="_blank">ronena@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div dir="ltr"><div><div>Works, thanks! <br><br></div>But only combining with my previews hack ("my" code to alter the preloaded page and <span name="Matthias BUSSONNIER">Matthias' to handle new-generated content.<br>


<br></span></div><span name="Matthias BUSSONNIER"><br></span></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Aug 26, 2013 at 10:57 AM, Matthias BUSSONNIER <span dir="ltr"><<a href="mailto:bussonniermatthias@gmail.com" target="_blank">bussonniermatthias@gmail.com</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
Le 25 août 2013 à 22:11, Ronen Abravanel a écrit :<br>
<div><br>
> 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.<br>
><br>
> 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.<br>



><br>
<br>
<br>
</div>Yes extending marked is outside of scope of IPython.<br>
<br>
Sadly we don't trigger even on markdown rendering. You can open an issue on github about that.<br>
<br>
the current rendering code is the following :<br>
<br>
<br>
MarkdownCell.prototype.render = function () {<br>
        if (this.rendered === false) {<br>
            var text = this.get_text();<br>
            var math = null;<br>
            if (text === "") { text = this.placeholder; }<br>
            var text_and_math = IPython.mathjaxutils.remove_math(text);<br>
            text = text_and_math[0];<br>
            math = text_and_math[1];<br>
            var html = marked.parser(marked.lexer(text));<br>
            html = $(IPython.mathjaxutils.replace_math(html, math));<br>
            // links in markdown cells should open in new tabs<br>
            html.find("a[href]").not('[href^="#"]').attr("target", "_blank");<br>
            try {<br>
                this.set_rendered(html);<br>
            } catch (e) {<br>
                console.log("Error running Javascript in Markdown:");<br>
                console.log(e);<br>
                this.set_rendered($("<div/>").addClass("js-error").html(<br>
                    "Error rendering Markdown!<br/>" + e.toString())<br>
                );<br>
            }<br>
            this.element.find('div.text_cell_input').hide();<br>
            this.element.find("div.text_cell_render").show();<br>
            this.typeset()<br>
            this.rendered = true;<br>
        }<br>
    };<br>
<br>
I can give you the **bad** advice to monkey patch<br>
MarkdownCell.prototype.render<br>
<br>
to be the following + what you need to handle RTL.<br>
It is **only** a temporary solution that **will** break later.<br>
<br>
<br>
In custom js that would look ilke  :<br>
<br>
IPython.MarkdownCell.prototype.render = function () {<br>
        if (this.rendered === false) {<br>
            … same as above<br>
            this.typeset()<br>
<br>
            // triger even and/or bidiweb.style('.rendered_html *');<br>
            // or anly the `html` DOM above for speed.<br>
            // if you are greedy.<br>
            this.rendered = true;<br>
        }<br>
    };<br>
<span><font color="#888888"><br>
<br>
--<br>
</font></span><div><div>M<br>
_______________________________________________<br>
IPython-dev mailing list<br>
<a href="mailto:IPython-dev@scipy.org" target="_blank">IPython-dev@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/ipython-dev" target="_blank">http://mail.scipy.org/mailman/listinfo/ipython-dev</a><br>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>