[filters] How to pass options to filters - aafigure

108 views
Skip to first unread message

Yann E. MORIN

unread,
Sep 5, 2014, 4:19:12 PM9/5/14
to asci...@googlegroups.com, Yann E. MORIN
Hello!

I'm trying to use the aafigure filter:
  - https://code.google.com/p/asciidoc-aafigure-filter/

The plugin works, in that the aafigure input in my asciidoc
is rendered into an SVG file, and included in the HTML output
(as an <img...> tag, of course).

However, it seems I am unable to understand how to pass
options/arguments/parameters to the filter.

Here is (part of) my asciidoc input:

[aafigure,,format="png"]
----
    +----------------------+
    | Board                |
    +----------------------+
    | "- Kernel arg hook"  |
    | "- Boot arg hook"    |
    | "- Custom hooks"     |
    +----------------------+
----

But yet, the output is still SVG.

If I set a single comma, like: [aafigure,format="png"] then it tries
to output to a file named 'format=png' .

How am I supposed to actually pass options to the filter?
Thanks in advance for any suggestion! ;-)

Regards,
Yann E. MORIN.

Yann E. MORIN

unread,
Sep 5, 2014, 6:41:48 PM9/5/14
to asci...@googlegroups.com
Hello again,

On 2014-09-05 13:19 -0700, Yann E. MORIN spake thusly:
> I'm trying to use the aafigure filter:
> - https://code.google.com/p/asciidoc-aafigure-filter/
>
> The plugin works, in that the aafigure input in my asciidoc
> is rendered into an SVG file, and included in the HTML output
> (as an <img...> tag, of course).
>
> However, it seems I am unable to understand how to pass
> options/arguments/parameters to the filter.
>
> Here is (part of) my asciidoc input:
>
> [aafigure,,format="png"]
> ----
> +----------------------+
> | Board |
> +----------------------+
> | "- Kernel arg hook" |
> | "- Boot arg hook" |
> | "- Custom hooks" |
> +----------------------+
> ----
> But yet, the output is still SVG.

Ok, I found how to use that one:

[aafigure]
[format="png"]
----
My aafigure text here.
----

Now, I'm still stuck at passing options:

[aafigure]
[options="textual"]
----
oooo
----

Should produce just a run of 4 'o', but it generates a filled block, as
though the [options="textual"] was not present.

Still, what ma I missing?

Regards,
Yann E. MORIN.

--
.-----------------.--------------------.------------------.--------------------.
| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ |
| +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |
'------------------------------^-------^------------------^--------------------'

Lex Trotman

unread,
Sep 5, 2014, 7:24:52 PM9/5/14
to asci...@googlegroups.com
On 6 September 2014 06:19, Yann E. MORIN <yann.mo...@gmail.com> wrote:
> Hello!
>
> I'm trying to use the aafigure filter:
> - https://code.google.com/p/asciidoc-aafigure-filter/
>
> The plugin works, in that the aafigure input in my asciidoc
> is rendered into an SVG file, and included in the HTML output
> (as an <img...> tag, of course).
>
> However, it seems I am unable to understand how to pass
> options/arguments/parameters to the filter.
>
> Here is (part of) my asciidoc input:
>
> [aafigure,,format="png"]

You need quotes around *all* parameters if you put quotes around any
values, see http://wiki.asciidoc-aafigure-filter.googlecode.com/hg/asciidoc-aafigure-readme.html.

Cheers
Lex

> ----
> +----------------------+
> | Board |
> +----------------------+
> | "- Kernel arg hook" |
> | "- Boot arg hook" |
> | "- Custom hooks" |
> +----------------------+
> ----
>
> But yet, the output is still SVG.
>
> If I set a single comma, like: [aafigure,format="png"] then it tries
> to output to a file named 'format=png' .
>
> How am I supposed to actually pass options to the filter?
> Thanks in advance for any suggestion! ;-)
>
> Regards,
> Yann E. MORIN.
>
> --
> You received this message because you are subscribed to the Google Groups
> "asciidoc" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to asciidoc+u...@googlegroups.com.
> To post to this group, send email to asci...@googlegroups.com.
> Visit this group at http://groups.google.com/group/asciidoc.
> For more options, visit https://groups.google.com/d/optout.

