RTL in Markdown

前端 未结 6 1516
离开以前
离开以前 2021-01-30 03:05

Is there any existing addon spec for markdown that includes support for RTL languages?

What I\'m hoping for is something like

This paragraph is left t         


        
6条回答
  •  爱一瞬间的悲伤
    2021-01-30 03:32

    Here is a JavaScript implementation of Markdown, which (according to the commit comments) adds support for RTL languages, namely Arabic, Hebrew, Syriac, Thaana. And it seems trivially easy to add more languages.

    https://github.com/hasenj/showdown/

    It's based on Showdown, http://attacklab.net/showdown.

    It seems to automatically understand whether or not to render the text from right to left.
    Consider this code snippet: (from the very first commit at GitHub)

    var p_tag = "

    "; var rtl_p_tag = "

    "; // Check for RTL paragraphs: paragraphs that start with a character // from an RTL script. // RTL scripts are: Arabic, Hebrew, Syriac, Thaana // Unicode ranges reference: http://www.ssec.wisc.edu/~tomw/java/unicode.html var first_char = str.charCodeAt(str.search(/\S/)); //first non-white-space char if(first_char >= 1424 && first_char <= 1983) { p_tag = rtl_p_tag; } str = _RunSpanGamut(str); str = str.replace(/^([ \t]*)/g, p_tag);

    Hope this helps,
    Magnus

提交回复
热议问题