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


Python pandocfilters.walk方法代码示例

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


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

示例1: dollarfy

# 需要导入模块: import pandocfilters [as 别名]
# 或者: from pandocfilters import walk [as 别名]
def dollarfy(x):
    """Replaces Math elements in element list `x` with a $-enclosed string.

    stringify() passes through TeX math.  Use dollarfy(x) first to replace
    Math elements with math strings set in dollars.  `x` should be a deep copy
    so that the underlying document is left untouched.

    Returns `x`, modified in-place.
    """

    def _dollarfy(key, value, fmt, meta):  # pylint: disable=unused-argument
        """Replaces Math elements"""
        if key == 'Math':
            return Str('$' + value[1] + '$')
        return None

    return walk(x, _dollarfy, '', {})


# extract_attrs() ------------------------------------------------------------ 
开发者ID:tomduck,项目名称:pandoc-xnos,代码行数:22,代码来源:core.py

示例2: test_insert_secnos_factory_1

# 需要导入模块: import pandocfilters [as 别名]
# 或者: from pandocfilters import walk [as 别名]
def test_insert_secnos_factory_1(self):
        """Tests insert_secnos_factory() #1."""

        ## test.md: ---\nxnos-number-sections: True\n...\n\n# Title\n\n$$ x $$ {#eq:1}\n ##

        # Command: pandoc test.md -t json
        src = eval(r'''{"blocks": [{"t": "Header", "c": [1, ["title", [], []], [{"t": "Str", "c": "Title"}]]}, {"t": "Para", "c": [{"t": "Math", "c": [{"t": "DisplayMath"}, " x "]}, {"t": "Space"}, {"t": "Str", "c": "{#eq:1}"}]}], "pandoc-api-version": [1, 17, 5, 4], "meta": {"xnos-number-sections": {"t": "MetaBool", "c": True}}}''')

        # Check src against current pandoc
        md = subprocess.Popen(('echo', '---\nxnos-number-sections: True\n...\n\n# Title\n\n$$ x $$ {#eq:1}\n'), stdout=subprocess.PIPE)

        output = eval(subprocess.check_output(
            'pandoc -t json'.split(),
            stdin=md.stdout).strip().decode("utf-8").replace('true', 'True'))
        self.assertEqual(src, output)

        expected = eval(r'''{"blocks": [{"t": "Header", "c": [1, ["title", [], []], [{"t": "Str", "c": "Title"}]]}, {"t": "Para", "c": [{"t": "Math", "c": [["eq:1", [], [["secno", 1]]], {"t": "DisplayMath"}, " x "]}, {"t": "Space"}]}], "pandoc-api-version": [1, 17, 5, 4], "meta": {"xnos-number-sections": {"t": "MetaBool", "c": True}}}''')

        # Make the comparison
        meta = src['meta']
        fmt = 'html'
        attach_attrs_math = attach_attrs_factory(Math, 0, allow_space=True)
        insert_secnos = insert_secnos_factory(Math)
        tmp = walk(src, attach_attrs_math, fmt, meta)
        self.assertEqual(walk(tmp, insert_secnos, fmt, meta), expected) 
开发者ID:tomduck,项目名称:pandoc-xnos,代码行数:27,代码来源:test.py

示例3: test_insert_secnos_factory_2

