Skip to content

Commit 2a6eb2f

Browse files
committed
Update for v0.0.74
1 parent 084f57f commit 2a6eb2f

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
*.pyc
2-
__pycache__/
2+
__pycache__/
3+
*.egg-info/
4+
venv/

ipycalc/calc.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,6 @@ def sync_namespaces(local_ns):
174174
#%%
175175
def process_line(calc_line, local_ns):
176176

177-
# Ampersand symbols will mess with latex table formatting unless they have a `\` in front of them
178-
calc_line = calc_line.replace('&', r'&')
179-
180177
# Break up the line into components: `description`, `variable`, `equation`, `value` and `reference`
181178
# Split `reference` off from the rest of the line
182179
if '#' in calc_line:
@@ -307,6 +304,8 @@ def compute_value(expression, target_unit, target_precision):
307304

308305
# Format the description
309306
if description != '':
307+
# Escape ampersand symbols for latex table formatting
308+
description = description.replace('&', r'\&')
310309
description = description + ': '
311310

312311
# Format the variable to be Python friendly
@@ -355,6 +354,8 @@ def compute_value(expression, target_unit, target_precision):
355354

356355
# Format the reference
357356
reference = reference.strip()
357+
# Escape ampersand symbols for latex table formatting
358+
reference = reference.replace('&', r'\&')
358359

359360
# Return the line formatted in all its glory
360361
latex_text = linebreaks(description, 'text') + '&' + linebreaks(latex_variable + latex_equation + latex_value, 'math') + '&' + linebreaks(reference, 'text') + '\\\\ \n'
@@ -689,8 +690,8 @@ def funit(value, precision=None):
689690
# Step through each character in the value
690691
for i, char in enumerate(latex_value):
691692

692-
# Find the first non-numeric non-decimal character
693-
if not latex_value[i].isnumeric() and latex_value[i] !='.':
693+
# Find the first non-numeric non-decimal character, excluding the minus sign for negative numbers
694+
if not latex_value[i].isnumeric() and latex_value[i] !='.' and latex_value[i] !='-':
694695

695696
# Add a space between the value and the units
696697
latex_value = latex_value[0:i] + ' \\ ' + latex_value[i:len(latex_value)]

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setuptools.setup(
77
name="ipycalc",
8-
version="0.0.73",
8+
version="0.0.74",
99
author="D. Craig Brinck, PE, SE",
1010
author_email="Building.Code@outlook.com",
1111
description="Clean looking engineering calculations for IPython",

0 commit comments

Comments
 (0)