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

fixed headings working inside of code blocks #51

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

x1xo
Copy link
Contributor

@x1xo x1xo commented Jul 3, 2024

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.

  • Bug Fixes:
    • Fixed an issue where headings were not rendered correctly inside code blocks.

Copy link

sourcery-ai bot commented Jul 3, 2024

Reviewer's Guide by Sourcery

This 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

Files Changes
assets/js/script.js Reorganized the heading replacements to occur after inline code processing to ensure headings are correctly processed even when inside code blocks.

Tips
  • Trigger a new Sourcery review by commenting @sourcery-ai review on the pull request.
  • Continue your discussion with Sourcery by replying directly to review comments.
  • You can change your review settings at any time by accessing your dashboard:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

Copy link

@sourcery-ai sourcery-ai bot left a 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

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
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>')
Copy link

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.

Suggested change
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)

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.

1 participant