# 需要导入模块: import pandocfilters [as 别名]
# 或者: from pandocfilters import walk [as 别名]
def test_insert_secnos_factory_2(self):
        """Tests insert_secnos_factory() #2."""

        ## test.md: ---\nxnos-number-sections: True\n...\n\n# Title\n\n$$ x $$\n ##

        # Command: pandoc test.md -t json
        src = eval(r'''{"blocks": [{"t": "Header", "c": [1, ["title", [], []], [{"t": "Str", "c": "Title"}]]}, {"t": "Para", "c": [{"t": "Math", "c": [{"t": "DisplayMath"}, " x "]}]}], "pandoc-api-version": [1, 17, 5, 4], "meta": {"xnos-number-sections": {"t": "MetaBool", "c": True}}}''')

        # Check src against current pandoc
        md = subprocess.Popen(('echo', '---\nxnos-number-sections: True\n...\n\n# Title\n\n$$ x $$\n'), stdout=subprocess.PIPE)

        output = eval(subprocess.check_output(
            'pandoc -t json'.split(),
            stdin=md.stdout).strip().decode("utf-8").replace('true', 'True'))
        self.assertEqual(src, output)

        expected = eval(r'''{"blocks": [{"t": "Header", "c": [1, ["title", [], []], [{"t": "Str", "c": "Title"}]]}, {"t": "Para", "c": [{"t": "Math", "c": [{"t": "DisplayMath"}, " x "]}]}], "pandoc-api-version": [1, 17, 5, 4], "meta": {"xnos-number-sections": {"t": "MetaBool", "c": True}}}''')

        # Make the comparison
        meta = src['meta']
        fmt = 'html'
        attach_attrs_math = attach_attrs_factory(Math, 0, allow_space=True)
        insert_secnos = insert_secnos_factory(Math)
        tmp = walk(src, attach_attrs_math, fmt, meta)
        self.assertEqual(walk(tmp, insert_secnos, fmt, meta), expected) 
开发者ID:tomduck,项目名称:pandoc-xnos,代码行数:27,代码来源:test.py

示例4: test_repair_refs_1

# 需要导入模块: import pandocfilters [as 别名]
# 或者: from pandocfilters import walk [as 别名]
def test_repair_refs_1(self):
        """Tests repair_refs() #1."""

        ## test.md: {@doe:1999} ##

        # Command: pandoc-1.17.2 test.md -f markdown+autolink_bare_uris -t json
        src = eval(r'''[{"unMeta":{}},[{"t":"Para","c":[{"t":"Link","c":[["",[],[]],[{"t":"Str","c":"{@doe"}],["mailto:%7B@doe",""]]},{"t":"Str","c":":1999}"}]}]]''')

        # Command: pandoc-1.17.2 test.md -t json
        expected = eval(r'''[{"unMeta":{}},[{"t":"Para","c":[{"t":"Str","c":"{"},{"t":"Cite","c":[[{"citationSuffix":[],"citationNoteNum":0,"citationMode":{"t":"AuthorInText","c":[]},"citationPrefix":[],"citationId":"doe:1999","citationHash":0}],[{"t":"Str","c":"@doe:1999"}]]},{"t":"Str","c":"}"}]}]]''')

        # Make the comparison
        pandocxnos.init('1.17.2')
        self.assertEqual(walk(src, repair_refs, '', {}), expected)

    # NOTE: Broken refs are fixed with pandoc 1.18 
开发者ID:tomduck,项目名称:pandoc-xnos,代码行数:18,代码来源:test.py

示例5: test_repair_refs_3

# 需要导入模块: import pandocfilters [as 别名]
# 或者: from pandocfilters import walk [as 别名]
def test_repair_refs_3(self):
        """Tests repair_refs() #3."""

        ## test.md: See {+@eq:1}. ##

        # Command: pandoc-1.17.2 test.md -f markdown+autolink_bare_uris -t json
        src = eval(r'''[{"unMeta":{}},[{"t":"Para","c":[{"t":"Str","c":"See"},{"t":"Space","c":[]},{"t":"Link","c":[["",[],[]],[{"t":"Str","c":"{+@eq"}],["mailto:%7B+@eq",""]]},{"t":"Str","c":":1}."}]}]]''')

        # Command: pandoc test.md -t json
        expected = eval(r'''[{"unMeta":{}},[{"t":"Para","c":[{"t":"Str","c":"See"},{"t":"Space","c":[]},{"t":"Str","c":"{+"},{"t":"Cite","c":[[{"citationSuffix":[],"citationNoteNum":0,"citationMode":{"t":"AuthorInText","c":[]},"citationPrefix":[],"citationId":"eq:1","citationHash":0}],[{"t":"Str","c":"@eq:1"}]]},{"t":"Str","c":"}."}]}]]''')

        # Make the comparison
        pandocxnos.init('1.17.2')
        self.assertEqual(walk(src, repair_refs, {}, ''), expected)


    # NOTE: Broken refs are fixed with pandoc 1.18 
