Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: properly parse bolded italics #1808

Merged
merged 1 commit into from
Feb 23, 2023

Conversation

zaidhaan
Copy link
Contributor

It would appear that the current markdown replacer function for bolded italics (line 448) that converts a match into an ultrahtml h() object doesn't expect an array in c's place.

const _markdownReplacements: [RegExp, (c: (string | Node)[]) => Node][] = [
[/\*\*\*(.*?)\*\*\*/g, c => h('b', null, [h('em', null, c)])],
[/\*\*(.*?)\*\*/g, c => h('b', null, c)],
[/\*(.*?)\*/g, c => h('em', null, c)],
[/~~(.*?)~~/g, c => h('del', null, c)],
[/`([^`]+?)`/g, c => h('code', null, c)],
// transform @username@twitter.com as links
[/\B@([a-zA-Z0-9_]+)@twitter\.com\b/gi, c => h('a', { href: `https://twitter.com/${c}`, target: '_blank', rel: 'nofollow noopener noreferrer', class: 'mention external' }, `@${c}@twitter.com`)],
]

When supplied with c = ['foo'], it simply puts ['foo'] in the elements children, which isn't properly parsed by Vue. If instead, it is in the form 'foo', it's parsed properly.

I'm not too familiar with ultrahtml but this seems to work for me and seems to be the root cause as far as I can tell.

Before: (Screenshot taken from mocked dev, but I'd guess viewing this would yield similar results)
image

After:
image

Fixes #1804.

@stackblitz
Copy link

stackblitz bot commented Feb 22, 2023

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@netlify
Copy link

netlify bot commented Feb 22, 2023

Deploy Preview for elk-zone ready!

Name Link
🔨 Latest commit a26137b
🔍 Latest deploy log https://app.netlify.com/sites/elk-zone/deploys/63f69a4a0a1f55000892d2c3
😎 Deploy Preview https://deploy-preview-1808--elk-zone.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Feb 22, 2023

Deploy Preview for elk-docs canceled.

Name Link
🔨 Latest commit a26137b
🔍 Latest deploy log https://app.netlify.com/sites/elk-docs/deploys/63f69a4aa44c0800080c310f

@zaidhaan
Copy link
Contributor Author

zaidhaan commented Feb 22, 2023

Ah, so you guys have preview links, nice. This link demonstrates this fix (original, and elk).

@antfu antfu merged commit f98c667 into elk-zone:main Feb 23, 2023
@zaidhaan zaidhaan deleted the fix-bold-italic-parsing branch February 23, 2023 12:25
DataDrivenMD pushed a commit to Distal-Labs/elk that referenced this pull request Mar 11, 2023
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.

Bold and Italic cannot be displayed
2 participants