技术相关

2025-10-15

Word解决MarkDown粘贴公式问题

我在写专利时,需要将内容从Notion复制到Word中,但发现公式没能正确粘贴,仍然保留“$公式$”。
采用“Alt+F11”打开Microsoft Visual Basic for Applications,插入新模块,粘贴以下代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
  Sub ConvertEquations()
' 最终稳定版:采用倒序处理逻辑,确保转换成功 [5](@ref)
On Error GoTo ErrorHandler
Dim sel As Selection
Dim selRange As Range
Dim positions As New Collection
Dim i As Long
Dim currentPos As Long
Dim startPos As Long, endPos As Long

' --- 检查是否有选区 ---
If Selection.Type = wdSelectionIP Then
MsgBox "请先选中需要转换的文本区域!", vbExclamation, "操作提示"
Exit Sub
End If

Set sel = Application.Selection
Set selRange = sel.Range

' --- 阶段一:安全查找,只记录公式位置,不修改文档 ---
currentPos = 1
Do While currentPos <= Len(selRange.Text)
startPos = InStr(currentPos, selRange.Text, "$")
If startPos = 0 Then Exit Do
endPos = InStr(startPos + 1, selRange.Text, "$")
If endPos = 0 Then Exit Do

' 将找到的位置对(相对于选区开头)添加到集合中
Dim posPair(1) As Long
posPair(0) = startPos
posPair(1) = endPos
positions.Add posPair
currentPos = endPos + 1
Loop

' --- 阶段二:从后往前,根据记录的位置进行转换 ---
If positions.Count > 0 Then
For i = positions.Count To 1 Step -1
Dim currentRange As Range
Dim currentPair As Variant
currentPair = positions(i)
Set currentRange = selRange.Duplicate
currentRange.Start = selRange.Start + currentPair(0) - 1
currentRange.End = selRange.Start + currentPair(1)

' 提取两个$符号之间的公式文本
Dim equationText As String
equationText = Mid(currentRange.Text, 2, Len(currentRange.Text) - 2) ' 去掉首尾的$

' 清除当前范围的内容(包括$符号),并插入公式
currentRange.Delete
Set currentRange = ActiveDocument.Range(currentRange.Start, currentRange.Start)
currentRange.Text = equationText
currentRange.OMaths.Add currentRange
currentRange.OMaths.BuildUp
Next i
End If

MsgBox "转换成功!共处理 " & positions.Count & " 个行内公式。", vbInformation, "操作完成"
Exit Sub

ErrorHandler:
MsgBox "发生了一个错误: " & Err.Description, vbCritical, "宏运行错误"
End Sub

关闭之后,回到Word,按“Alt+F8”,选择“ConvertEquations”,点击“运行”即可。

2025-10-16

生活相关

2025-10-15
  • 技术与与思维的相互塑造
    • Vibe Coding 对程序员思维的影响
      • 个人体验:将编码工作交给AI后,对代码的理解和掌控力下降,
        反而更依赖于AI的提示和建议
    • AI掌握的知识远比人类多,经典的“技术/知识优势”在AI的辅助下逐渐填平,什么是重要的呢?作为学生,如果对技能与知识的掌握不再是优势,那么什么才是学习过程中应该掌握的呢?
      • 思考与判断力
    • 在两年前,我的工作方式还是找文档、查资料、写代码。依靠自己的知识和技能来完成任务。这使得我对技术有了更深的理解和掌握。
2025-10-16

灵感

2025-10-15
  • 碎片化知识管理工具
    • 信息的主动收集?
    • 单纯的记录整理?
2025-10-19
  • 用机器学习工具研究社会学?
    • 经济数据是良好的研究对象
    • 文本情绪分析?
2025-10-21
  • 架构/代码管理与日常收拾东西有什么相似之处吗?

    • 都是“整理”与“归类”的过程
    • 好的架构设计能让代码更易于理解和维护
    • 好的收纳方式能让物品更易于找到和使用
  • SDD —— Specification-Driven Development

    • 通过明确的规范来驱动开发过程
    • 易于Vibe Coding集成
    • Spec Kit
  • 编译原理:语义的形式化表示

    • 在于AI​意图的传递中是否可用?
    • 提示词工程?