开发者ID:tomduck,项目名称:pandoc-xnos,代码行数:19,代码来源:test.py

示例6: test_repair_refs_4

# 需要导入模块: import pandocfilters [as 别名]
# 或者: from pandocfilters import walk [as 别名]
def test_repair_refs_4(self):
        """Tests repair_refs() #4."""

        ## test.md: *@fig:plot1 and {+@fig:plot3}a. ##

        # Command: pandoc-1.17.2 test.md -f markdown+autolink_bare_uris -t json
        src = eval(r'''[{"unMeta":{}},[{"t":"Para","c":[{"t":"Link","c":[["",[],[]],[{"t":"Str","c":"*@fig"}],["mailto:*@fig",""]]},{"t":"Str","c":":plot1"},{"t":"Space","c":[]},{"t":"Str","c":"and"},{"t":"Space","c":[]},{"t":"Link","c":[["",[],[]],[{"t":"Str","c":"{+@fig"}],["mailto:%7B+@fig",""]]},{"t":"Str","c":":plot3}a."}]}]]''')

        # Command: pandoc-1.17.2 test.md -t json
        expected = eval(r'''[{"unMeta":{}},[{"t":"Para","c":[{"t":"Str","c":"*"},{"t":"Cite","c":[[{"citationSuffix":[],"citationNoteNum":0,"citationMode":{"t":"AuthorInText","c":[]},"citationPrefix":[],"citationId":"fig:plot1","citationHash":0}],[{"t":"Str","c":"@fig:plot1"}]]},{"t":"Space","c":[]},{"t":"Str","c":"and"},{"t":"Space","c":[]},{"t":"Str","c":"{+"},{"t":"Cite","c":[[{"citationSuffix":[],"citationNoteNum":0,"citationMode":{"t":"AuthorInText","c":[]},"citationPrefix":[],"citationId":"fig:plot3","citationHash":0}],[{"t":"Str","c":"@fig:plot3"}]]},{"t":"Str","c":"}a."}]}]]''')

        # Make the comparison
        pandocxnos.init('1.17.2')
        self.assertEqual(walk(src, repair_refs, {}, ''), expected)


    # NOTE: Broken refs are fixed with pandoc 1.18 
开发者ID:tomduck,项目名称:pandoc-xnos,代码行数:19,代码来源:test.py

示例7: test_repair_refs_5

# 需要导入模块: import pandocfilters [as 别名]
# 或者: from pandocfilters import walk [as 别名]
def test_repair_refs_5(self):
        """Tests repair_refs() #5."""

        ## test.md: +@eq:1, ##

        # Command: pandoc-1.17.2 test.md -f markdown+autolink_bare_uris -t json
        src = eval(r'''[{"unMeta":{}},[{"t":"Para","c":[{"t":"Link","c":[["",[],[]],[{"t":"Str","c":"+@eq"}],["mailto:+@eq",""]]},{"t":"Str","c":":1,"}]}]]''')

        # Command: pandoc-1.17.2 test.md -t json
        expected = eval(r'''[{"unMeta":{}},[{"t":"Para","c":[{"t":"Str","c":"+"},{"t":"Cite","c":[[{"citationSuffix":[],"citationNoteNum":0,"citationMode":{"t":"AuthorInText","c":[]},"citationPrefix":[],"citationId":"eq:1","citationHash":0}],[{"t":"Str","c":"@eq:1"}]]},{"t":"Str","c":","}]}]]''')

        # Make the comparison
        pandocxnos.init('1.17.2')
        self.assertEqual(walk(src, repair_refs, {}, ''), expected)


    # NOTE: Broken refs are fixed with pandoc 1.18 
