Integrate math extension into component system with position tracking#19
Merged
Integrate math extension into component system with position tracking#19
Conversation
…e rendering options * Updated buildHTMLMarkup to accept an options parameter for inline rendering, allowing the use of <span> instead of <div> for inline elements. * Modified createRenderer to handle inline rendering and prepend inline tokens when necessary, improving flexibility for custom components in the markdown processor. * Enhanced documentation to clarify usage of the new options for inline rendering and token handling.
…a handling * Updated the math renderer to use the createRenderer function, enhancing the extraction of metadata and supporting inline rendering options. * Introduced a new extractMeta function to streamline the processing of math tokens, including LaTeX and AsciiMath, and improved the handling of SVG rendering. * This refactor enhances the flexibility and maintainability of the markdown processor's math rendering capabilities.
* Introduced a new Math component to the default components, enabling the rendering of mathematical expressions using LaTeX and AsciiMath. * Updated the supported components list to include the new MATH type, enhancing the flexibility of the markdown processor for mathematical content. * The Math component securely renders math expressions using MathJax, ensuring proper handling of mathML and SVG outputs.
* Modified snapshot tests for math expressions to include new `data-seemark-element-type` and `data-seemark-payload` attributes. * Enhanced the handling of math expressions in the markdown processor, ensuring proper metadata extraction and rendering. * This update improves the flexibility and accuracy of math expression rendering in the markdown processor.
jamliaoo
commented
Jan 12, 2026
| const tag = inline ? 'span' : 'div'; | ||
|
|
||
| return `<div ${SEE_MARK_PAYLOAD_DATA_ATTRIBUTES}='${payload}' ${SEEMARK_ELEMENT_TYPE_DATA_ATTRIBUTE}="${type}">${children}</div>`; | ||
| return `<${tag} ${SEE_MARK_PAYLOAD_DATA_ATTRIBUTES}='${payload}' ${SEEMARK_ELEMENT_TYPE_DATA_ATTRIBUTE}="${type}">${children}</${tag}>`; |
Contributor
Author
There was a problem hiding this comment.
這裡讓 HTMLMarkup 可以是 span,若為 div 就無法作為 inline 元素放在 p 內
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景描述 (Why)
Math extension 原本直接輸出 HTML,不經過 component system,導致:
實作方法 (How)
將 math extension 整合至 component system,並擴充
createRenderer支援 inline 元素:inline選項:buildHTMLMarkup和createRenderer現在支援{ inline: true }來產生<span>而非<div>,避免破壞<p>內的結構。原本都用 div 的話會導致 inline 元素換行prependInlineTokens選項:處理 math 特有的 preceding text 模式實際變更
MATH到SUPPORTED_COMPONENT_TYPESbuildHTMLMarkup支援inline選項createRenderer支援inline和prependInlineTokens選項math.js使用createRendererMath.jsxdefault component測試驗證
<p>text<span>...</span></p>)補充說明
inline和prependInlineTokens選項預設為false,不影響現有 extensions