mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Migrate to py3 style type annotation: sphinx.util.texescape
This commit is contained in:
@@ -9,10 +9,7 @@
|
||||
"""
|
||||
|
||||
import re
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Dict # NOQA
|
||||
from typing import Dict
|
||||
|
||||
tex_replacements = [
|
||||
# map TeX special chars
|
||||
@@ -78,20 +75,17 @@ tex_replace_map = {}
|
||||
tex_hl_escape_map_new = {}
|
||||
|
||||
|
||||
def escape(s):
|
||||
# type: (str) -> str
|
||||
def escape(s: str) -> str:
|
||||
"""Escape text for LaTeX output."""
|
||||
return s.translate(tex_escape_map)
|
||||
|
||||
|
||||
def escape_abbr(text):
|
||||
# type: (str) -> str
|
||||
def escape_abbr(text: str) -> str:
|
||||
"""Adjust spacing after abbreviations. Works with @ letter or other."""
|
||||
return re.sub(r'\.(?=\s|$)', r'.\@{}', text)
|
||||
|
||||
|
||||
def init():
|
||||
# type: () -> None
|
||||
def init() -> None:
|
||||
for a, b in tex_replacements:
|
||||
tex_escape_map[ord(a)] = b
|
||||
tex_replace_map[ord(a)] = '_'
|
||||
|
||||
Reference in New Issue
Block a user