reference-handler 0.9.1__py2.py3-none-any.whl → 0.9.3__py2.py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,6 +12,6 @@ from .latex_utf8 import encode_latex # noqa: F401
12
12
  from ._version import get_versions
13
13
 
14
14
  versions = get_versions()
15
- __version__ = versions['version']
16
- __git_revision__ = versions['full-revisionid']
15
+ __version__ = versions["version"]
16
+ __git_revision__ = versions["full-revisionid"]
17
17
  del get_versions, versions
@@ -8,11 +8,11 @@ import json
8
8
 
9
9
  version_json = '''
10
10
  {
11
- "date": "2021-05-05T14:18:44-0400",
11
+ "date": "2026-10-17T13:57:51-0400",
12
12
  "dirty": false,
13
13
  "error": null,
14
- "full-revisionid": "2c570bee48e7419570bf15fd999fa83a68c0453a",
15
- "version": "0.9.1"
14
+ "full-revisionid": "96f322852777846d0aefaa5f66e71ba58794b5ee",
15
+ "version": "0.9.3"
16
16
  }
17
17
  ''' # END VERSION_JSON
18
18
 
@@ -70,54 +70,53 @@ import re
70
70
  import typing
71
71
  import unicodedata
72
72
 
73
- alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
73
+ alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
74
74
 
75
75
  # LaTeX characters in accent macros of form \<char>{<letter>}, i.e. \"{u}
76
76
  accent = {
77
- '"': '\N{Combining Diaeresis}',
78
- "'": '\N{Combining Acute Accent}',
79
- '.': '\N{Combining Dot Above}',
80
- '=': '\N{Combining Macron}',
81
- '^': '\N{Combining Circumflex Accent}',
82
- '`': '\N{Combining Grave Accent}',
83
- '|': '\N{Combining Vertical Line Above}',
84
- '~': '\N{Combining Tilde}',
85
- 'b': '\N{Combining Macron Below}',
86
- 'c': '\N{Combining Cedilla}',
87
- 'C': '\N{Combining Double Grave Accent}',
88
- 'd': '\N{Combining Dot Below}',
89
- 'f': '\N{Combining Inverted Breve}',
90
- 'h': '\N{Combining Hook Above}',
91
- 'H': '\N{Combining Double Acute Accent}',
92
- 'k': '\N{Combining Ogonek}',
93
- 'r': '\N{Combining Ring Above}',
94
- 't': '\N{Combining Double Inverted Breve}',
95
- 'u': '\N{Combining Breve}',
96
- 'U': '\N{Combining Double Vertical Line Above}',
97
- 'v': '\N{Combining Caron}'
77
+ '"': "\N{COMBINING DIAERESIS}",
78
+ "'": "\N{COMBINING ACUTE ACCENT}",
79
+ ".": "\N{COMBINING DOT ABOVE}",
80
+ "=": "\N{COMBINING MACRON}",
81
+ "^": "\N{COMBINING CIRCUMFLEX ACCENT}",
82
+ "`": "\N{COMBINING GRAVE ACCENT}",
83
+ "|": "\N{COMBINING VERTICAL LINE ABOVE}",
84
+ "~": "\N{COMBINING TILDE}",
85
+ "b": "\N{COMBINING MACRON BELOW}",
86
+ "c": "\N{COMBINING CEDILLA}",
87
+ "C": "\N{COMBINING DOUBLE GRAVE ACCENT}",
88
+ "d": "\N{COMBINING DOT BELOW}",
89
+ "f": "\N{COMBINING INVERTED BREVE}",
90
+ "h": "\N{COMBINING HOOK ABOVE}",
91
+ "H": "\N{COMBINING DOUBLE ACUTE ACCENT}",
92
+ "k": "\N{COMBINING OGONEK}",
93
+ "r": "\N{COMBINING RING ABOVE}",
94
+ "t": "\N{COMBINING DOUBLE INVERTED BREVE}",
95
+ "u": "\N{COMBINING BREVE}",
96
+ "U": "\N{COMBINING DOUBLE VERTICAL LINE ABOVE}",
97
+ "v": "\N{COMBINING CARON}",
98
98
  }
99
99
 
100
100
  # The regexp to detect the LaTeX accent commands. The two added characters
101
101
  # are the dotless i and j.
102
- accent_re = re.compile(
103
- r'\\([' + ''.join(accent.keys()) + r']){([a-zA-Z\u0131\u0237])}'
104
- )
102
+ accent_re = re.compile(r"\\([" + "".join(accent.keys()) + r"]){([a-zA-Z\u0131\u0237])}")
105
103
 
106
104
  # Invert the accent dictionary for each letter in the alphabet to make
107
105
  # a dictionary of LaTeX encodings.
108
106
  encoding = {}
109
107
  for key, val in accent.items():
110
108
  for char in list(alphabet):
111
- encoding[char + val] = '\\' + key + '{' + char + '}'
109
+ encoding[char + val] = "\\" + key + "{" + char + "}"
112
110
  # handle any precombined versions of the character
113
- string = unicodedata.normalize('NFC', char + val)
111
+ string = unicodedata.normalize("NFC", char + val)
114
112
  if len(string) == 1:
