On 04/02/11 14:18, Henrik wrote:
Thank you for your reply.
I added those debug lines and it is indeed working once I quoted the
style attribute.
Initially I had:
[aafigure,"bar.png",foreground="#ff1050",aspect="0.7"]
after changing it to:
["aafigure","bar.png",foreground="#ff1050",aspect="0.7"]
it works.
So I thought the style does not need to be quoted according to other
examples from the music and source filter but it appears quotes are
necessary once quoted attribute parameters are given.
That's correct, http://www.methods.co.nz/asciidoc/userguide.html#X21 ``If the
list contains any named or quoted attributes then all string attribute values
must be quoted.''
You don't have to quote numeric parameter values i.e. this will also work (in
fact the list of attributes can be any legal Python arguments list):
["aafigure","bar.png",foreground="#ff1050",aspect=0.7]
Cheers, Stuart
Regards
Henrik
On Feb 4, 6:32 am, Stuart Rackham<[email protected]> wrote:
Hi Henrik
On 03/02/11 19:37, Henrik wrote:
Hi,
probably a question for Stuart, but others may be able to help as
well.
I am working on an aafigure filter for AsciiDoc which is almost
completed. The thing I am struggling with is how to pass optional
arguments to the filter.
For example:
[aafigure,"block.png",scale=0.5,fill="00b",aspect=0.8,options="textual"]
----------------------------
+--------------------+
+ ASCII art is ugly +
+--------------------+
---------------------------
No problems with the first two positional arguments. But how to
implement the non-positional arguments like scale, fill, aspect and
textual?
This is what I thought it should be in the filter configuration, but
none of the optional arguments seem to be defined when the filter
style is parsed:
[aafigure-filter-style]
aafigure-style=template="aafigure{format?-{format}}-
block",subs=(),posattrs=("style","target"),filter='aafig2img.py
{verbose?-v} -o "{outdir={indir}}/{imagesdir=}{imagesdir?/}{target}" -
F {format=png}{fill? --fill {fill}}{foreground? --foreground
{foreground}}{background? --background {background}}{scale? --scale
{scale}}{aspect? --aspect {aspect}}{linewidth? --linewidth {linewidth}}
{textual-option? --textual} -'
What am I missing here?
Looks fine to me. I did a test: added a couple of named args to a simple source
code filter example:
["source","python",named1="one",named2="two"]
---------------------------------------------------------------------
Test
---------------------------------------------------------------------
Then I added a couple of print statements to the filter_lines() function just
after command-line substitution:
diff -r f1d6c6f658c0 asciidoc.py
--- a/asciidoc.py�������Thu Feb 03 12:29:23 2011 +1300
+++ b/asciidoc.py�������Fri Feb 04 09:18:51 2011 +1300
@@ -662,6 +662,9 @@
return lines
# Perform attributes substitution on the filter command.
s = subs_attrs(filter_cmd, attrs)
+ print filter_cmd
+ print attrs
+ print s
if not s:
message.error('undefined filter attribute in command: %s' %
filter_cmd)
return []
Heres the output:
$ asciidoc t.txt
source-highlight -f xhtml -s {language} {src_numbered?--line-number}
{src_tab?--tab={src_tab}}
{'named2': 'two', 'named1': 'one', 'language': 'python', 'style': 'source', '1':
'source', '0': '"source","python",named1="one",named2="two"', '2': 'python'}
source-highlight -f xhtml -s python
You can see the named args as keys 'named1' and 'named2' in the attributes
dictionary.
Try this and see if the attrs dictionary contains the expected named attributes.
Cheers, Stuart
Cheers
Henrik
--
You received this message because you are subscribed to the Google Groups
"asciidoc" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/asciidoc?hl=en.