Skip to content

Commit

Permalink
Merge pull request #39 from ppizarror/support-acronyms
Browse files Browse the repository at this point in the history
Added support for acronyms
  • Loading branch information
ppizarror authored Mar 8, 2023
2 parents 1c546c1 + 7276610 commit a1a4358
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 13 deletions.
3 changes: 2 additions & 1 deletion build.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"""

import os
import shutil
import struct
import sys

Expand Down Expand Up @@ -36,7 +37,7 @@
if os.path.isdir('build'):
for k in os.listdir('build'):
if 'bdist.' in k or k == 'lib':
os.system(f'rm -rf build/{k}')
shutil.rmtree(f'build/{k}')
os.system(f'python setup.py sdist --dist-dir dist/pip bdist_wheel --dist-dir dist/pip')

elif mode == 'twine':
Expand Down
5 changes: 4 additions & 1 deletion codecov.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
ignore:
- "pydetex/gui.py"
- "build.py"
- "gui.py"
- "pydetex/_gui_utils.py"
- "pydetex/gui.py"
- "setup.py"
- "test/*.py"
18 changes: 11 additions & 7 deletions pydetex/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,10 @@ def output_text_for_some_commands(
# relaced is 'YOUR TAG {0}, {1}
# All *arguments will be formatted using the tag
commands: List[Tuple[str, List[Tuple[int, bool]], Union[str, Callable[[str, ...], str]], int, Optional[str], Optional[str], Tuple[bool, bool]]] = [
('ac', [(1, False)], '{0}', 1, 'normal', 'normal', (False, False)), # Acronym
('acf', [(1, False)], '{0}', 1, 'normal', 'normal', (False, False)), # Acronym
('acl', [(1, False)], '{0}', 1, 'normal', 'normal', (False, False)), # Acronym
('acs', [(1, False)], '{0}', 1, 'normal', 'normal', (False, False)), # Acronym
('caption', [(1, False)], LANG_TT_TAGS.get(lang, 'caption'), 1, None, None, (False, True)),
('chapter', [(1, False)], '{0}', 1, 'normal', 'bold', (True, True)),
('chapter*', [(1, False)], '{0}', 1, 'normal', 'bold', (True, True)),
Expand All @@ -709,16 +713,16 @@ def output_text_for_some_commands(
('emph', [(1, False)], '{0}', 1, 'normal', 'italic', (False, False)),
('enquote', [(1, False)], lambda t: '"{0}"'.format(t), 1, 'normal', 'normal', (False, False)),
('href', [(2, False)], LANG_TT_TAGS.get(lang, 'link'), 2, None, None, (False, False)),
('insertimage', [(3, False)], LANG_TT_TAGS.get(lang, 'figure_caption'), 3, None, None, (False, True)), # Template-Informe
('insertimage', [(4, False)], LANG_TT_TAGS.get(lang, 'figure_caption'), 4, None, None, (False, False)), # Template-Informe
('insertimageboxed', [(4, False)], LANG_TT_TAGS.get(lang, 'figure_caption'), 4, None, None, (False, True)), # Template-Informe
('insertimageboxed', [(5, False)], LANG_TT_TAGS.get(lang, 'figure_caption'), 5, None, None, (False, True)), # Template-Informe
('institutionentry', [(1, False), (2, False), (3, False), (4, False)], '{0} ({1}-{2}). {3}', 4, 'normal', 'normal', (False, False)), # Professional-CV
('institutionentryshort', [(1, False), (2, False), (3, False), (4, False)], '{0} ({1}-{2}). {3}', 4, 'normal', 'normal', (False, False)), # Professional-CV
('insertimage', [(3, False)], LANG_TT_TAGS.get(lang, 'figure_caption'), 3, None, None, (False, True)), # (Template) Informe
('insertimage', [(4, False)], LANG_TT_TAGS.get(lang, 'figure_caption'), 4, None, None, (False, False)), # (Template) Informe
('insertimageboxed', [(4, False)], LANG_TT_TAGS.get(lang, 'figure_caption'), 4, None, None, (False, True)), # (Template) Informe
('insertimageboxed', [(5, False)], LANG_TT_TAGS.get(lang, 'figure_caption'), 5, None, None, (False, True)), # (Template) Informe
('institutionentry', [(1, False), (2, False), (3, False), (4, False)], '{0} ({1}-{2}). {3}', 4, 'normal', 'normal', (False, False)), # (Template) Professional-CV
('institutionentryshort', [(1, False), (2, False), (3, False), (4, False)], '{0} ({1}-{2}). {3}', 4, 'normal', 'normal', (False, False)), # (Template) Professional-CV
('lowercase', [(1, False)], lambda t: t.lower(), 1, 'normal', 'normal', (False, False)),
('MakeLowercase', [(1, False)], lambda t: t.lower(), 1, 'normal', 'normal', (False, False)),
('MakeUppercase', [(1, False)], lambda t: t.upper(), 1, 'normal', 'normal', (False, False)),
('otherentry', [(1, False), (2, False)], '{0} {1}', 2, 'normal', 'normal', (False, False)), # Professional-CV
('otherentry', [(1, False), (2, False)], '{0} {1}', 2, 'normal', 'normal', (False, False)), # (Template) Professional-CV
('paragraph', [(1, False)], '{0}', 1, 'normal', 'bold', (True, True)),
('quotes', [(1, False)], lambda t: '"{0}"'.format(t), 1, 'normal', 'normal', (False, False)),
('section', [(1, False)], '{0}', 1, 'normal', 'bold', (True, True)),
Expand Down
6 changes: 2 additions & 4 deletions pydetex/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

__all__ = ['Version', 'vernum', 'ver', 'rev']

from typing import Tuple


class Version(tuple):
"""
Expand All @@ -19,7 +17,7 @@ class Version(tuple):
__slots__ = ()
fields = 'major', 'minor', 'patch'

def __new__(cls, major, minor, patch) -> Tuple:
def __new__(cls, major, minor, patch) -> 'Version':
return tuple.__new__(cls, (major, minor, patch))

def __repr__(self) -> str:
Expand All @@ -34,6 +32,6 @@ def __str__(self) -> str:
patch = property(lambda self: self[2])


vernum = Version(0, 9, 8)
vernum = Version(0, 9, 9)
ver = str(vernum)
rev = ''
10 changes: 10 additions & 0 deletions test/test_parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,16 @@ def out(s_: str) -> str:
s = '\doublequotes{\href{a}{link}}'
self.assertEqual(out(s), '"LINK: link"')

# Test acronym
s = '\\ac{XYZ}'
self.assertEqual(out(s), 'XYZ')
s = '\\acf{XYZ}'
self.assertEqual(out(s), 'XYZ')
s = '\\acs{XYZ}'
self.assertEqual(out(s), 'XYZ')
s = '\\acl{XYZ}'
self.assertEqual(out(s), 'XYZ')

def test_unicode_chars_equations(self) -> None:
"""
Test unicode char equations.
Expand Down

0 comments on commit a1a4358

Please sign in to comment.