Skip to content

Conversation

P-SiZK
Copy link
Contributor

@P-SiZK P-SiZK commented Sep 24, 2025

What

Add support for a new inline math syntax: $`...`$.
This allows writing inline math without escaping, avoiding conflicts with Markdown syntax.

This new syntax follows the inline math syntax used on GitHub (reference) and GitLab (reference).

How

  • Added new filter: Created Qiita::Markdown::Filters::InlineMath class
    • Detects $<code>...</code>$ patterns
    • Converts <code> tags to <span>$formula$</span>
    • Implemented validation logic to avoid conflicts with $$ (block math format)

@P-SiZK P-SiZK self-assigned this Sep 24, 2025
@Copilot Copilot AI review requested due to automatic review settings September 24, 2025 07:42
Copy link

Summary of Changes

Hello @P-SiZK, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the Qiita Markdown parser by adding a new inline math feature. It allows users to embed mathematical formulas directly within text using a clear $...$ syntax, which is then transformed into a displayable HTML span. This change improves the readability and ease of writing math in Markdown by eliminating the need for complex escaping, while also ensuring compatibility with existing block math conventions.

Highlights

  • New Inline Math Format: Introduces support for a new inline math format using $...$ syntax, allowing mathematical expressions to be written without requiring character escaping.
  • Conflict Avoidance: The new format is designed to avoid conflicts with standard Markdown syntax, specifically differentiating from block math ($$).
  • New Filter Implementation: A new filter, Qiita::Markdown::Filters::InlineMath, has been added to detect and process the new inline math patterns.
  • HTML Transformation: The filter converts detected <code> tags within the new inline math format into <span>$formula$</span> for proper rendering.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds support for a new inline math format $<code>...</code>$ to the Qiita Markdown processor. This allows writing inline math without escaping characters, avoiding conflicts with standard Markdown syntax while preventing conflicts with existing block math format ($$).

  • Created InlineMath filter to detect and convert the new format
  • Integrated the filter into the processing pipeline
  • Added comprehensive test coverage for various scenarios

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
lib/qiita/markdown/filters/inline_math.rb New filter implementation that converts $<code>...</code>$ patterns to <span>$formula$</span>
lib/qiita/markdown/processor.rb Adds the InlineMath filter to the default filter pipeline
lib/qiita/markdown.rb Includes the new filter module in the main require statements
spec/qiita/markdown/filters/inline_math_spec.rb Test suite covering various inline math scenarios including edge cases

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new filter for inline math, which is a great addition. The implementation is on the right track. I've identified a couple of areas for improvement. The logic for detecting the $ delimiters could be more robust to handle edge cases like $$$. I've suggested a way to fix this using a regular expression. I also noticed a small opportunity to refactor the code to avoid redundancy. Finally, I've recommended adding more test cases to cover these edge cases and ensure the filter is solid. Overall, good work!

@P-SiZK P-SiZK force-pushed the add-inline-math-filter branch from 356dd9f to aed13f4 Compare September 24, 2025 07:55
@P-SiZK P-SiZK requested review from a team and ohakutsu and removed request for a team September 24, 2025 07:56
Copy link
Member

@ohakutsu ohakutsu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@P-SiZK P-SiZK merged commit 9a0a579 into master Sep 25, 2025
7 checks passed
@P-SiZK P-SiZK deleted the add-inline-math-filter branch September 25, 2025 06:10
@P-SiZK P-SiZK mentioned this pull request Sep 25, 2025
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.

2 participants