Yann E. MORIN

unread,
Sep 6, 2014, 8:23:39 AM9/6/14
to asci...@googlegroups.com
Lex, All,

On 2014-09-06 09:24 +1000, Lex Trotman spake thusly:
> On 6 September 2014 06:19, Yann E. MORIN <yann.mo...@gmail.com> wrote:
> > Hello!
> >
> > I'm trying to use the aafigure filter:
> > - https://code.google.com/p/asciidoc-aafigure-filter/
> >
> > The plugin works, in that the aafigure input in my asciidoc
> > is rendered into an SVG file, and included in the HTML output
> > (as an <img...> tag, of course).
> >
> > However, it seems I am unable to understand how to pass
> > options/arguments/parameters to the filter.
> >
> > Here is (part of) my asciidoc input:
> >
> > [aafigure,,format="png"]
>
> You need quotes around *all* parameters if you put quotes around any
> values, see http://wiki.asciidoc-aafigure-filter.googlecode.com/hg/asciidoc-aafigure-readme.html.

OK, thanks. I missed that (stupid me).

However, the options are still not passed to the filter:

["aafigure",format="png",options="textual"]
----
oooo
----

Should just generate a run of four 'o' characters, but still the
aafigure filter is not passed the 'textual' option.

Here is a strace log:

strace -ff -o strace/a2x.log -s 4096 -- a2x --xsltproc-opts \
"--stringparam toc.section.depth 1" -f xhtml -d book \
-L -r images -D manual manual.txt --asciidoc-opts="" -v

Then I can see:

$ grep -E 'execve\(.*aafig' strace/*'
strace/a2x.log.24398:execve("/bin/sh", ["/bin/sh", "-c", "\"/usr/bin/python\"
\"/home/ymorin/dev/buildroot/br.config/docs/filters/aafigure/aafig2img.py\"
-v -o \"/home/ymorin/dev/buildroot/br.config/docs/manual/manual__1.png\"
-Fpng -"], [/* 85 vars */]) = 0

The filter is in:
./filter/aafigure/aafigure-filter.conf
./filter/aafigure/aafig2img.py

and has:
[aafigure-filter-style]
aafigure-style=template="aafigure-block",subs=(),posattrs=("style","target"),
filter='aafig2img.py [.....] {textual-option? --textual} [.....] -'

[.....] is me eliding all the other options...

Now I tried with the single-option, and quoting all the parameters:

["aafigure",format="png","textual-option"]
----
oooo
----

Now asciidoc whines:
asciidoc: ERROR: ug-concepts.txt: line 39: illegal style name: "aafigure"

Ditto if I unquote the single option:

["aafigure",format="png",textual-option]
----
oooo
----

asciidoc: ERROR: ug-concepts.txt: line 39: illegal style name: "aafigure"

And now, if I put the option on its own line:

["aafigure",format="png"]
[options="textual"]
----
oooo
----

Again, the textual option is not passed to the aafigure filter (as seen
in an strace log.)

So, let's try with the single-option form, now:

["aafigure",format="png"]
["textual-option"]
----
oooo
----

asciidoc: WARNING: ug-concepts.txt: line 40: missing style:
[blockdef-listing]: textual-option

Without quoting it, same warning.

What am I missing again?

BTW, using asciidoc 8.6.9, on Ubuntu 14.04.

Regards,
Yann E. MORIN.

--

Lex Trotman

unread,
Sep 6, 2014, 7:22:21 PM9/6/14
to asci...@googlegroups.com
BTW, Options go before the filename, then -v would print the command
that was run and you wouldn't need the strace to see it :)

