使用gitbook生成PDF报错问题

虽然是一个很小的问题,但是耗费的时间一点都不少。仅此记录,以免下次使用时发生错误。

报错信息如下:

bash-3.2# gitbook pdf /Users/zhangzhan/Desktop/test /Users/zhangzhan/Desktop/test6.pdf -d
info: 7 plugins are installed 
info: 6 explicitly listed 
info: loading plugin "highlight"... OK 
info: loading plugin "search"... OK 
info: loading plugin "lunr"... OK 
info: loading plugin "sharing"... OK 
info: loading plugin "fontsettings"... OK 
info: loading plugin "theme-default"... OK 
info: found 521 pages 
info: found 8 asset files 
error: error while generating page "nei-jian-han-shu-zhai-yao.md": 

Template render error: (/Users/zhangzhan/Desktop/test/nei-jian-han-shu-zhai-yao.md) [Line 107, Column 149]
  expected variable end
Template render error: (/Users/zhangzhan/Desktop/test/nei-jian-han-shu-zhai-yao.md) [Line 107, Column 149]
  expected variable end
    at Object.exports.prettifyError (/Users/zhangzhan/.gitbook/versions/3.2.3/node_modules/nunjucks/src/lib.js:34:15)
    at new_cls.render (/Users/zhangzhan/.gitbook/versions/3.2.3/node_modules/nunjucks/src/environment.js:469:27)
    at new_cls.renderString (/Users/zhangzhan/.gitbook/versions/3.2.3/node_modules/nunjucks/src/environment.js:327:21)
    at Promise.apply (/Users/zhangzhan/.gitbook/versions/3.2.3/node_modules/q/q.js:1165:26)
    at Promise.promise.promiseDispatch (/Users/zhangzhan/.gitbook/versions/3.2.3/node_modules/q/q.js:788:41)
    at /Users/zhangzhan/.gitbook/versions/3.2.3/node_modules/q/q.js:1391:14
    at runSingle (/Users/zhangzhan/.gitbook/versions/3.2.3/node_modules/q/q.js:137:13)
    at flush (/Users/zhangzhan/.gitbook/versions/3.2.3/node_modules/q/q.js:125:13)
    at _combinedTickCallback (internal/process/next_tick.js:73:7)
    at process._tickCallback (internal/process/next_tick.js:104:9)

源 macdown 文档内容部分如下:

`array_to_json('{{1,5},{99,100}}'::int[])` 

处理方案:

添加转义字符

array\_to\_json('\{\{1,5\},\{99,100\}\}'::int[])
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
可能是因为您没有在 GitBook 的配置文件中设置生成目录的选项。您可以在 book.json 文件中添加以下代码: ``` "plugins": [ "expandable-chapters", "expandable-sections", "anchor-navigation-ex", "splitter", "tbfed-pagefooter", "tbfed-gitbook", "tbfed-navbar", "tbfed-sidebar", "tbfed-author", "tbfed-copy-code", "tbfed-mermaid", "tbfed-kroki" ], "pluginsConfig": { "anchor-navigation-ex": { "showLevel": false, "scrollToTop": true }, "tbfed-pagefooter": { "contribute": true, "contributeText": "Edit This Page", "github": "https://github.com/username/repo", "githubText": "GitHub", "slack": "https://slack.com/username", "slackText": "Slack", "twitter": "https://twitter.com/username", "twitterText": "Twitter", "wechat": "wechatid", "wechatText": "WeChat" }, "tbfed-gitbook": { "isMulti": false, "bookName": "GitBook", "bookLogo": "https://raw.githubusercontent.com/tbfed/tbfed-pagefooter/master/images/gitbook.png", "bookDescription": "GitBook 是一个基于 Node.js 的命令行工具,可用于创建漂亮的电子书。", "bookKeywords": "GitBook, Node.js, 电子书", "bookLanguage": "zh-hans", "bookDirection": "ltr", "bookRepository": "https://github.com/GitbookIO/gitbook.git", "bookHomepage": "https://www.gitbook.com/", "bookLicense": "MIT", "bookVersion": "3.2.3", "bookAuthor": "GitBook", "bookContributors": [ { "name": "Tommy Lau", "email": "tommy@tbfed.com", "url": "https://www.tbfed.com/" } ] }, "tbfed-navbar": { "websiteName": "GitBook", "websiteLogo": "https://raw.githubusercontent.com/tbfed/tbfed-pagefooter/master/images/gitbook.png", "fixed": true, "links": [ { "text": "Home", "link": "https://www.gitbook.com/" }, { "text": "Docs", "link": "https://docs.gitbook.com/" }, { "text": "Blog", "link": "https://www.gitbook.com/blog/" }, { "text": "Community", "link": "https://www.gitbook.com/community" } ] }, "tbfed-sidebar": { "isMulti": false, "intro": "GitBook 是一个基于 Node.js 的命令行工具,可用于创建漂亮的电子书。", "navs": [ { "name": "Getting Started", "link": "/getting-started.html", "icon": "fa fa-rocket", "subs": [ { "name": "Introduction", "link": "/getting-started/introduction.html" }, { "name": "Installation", "link": "/getting-started/installation.html" }, { "name": "Usage", "link": "/getting-started/usage.html" } ] }, { "name": "Configuration", "link": "/configuration.html", "icon": "fa fa-cog", "subs": [ { "name": "Basic", "link": "/configuration/basic.html" }, { "name": "Advanced", "link": "/configuration/advanced.html" } ] }, { "name": "Plugins", "link": "/plugins.html", "icon": "fa fa-plug", "subs": [ { "name": "Official Plugins", "link": "/plugins/official-plugins.html" }, { "name": "Third-party Plugins", "link": "/plugins/third-party-plugins.html" } ] }, { "name": "Themes", "link": "/themes.html", "icon": "fa fa-paint-brush", "subs": [ { "name": "Official Themes", "link": "/themes/official-themes.html" }, { "name": "Third-party Themes", "link": "/themes/third-party-themes.html" } ] } ] }, "tbfed-author": { "name": "GitBook", "email": "support@gitbook.com", "url": "https://www.gitbook.com/" }, "tbfed-copy-code": { "buttonText": "Copy", "color": "#ffffff", "bgColor": "#4d4d4d", "notifyText": "Copied!", "time": 1000 }, "tbfed-mermaid": { "theme": "default" }, "tbfed-kroki": { "url": "https://kroki.io", "diagrams": [ "blockdiag", "seqdiag", "actdiag", "nwdiag", "rackdiag", "packetdiag", "erd", "plantuml", "umlet", "vega", "vegalite", "wavedrom", "nomnoml", "svgbob" ] } } ``` 然后重新生成您的 GitBook 即可看到目录。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值