Skip to content

Commit

Permalink
More conservative strong/em markdown matcher
Browse files Browse the repository at this point in the history
Both matchers are now constrained so that they will only be transformed
if the left-hand characters are the start of the text or preceeded by
whitespace, and the right-hand characters are the end of the text or
followed by whitespace or a punctuation mark.

This misses some cases, e.g. emphasis inside of parantheticals, but has
better behavior with e.g. underscores in function names outside of code
blocks.

Fixes Mozilla-Ocho#317.
  • Loading branch information
mrdomino committed Apr 22, 2024
1 parent a49e33d commit f99fb96
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions llama.cpp/server/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1121,8 +1121,8 @@

// Headlines, emphasis and line breaks
.replace(/^#{1,6} (.*)$/gim, '<h3>$1</h3>')
.replace(/(__|\*\*)(.*?)\1/g, '<strong>$2</strong>')
.replace(/(_|\*)(.*?)\1/g, '<em>$2</em>')
.replace(/(^|\s)(__|\*)(.*?)\2($|\s|[.?!])/g, '$1<strong>$3</strong>$4')
.replace(/(^|\s)(_|\*)(.*?)\2($|\s|[.?!])/g, '$1<em>$3</em>$4')
.replace(/\n/gim, '<br />')

// Paste the extracted blocks back in again
Expand Down

0 comments on commit f99fb96

Please sign in to comment.