-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d8b7db3
commit 4193d63
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{# Macro to split long words #} | ||
{%- macro split_words(text, cutoff) -%} | ||
{%- set cutoff = cutoff|default(20) -%} | ||
{%- set output = text|latex_escape_all -%} | ||
{%- set splittedOutput = output|split(' ') %} | ||
{%- if splittedOutput|length == 1 -%} | ||
\seqsplit{ {{- output|raw -}} } | ||
{%- else -%} | ||
{%- for splittedPart in splittedOutput -%} | ||
{%- set splittedDash = splittedPart|split('-') -%} | ||
{%- if splittedDash|length == 1 and splittedPart|length >= cutoff-%} | ||
\seqsplit{ {{- splittedPart|raw -}} } | ||
{%- elseif splittedDash|length > 1 -%} | ||
{%- for splittedDashPart in splittedDash -%} | ||
{%- if splittedDashPart|length >= cutoff -%} | ||
\seqsplit{ {{- splittedDashPart|raw -}} } | ||
{%- else -%} | ||
{{- splittedDashPart|raw -}} | ||
{%- endif -%} | ||
{%- if not loop.last -%}{{- '-' -}}{%- endif -%} | ||
{%- endfor -%} | ||
{%- else -%} | ||
{{- splittedPart|raw -}} | ||
{%- endif -%} | ||
{%- if not loop.last %} {% endif -%} | ||
{%- endfor -%} | ||
{%- endif -%} | ||
{%- endmacro -%} |