115
113
  encoding[string] = encoding[char + val]
116
114
  for char in [
117
- '\N{Latin Small Letter Dotless I}', '\N{Latin Small Letter Dotless J}'
115
+ "\N{LATIN SMALL LETTER DOTLESS I}",
116
+ "\N{LATIN SMALL LETTER DOTLESS J}",
118
117
  ]:
119
- encoding[char + val] = r'\%s{%s}' % (key, char)
120
- string = unicodedata.normalize('NFC', char + val)
118
+ encoding[char + val] = r"\%s{%s}" % (key, char)
119
+ string = unicodedata.normalize("NFC", char + val)
121
120
  # These characters have no precombined versions, but check anyway
122
121
  if len(string) == 1:
123
122
  encoding[string] = encoding[char + val]
@@ -137,20 +136,20 @@ def _decode_latex_accent(match: typing.Match) -> str:
137
136
 
138
137
  # LaTeX single character symbols
139
138
  symbol = {
140
- 'i': '\N{Latin Small Letter Dotless I}',
141
- 'j': '\N{Latin Small Letter Dotless J}',
142
- 'l': '\N{Latin Small Letter L With Stroke}',
143
- 'L': '\N{Latin Capital Letter L With Stroke}',
144
- 'o': '\N{Latin Small Letter O With Stroke}',
145
- 'O': '\N{Latin Capital Letter O With Stroke}'
139
+ "i": "\N{LATIN SMALL LETTER DOTLESS I}",
140
+ "j": "\N{LATIN SMALL LETTER DOTLESS J}",
141
+ "l": "\N{LATIN SMALL LETTER L WITH STROKE}",
142
+ "L": "\N{LATIN CAPITAL LETTER L WITH STROKE}",
143
+ "o": "\N{LATIN SMALL LETTER O WITH STROKE}",
144
+ "O": "\N{LATIN CAPITAL LETTER O WITH STROKE}",
146
145
  }
147
146
 
148
147
  # The regexp to detect the LaTeX commands for special characters
149
- symbol_re = re.compile(r'\\([' + ''.join(symbol.keys()) + '])')
148
+ symbol_re = re.compile(r"\\([" + "".join(symbol.keys()) + "])")
150
149
 
151
150
  # Invert the symbol dictionary to make a dictionary of LaTeX encodings.
152
151
  for key, val in symbol.items():
153
- encoding[val] = '\\' + key
152
+ encoding[val] = "\\" + key
154
153
 
155
154
 
156
155
  def _decode_latex_symbol(match: typing.Match) -> str:
@@ -166,10 +165,10 @@ def _decode_latex_symbol(match: typing.Match) -> str:
166
165
 
167
166
 
168
167
  # LaTeX dashes
169
- dash = {'--': '\N{EN Dash}', '---': '\N{EM Dash}'}
168
+ dash = {"--": "\N{EN DASH}", "---": "\N{EM DASH}"}
170
169
 
171
170
  # The regexp to detect the LaTeX commands for dashes
172
- dash_re = re.compile(r'([^-]?)(-{2,3})([^-]?)')
171
+ dash_re = re.compile(r"([^-]?)(-{2,3})([^-]?)")
173
172
 
174
173
  # Invert the dictionary tomake a dictionary of LaTeX encodings.
175
174
  for key, val in dash.items():
@@ -205,13 +204,11 @@ def decode_latex(text: str) -> str:
205
204
  """
206
205
 
207
206
  return brace_re.sub(
208
- r'\1',
207
+ r"\1",
209
208
  accent_re.sub(
210
209
  _decode_latex_accent,
211
- symbol_re.sub(
212
- _decode_latex_symbol, dash_re.sub(_decode_latex_dash, text)
213
- )
214
- )
210
+ symbol_re.sub(_decode_latex_symbol, dash_re.sub(_decode_latex_dash, text)),
211
+ ),
215
212
  )
216
213
 
217
214
 
@@ -228,7 +225,7 @@ def encode_latex(text: str) -> str:
228
225
  """
229
226
 
230
227
  # Map the double character representations
231
- text2 = ''
228
+ text2 = ""
232
229
  char1 = text[0]
233
230
  i = 1
234
231
  len_text = len(text)
@@ -250,7 +247,7 @@ def encode_latex(text: str) -> str:
250
247
  text2 += char1
251
248
 
252
249
  # Map the single characters representations
253
- result = ''
250
+ result = ""
254
251
  for char in list(text2):
255
252
  if char in encoding:
256
253
  result += encoding[char]
@@ -260,7 +257,7 @@ def encode_latex(text: str) -> str:
260
257
  return result
261
258
 
262
259
 
263
- if __name__ == '__main__': # pragma: no cover
260
+ if __name__ == "__main__": # pragma: no cover
264
261
  text = r"""
265
262
  (Vorlova_2015) Barbora Vorlov{\'{a}} and Dana Nachtigallov{\'{a}} and Jana
266
263
  Jir{\'{a}}skov{\'{a}}-Van{\'{\i}}{\v{c}}kov{\'{a}} and Haresh Ajani and Petr