From 93f88b5a8c11481ba25b4a5f9d7771935cc9fbb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikl=C3=B3s=20T=C3=B3th?= <tothmiklostibor@gmail.com> Date: Mon, 15 Mar 2021 16:32:30 +0100 Subject: [PATCH] fix latex escapes --- gen_seq_diag.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gen_seq_diag.py b/gen_seq_diag.py index 9e829a9..6eb1d5c 100755 --- a/gen_seq_diag.py +++ b/gen_seq_diag.py @@ -16,6 +16,8 @@ iden = 4 * ' ' # tree trees = [] +def escapeLatex(inp): + return inp.replace("%", "\\%").replace("#", "\\#") def fetch_file(p): with open(p, 'r', encoding='utf-8') as f: @@ -204,7 +206,7 @@ class Call(Stmt): ctx.args.append(args) ctx.append(lvl, '\\begin{umlcall}' + '[' + - f'op={{{call.member}({args_str})}},' + + f'op={{{call.member}({escapeLatex(args_str)})}},' + f'return={{{ret}}},' + f'dt=7' + ']' + @@ -503,7 +505,7 @@ def main(): args_str = latex_escape(', '.join( [p[1] for p in types[spec_type].methods[spec_method].params])) - print(f'\\begin{{umlcall}}[op={{{spec_method}({args_str})}},' + + print(f'\\begin{{umlcall}}[op={{{spec_method}({escapeLatex(args_str)})}},' + f'return={{\\ }}]{{act}}{{{spec_obj}}}') print(''.join(ctx.s)) print('\\end{umlcall}') -- GitLab