开发者ID:tomduck,项目名称:pandoc-xnos,代码行数:19,代码来源:test.py

示例8: test_repair_refs_6

# 需要导入模块: import pandocfilters [as 别名]
# 或者: from pandocfilters import walk [as 别名]
def test_repair_refs_6(self):
        """Tests repair_refs() #6."""

        ## test.md: {@fig:1{baz=bat}}a ##

        # Command: pandoc-1.17.2 test.md -f markdown+autolink_bare_uris -t json
        src = eval(r'''[{"unMeta":{}},[{"t":"Para","c":[{"t":"Link","c":[["",[],[]],[{"t":"Str","c":"{@fig"}],["mailto:%7B@fig",""]]},{"t":"Str","c":":1{baz=bat}}a"}]}]]''')

        # Command: pandoc-1.17.2 test.md -t json
        expected = eval(r'''[{"unMeta":{}},[{"t":"Para","c":[{"t":"Str","c":"{"},{"t":"Cite","c":[[{"citationSuffix":[],"citationNoteNum":0,"citationMode":{"t":"AuthorInText","c":[]},"citationPrefix":[],"citationId":"fig:1","citationHash":0}],[{"t":"Str","c":"@fig:1"}]]},{"t":"Str","c":"{baz=bat}}a"}]}]]''')

        # Make the comparison
        pandocxnos.init('1.17.2')
        self.assertEqual(walk(src, repair_refs, {}, ''), expected)


    # NOTE: Broken refs are fixed with pandoc 1.18 
开发者ID:tomduck,项目名称:pandoc-xnos,代码行数:19,代码来源:test.py

示例9: test_repair_refs_7

# 需要导入模块: import pandocfilters [as 别名]
# 或者: from pandocfilters import walk [as 别名]
def test_repair_refs_7(self):
        """Tests repair_refs() #7."""

        ## test.md: {@fig:1{baz=bat foo=bar}}a ##

        # Command: pandoc-1.17.2 test.md -f markdown+autolink_bare_uris -t json
        src = eval(r'''[{"unMeta":{}},[{"t":"Para","c":[{"t":"Link","c":[["",[],[]],[{"t":"Str","c":"{@fig"}],["mailto:%7B@fig",""]]},{"t":"Str","c":":1{baz=bat"},{"t":"Space","c":[]},{"t":"Str","c":"foo=bar}}a"}]}]]''')

        # Command: pandoc-1.17.2 test.md -t json
        expected = eval(r'''[{"unMeta":{}},[{"t":"Para","c":[{"t":"Str","c":"{"},{"t":"Cite","c":[[{"citationSuffix":[],"citationNoteNum":0,"citationMode":{"t":"AuthorInText","c":[]},"citationPrefix":[],"citationId":"fig:1","citationHash":0}],[{"t":"Str","c":"@fig:1"}]]},{"t":"Str","c":"{baz=bat"},{"t":"Space","c":[]},{"t":"Str","c":"foo=bar}}a"}]}]]''')

        # Make the comparison
        pandocxnos.init('1.17.2')
        self.assertEqual(walk(src, repair_refs, {}, ''), expected)


    # NOTE: Broken refs are fixed with pandoc 1.18 
开发者ID:tomduck,项目名称:pandoc-xnos,代码行数:19,代码来源:test.py

示例10: test_process_refs_factory_1

