asciidoctor / asciidoctor.org

:globe_with_meridians: Asciidoctor project site. Composed in AsciiDoc. Baked with Awestruct.
https://asciidoctor.org
Other
323 stars 805 forks source link

Wrong default value for :docinfo: #845

Closed ismailarilik closed 5 years ago

ismailarilik commented 5 years ago

Here there is a sentence:

Setting docinfo with no value is equivalent to setting the value to private.

But I think it is wrong. I have index.adoc and index-docinfo.html file in the same directory. index-docinfo.html file has this content:

<script src="http://localhost:35729/livereload.js?snipver=1"></script>

When I tried to convert the AsciiDoc file to HTML, script was not injected.

Then I added this line to index.adoc:

:docinfo: private-head

Then script was injected and worked successfully.

So I think default value changed for this directive but I don't know what it is so what I can do is opening an issue rather than fixing this and sending a PR; sorry.

mojavelinux commented 5 years ago

We have tests to verify this behavior, so I'm confident that the cited statement is correct.

Which version of Asciidoctor are you using? How are you calling Asciidoctor? It's possible that a default value is being set somewhere in your toolchain.

ismailarilik commented 5 years ago

Output of asciidoctor -v:

Asciidoctor 1.5.8 [https://asciidoctor.org]
Runtime Environment (ruby 2.6.1p33 (2019-01-30 revision 66950) [x64-mingw32]) (lc:IBM857 fs:Windows-1254 in:IBM857 ex:IBM857)

I use Asciidoctor API with Guard:

require 'asciidoctor'

guard 'shell' do
  watch(/^.*\.adoc$/) do
    Asciidoctor.convert_file 'index.adoc', safe: :safe
  end
end

I wrote this line to index.adoc file and problem was fixed:

:docinfo: private-head

I removed this line and tried again. But script wasn't injected as I said before. Also with this line, corresponding livereload functionality worked, but without it this functionality didn't work.

mojavelinux commented 5 years ago

You always have to set the docinfo attribute. It's just that the value can be blank. In other words, your document needs to look like this:

:docinfo:

content of document

That's what we mean when we say that the default value (when blank) is private. It doesn't mean the attribute is set by default.

The other option is to pass the attribute to the API:

Asciidoctor.convert_file 'index.adoc', safe: :safe, attributes: 'docinfo'
ismailarilik commented 5 years ago

Hmm, sorry. I misunderstood. Thanks... 😄