【问题标题】:Asciidoctor render_file missing CSSAsciidoctor render_file 缺少 CSS
【发布时间】:2014-02-25 02:33:46
【问题描述】:

从 CLI 运行 AsciiDoctor 会创建一个带有嵌入样式表的 HTML 文档:

$ asciidoctor mysample.adoc

....
<title>My First Experience with the Dangers of Documentation</title>
<style>
/* Asciidoctor default stylesheet | MIT License | http://asciidoctor.org */
article, aside, details, figcaption, figure, footer, header, hgroup, main, nav, section, summary { display: block; }
...

但是,在 Ruby 文件中运行 Asciidoctor 不会:

r.rb:

#!/usr/bin/env ruby

require 'asciidoctor'
Asciidoctor.render_file('mysample.adoc', :in_place => true)

$ ./r.rb

...
<title>My First Experience with the Dangers of Documentation</title>
<link rel="stylesheet" href="./asciidoctor.css">
...

documentation 并不表示应该有任何区别。我错过了什么?

详情:

  • Asciidoctor 0.1.4
  • 红宝石 2.0.0p247

【问题讨论】:

    标签: css ruby ruby-2.0 asciidoctor


    【解决方案1】:

    要嵌入样式表,您必须以“不安全”模式呈现文件:

    require 'asciidoctor'
    Asciidoctor.render_file('mysample.adoc', :in_place => true, :safe => 'unsafe')
    

    【讨论】:

    • 要将其嵌入guardfile,我必须使用语法Asciidoctor.render_file('mysample.adoc', {:in_place =&gt; true, :safe =&gt; :unsafe})
    【解决方案2】:

    从技术上讲,您只需将安全模式设置为 :server 或 :safe。只有 :secure 安全模式(使用 API 时的默认设置)强制启用 linkcss 属性。

    我正在考虑在 1.5.0 中对此进行更改。我不认为向整个文档添加样式是不安全的。此外,有很多方法可以覆盖此行为,因此不会丢失任何内容,但肯定会获得可用性。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-08-21
      • 1970-01-01
      • 2023-01-05
      • 2011-11-06
      • 1970-01-01
      • 2018-11-27
      • 2015-12-31
      • 1970-01-01
      相关资源
      最近更新 更多