llama.cpp icon indicating copy to clipboard operation
llama.cpp copied to clipboard

Server front-end: do not apply Markdown formatting in code sections

Open mgroeber9110 opened this issue 1 year ago • 0 comments

This modifies the rules for "Markdownish" formatting in the server's front-end to only replace formatting characters (like '_' and '*') and headings outside of code sections.

This keeps the formatter from messing up Python comments (# comment) and function names with underscores in code examples (my_example_function()).

The idea of the regex follows the accepted answer here: https://stackoverflow.com/questions/6462578/regex-to-match-all-instances-not-inside-quotes - only perform the replacement if it is followed by an even number of backquotes. This is still not perfect for truncated or invalid Markdown, and it only applies the correct formatting once the code section is closed, but at least it fixes some straightforward cases of code rendering.

mgroeber9110 avatar Apr 23 '24 16:04 mgroeber9110