Skip to content

lyj76/gpt_math_markdown_convert

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gpt_math_markdown_convert

简体中文说明 (README.zh-CN.md)

A practical Markdown math cleaner for KaTeX / LaTeX parse errors. It is designed for notes generated by OCR, AI, or copy-paste workflows and fixes many broken math patterns automatically.

Keywords: markdown math, katex parse error, latex cleanup, obsidian math, typora formula, math notes converter

Why This Tool

Typical broken input often causes errors like:

  • Can't use function '$' in math mode
  • malformed inline math such as V$f$ or f$P$

This project normalizes math-like snippets into safer Markdown math blocks/inline syntax.

Before vs After

Case 1: Broken inline math inside display math

Before: alt text

After: alt text

Case 2: Broken ideal notation

Before:

$$
I(S)=$x, y$
$$

After:

$$
I(S)=(x, y)
$$

Case 3: Bracket-style block converted to standard math block

Before:

[
k[x_1,\dots,x_n]
]

After:

$$
k[x_1, \dots, x_n]
$$

Features

  • Convert standalone [ ... ] blocks into $$ ... $$
  • Convert selected inline ( ... ) expressions into $...$
  • Avoid modifying existing $...$ and $$...$$ math regions
  • Reduce over-conversion that leads to KaTeX errors
  • Single-file, multi-file, and drag-and-drop workflow on Windows

Quick Start

Run with Python

python tr.py input.md
python tr.py input.md -o output.md
python tr.py a.md b.md c.md

If no positional input is provided, the script will ask for filenames interactively.

Build Windows EXE

python -m pip install pyinstaller
python -m PyInstaller --onefile tr.py

Output:

  • dist\\tr.exe

Drag and Drop Usage

  • Drag one or more .md files onto dist\\tr.exe
  • Or drag files onto convert_drag.bat (it uses EXE first, then falls back to Python)

Project Structure

  • tr.py: converter logic + CLI entry
  • scripts/build_exe.ps1: PowerShell build helper
  • convert_drag.bat: drag-and-drop launcher for Windows
  • dist/: packaged executable output

Scope and Notes

  • Input encoding: UTF-8
  • Default output: <input_stem>_converted.md (same directory)
  • -o/--output is only valid with a single input file

License

MIT (see LICENSE)

About

convert gpt copied markdown(which tex don't right) to right version

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors