代码之家  ›  专栏  ›  技术社区  ›  Paul Biggar

我可以在重组文本中添加“Smartypants”吗?

  •  5
  • Paul Biggar  · 技术社区  · 14 年前

    我使用重构文本,我喜欢smartypants做的减价。有没有一种方法可以为StructuredText启用相同的功能?

    2 回复  |  直到 14 年前
        1
  •  2
  •   Alex Martelli    14 年前

    你试过了吗 smartypants.py restructuredText

    如果这对您不起作用,那么用户已经提交了 patch 到python-markdown2,他称之为“这个SmartyPants补丁”--它已经被接受了,从一个月前开始,它就是python-markdown2当前源代码树的一部分( r259 svn tree

        2
  •  1
  •   Paul Biggar    14 年前

    正如亚历克斯·马尔泰利所说,智能蚂蚁是我所需要的。然而,我正在寻找关于如何使用它的更详细的信息。下面是一个Python脚本,它读取第一个命令行参数中命名的文件,将其转换为HTML,使用Pygments sourcecode

    #!/usr/bin/python
    # EASY-INSTALL-SCRIPT: 'docutils==0.5','rst2html.py'
    """
    A minimal front end to the Docutils Publisher, producing HTML.
    """
    
    try:
        from ulif.rest import directives_plain
        from ulif.rest import roles_plain
        from ulif.rest import pygments_directive
    
        import locale
        locale.setlocale(locale.LC_ALL, '')
    except:
      pass
    
    from docutils.core import publish_doctree, publish_from_doctree
    from smartypants import smartyPants
    import sys
    
    
    description = ('Personal docutils parser with extra features.')
    
    doctree = publish_doctree(file(sys.argv[1]).read())
    result = publish_from_doctree(doctree, writer_name='html')
    result = smartyPants(result)
    print result