Commit 92e82d0875918c89ec67422808cd7e80cd9099d4

Authored by Miguel Barão
1 parent 8dcdb358
Exists in master and in 1 other branch dev

- fixed markdown rendering

Showing 1 changed file with 10 additions and 12 deletions   Show diff stats
tools.py
... ... @@ -89,16 +89,12 @@ class MarkdownWithMath(mistune.Markdown):
89 89 class HighlightRenderer(mistune.Renderer):
90 90 def block_code(self, code, lang='text'):
91 91 try:
92   - lexer = get_lexer_by_name(lang, stripall=True)
  92 + lexer = get_lexer_by_name(lang, stripall=False)
93 93 except:
94   - lexer = get_lexer_by_name('text', stripall=True)
  94 + lexer = get_lexer_by_name('text', stripall=False)
95 95  
96 96 formatter = HtmlFormatter()
97   - return "{open_block}{formatted}{close_block}".format(
98   - open_block="<div class='code-highlight'>" if lang != 'text' else '',
99   - formatted=highlight(code, lexer, formatter),
100   - close_block="</div>" if lang != 'text' else ''
101   - )
  97 + return highlight(code, lexer, formatter)
102 98  
103 99 # def table(self, header, body):
104 100 # return "<table class='table table-bordered table-hover'>" + header + body + "</table>"
... ... @@ -148,7 +144,7 @@ def load_yaml(filename, default=None):
148 144 return yaml.load(f)
149 145 except yaml.YAMLError as e:
150 146 mark = e.problem_mark
151   - logger.error('In YAML file "{0}" near line {1}, column {2}.'.format(filename, mark.line, mark.column+1))
  147 + logger.error(f'In YAML file "{filename}" near line {mark.line}, column {mark.column+1}.')
152 148 return default
153 149  
154 150 # ---------------------------------------------------------------------------
... ... @@ -165,11 +161,13 @@ def run_script(script, stdin=&#39;&#39;, timeout=5):
165 161 timeout=timeout,
166 162 )
167 163 except FileNotFoundError:
168   - logger.error(f'Script "{script}" not found.')
  164 + logger.error(f'Could not execute script "{script}": not found.')
169 165 except PermissionError:
170   - logger.error(f'Script "{script}" not executable. Wrong permissions?')
  166 + logger.error(f'Could not execute script "{script}": wrong permissions.')
  167 + except OSError:
  168 + logger.error(f'Could not execute script "{script}": unknown reason.')
171 169 except subprocess.TimeoutExpired:
172   - logger.error(f'Timeout {timeout}s exceeded while running "{script}".')
  170 + logger.error(f'Timeout exceeded ({timeout}s) while running "{script}".')
173 171 else:
174 172 if p.returncode != 0:
175 173 logger.error(f'Script "{script}" returned error code {p.returncode}.')
... ... @@ -177,6 +175,6 @@ def run_script(script, stdin=&#39;&#39;, timeout=5):
177 175 try:
178 176 output = yaml.load(p.stdout)
179 177 except:
180   - logger.error('Error parsing yaml output of "{script}"')
  178 + logger.error(f'Error parsing yaml output of "{script}"')
181 179 else:
182 180 return output
... ...