将格式化的纯文本转换为HTML

时间:2012-09-12 09:38:46

标签: javascript jquery html

我有一堆像这样格式化的数据,在预标签中显示效果很好:

1: Here's my first row, and it is
   quite long...
   and can span over several rows.
2: This is the second row.

但是,我希望对它有一些控制权,可能会把它变成html:

<ol>
    <li>Here's my first row, and it is<br/>quite long...<br/>and can span over several rows.</li>
    <li>This is the second row</li>
</ol>

我似乎无法在线找到pre-to-html-converter。我该怎么做呢?

干杯!

2 个答案:

答案 0 :(得分:2)

将文本文件转换为HTML的常用工具是MarkdownTextile。每个都有很多实现(和维基百科列表8 JS implementations of Markdown)。

我怀疑开箱即可适应你所拥有的特定文本,但他们的源代码应该是一个合理的起点。

答案 1 :(得分:1)

尝试使用Wiki标记引擎like the one that SO uses