# 需要导入模块: import pandocfilters [as 别名]
# 或者: from pandocfilters import walk [as 别名]
def test_process_refs_factory_1(self):
        """Tests process_refs_factory() #1."""

        ## test.md: As shown in @fig:one. ##

        # Command: pandoc test.md -t json
        src = eval(r'''{"blocks":[{"t":"Para","c":[{"t":"Str","c":"As"},{"t":"Space"},{"t":"Str","c":"shown"},{"t":"Space"},{"t":"Str","c":"in"},{"t":"Space"},{"t":"Cite","c":[[{"citationSuffix":[],"citationNoteNum":0,"citationMode":{"t":"AuthorInText"},"citationPrefix":[],"citationId":"fig:one","citationHash":0}],[{"t":"Str","c":"@fig:one"}]]},{"t":"Str","c":"."}]}],"pandoc-api-version":[%s],"meta":{}}'''%PANDOC_API_VERSION)

        # Check src against current pandoc
        md = subprocess.Popen(('echo', 'As shown in @fig:one.'),
                              stdout=subprocess.PIPE)
        output = eval(subprocess.check_output(
            'pandoc -t json'.split(),
            stdin=md.stdout).strip())
        self.assertEqual(src, output)

        # Hand-coded (added empty attributes)
        expected = eval(r'''{"meta":{},"blocks":[{"t":"Para","c":[{"t":"Str","c":"As"},{"t":"Space"},{"t":"Str","c":"shown"},{"t":"Space"},{"t":"Str","c":"in"},{"t":"Space"},{"t":"Cite","c":[["",[],[]],[{"citationSuffix":[],"citationNoteNum":0,"citationMode":{"t":"AuthorInText"},"citationPrefix":[],"citationId":"fig:one","citationHash":0}],[{"t":"Str","c":"@fig:one"}]]},{"t":"Str","c":"."}]}],"pandoc-api-version":[%s]}'''%PANDOC_API_VERSION)

        # Make the comparison
        process_refs = process_refs_factory(None, ['fig:one'], 0)
        self.assertEqual(walk(src, process_refs, '', {}), expected) 
开发者ID:tomduck,项目名称:pandoc-xnos,代码行数:24,代码来源:test.py

示例11: test_process_refs_factory_2

# 需要导入模块: import pandocfilters [as 别名]
# 或者: from pandocfilters import walk [as 别名]
def test_process_refs_factory_2(self):
        """Tests process_refs_factory() #2."""

        ## test.md: (@eq:one) ##

        # Command: pandoc test.md -t json
        src = eval(
            r'''{"blocks":[{"t":"Para","c":[{"t":"Str","c":"("},{"t":"Cite","c":[[{"citationSuffix":[],"citationNoteNum":0,"citationMode":{"t":"AuthorInText"},"citationPrefix":[],"citationId":"eq:one","citationHash":0}],[{"t":"Str","c":"@eq:one"}]]},{"t":"Str","c":")"}]}],"pandoc-api-version":[%s],"meta":{}}'''%PANDOC_API_VERSION)

        # Check src against current pandoc
        md = subprocess.Popen(('echo', '(@eq:one)'), stdout=subprocess.PIPE)
        output = eval(subprocess.check_output(
            'pandoc -t json'.split(),
            stdin=md.stdout).strip())
        self.assertEqual(src, output)

        # Hand-coded (attributes added)
        expected = eval(r'''{"blocks":[{"t":"Para","c":[{"t":"Str","c":"("},{"t":"Cite","c":[["",[],[]],[{"citationSuffix":[],"citationNoteNum":0,"citationMode":{"t":"AuthorInText"},"citationPrefix":[],"citationId":"eq:one","citationHash":0}],[{"t":"Str","c":"@eq:one"}]]},{"t":"Str","c":")"}]}],"pandoc-api-version":[%s],"meta":{}}'''%PANDOC_API_VERSION)

        # Make the comparison
        process_refs = process_refs_factory(None, ['eq:one'], 0)
        self.assertEqual(walk(src, process_refs, '', {}), expected) 
开发者ID:tomduck,项目名称:pandoc-xnos,代码行数:24,代码来源:test.py

示例12: test_process_refs_factory_3

