Closed wva154 closed 8 years ago
Hello @wva154 Yes I can reproduce this issue, good catch :+1:
I think the space between attributes is ignored.
= Test
{attribute-a}
{attribute-b}
attribute-a=a attribute-b=b
customAttributes
must be split by space:
if (customAttributes) {
attributes.push(customAttributes.split(' '));
}
https://github.com/asciidoctor/asciidoctor-chrome-extension/blob/master/app/js/renderer.js#L137
It's actually a bit more complex than that, though that certainly works for all but the edge cases. See https://github.com/asciidoctor/asciidoctor/blob/v1.5.4/lib/asciidoctor.rb#L1285-L1294
Indeed this a bit moooooore complex. I will pass attributes as a String and let "Asciidoctor core" handles the edge cases :wink:
Same issue here since upgrading the extension :/
@Mogztter and @M3lkior, I think the problem is that the custom attributes are getting pushed onto the array as a single entry. In other words, the array looks like this:
[
'showtitle',
'icons=font@',
...
'outfilesuffix=.adoc',
'skip-front-matter=1 attributeA=1''
]
So the Asciidoctor API sees the value of the skip-front-matter
attribute as 1 attributeA=1
.
I had this same problem in the Jekyll AsciiDoc plugin, so I implemented full attribute parsing. That logic will eventually make its way into the Asciidoctor API. Until then, here it is:
The only difference is that since the input is a text field, you'll need to also add the space escape logic that can be found here:
https://github.com/asciidoctor/asciidoctor/blob/v1.5.4/lib/asciidoctor.rb#L1285-L1294
If you'd like to work upstream instead to introduce this API, I'd be open to working with you on that. See https://github.com/asciidoctor/asciidoctor/issues/1084
@mojavelinux For now I think I will pass all attributes as a single String. That way Asciidoctor will handle the space escape logic, see #134
@Mogztter Yes, that will also solve the issue.
Hi guys, since the current version in the chrome web store does not include this fix, could you please publish a new one with it? It took me a while to understand why the custom attributes did not work (unless I entered only one) until I found this issue :) Thanks!
PS: yes, I can just clone the project and use developer mode, but I think that from a user point of view it's a rather confusing bug.
Hi @akosma,
Sorry about that, my attention was focused on Asciidoctor.js. I will try to find the time this week to publish the new version on the Chrome Web Store :sparkles:
Now that is fantastic! :) thank you so much, for all the effort. This whole family of projects is helping me a lot!
Just for the record, and this might be handy for someone else, in the meantime I'm passing the custom attributes in the querystring, which works beautifully well with the current version of the Chrome extension:
file:///Users/folder/file.asciidoc?toc&numbered&source-language=objectivec&…
You're welcome, I'm glad to know that you like it :wink: I've just published a new version (1.5.4.111), it should be available soon:
https://github.com/asciidoctor/asciidoctor-chrome-extension/releases/tag/v1.5.4.111
Wohoooo! :) thanks
It seems that when setting custom attributes with the options menu, that only the first one is detected and used. For example using the string
skip-front-matter=1 attributeA=1
it respects the skip-front-matter, but attributeA is not set and using the string
attributeA=1 skip-front-matter=1
do sets attributeA but ignores the skip-front-matter attribute.
Can anyone confirm this issue?