Skip to content

Commit 4a104b5

Browse files
committed
Updating for pandoc 1.16
1 parent 443308b commit 4a104b5

2 files changed

Lines changed: 10 additions & 24 deletions

File tree

pandoc_numbering.py

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Pandoc filter to number all kinds of things.
55
"""
66

7-
from pandocfilters import walk, stringify, Str, Space, Para, Strong, Span, Link, Emph, RawInline
7+
from pandocfilters import toJSONFilters, walk, stringify, Str, Space, Para, Strong, Span, Link, Emph, RawInline
88
from functools import reduce
99
import sys
1010
import json
@@ -16,26 +16,6 @@
1616
count = {}
1717
information = {}
1818

19-
def toJSONFilters(actions):
20-
"""Converts a list of actions into a filter
21-
"""
22-
try:
23-
input_stream = io.TextIOWrapper(sys.stdin.buffer, encoding='utf-8')
24-
except AttributeError:
25-
# Python 2 does not have sys.stdin.buffer.
26-
# REF: http://stackoverflow.com/questions/2467928/python-unicodeencodeerror-when-reading-from-stdin
27-
input_stream = codecs.getreader("utf-8")(sys.stdin)
28-
29-
doc = json.loads(input_stream.read())
30-
31-
if len(sys.argv) > 1:
32-
format = sys.argv[1]
33-
else:
34-
format = ""
35-
36-
altered = reduce(lambda x, action: walk(x, action, format, doc[0]['unMeta']), actions, doc)
37-
json.dump(altered, sys.stdout)
38-
3919
def removeAccents(string):
4020
nfkd_form = unicodedata.normalize('NFKD', string)
4121
return u"".join([c for c in nfkd_form if not unicodedata.combining(c)])
@@ -122,7 +102,13 @@ def referencing(key, value, format, meta):
122102

123103
# Is it a link with a right reference?
124104
if key == 'Link':
125-
[text, [reference, title]] = value
105+
try:
106+
# pandoc 1.15
107+
[text, [reference, title]] = value
108+
except ValueError:
109+
# pandoc 1.16
110+
[attributes, text, [reference, title]] = value
111+
126112
if re.match('^#([a-zA-Z][\w:.-]*)?$', reference):
127113
# Compute the name
128114
tag = reference[1:]

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
# Versions should comply with PEP440. For a discussion on single-sourcing
2929
# the version across setup.py and the project code, see
3030
# https://packaging.python.org/en/latest/single_source_version.html
31-
version='0.3.2',
31+
version='0.3.3',
3232

3333
# The project's description
3434
description='A pandoc filter for automatic numbering',
@@ -95,7 +95,7 @@
9595
# your project is installed. For an analysis of "install_requires" vs pip's
9696
# requirements files see:
9797
# https://packaging.python.org/en/latest/requirements.html
98-
install_requires=['pandocfilters'],
98+
install_requires=['pandocfilters>=1.3'],
9999

100100
# List additional groups of dependencies here (e.g. development
101101
# dependencies). You can install these using the following syntax,

0 commit comments

Comments
 (0)