Improved markdown, micron and syntax highlight rendering consistency and accuracy

This commit is contained in:
Mark Qvist
2026-05-05 19:54:39 +02:00
parent bb051e5a11
commit 2ddbef70fe
3 changed files with 17 additions and 7 deletions
+12 -2
View File
@@ -237,13 +237,23 @@ class MicronFormatter:
if color and value:
escaped = self._escape_value(value)
output_parts.append(f"`FT{color}{escaped}`f")
if escaped.startswith("\n"): ilb = "\n"; escaped = escaped[1:]
else: ilb = ""
if escaped.endswith("\n"): tlb = "\n"; escaped = escaped[:-1]
else: tlb = ""
output_parts.append(f"{ilb}`FT{color}{escaped}`f{tlb}")
else: output_parts.append(self._escape_value(value))
prev_was_dot = is_dot
outfile.write("".join(output_parts))
output = "".join(output_parts)
final_output = ""
for line in output.splitlines():
if line.startswith(">"): line = f"`>{line}"
final_output += f"{line}\n"
outfile.write(final_output)
def _get_color_key_for_token(self, ttype):
token_parts = []
+4 -4
View File
@@ -709,14 +709,14 @@ class NomadNetworkNode():
content = self.get_blob_content(repo_path, resolved_ref, file_path)
if content is not None:
if renderable and render:
if file_ext == ".mu": content_parts.append(f"{content}\n")
elif file_ext == ".md": content_parts.append(f"{self.mdc.format_block(content)}\n")
if file_ext == ".mu": content_parts.append(f"{content.rstrip()}\n")
elif file_ext == ".md": content_parts.append(f"{self.mdc.format_block(content).rstrip()}\n")
else : content_parts.append(f"`=\n{content}\n`=")
else:
if self.highlight_syntax:
highlighted = self.highlighter.highlight(content, file_path)
content_parts.append(highlighted)
highlighted = self.highlighter.highlight(content, file_path).rstrip()
content_parts.append(highlighted+"\n")
else: content_parts.append(f"`=\n{content}\n`=")
+1 -1
View File
@@ -315,7 +315,7 @@ class MarkdownToMicron:
content = match.group(2)
level = len(hashes)
prefix = ">" * min(level, 6)
return f"{prefix}{content}"
return f"{prefix}{self._format_inline(content)}"
def _format_list_item(self, match):
indent = match.group(1)