Asciidoctor render_file missing CSS

Running AsciiDoctor from the CLI creates an HTML document with a built-in stylesheet:

$ 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; }
...

However, running Asciidoctor in a Ruby file fails:

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">
...

The documentation does not indicate that there should be any difference. What am I missing?

More details:

  • Ascidodox 0.1.4
  • ruby 2.0.0p247
+3
source share
2 answers

To embed a stylesheet, you need to display the file in "unsafe" mode:

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

Technically, you only need to set safe mode to: server or: safe. Only safe safe mode (by default when using the API) enforces the linkcss attribute.

1.5.0. , . , , , .

+1

All Articles