Skip to content

feat: add Nemeth braille math support to markdown processor#26

Merged
jamliaoo merged 8 commits intomainfrom
feat/nemeth2latex
Apr 5, 2026
Merged

feat: add Nemeth braille math support to markdown processor#26
jamliaoo merged 8 commits intomainfrom
feat/nemeth2latex

Conversation

@jamliaoo
Copy link
Copy Markdown
Contributor

背景描述 (Why)

SeeMark 目前支援 LaTeX 和 AsciiMath 的數學渲染,新增 Nemeth 點字(braille)編寫的數學式。

實作方法 (How)

新增一個 nemeth marked extension,使用 @⠀...⠀@ 語法(@ 符號夾住 Unicode U+2800–U+28FF 點字字元)識別 Nemeth 數學區塊。

轉換流程:

  1. Nemeth 點字 → LaTeX(透過 @coseeing/nemeth2latex
  2. LaTeX → MathML(既有 latex2mml
  3. MathML → SVG(既有 mml2svg

渲染結果整合進現有的 Math 組件,typed 欄位標記為 'nemeth',同時保留原始點字內容 (math) 及轉換後的 LaTeX (latex)。

實際變更

  • 新增 @coseeing/nemeth2latex 依賴
  • 新增 src/markdown-processor/marked-extentions/nemeth.js — Nemeth marked extension
  • markdown-processor.js 中註冊 nemeth extension
  • 更新 Math.jsx PropTypes,新增 latex 欄位及 'nemeth' typed 選項
  • 新增測試案例及 snapshot

測試驗證

  • @⠁⠘⠆@(點字 )可正確解析,typed === 'nemeth'latex === 'a^2'
  • Snapshot 測試通過,確認 MathML / SVG 輸出正確

補充說明

  • Nemeth 語法使用 @⠀...⠀@ 包裹,其中第一個 @ 後緊跟點字字元,與既有的 @[@! 語法不衝突
  • latex prop 為新增欄位,供 consumer(如 Access8MathWeb)存取轉換後的 LaTeX 原始碼
  • @coseeing/nemeth2latex 尚未發布至 npm,目前以 npm link 在本地測試。正式合併前需先發布該套件並更新 package.json 中的版本號

相關連結

Comment on lines 21 to +23
math: PropTypes.string,
typed: PropTypes.oneOf(['latex', 'asciimath']),
typed: PropTypes.oneOf(['latex', 'asciimath', 'nemeth']),
latex: PropTypes.string,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

如果 props 命名容易混淆的話也可以再討論~不過 math 要改的話可能有 breaking change

  • math 存原始輸入,格式取決於 typed
  • latex 只有 nemeth 情境才有值,因為點字需要先轉成 LaTeX 作為中間格式,保留下來方便下游使用(例如 Access8MathWeb 拿來做其他處理)
prop typed: 'latex' typed: 'asciimath' typed: 'nemeth'
math LaTeX 原始字串,e.g. a+b=c AsciiMath 原始字串,e.g. a+b=c Nemeth 點字原始字串,e.g. ⠁⠘⠆
latex 未傳入(undefined 未傳入(undefined 轉換後的 LaTeX,e.g. a^2

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

覺得暫時先這樣 OK。

"rollup": "^4.40.1"
},
"dependencies": {
"@coseeing/nemeth2latex": "^0.1.0",
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

尚未發布 npm,local 目前用 npm link 做測試

jamliaoo added 7 commits April 5, 2026 18:28
…port

* Integrated a new Nemeth extension into the markdown processor to handle braille math syntax.
* Updated the processor's configuration to include the Nemeth extension, improving support for mathematical content in braille format.
* Enhanced the rendering capabilities for Nemeth tokens, ensuring proper conversion to LaTeX, MathML, and SVG outputs.
* Added a new test case to validate the handling of Nemeth braille math expressions in the markdown processor.
* Updated snapshot tests to ensure accurate rendering and metadata extraction for Nemeth math expressions.
* Improved overall test coverage for mathematical content processing in braille format.
@jamliaoo jamliaoo force-pushed the feat/nemeth2latex branch from cedbade to 94dd27a Compare April 5, 2026 10:29
@jamliaoo
Copy link
Copy Markdown
Contributor Author

jamliaoo commented Apr 5, 2026

後續更新

  • rebase main
  • 加上 .npmrc 讓 npm 知道要上 github 抓套件
  • 調整 ci,加上 github token 才有權限安裝套件
  • bump version

@jamliaoo jamliaoo merged commit 3c6f7a1 into main Apr 5, 2026
1 check passed
@jamliaoo jamliaoo deleted the feat/nemeth2latex branch April 5, 2026 10:37
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