# 需要导入模块: import pandocfilters [as 别名]
# 或者: from pandocfilters import walk [as 别名]
def test_process_refs_factory_3(self):
        """Tests process_refs_factory() #3."""

        ## test.md: See {@tbl:1}. ##

        # Command: pandoc test.md -t json
        src = eval(r'''{"blocks":[{"t":"Para","c":[{"t":"Str","c":"See"},{"t":"Space"},{"t":"Str","c":"{"},{"t":"Cite","c":[[{"citationSuffix":[],"citationNoteNum":0,"citationMode":{"t":"AuthorInText"},"citationPrefix":[],"citationId":"tbl:1","citationHash":0}],[{"t":"Str","c":"@tbl:1"}]]},{"t":"Str","c":"}."}]}],"pandoc-api-version":[%s],"meta":{}}'''%PANDOC_API_VERSION)

        # Check src against current pandoc
        md = subprocess.Popen(('echo', 'See {@tbl:1}.'), stdout=subprocess.PIPE)
        output = eval(subprocess.check_output(
            'pandoc -t json'.split(), stdin=md.stdout).strip())
        self.assertEqual(src, output)

        # Hand-coded (braces stripped, attributes added)
        expected = eval(r'''{"meta":{},"blocks":[{"t":"Para","c":[{"t":"Str","c":"See"},{"t":"Space"},{"t":"Cite","c":[["",[],[]],[{"citationSuffix":[],"citationNoteNum":0,"citationMode":{"t":"AuthorInText"},"citationPrefix":[],"citationId":"tbl:1","citationHash":0}],[{"t":"Str","c":"@tbl:1"}]]},{"t":"Str","c":"."}]}],"pandoc-api-version":[%s],"meta":{}}'''%PANDOC_API_VERSION)

        # Make the comparison
        process_refs = process_refs_factory(None, ['tbl:1'], 0)
        self.assertEqual(walk(src, process_refs, '', {}), expected) 
开发者ID:tomduck,项目名称:pandoc-xnos,代码行数:22,代码来源:test.py

示例13: test_process_refs_factory_4

# 需要导入模块: import pandocfilters [as 别名]
# 或者: from pandocfilters import walk [as 别名]
def test_process_refs_factory_4(self):
        """Tests process_refs_factory() #4."""

        ## test.md: See +@eq:1. ##

        # Command: pandoc test.md -t json
        src = eval(r'''{"blocks":[{"t":"Para","c":[{"t":"Str","c":"See"},{"t":"Space"},{"t":"Str","c":"+"},{"t":"Cite","c":[[{"citationSuffix":[],"citationNoteNum":0,"citationMode":{"t":"AuthorInText"},"citationPrefix":[],"citationId":"eq:1","citationHash":0}],[{"t":"Str","c":"@eq:1"}]]},{"t":"Str","c":"."}]}],"pandoc-api-version":[%s],"meta":{}}'''%PANDOC_API_VERSION)

        # Check src against current pandoc
        md = subprocess.Popen(('echo', 'See +@eq:1.'), stdout=subprocess.PIPE)
        output = eval(subprocess.check_output(
            'pandoc -t json'.split(), stdin=md.stdout).strip())
        self.assertEqual(src, output)

        # Hand-coded (modifier extracted, attributes added)
        expected = eval(r'''{"meta":{},"blocks":[{"t":"Para","c":[{"t":"Str","c":"See"},{"t":"Space"},{"t":"Cite","c":[["",[],[["modifier","+"]]],[{"citationSuffix":[],"citationNoteNum":0,"citationMode":{"t":"AuthorInText"},"citationPrefix":[],"citationId":"eq:1","citationHash":0}],[{"t":"Str","c":"@eq:1"}]]},{"t":"Str","c":"."}]}],"pandoc-api-version":[%s]}'''%PANDOC_API_VERSION)

        # Make the comparison
        process_refs = process_refs_factory(None, ['eq:1'], 0)
        self.assertEqual(walk(src, process_refs, '', {}), expected) 
开发者ID:tomduck,项目名称:pandoc-xnos,代码行数:22,代码来源:test.py

示例14: test_process_refs_factory_5

