在 LDoc 中创建表?

Creating tables in LDoc?

提问人:cj- 提问时间:6/30/2019 更新时间:6/30/2019 访问量:212

问:

如何使用 LDoc 和 lua-discount 生成表? 我需要一些特殊的配置或版本吗?

我正在使用 LDoc 为用 Lua 编写的游戏生成文档。它在大多数情况下有效,但它使用 markdown.lua,默认情况下不支持 markdown 表。所以我把它换成了使用 lua-discount。但它仍然不生成表。

  • LDoc 文档确实指定了我可以使用 lua-discount,并且它提供了对表的支持。
  • 我尝试使用示例表来隔离问题。
  • 直接对表调用 lua-discount 会产生相同的结果。
  • LDoc 和 lua-discount 都是使用没有任何版本号的 luarocks 安装的。
  • 我尝试切换到 lunamark,但忘记安装它,所以它默认回 lua-discount。所以我知道它正在检测 lua-discount。

我的 LDoc 配置:

title='A game'
readme='manuals'
format='discount'
file={ 'src', 'tests', 'library/library/library.c' }
dir='docs'
no_summary=true
kind_names={ topic='Manuals', module='API' }

我将 markdown 文件放在 manuals 文件夹中。为了测试,我从 PHP markdown 文档(https://michelf.ca/projects/php-markdown/extra/)中获取了 lua-discount 应该支持的表格,并将其放在自己的文件中,上面和下面都有空行:


First Header  | Second Header
------------- | -------------
Content Cell  | Content Cell
Content Cell  | Content Cell

它生成了:



    First Header  | Second Header
——————– | ——————–
Content Cell  | Content Cell
Content Cell  | Content Cell


但应该生成:

<table>
<thead>
<tr>
  <th>First Header</th>
  <th>Second Header</th>
</tr>
</thead>
<tbody>
<tr>
  <td>Content Cell</td>
  <td>Content Cell</td>
</tr>
<tr>
  <td>Content Cell</td>
  <td>Content Cell</td>
</tr>
</tbody>
</table>
Lua 降价

评论


答:

0赞 cj- 6/30/2019 #1

我被引导到 discord.gg/code 寻求帮助,那里有人注意到我使用的折扣与记录的折扣不同。原来有 2 个完全不同的 lua-discount 版本!http://asbradbury.org/projects/lua-discount/(Luarocks 的版本)和 https://github.com/craigbarnes/lua-discount

luarocks 上的版本要么已经过时,要么实际上从未支持过表。

因此,为了解决这个问题,我必须:

  • 下载使用 CMake (https://github.com/squeek502/lua-discount) 的存储库的分叉版本。
  • 将折扣添加到空折扣文件夹。
  • 设置LUA_DIR。
  • 制作 lua-discount(适用于 Visual Studio 2019 命令提示符)。
  • 将发布 dll 复制到 luarocks。
  • 删除已安装到 Program Files 的折扣。