Skip to content

Conversation

@pengcai6
Copy link

@pengcai6 pengcai6 commented Jul 1, 2025

🔧 修复内容

本 PR 修复了项目在 Pandoc 3.x 版本上的兼容性问题,使项目能够在最新版本的 Pandoc 上正常运行。

主要修改

  1. Table API 兼容性修复

    • 修复了 pandoc.Table 构造函数的参数变化
    • 更新了 TableBody 参数顺序:(attr, row_head_columns, head, body)
    • 修复了 TableHeadTableFoot 的构造方式
  2. List 方法更新

    • 将已废弃的 inlines:erase(i) 替换为 inlines:remove(i)
    • 修复了循环变量冲突问题
  3. 空值安全检查

    • 为所有 metavalues 字段添加了空值保护
    • 防止因缺失元数据导致的运行时错误
  4. 兼容性层

    • 添加了条件函数定义,保持向后兼容性
    • 仅在需要时定义自定义 Table 相关函数

测试环境

  • Pandoc 版本: 3.7.0.2
  • Lua 版本: 5.4
  • 操作系统: macOS
  • 测试状态: ✅ 所有核心功能正常工作

功能验证

✅ 封面生成 (cover)
✅ 图表编号 (numbering)
✅ 章节处理 (section)
✅ 书签功能 (bookmark)
✅ 域处理 (field)
✅ 段内换行 (softbreak)
✅ 参考文献 (citeproc)
✅ 字数统计 (word_count)

生成文件

成功生成了完整的南京大学学位论文 Word 文档,所有格式和功能均正常。

向后兼容性

本修改保持了与旧版本 Pandoc 的兼容性,通过条件检查确保在不同版本的 Pandoc 上都能正常工作。


测试命令:

cd thesis
pandoc --lua-filter ../src/thesis.lua --citeproc sample.md --reference-doc nju-thesis-reference.docx --output sample.docx

Fixes compatibility with Pandoc 3.x while maintaining backward compatibility.

- Fix Table constructor API changes for Pandoc 3.x
- Update TableBody parameter order (attr, row_head_columns, head, body)
- Replace deprecated inlines:erase() with inlines:remove()
- Add null safety checks for metavalues fields
- Add compatibility layer for Table-related functions
- Maintain backward compatibility with conditional function definitions

Tested with Pandoc 3.7.0.2 on macOS
All core features working: cover, numbering, section, bookmark, field, softbreak, citeproc
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.

1 participant