以前ai喜欢说$x$和$$x$$的属性公式,但是后面训练改了,变得都是输出()或者的格式了
但是vscode,typora,思源笔记等对这种公式似乎都不支持,有什么办法让笔记软件支持吗?
我目前是让ai写了个正则表达式页面来替换这些,手动复制粘贴还有点麻烦
可以自己写个编辑器插件。。但是弄进去会比较麻烦,除非自己写个编辑器。我记得思源好像支持数学公式来着GitHub - Vanessa219/vditor: ♏ 一款浏览器端的 Markdown 编辑器,支持所见即所得(富文本)、即时渲染(类似 Typora)和分屏预览模式。An In-browser Markdown editor, support WYSIWYG (Rich Text), Instant Rendering (Typora-like) and Split View modes.
vscode自己可以写个插件
typora没开源就不了解了
这个只能看看能不能在LLM输出的节点加个转换步骤了,用提示词或者工作流来实现
这个我们最近也在做,不过是md转成word之后,latex还是有点问题,就写了一个powershell的脚本,批量转换word中$$乱码问题,转换成数学公式
# LaTeX Converter Script
# For WPS/Word documents
# 2025-04-18
# @author: Ashu
# @version: 0.4
# @description: Convert LaTeX to Text
# can convert all documents in current folder or selected folder
# Convert LaTeX to Text
function c($s){
$r=$s
$r=$r-replace"\\pm","+/-"-replace"\\sim","-"-replace"\\[a-zA-Z]+",""-replace"\\\s"," "-replace"[\$\{\}]",""-replace"\\",""-replace"~"," "
return $r
}
# Select file dialog
function g{
Add-Type -A System.Windows.Forms
$d=New-Object System.Windows.Forms.OpenFileDialog
$d.Filter="Documents (*.doc;*.docx)|*.doc;*.docx"
$d.Title="Select document"
if($d.ShowDialog()-eq[System.Windows.Forms.DialogResult]::OK){return $d.FileName}
return $null
}
# Select folder dialog
function f{
Add-Type -A System.Windows.Forms
$d=New-Object System.Windows.Forms.FolderBrowserDialog
$d.Description="Select folder with documents"
if($d.ShowDialog()-eq[System.Windows.Forms.DialogResult]::OK){return $d.SelectedPath}
return $null
}
# Create output directory if not exists
function createOutDir{
$outDir = Join-Path (Get-Location) "latexToTexted"
if(!(Test-Path $outDir)) {
New-Item -ItemType Directory -Path $outDir | Out-Null
Write-Host "Created output directory: $outDir" -F Green
}
return $outDir
}
# Process document
function p($f){
try{
try{$a=New-Object -C "KWPS.Application";Write-Host "Using WPS..."-F Green}
catch{try{$a=New-Object -C "Word.Application";Write-Host "Using Word..."-F Green}
catch{Write-Host "Error: WPS or Word required!"-F Red;return}}
# Create output directory
$outDir = createOutDir
Write-Host "Opening..."-F Cyan
$d=$a.Documents.Open($f)
Write-Host "Converting..."-F Cyan
foreach($p in $d.Paragraphs){
$o=$p.Range.Text
$n=c $o
if($o-ne$n){$p.Range.Text=$n}
}
# Get just the filename without path
$n=[IO.Path]::GetFileName($f)
$np=Join-Path $outDir $n
Write-Host "Saving..."-F Cyan
$d.SaveAs($np)
$d.Close()
Write-Host "Done! Saved as: $np"-F Green
return $true
}
catch{Write-Host "Error: $_"-F Red;return $false}
finally{
if($a){
$a.Quit()
[Runtime.InteropServices.Marshal]::ReleaseComObject($a)|Out-Null
[GC]::Collect()
[GC]::WaitForPendingFinalizers()
}
}
}
# Process all documents in folder
function a($path){
$files=Get-ChildItem -Path $path -Filter "*.doc*"
if($files.Count -eq 0){
Write-Host "No documents found in folder!"-F Yellow
return
}
Write-Host "Found $($files.Count) documents in $path"-F Cyan
$s=0;$f=0
foreach($file in $files){
Write-Host "Processing $($file.Name)..." -F Cyan
if(p $file.FullName){$s++}else{$f++}
}
Write-Host "Batch complete! Success: $s, Failed: $f"-F $(if($f-eq 0){"Green"}else{"Yellow"})
}
# Main menu
function m{
Clear-Host
Write-Host "== LaTeX Converter =="
Write-Host "1. Convert single document"
Write-Host "2. Convert all documents in current folder"
Write-Host "3. Convert all documents in selected folder"
Write-Host "4. Exit"
$c=Read-Host "Option"
switch($c){
"1"{$file=g;if($file){p $file}else{Write-Host "No file selected."-F Yellow}
Write-Host "Press any key...";[void][Console]::ReadKey($true);m}
"2"{a (Get-Location);Write-Host "Press any key...";[void][Console]::ReadKey($true);m}
"3"{$folder=f;if($folder){a $folder}else{Write-Host "No folder selected."-F Yellow}
Write-Host "Press any key...";[void][Console]::ReadKey($true);m}
"4"{Exit}
default{Write-Host "Invalid choice."-F Red;Start-Sleep -S 1;m}
}
}
# Start program
m
新建文本,保存后缀名为.ps1。
如果你使用Obsidian的话,推荐一下我自己的一个小插件
哈哈,看起来都是在插件解决,今天刚刚找到思源笔记的
不知道后面vscode和typora有没有
这是由软件实现的,比如用mathjax就可以自己设置:TeX Input Processor Options — MathJax 3.2 documentation
我现在都是要提醒AI输出格式为markdown格式,然后直接复制到typora里面,格式就是对的,如果不提醒就得重新改
其实原理很简单,就是正则替换一下符号,代码当时用gpt写的
我一般直接在system prompt里加格式要求,不然有时是LaTeX公式,有时是unicode字符,不稳定。
嗯,这个我让gpt写了个网页
只是每次去粘贴到网页替换比较麻烦
不过现在没啥问题了,思源笔记有插件可以自动转换粘贴的格式
确实可以
此话题已在最后回复的 30 天后被自动关闭。不再允许新回复。