当前位置: 首页>>代码示例>>Python>>正文


Python AsciiDocAPI.options方法代码示例

本文整理汇总了Python中asciidocapi.AsciiDocAPI.options方法的典型用法代码示例。如果您正苦于以下问题:Python AsciiDocAPI.options方法的具体用法?Python AsciiDocAPI.options怎么用?Python AsciiDocAPI.options使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在asciidocapi.AsciiDocAPI的用法示例。


在下文中一共展示了AsciiDocAPI.options方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: htmlize

# 需要导入模块: from asciidocapi import AsciiDocAPI [as 别名]
# 或者: from asciidocapi.AsciiDocAPI import options [as 别名]
def htmlize(filename):
	asciidoc = AsciiDocAPI('../asciidoc/asciidoc.py')
	outfile = StringIO.StringIO()
	asciidoc.options('--no-header-footer')
	#asciidoc.options.append('--attribute', 'linkcss=untroubled.css')
	asciidoc.execute(filename, outfile) #, backend='html5')
	return str(outfile.getvalue())
开发者ID:martina-if,项目名称:pywi,代码行数:9,代码来源:htmlize.py

示例2: read

# 需要导入模块: from asciidocapi import AsciiDocAPI [as 别名]
# 或者: from asciidocapi.AsciiDocAPI import options [as 别名]
    def read(self, source_path):
        """Parse content and metadata of asciidoc files"""
        from cStringIO import StringIO
        with pelican_open(source_path) as source:
            text = StringIO(source)
        content = StringIO()
        ad = AsciiDocAPI()

        options = self.settings.get('ASCIIDOC_OPTIONS', [])
        if isinstance(options, (str, unicode)):
            options = [m.strip() for m in options.split(',')]
        options = self.default_options + options
        for o in options:
            ad.options(*o.split())

        ad.execute(text, content, backend="html4")
        content = content.getvalue()

        metadata = {}
        for name, value in ad.asciidoc.document.attributes.items():
            name = name.lower()
            metadata[name] = self.process_metadata(name, value)
        if 'doctitle' in metadata:
            metadata['title'] = metadata['doctitle']
        return content, metadata
开发者ID:AndreLesa,项目名称:pelican,代码行数:27,代码来源:readers.py

示例3: run

# 需要导入模块: from asciidocapi import AsciiDocAPI [as 别名]
# 或者: from asciidocapi.AsciiDocAPI import options [as 别名]
def run(content):
    infile = StringIO.StringIO(content)
    outfile = StringIO.StringIO()
    asciidoc = AsciiDocAPI()
    asciidoc.options('--no-header-footer')
    asciidoc.execute(infile, outfile, backend='html4')
    return outfile.getvalue()
开发者ID:Alsivkov,项目名称:ofSite,代码行数:9,代码来源:__init__.py

示例4: asciidoc_output

# 需要导入模块: from asciidocapi import AsciiDocAPI [as 别名]
# 或者: from asciidocapi.AsciiDocAPI import options [as 别名]
	def asciidoc_output(self,asciidoc_markup,backend='xhtml11',attributes=[],options=['--no-header-footer'],debug=False):
		infile = StringIO.StringIO(asciidoc_markup)
		outfile = StringIO.StringIO()
		asciidoc = AsciiDocAPI('../../../asciidoc.py')
		for option in options:
			asciidoc.options(option)
		for attribute in attributes:
			asciidoc.attributes[attribute] = 1
		asciidoc.execute(infile, outfile,backend)
		if debug: print asciidoc.messages
		return outfile.getvalue()
开发者ID:Ailenswpu,项目名称:external,代码行数:13,代码来源:slidy2_UnitTest.py

示例5: render

# 需要导入模块: from asciidocapi import AsciiDocAPI [as 别名]
# 或者: from asciidocapi.AsciiDocAPI import options [as 别名]
 def render(self, context):
     output = self.nodelist.render(context)
     try:
         from asciidocapi import AsciiDocAPI
     except ImportError:
         print u"Requires AsciiDoc library to use AsciiDoc tag."
         raise
     asciidoc = AsciiDocAPI()
     asciidoc.options("--no-header-footer")
     result = StringIO.StringIO()
     asciidoc.execute(StringIO.StringIO(output.encode("utf-8")), result, "html4")
     return safestring.mark_safe(result.getvalue())
开发者ID:andrulik,项目名称:hyde,代码行数:14,代码来源:aym.py

示例6: read

# 需要导入模块: from asciidocapi import AsciiDocAPI [as 别名]
# 或者: from asciidocapi.AsciiDocAPI import options [as 别名]
 def read(self, filename):
   """Parse content and metadata of asciidoc files"""
   ad = AsciiDocAPI()
   ad.options('--no-header-footer')
   ad.attributes['pygments'] = 'pygments'
   if self.settings['ASCIIDOC_CONF']:
     ad.attributes['conf-files'] = self.settings['ASCIIDOC_CONF']
   buf = StringIO.StringIO()
   ad.execute(filename, buf, 'html5')
   content = buf.getvalue()
   buf.close()
   meta = self.read_meta(filename)
   return content, meta
开发者ID:jedahu,项目名称:pelican,代码行数:15,代码来源:readers.py

示例7: __init__

# 需要导入模块: from asciidocapi import AsciiDocAPI [as 别名]
# 或者: from asciidocapi.AsciiDocAPI import options [as 别名]
 def __init__(self,asciidocpath):
     adfile = open(asciidocpath,'r')
     outfile = StringIO.StringIO()
     asciidoc = AsciiDocAPI()
     asciidoc.options('--no-header-footer')
     asciidoc.execute(adfile, outfile, backend='html4')
     attributes = asciidoc.asciidoc.document.attributes #.attributes.values
     #print attributes
     self.file = os.path.basename(asciidocpath[:asciidocpath.find('.asciidoc')]) + '.html'
     self.date = attributes['date']
     self.title = attributes['doctitle']
     self.summary = attributes['summary']
     self.author = attributes['author']
     self.author_site = attributes['author_site']
     self.body = outfile.getvalue().decode('utf-8','replace')
     self.type = 'asciidoc'
开发者ID:kpasko,项目名称:ofSite,代码行数:18,代码来源:tutorials.py

示例8: asciidoc

# 需要导入模块: from asciidocapi import AsciiDocAPI [as 别名]
# 或者: from asciidocapi.AsciiDocAPI import options [as 别名]
def asciidoc(env, value):
    """
    (simple) Asciidoc filter
    """
    try:
        from asciidocapi import AsciiDocAPI
    except ImportError:
        print(u"Requires AsciiDoc library to use AsciiDoc tag.")
        raise

    output = value

    asciidoc = AsciiDocAPI()
    asciidoc.options("--no-header-footer")
    result = StringIO()
    asciidoc.execute(StringIO(output.encode("utf-8")), result, backend="html4")
    return str(result.getvalue(), "utf-8")
开发者ID:hyde,项目名称:hyde,代码行数:19,代码来源:jinja.py

示例9: asciidoc

# 需要导入模块: from asciidocapi import AsciiDocAPI [as 别名]
# 或者: from asciidocapi.AsciiDocAPI import options [as 别名]
def asciidoc(env, value):
    """
    (simple) Asciidoc filter
    """
    try:
        from asciidocapi import AsciiDocAPI
    except ImportError:
        print u"Requires AsciiDoc library to use AsciiDoc tag."
        raise

    import StringIO
    output = value

    asciidoc = AsciiDocAPI()
    asciidoc.options('--no-header-footer')
    result = StringIO.StringIO()
    asciidoc.execute(StringIO.StringIO(output.encode('utf-8')), result, backend='html4')
    return unicode(result.getvalue(), "utf-8")
开发者ID:DaveRichmond,项目名称:hyde,代码行数:20,代码来源:jinja.py

示例10: AsciiDocModule

# 需要导入模块: from asciidocapi import AsciiDocAPI [as 别名]
# 或者: from asciidocapi.AsciiDocAPI import options [as 别名]
class AsciiDocModule(Module):

    def _configure(self):
        self._asciidoc = AsciiDocAPI()
        self._asciidoc.attributes['root'] = self._conf['destdir']
        self._asciidoc.attributes['source-highlighter'] = 'pygments'
        self._asciidoc.attributes['caption'] = ''
        self._asciidoc.attributes['iconsdir'] = '/usr/share/asciidoc/icons/'
        self._asciidoc.attributes['confdir'] = os.path.join(self._conf['maindir'], 'asciidoc')
        conf_file = os.path.join(self._asciidoc.attributes['confdir'], 'asciidoc-devyco.conf')
        self._asciidoc.options('--conf-file', conf_file)
        self._asciidoc.options('--no-header-footer')
        self.processed_files = []

    def _run(self):
        for item in self.list_files(['*.adoc', '*.asciidoc', '*.txt']):
            target = noext(item) + '.partial'
            self._convert(item, target)
            self._post_process(target)

    def _convert(self, source, target):
        try:
            self._asciidoc.execute(source, target)
            for message in self._asciidoc.messages:
                sys.stderr.write('Error parsing Asciidoc file %s: %s\n' %
                                 (source, message))
            self.processed_files.append(source)
        except AsciiDocError as e:
            sys.stderr.write("Error parsing AsciiDoc in file: %s\n" % source)
            sys.stderr.write("%s\n" % e.message)

    def _post_process(self, target):
        with codecs.open(target,'r',encoding='utf8') as f:
            soup = BeautifulSoup(f, 'html.parser')
        for link in soup.find_all('a', href=ADOC_LINK):
            link['href'] = noext(link['href']) + '.html'

        with open(target, 'w') as f:
            f.write(soup.encode('utf-8'))

    def cleanup(self, context):
        for f in self.processed_files:
            os.remove(f)
开发者ID:Yubico,项目名称:developers.yubico.com,代码行数:45,代码来源:asciidoc.py

示例11: open

# 需要导入模块: from asciidocapi import AsciiDocAPI [as 别名]
# 或者: from asciidocapi.AsciiDocAPI import options [as 别名]
#!/usr/bin/env python

import sys
import yaml
from jinja2 import Template
from asciidocapi import AsciiDocAPI
from StringIO import StringIO

t_content = ""
with open(sys.argv[1], 'r') as f:
    t_content = f.read().decode('utf8')
template = Template(t_content)
obj = yaml.load(sys.stdin)
sys.stderr.write(str(obj))

in_data = StringIO(template.render(obj).encode('utf8'))
out_data = StringIO()
asciidoc = AsciiDocAPI()
asciidoc.options('--no-header-footer')
asciidoc.execute(in_data, out_data, backend='xhtml11')
sys.stdout.write(out_data.getvalue())
开发者ID:man0xff,项目名称:asciidoc-yaml2any,代码行数:23,代码来源:yaml2any.py


注:本文中的asciidocapi.AsciiDocAPI.options方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。