Markdown中的RTL [英] RTL in Markdown
问题描述
是否存在现有的Markdown附加规范,其中包括对RTL语言的支持?
Is there any existing addon spec for markdown that includes support for RTL languages?
我希望的是
This paragraph is left to right
<- This paragraph is right to left
或者什么...我可以调整解析器来处理此问题,但是我想确保它不存在.
Or something... I can tweak my parser to handle this but I want to make sure it doesn't exist already.
推荐答案
这是Markdown的JavaScript实现,(根据提交的评论)增加了对RTL语言(即阿拉伯语,希伯来语,叙利亚语,塔纳语)的支持.添加更多语言似乎很容易.
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/
它基于Showdown, http://attacklab.net/showdown .
It's based on Showdown, http://attacklab.net/showdown.
似乎可以自动理解是否从右向左呈现文本.
考虑以下代码片段:(从GitHub的第一次提交开始)
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 = "<p>";
var rtl_p_tag = "<p style='direction:rtl; text-align: right'>";
// 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
这篇关于Markdown中的RTL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!