-
Notifications
You must be signed in to change notification settings - Fork 89
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
fixed headings working inside of code blocks #51
base: main
Are you sure you want to change the base?
Conversation
Reviewer's Guide by SourceryThis pull request addresses the issue of headings not working correctly inside code blocks. The changes involve moving the heading replacement logic to occur after the inline code processing, ensuring that headings are properly formatted even when they appear within code blocks. File-Level Changes
Tips
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @x1xo - I've reviewed your changes and they look great!
Here's what I looked at during the review
- 🟡 General issues: 1 issue found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.
@@ -470,6 +466,10 @@ addEventListener('DOMContentLoaded', () => { | |||
// Inline code | |||
txt = txt.replace(/`([^`]+?)`|``([^`]+?)``/g, (m, x, y, z) => x ? `<code class="inline">${x}</code>` : y ? `<code class="inline">${y}</code>` : z ? `<code class="inline">${z}</code>` : m) | |||
} | |||
|
|||
txt = txt.replace(/^# (.*)$/gm, '<h1 class="heading1">$1</h1>') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (bug_risk): Consider moving heading replacements back to their original position.
The heading replacements were moved to a different part of the function. This could potentially affect the order of replacements and lead to unexpected results. Consider moving them back to their original position to maintain the intended order of operations.
txt = txt.replace(/^# (.*)$/gm, '<h1 class="heading1">$1</h1>') | |
txt = txt.replace(/^# (.*)$/gm, '<h1 class="heading1">$1</h1>') | |
.replace(/^## (.*)$/gm, '<h2 class="heading2">$1</h2>') | |
.replace(/^### (.*)$/gm, '<h3 class="heading3">$1</h3>') | |
txt = txt.replace(/`([^`]+?)`|``([^`]+?)``/g, (m, x, y, z) => x ? `<code class="inline">${x}</code>` : y ? `<code class="inline">${y}</code>` : z ? `<code class="inline">${z}</code>` : m) |
Summary by Sourcery
This pull request addresses a bug where headings were not being rendered correctly when inside code blocks. The logic for handling headings has been moved to ensure proper rendering.