本文整理汇总了Python中pandoc.Document方法的典型用法代码示例。如果您正苦于以下问题:Python pandoc.Document方法的具体用法?Python pandoc.Document怎么用?Python pandoc.Document使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pandoc
的用法示例。
在下文中一共展示了pandoc.Document方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_long_description
# 需要导入模块: import pandoc [as 别名]
# 或者: from pandoc import Document [as 别名]
def get_long_description():
long_description = open('README.md').read()
try:
import subprocess
import pandoc
process = subprocess.Popen(
['which pandoc'],
shell=True,
stdout=subprocess.PIPE,
universal_newlines=True)
pandoc_path = process.communicate()[0]
pandoc_path = pandoc_path.strip('\n')
pandoc.core.PANDOC_PATH = pandoc_path
doc = pandoc.Document()
doc.markdown = long_description
long_description = doc.rst
except:
print("Could not find pandoc or convert properly")
print(" make sure you have pandoc (system) and pyandoc (python module) installed")
return long_description
示例2: md_to_rst
# 需要导入模块: import pandoc [as 别名]
# 或者: from pandoc import Document [as 别名]
def md_to_rst(md):
import six
import pandoc
# pandoc.core.PANDOC_PATH = '/path/to/pandoc'
if isinstance(md, six.text_type):
md = md.encode('utf-8')
doc = pandoc.Document()
doc.markdown = md
result = doc.rst
if isinstance(result, bytes):
result = result.decode('utf-8')
return result
示例3: get_long_description
# 需要导入模块: import pandoc [as 别名]
# 或者: from pandoc import Document [as 别名]
def get_long_description():
long_description = open('README.md').read()
try:
import subprocess
import pandoc
doc = pandoc.Document()
doc.markdown = long_description.encode('utf-8')
open("README.rst", "wb").write(doc.rst)
except:
print("Could not find pandoc or convert properly")
print(" make sure you have pandoc (system) and pyandoc (python module) installed")
return long_description
示例4: get_long_description
# 需要导入模块: import pandoc [as 别名]
# 或者: from pandoc import Document [as 别名]
def get_long_description():
long_description = open('README.md').read()
try:
import subprocess
import pandoc
process = subprocess.Popen(
['which pandoc'],
shell=True,
stdout=subprocess.PIPE,
universal_newlines=True)
pandoc_path = process.communicate()[0]
pandoc_path = pandoc_path.strip('\n')
pandoc.core.PANDOC_PATH = pandoc_path
doc = pandoc.Document()
doc.markdown = long_description
long_description = doc.rst
open("README.rst", "w").write(doc.rst)
except:
if os.path.exists("README.rst"):
long_description = open("README.rst").read()
else:
print("Could not find pandoc or convert properly")
print(" make sure you have pandoc (system) and pyandoc (python module) installed")
return long_description
示例5: get_description
# 需要导入模块: import pandoc [as 别名]
# 或者: from pandoc import Document [as 别名]
def get_description():
with open('README.md') as f:
desc = f.read()
short = desc.split('===\n')[1].strip().split('\n')[0]
if pandoc:
doc = pandoc.Document()
doc.markdown = desc.encode('utf-8')
desc = doc.rst.decode('utf-8')
return short, desc
示例6: markdown_to_rst
# 需要导入模块: import pandoc [as 别名]
# 或者: from pandoc import Document [as 别名]
def markdown_to_rst(src):
pandoc.core.PANDOC_PATH = "/usr/local/bin/pandoc"
if not os.path.exists(pandoc.core.PANDOC_PATH):
raise Exception("Pandoc not available")
doc = pandoc.Document()
doc.markdown = open("README.md").read()
return doc.rst
示例7: include_readme
# 需要导入模块: import pandoc [as 别名]
# 或者: from pandoc import Document [as 别名]
def include_readme():
try:
import pandoc
except ImportError:
return ''
pandoc.core.PANDOC_PATH = find_executable('pandoc')
readme_file = os.path.join(os.path.dirname(__file__), 'README.md')
doc = pandoc.Document()
with open(readme_file, 'r') as rf:
doc.markdown = rf.read()
return doc.rst
示例8: include_readme
# 需要导入模块: import pandoc [as 别名]
# 或者: from pandoc import Document [as 别名]
def include_readme():
try:
import pandoc
except ImportError:
return b''
pandoc.core.PANDOC_PATH = find_executable('pandoc')
readme_file = os.path.join(os.path.dirname(__file__), 'README.md')
doc = pandoc.Document()
with open(readme_file, 'r') as rf:
doc.markdown = rf.read()
return doc.rst.decode('utf-8')