雨果与 Asciidoctor

Seb*_*eld 2 blogs asciidoctor hugo

我正在尝试用 Hugo 建立一个博客,只要我使用 Markdown,它基本上就可以正常工作。但由于我在存储库中还有一些带有 antora 的其他网站内容(文档),所以我想用 asciidoc 编写所有文本。但当我尝试从 adoc 文件生成网站时,我总是遇到这个错误。Markdown 可以工作,但 Asciidoc 给出了这个例外:

\n
sebastian@kobol:~/work/repos/sommerfeld-io/website/blog$ hugo\nStart building sites \xe2\x80\xa6 \nhugo v0.92.1-85E2E862 linux/amd64 BuildDate=2022-01-27T11:44:41Z VendorInfo=gohugoio\nError: Error building site: "/home/sebastian/work/repos/sommerfeld-io/website/blog/content/posts/my-second-post.adoc:1:1": access denied: "asciidoctor" is not whitelisted in policy "security.exec.allow"; the current security configuration is:\n\n[security]\n  enableInlineShortcodes = false\n  [security.exec]\n    allow = ['^dart-sass-embedded$', '^go$', '^npx$', '^postcss$']\n    osEnv = ['(?i)^(PATH|PATHEXT|APPDATA|TMP|TEMP|TERM)$']\n\n  [security.funcs]\n    getenv = ['^HUGO_']\n\n  [security.http]\n    methods = ['(?i)GET|POST']\n    urls = ['.*']\n\n\nTotal in 40 ms\n
Run Code Online (Sandbox Code Playgroud)\n

任何人都可以给我一个关于如何允许从hugo builds 访问asciidoctor 的提示吗?

\n

Ric*_*ith 5

这是默认的安全策略。您需要编辑您的config.toml文件(或放置 Hugo 配置文件的任何位置)并添加自定义安全策略。

至少,自定义安全策略将是默认策略的“剪切和粘贴”,并添加一两个额外的正则表达式。

例如:

[security]
enableInlineShortcodes = false

[security.exec]
allow = ["^dart-sass-embedded$", "^go$", "^npx$", "^postcss$", "^asciidoctor$"]
osEnv = ["(?i)^(PATH|PATHEXT|APPDATA|TMP|TEMP|TERM|RUBYLIB)$"]

[security.funcs]
getenv = ["^HUGO_"]

[security.http]
methods = ["(?i)GET|POST"]
urls = [".*"]
Run Code Online (Sandbox Code Playgroud)

我还添加了RUBYLIB环境变量来告诉 Hugo 告诉 AsciiDoctor 其内联宏扩展所在的位置。