I can't see any other filters that use the options=... syntax, and the
Asciidoc documentation says the options are available in markup, not
explicitly that they will be available in the filter command, so
possibly it never worked.

You should contact the aafigure maintainer to verify the filter works
with the version of asciidoc you are using.

Cheers
Lex

Yann E. MORIN

unread,
Sep 6, 2014, 8:10:13 PM9/6/14
to asci...@googlegroups.com
Lex, All,

On 2014-09-07 09:22 +1000, Lex Trotman spake thusly:
> On 6 September 2014 22:23, Yann E. MORIN <yann.mo...@free.fr> wrote:
[--SNIP--]
> > However, the options are still not passed to the filter:
> >
> > ["aafigure",format="png",options="textual"]
> > ----
> > oooo
> > ----

BTW, while at it: Would it be possible that, when the output format is
'text', the block is not rendered at all, and just passed as-is to the
output?

Currently, the block is simply replaced by the name of the image (or
ignored for me, since I have: [image-blockmacro] {empty} in my
configuration.)

> > Should just generate a run of four 'o' characters, but still the
> > aafigure filter is not passed the 'textual' option.
> >
> > Here is a strace log:
> >
> > strace -ff -o strace/a2x.log -s 4096 -- a2x --xsltproc-opts \
> > "--stringparam toc.section.depth 1" -f xhtml -d book \
> > -L -r images -D manual manual.txt --asciidoc-opts="" -v
>
> BTW, Options go before the filename, then -v would print the command
> that was run and you wouldn't need the strace to see it :)

Ah, nice to know. Thanks! :-)

> I can't see any other filters that use the options=... syntax, and the
> Asciidoc documentation says the options are available in markup, not
> explicitly that they will be available in the filter command, so
> possibly it never worked.

Oh. This is sad news, if that's the case... :-/

> You should contact the aafigure maintainer to verify the filter works
> with the version of asciidoc you are using.

Well, I was hoping he would be lurking around here! ;-)

I now contacted him. If/when I have an answer, I'll be sure to keep the
list informed about the outcome.

Thanks again for your help! :-)

hwm...@gmail.com

unread,
Sep 6, 2014, 10:56:14 PM9/6/14
to asci...@googlegroups.com, yann.mo...@free.fr
Hello Yann,

I developed those filters 3 years ago and the option processing was working with the AsciiDoc version of that time which was 8.6.6. I tested today and using 8.6.6 all works beautifully. However I can confirm that version 8.6.9 for example will not pass the options to the filters. So it appears that along the line AsciiDoc lost its capability to pass options to filters. The core filters do not use options so that may explain why this does not show up in regression testing.

I suggest to go back to version 8.6.6 until a fix is available.

Henrik

Lex Trotman

unread,
Sep 6, 2014, 11:16:53 PM9/6/14
to asci...@googlegroups.com
On 7 September 2014 10:10, Yann E. MORIN <yann.mo...@free.fr> wrote:
> Lex, All,
>
> On 2014-09-07 09:22 +1000, Lex Trotman spake thusly:
>> On 6 September 2014 22:23, Yann E. MORIN <yann.mo...@free.fr> wrote:
> [--SNIP--]
>> > However, the options are still not passed to the filter:
>> >
>> > ["aafigure",format="png",options="textual"]
>> > ----
>> > oooo
>> > ----
>
> BTW, while at it: Would it be possible that, when the output format is
> 'text', the block is not rendered at all, and just passed as-is to the
> output?

That would be up to the filter.