# 需要导入模块: import pandocfilters [as 别名]
# 或者: from pandocfilters import walk [as 别名]
def test_process_refs_factory_5(self):
        """Tests process_refs_factory() #5."""

        ## test.md: See {+@tbl:1}. ##

        # Command: pandoc test.md -t json
        src = eval(r'''{"blocks":[{"t":"Para","c":[{"t":"Str","c":"See"},{"t":"Space"},{"t":"Str","c":"{+"},{"t":"Cite","c":[[{"citationSuffix":[],"citationNoteNum":0,"citationMode":{"t":"AuthorInText"},"citationPrefix":[],"citationId":"tbl:1","citationHash":0}],[{"t":"Str","c":"@tbl:1"}]]},{"t":"Str","c":"}."}]}],"pandoc-api-version":[%s],"meta":{}}'''%PANDOC_API_VERSION)

        # Check src against current pandoc
        md = subprocess.Popen(('echo', 'See {+@tbl:1}.'), stdout=subprocess.PIPE)
        output = eval(subprocess.check_output(
            'pandoc -t json'.split(), stdin=md.stdout).strip())
        self.assertEqual(src, output)

        # Hand-coded (braces stripped, modifier extracted, attributes added)
        expected = eval(r'''{"meta":{},"blocks":[{"t":"Para","c":[{"t":"Str","c":"See"},{"t":"Space"},{"t":"Cite","c":[["",[],[["modifier","+"]]],[{"citationSuffix":[],"citationNoteNum":0,"citationMode":{"t":"AuthorInText"},"citationPrefix":[],"citationId":"tbl:1","citationHash":0}],[{"t":"Str","c":"@tbl:1"}]]},{"t":"Str","c":"."}]}],"pandoc-api-version":[%s]}'''%PANDOC_API_VERSION)

        # Make the comparison
        process_refs = process_refs_factory(None, ['tbl:1'], 0)
        self.assertEqual(walk(src, process_refs, '', {}), expected) 
开发者ID:tomduck,项目名称:pandoc-xnos,代码行数:22,代码来源:test.py

示例15: test_process_refs_factory_7

# 需要导入模块: import pandocfilters [as 别名]
# 或者: from pandocfilters import walk [as 别名]
def test_process_refs_factory_7(self):
        """Tests process_refs_factory() #7."""

        ## test.md: See [+@eq:1]. ##

        # Command: pandoc test.md -t json
        src = eval(r'''{"blocks":[{"t":"Para","c":[{"t":"Str","c":"See"},{"t":"Space"},{"t":"Cite","c":[[{"citationSuffix":[],"citationNoteNum":0,"citationMode":{"t":"NormalCitation"},"citationPrefix":[{"t":"Str","c":"+"}],"citationId":"eq:1","citationHash":0}],[{"t":"Str","c":"[+@eq:1]"}]]},{"t":"Str","c":"."}]}],"pandoc-api-version":[%s],"meta":{}}'''%PANDOC_API_VERSION)

        # Check src against current pandoc
        md = subprocess.Popen(('echo', 'See [+@eq:1].'), stdout=subprocess.PIPE)
        output = eval(subprocess.check_output(
            'pandoc -t json'.split(), stdin=md.stdout).strip())
        self.assertEqual(src, output)

        # Hand-coded (modifier extracted, attributes added)
        expected = eval(r'''{"meta":{},"blocks":[{"t":"Para","c":[{"t":"Str","c":"See"},{"t":"Space"},{"t":"Cite","c":[["",[],[["modifier","+"]]],[{"citationSuffix":[],"citationNoteNum":0,"citationMode":{"t":"NormalCitation"},"citationPrefix":[],"citationId":"eq:1","citationHash":0}],[{"t":"Str","c":"[+@eq:1]"}]]},{"t":"Str","c":"."}]}],"pandoc-api-version":[%s]}'''%PANDOC_API_VERSION)

        # Make the comparison
        process_refs = process_refs_factory(None, ['eq:1'], 0)
        self.assertEqual(walk(src, process_refs, '', {}), expected) 
开发者ID:tomduck,项目名称:pandoc-xnos,代码行数:22,代码来源:test.py


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