On 07/09/10 23:34, Phillip Lord wrote:
Stuart Rackham<[email protected]>  writes:
On 07/09/10 01:11, Phillip Lord wrote:



I have a two part question with respect to blogpost. First, I'd like to
be able to get the output from the asciidoc invocation through to the
command line. Currently, I think, it's getting swallowed somewhere,
in the asciidocapi.py calls

Yes.



Second, the reason that I am doing this, is that I want to add an
additional configuration file into the asciidoc invocation. Normally I
want to do this on a per-blog basis; I can't add in "-f blog.conf"
command line options to asciidoc (not blogpost!), in the way that I
used to in the past. I thought to patch blogpost to achieve this.
Currently, it's not working, and I don't know why, because I can't see
the results of the asciidoc invocation!

It would make sense to be able to pass --verbose to asciidoc if you used the
blogpost --verbose option -- I've just committed an update to do this:
http://code.google.com/p/blogpost/source/detail?r=7e465dcd79e4110b25f0da7261e81fa7fafe2ed9

Good stuff. Having to specify twice had me confused for a bit, but then
I read the docs.

Decided to do it that way for backward compatibility and because the reason for not including asciidoc output in the first place was that it swamped everything else.



Passing asciidoc options would also be nice --asciidoc-opts=ASCIIDOC_OPTS c.f. 
a2x


Would something like this do the trick? It seems to work in my hands.

It would work most of the time, but there are corner cases:

1. Multiple arguments e.g. --asciidoc-opt "-f xxx -a yyy=zzz"
2. Quoted arguments e.g. --asciidoc-opt '-f "my conf file.conf"'
3. Arguments with values and no spaces e.g. --asciidoc-opt "-ayyy=zzz"

The parse_options() function in a2x.py deals with 1 and 2 but in my mind that's getting to messy. The more I think about it the more I think simply adding an --asciidoc-conf option to blogpost would be the way to go. The asciidoc -a,--attribute option would also be handy c.f. a2x (but this necessitates renaming the existing blogpost -a,--attributes option which is poorly named anyway (it refers to blogpost parameters which are mapped via a blogpost- prefix to asciidoc attributes) and is easily confused with the asciidoc attributes.

I've updated the trunk and renamed --attributes to --mandatory-parameters (apologies for any inconvenience this backward incompatibility may cause).

http://code.google.com/p/blogpost/source/detail?r=4fb81aa1ef9279e25b9ca2d2e5c42ce526e51d1f


Cheers, Stuart






changeset:   89:1da48f83d7df
tag:         tip
user:        Phillip Lord<[email protected]>
date:        Tue Sep 07 12:31:50 2010 +0100
summary:     Support for the passing of asciidoc options from blogpost command 
line.

diff -r dbd30d960339 -r 1da48f83d7df blogpost.py
--- a/blogpost.py       Tue Sep 07 11:42:18 2010 +0100
+++ b/blogpost.py       Tue Sep 07 12:31:50 2010 +0100
@@ -209,6 +209,14 @@
          asciidoc.options('--doctype', self.doctype)
          if OPTIONS.verbose>  1:
              asciidoc.options('--verbose')
+        if( OPTIONS.asciidoc_opts ):
+            for i in OPTIONS.asciidoc_opts:
+                infomsg( 'setting option for asciidoc: %s' % i )
+                split = i.partition( " " )
+                if( split[ 2 ] ):
+                    asciidoc.options( split[ 0 ], split[ 2 ] )
+                else:
+                    asciidoc.options( split[ 0 ] )
          outfile = StringIO.StringIO()
          asciidoc.execute(self.blog_file, outfile, backend='wordpress')
          result = outfile.getvalue()
@@ -693,6 +701,9 @@
      parser.add_option('-v', '--verbose',
          action='count', dest='verbose', default=0,
          help='increase verbosity')
+    parser.add_option('--asciidoc-opts',
+        action='append',dest='asciidoc_opts', default=[],
+        metavar='ASCIIDOC_OPTIONS', help='asciidoc options')
      if len(sys.argv) == 1:
          parser.parse_args(['--help'])
      OPTIONS, args = parser.parse_args()
diff -r dbd30d960339 -r 1da48f83d7df doc/blogpost.1.txt
--- a/doc/blogpost.1.txt        Tue Sep 07 11:42:18 2010 +0100
+++ b/doc/blogpost.1.txt        Tue Sep 07 12:31:50 2010 +0100
@@ -56,6 +56,10 @@

  OPTIONS
  -------
+*--asciidoc-options='OPTION'::
+  Specifies an OPTION to be passed to the underlying 'asciidoc(1)' invocation.
+  For options with arguments OPTION should be quoted.
+
  *-a, --attributes*='ATTRIBUTES'::
    Specifies a comma separated list of one or more weblog parameters
    that must be defined in the 'BLOG_FILE'. If this option is not


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

Reply via email to