>
> Currently, the block is simply replaced by the name of the image (or
> ignored for me, since I have: [image-blockmacro] {empty} in my
> configuration.)
>
>> > Should just generate a run of four 'o' characters, but still the
>> > aafigure filter is not passed the 'textual' option.
>> >
>> > Here is a strace log:
>> >
>> > strace -ff -o strace/a2x.log -s 4096 -- a2x --xsltproc-opts \
>> > "--stringparam toc.section.depth 1" -f xhtml -d book \
>> > -L -r images -D manual manual.txt --asciidoc-opts="" -v
>>
>> BTW, Options go before the filename, then -v would print the command
>> that was run and you wouldn't need the strace to see it :)
>
> Ah, nice to know. Thanks! :-)
>
>> I can't see any other filters that use the options=... syntax, and the
>> Asciidoc documentation says the options are available in markup, not
>> explicitly that they will be available in the filter command, so
>> possibly it never worked.
>
> Oh. This is sad news, if that's the case... :-/
>
>> You should contact the aafigure maintainer to verify the filter works
>> with the version of asciidoc you are using.
>
> Well, I was hoping he would be lurking around here! ;-)

I see you found him :)

You or Henrick should raise an issue on github to prevent it being forgotten.

Cheers
Lex

>
> I now contacted him. If/when I have an answer, I'll be sure to keep the
> list informed about the outcome.
>
> Thanks again for your help! :-)
>
> Regards,
> Yann E. MORIN.
>
> --
> .-----------------.--------------------.------------------.--------------------.
> | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
> | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ |
> | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no |
> | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |
> '------------------------------^-------^------------------^--------------------'
>

Yann E. MORIN

unread,
Sep 7, 2014, 5:36:16 AM9/7/14
to asci...@googlegroups.com
Lex, All,

On 2014-09-07 13:16 +1000, Lex Trotman spake thusly:
> On 7 September 2014 10:10, Yann E. MORIN <yann.mo...@free.fr> wrote:
> > BTW, while at it: Would it be possible that, when the output format is
> > 'text', the block is not rendered at all, and just passed as-is to the
> > output?
> That would be up to the filter.

OK, I'll see if I can cook up something.

How can the filter know what the output format is?

Which brings up the other question:

How in asciidoc syntax can we know what the output format is? I looked
at the different attributes, but all I could find was {backend} which is
not the output format.

> You or Henrick should raise an issue on github to prevent it being forgotten.

I will do shortly. Thanks again for the help, it's much appreciated! :-)

Lex Trotman

unread,
Sep 7, 2014, 7:39:47 AM9/7/14
to asci...@googlegroups.com
On 7 September 2014 19:36, Yann E. MORIN <yann.mo...@free.fr> wrote:
> Lex, All,
>
> On 2014-09-07 13:16 +1000, Lex Trotman spake thusly:
>> On 7 September 2014 10:10, Yann E. MORIN <yann.mo...@free.fr> wrote:
>> > BTW, while at it: Would it be possible that, when the output format is
>> > 'text', the block is not rendered at all, and just passed as-is to the
>> > output?
>> That would be up to the filter.
>
> OK, I'll see if I can cook up something.
>
> How can the filter know what the output format is?
>
> Which brings up the other question:
>
> How in asciidoc syntax can we know what the output format is? I looked
> at the different attributes, but all I could find was {backend} which is
> not the output format.

Well, the backend is the output from asciidoc, and is the output
format for the various HTML backends.

However if the backend is docbook then other toolchains usually
transform it further and asciidoc doesn't know about it. If you run
those toolchains using the a2x script then the a2x-format attribute is
provided to asciidoc to specify the output of the toolchain that a2x
is running. If you don't use a2x then it is up to you.

Cheers
Lex

>
>> You or Henrick should raise an issue on github to prevent it being forgotten.
>
> I will do shortly. Thanks again for the help, it's much appreciated! :-)
>
> Regards,
> Yann E. MORIN.
>
> --
> .-----------------.--------------------.------------------.--------------------.
> | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
> | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ |
> | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no |
> | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |
> '------------------------------^-------^------------------^--------------------'
>

Yann E. MORIN

unread,
Sep 7, 2014, 8:25:19 AM9/7/14
to asci...@googlegroups.com
Lex, All,

