跳转到主要内容

rst2textile 是 docutils textile writer,可以将 reStructuredText(rst) 转换为 Textile 格式。

项目描述

rst2textile 是 docutils textile writer,可以将 reStructuredText(rst) 转换为 Textile 格式。

功能

  • Textile 的 docutils writer。

    • 支持的语法包括

      • 标题:h1/h2 等

      • 文档信息:字段列表(如 :Date: today)位于 rst 文件顶部。

      • 段落

      • 强调:*em*

      • 粗体:**strong**

      • 列表项:* egg

      • 枚举项:#. ham

      • 引用

      • 链接:`foo <http://example.com/>`_

      • 图片:.. image:: http://example.com/image.png

      • 字面量:``some code``::

  • Sphinx textile builder(实验性)。

    1. 编写 conf.py extensions = [‘docutils_textile’]

    2. 使用 sphinx-build -b textile source _build/textile 构建

安装

$ pip install rst2textile

如果您想使用未发布版本,可以从仓库安装

$ pip install -e hg+https://bitbucket.org/shimizukawa/rst2textile#egg=rst2textile

运行

$ rst2textile.py input.rst output.txt

$ python -m rst2textile input.rst output.txt

测试

$ python setup.py test

$ python test.py

依赖关系

  • Python 2.6, 2.7, 3.3, 3.4

  • Docutils 0.12, 0.11, 0.10

限制

待办事项

  • 文档

  • 实现一些 Textile 格式。

变更记录

0.2.1 (2014/10/04)

  • 修复:将表格列数减少为更短的行。

0.2.0 (2014/10/04)

  • 添加对 textile 表格输出的支持。感谢 tell-k。

  • 删除与 pysetup 相关的行。

  • 更改支持的 Python 版本:2.6, 2.7, 3.3, 3.4

  • 更改支持的 docutils 版本:0.12, 0.11, 0.10

0.1.1 (2012/4/29)

  • 添加支持的 Python 版本:2.4, 2.5, 2.6, 3.1, 3.2, 3.3

0.1.0 (2012/4/22)

  • 首次发布

  • 支持的语法:h1/h2.., docinfo, 段落, em, strong, 列表项, 枚举列表项, 块引用, 链接, 图片, 文字

转换示例

标题1

rst

==========
Heading1
==========

textile

h1. Heading1

标题

rst

==========
Heading1
==========

Heading2
==========

Heading3
----------

Heading4
^^^^^^^^^^

textile

h1. Heading1


h2. Heading2


h3. Heading3


h4. Heading4

文档信息

rst

HelloWorld
===========

:Date: Today
:Author: SpamEgg
:Location: Here

textile

h1. HelloWorld

Date:
   Today

Author:
   SpamEgg

Location:
   Here

段落

rst

Normal Text

textile

Normal Text

强调

rst

*emphasized* (e.g., italics)

textile

_emphasized_ (e.g., italics)

强烈强调

rst

**strongly emphasized** (e.g., boldface)

textile

*strongly emphasized* (e.g., boldface)

列表项

rst

- An item in a bulleted (unordered) list

- Another item in a bulleted list

  - Second Level

  * Second Level Items

    * Third level

textile

* An item in a bulleted (unordered) list
* Another item in a bulleted list
** Second Level
** Second Level Items
*** Third level

枚举列表项

rst

#. An item in an enumerated (ordered) list xxxxxxx
#. Another item in an enumerated list yyyyyy

   #. Another level in an enumerated list vvvvvvvv
   #. Another level in an enumerated list vvvvvvvv

#. 3rd element at indent level1

textile

# An item in an enumerated (ordered) list xxxxxxx
# Another item in an enumerated list yyyyyy
## Another level in an enumerated list vvvvvvvv
## Another level in an enumerated list vvvvvvvv
# 3rd element at indent level1

块引用

rst

Blockquotes

   This text will be enclosed in an HTML blockquote element.

   Second Paragraph.

textile

Blockquotes

bq. This text will be enclosed in an HTML blockquote element.
bq. Second Paragraph.

图片

rst

.. image:: http://example.com/image.jpg

.. figure:: local/image/path.png

textile

!http://example.com/image.jpg!

!local/image/path.png!

内部引用

rst

HelloWorld
===========

reference to HelloWorld_ !

textile

h1. HelloWorld

reference to "HelloWorld" !

文字(代码)

rst

::

   class Foo(object):

       def __init__(self, value):
           print "value = %d" % value
           raise NotImplementedError(u'EmptyClass')

textile

<pre>
class Foo(object):

    def __init__(self, value):
        print "value = %d" % value
        raise NotImplementedError(u'EmptyClass')
</pre>

表格

rst

+------------------------+------------+----------+----------+
| Header row, column 1   | Header 2   | Header 3 | Header 4 |
| (header rows optional) |            |          |          |
+========================+============+==========+==========+
| body row 1, column 1   | column 2   | column 3 | column 4 |
+------------------------+------------+----------+----------+
| body row 2             | ...        | ...      |          |
+------------------------+------------+----------+----------+

textile

|_.  Header row, column 1
(header rows optional)|_.  Header 2     |_.  Header 3   |_.  Header 4   |
| body row 1, column 1     | column 2     | column 3   | column 4   |
| body row 2               | ...          | ...        |            |

rst

=====  =====  =======
A      B      A and B
=====  =====  =======
False  False  False
True   False  False
False  True   False
True   True   True
=====  =====  =======

textile

|_.  A     |_.  B     |_.  A and B |
| False | False | False   |
| True  | False | False   |
| False | True  | False   |
| True  | True  | True    |

CSV 表格

rst

.. csv-table::
   :header: "Treat", "Quantity", "Description"
   :widths: 15, 10, 30

   "Albatross", 2.99, "On a stick!"
   "Crunchy Frog", 1.49, "If we took the bones out, it wouldn't be
   crunchy, now would it?"
   "Gannet Ripple", 1.99, "On a stick!"

textile

|_.  Treat           |_.  Quantity   |_.  Description                    |
| Albatross       | 2.99       | On a stick!                    |
| Crunchy Frog    | 1.49       | If we took the bones out, it wouldn't be
crunchy, now would it?|
| Gannet Ripple   | 1.99       | On a stick!                    |

列表表格

rst

.. list-table::
   :widths: 15 10 30
   :header-rows: 1

   * - Treat
     - Quantity
     - Description
   * - Albatross
     - 2.99
     - On a stick!
   * - Crunchy Frog
     - 1.49
     - If we took the bones out, it wouldn't be
       crunchy, now would it?
   * - Gannet Ripple
     - 1.99
     - On a stick!

textile

|_.  Treat           |_.  Quantity   |_.  Description                    |
| Albatross       | 2.99       | On a stick!                    |
| Crunchy Frog    | 1.49       | If we took the bones out, it wouldn't be
crunchy, now would it?|
| Gannet Ripple   | 1.99       | On a stick!                    |

项目详情


下载文件

下载适用于您平台的文件。如果您不确定选择哪个,请了解更多关于 安装包 的信息。

源分布

rst2textile-0.2.1.tar.gz (11.7 kB 查看哈希值)

上传时间

构建分布

rst2textile-0.2.1-py2.py3-none-any.whl (14.0 kB 查看哈希值)

上传时间 Python 2 Python 3

由以下组织支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误记录 StatusPage StatusPage 状态页面