Skip to content

Commit

Permalink
Fix markdown regex for webkit
Browse files Browse the repository at this point in the history
  • Loading branch information
greentfrapp committed Sep 1, 2022
1 parent 1e8e754 commit 565be1f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@ export function registerBlock(id:string, label:string, component:any, icon:strin
export function markdownToHtml (mdString:string) {
// Adapted from https://randyperkins2k.medium.com/writing-a-simple-markdown-parser-using-javascript-1f2e9449a558
return mdString
.replace(/(?<!\\)\*(?<!\\)\*(.*?)(?<!\\)\*(?<!\\)\*/g, '<strong>$1</strong>')
.replace(/(?<!\\)\*(.*?)(?<!\\)\*/g, '<em>$1</em>')
.replace(/\\\*/g, '*')
.replace(/\\\*/g, '\\*\\*')
.replace(/\*\*(.*?)\*\*/g, '<strong>$1</strong>')
.replace(/\*(.*?)\*/g, '<em>$1</em>')
.replaceAll('\\<em>\\</em>', '*')
// .replace(/(?<!\\)\*(?<!\\)\*(.*?)(?<!\\)\*(?<!\\)\*/g, '<strong>$1</strong>')
// .replace(/(?<!\\)\*(.*?)(?<!\\)\*/g, '<em>$1</em>')
// .replace(/\\\*/g, '*')
.trim()
}

Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/lotion.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ test('converting between types via keyboard should work and maintain caret posit
await page.keyboard.type('/heading 2')
await page.keyboard.press('Enter')
// Wait for text to update to "Get Started"
await block.allTextContents()
await block.waitFor()
// Testing caret position
await page.keyboard.press('s')
block = await page.locator('text="Get Startsed"')
Expand Down

0 comments on commit 565be1f

Please sign in to comment.