On 2014-09-07 21:39 +1000, Lex Trotman spake thusly:
> On 7 September 2014 19:36, Yann E. MORIN <yann.mo...@free.fr> wrote:
> > How can the filter know what the output format is?
> >
> > Which brings up the other question:
> >
> > How in asciidoc syntax can we know what the output format is? I looked
> > at the different attributes, but all I could find was {backend} which is
> > not the output format.
>
> Well, the backend is the output from asciidoc, and is the output
> format for the various HTML backends.
>
> However if the backend is docbook then other toolchains usually
> transform it further and asciidoc doesn't know about it. If you run
> those toolchains using the a2x script then the a2x-format attribute is
> provided to asciidoc to specify the output of the toolchain that a2x
> is running. If you don't use a2x then it is up to you.

Ah, I think I found a better solution yet: do not even pass the filter
if output is "text"

[{a2x-format$^text$::"my-filter"}]
----
My ASCII-art diagrams
----

Works as expected, even though this might not be the best solution.

hwm...@gmail.com

unread,
Sep 8, 2014, 7:47:58 PM9/8/14
to asci...@googlegroups.com, yann.mo...@free.fr
Hi,

Just to clarify some of the previous discussion since my last post.


1) option not passed

The option passing worked for all filters since AsciiDoc 8.6.3 until AsciiDoc 8.6.6.

Some time after AsciiDoc 8.6.6 AsciiDoc stopped generating the <optionname>-option attributes when processing the filter configuration files. This is the problem we are facing now and it needs to be fixed in the AsciiDoc core. There is nothing which can be done in the filter itself as currently the option information is not passed to the filer configuration files.

2) Not processing the filter depending on backend used (for example text)

I don't think this should be a function og the aafigure filter. What you want is to use a different filter depending on the backend. One to generate text, the other to run aafigure.
I would recommend to keep the logic to select which filter you want in the source document. You can use the basebackend macros to select the filters you want to use to generate a certain output.

Henrik






Henrik

Zang MingJie

unread,
Sep 19, 2014, 8:18:58 AM9/19/14
to asci...@googlegroups.com, yann.mo...@free.fr

Lex Trotman

unread,
Oct 1, 2014, 4:03:13 AM10/1/14
to asci...@googlegroups.com
On 19 September 2014 22:18, Zang MingJie <zealo...@gmail.com> wrote:
> Try this patch:
>
> https://github.com/kghost/asciidoc/commit/4311d7f699b9ddaccbc421150ca35823e5d68169

Hi,

Can yo make it a pull request on the asciidoc github
https://github.com/asciidoc/asciidoc
>
> I have created an issue last year, but no respond
>
> https://code.google.com/p/asciidoc/issues/detail?id=20

ahhh sorry, since the move to github I don't think the google code
issues are read very often, but since none of the current contributors
owns it we can't provide a message pointing to github.

Cheers
Lex

>
>
> On Tuesday, September 9, 2014 7:47:58 AM UTC+8, hwm...@gmail.com wrote:
>>
>> Hi,
>>
>> Just to clarify some of the previous discussion since my last post.
>>
>>
>> 1) option not passed
>>
>> The option passing worked for all filters since AsciiDoc 8.6.3 until
>> AsciiDoc 8.6.6.
>>
>> Some time after AsciiDoc 8.6.6 AsciiDoc stopped generating the
>> <optionname>-option attributes when processing the filter configuration
>> files. This is the problem we are facing now and it needs to be fixed in the
>> AsciiDoc core. There is nothing which can be done in the filter itself as
>> currently the option information is not passed to the filer configuration
>> files.
>>
>> 2) Not processing the filter depending on backend used (for example text)
>>
>> I don't think this should be a function og the aafigure filter. What you
>> want is to use a different filter depending on the backend. One to generate
>> text, the other to run aafigure.
>> I would recommend to keep the logic to select which filter you want in the
>> source document. You can use the basebackend macros to select the filters
>> you want to use to generate a certain output.
>>
>> Henrik
>>
>>
>>
>>
>>
>>
>> Henrik
>
Reply all
Reply to author
Forward
0 new messages