Skip to content
Snippets Groups Projects
Commit b0d753ed authored by Karim Ahmed's avatar Karim Ahmed
Browse files

Merge branch 'fix/break_line_properly_into_latex' into 'master'

Fix: Break line properly into latex when next line starts with `_`

See merge request !876
parents b3e11b25 3637c471
1 merge request!876Fix: Break line properly into latex when next line starts with `_`
......@@ -493,10 +493,30 @@ def make_par_table(parms):
# Add space in long strings without line breakers ` ,-/` to
# wrap them in latex
def split_len(seq, length):
"""
Splits a sequence into smaller segments of a specified length,
concatenates them, and adds line-breaking characters
to ensure proper line breaks in LaTeX.
Args:
seq (str): The sequence to be split.
length (int): The desired length of each segment.
Returns:
str: The concatenated line with line-breaking characters.
Examples:
>>> split_len("slurm_prof_230711_095647.832671_0", 10)
''slurm_prof_230711_09\\-5647.832671_0\\-''
"""
lbc = set(' ,-/')
line = ''
for i in range(0, len(seq), length):
sub_line = seq[i:i + length]
# Ensure proper line break if the
# start of the new line begins with `_`
if sub_line[0] == '_' and line[-1] == "-":
line += '\\'
line += sub_line.replace('/', '/\-')
if not any(c in lbc for c in sub_line):
line += '\-'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment