Skip to content

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

Merged
ggerganov merged 1 commit intoggml-org:masterfrom
mgroeber9110:master
Apr 24, 2024
Merged

Server front-end: do not apply Markdown formatting in code sections#6850
ggerganov merged 1 commit intoggml-org:masterfrom
mgroeber9110:master

Conversation

@mgroeber9110
Copy link
Copy Markdown
Contributor

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 mgroeber9110 changed the title Server: do not apply Markdown formatting in code sections Server front-end: do not apply Markdown formatting in code sections Apr 23, 2024
@ggerganov ggerganov merged commit 3fe847b into ggml-org:master Apr 24, 2024
Seunghhon pushed a commit to Seunghhon/llama.cpp that referenced this pull request Apr 26, 2026
phuongncn pushed a commit to phuongncn/llama.cpp-gx10-dgx-sparks-deepseekv4 that referenced this pull request Apr 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants