On 08/11/10 07:31, Laurent Laville wrote:
uhm, sorry to disapointed you Stuart, but :

Did you try with asciidoc.py / not the a2x toolchain to generate xhtml
target

Because, me I got these results

asciidoc.py --verbose QA.txt

asciidoc: reading: C:\asciidoc-8.6.2\asciidoc.conf
asciidoc: reading: C:\asciidoc-8.6.2\asciidoc.conf
asciidoc: reading: C:\TODO\docs\QA.txt
asciidoc: reading: C:\asciidoc-8.6.2\xhtml11.conf
asciidoc: reading: C:\asciidoc-8.6.2\filters\code\code-filter.conf
asciidoc: reading: C:\asciidoc-8.6.2\filters\graphviz\graphviz-filter.conf
asciidoc: reading: C:\asciidoc-8.6.2\filters\latex\latex-filter.conf
asciidoc: reading: C:\asciidoc-8.6.2\filters\music\music-filter.conf
asciidoc: reading:
C:\asciidoc-8.6.2\filters\source\source-highlight-filter.conf
asciidoc: reading:
C:\asciidoc-8.6.2\filters\source\_source-highlight-filter.conf
asciidoc: reading: C:\asciidoc-8.6.2\lang-en.conf
asciidoc: writing: C:\TODO\docs\QA.html
asciidoc: QA.txt: line 61: filtering: pygmentize -f html -l php

My mistake, I should have said "asciidoc" not "a2x", but but you picked up on that and tried asciidoc -- so why is the pygmentize -O encoding=UTF-8 option missing? Take a look at your C:\asciidoc-8.6.2\filters\source\source-highlight-filter.conf file,
line 61 should have the encoding attribute:

http://code.google.com/p/asciidoc/source/diff?spec=svnd66e74ae22fa83306a200e68ae50a942dcb85d2d&r=d66e74ae22fa83306a200e68ae50a942dcb85d2d&format=side&path=/filters/source/source-highlight-filter.conf



*** Error while highlighting:
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 57:
ordinal not in range(128)
    (file "C:\Python27\lib\site-packages\pygments\lexer.py", line 148,
in get_tokens)
asciidoc: WARNING: QA.txt: line 203: filter non-zero exit code:
pygmentize -f html -l php: returned 1
asciidoc: WARNING: QA.txt: line 203: no output from filter: pygmentize
-f html -l php
asciidoc: QA.txt: line 253: filtering: pygmentize -f html -l php

And strange if I used the a2x toolchain, to generate xhtml (we use the
docbook backend, so no pygments higlight),  I got these results :

a2x.py --format xhtml --verbose --no-xmllint QA.txt

a2x: args: ['--format', 'xhtml', '--verbose', '--no-xmllint', 'QA.txt']
a2x: executing: python C:\asciidoc-8.6.2\asciidoc.py --backend docbook
--verbose  --out-file C:\TODO\docs\QA.xml C:\TODO\docs\QA.txt
asciidoc: reading: C:\asciidoc-8.6.2\asciidoc.conf
asciidoc: reading: C:\asciidoc-8.6.2\asciidoc.conf
asciidoc: reading: C:\TODO\docs\QA.txt
asciidoc: reading: C:\asciidoc-8.6.2\docbook45.conf
asciidoc: reading: C:\asciidoc-8.6.2\filters\code\code-filter.conf
asciidoc: reading: C:\asciidoc-8.6.2\filters\graphviz\graphviz-filter.conf
asciidoc: reading: C:\asciidoc-8.6.2\filters\latex\latex-filter.conf
asciidoc: reading: C:\asciidoc-8.6.2\filters\music\music-filter.conf
asciidoc: reading:
C:\asciidoc-8.6.2\filters\source\source-highlight-filter.conf

asciidoc: reading:
C:\asciidoc-8.6.2\filters\source\_source-highlight-filter.conf
asciidoc: reading: C:\asciidoc-8.6.2\lang-en.conf
asciidoc: writing: C:\TODO\docs\QA.xml
a2x: chdir C:\TODO\docs
a2x: executing: xsltproc  --stringparam callout.graphics 0 --stringparam
navig.graphics 0 --stringparam admon.textlabel 1 --stringparam
admon.graphics 0  --outp
ut C:\TODO\docs\QA.html C:\asciidoc-8.6.2\docbook-xsl\xhtml.xsl
C:\TODO\docs\QA.xml
a2x: chdir C:\TODO\docs
a2x: finding resources in: C:\TODO\docs\QA.html
a2x: finding resources in: C:\TODO\docs\QA.html
a2x: copying "C:\asciidoc-8.6.2\stylesheets\docbook-xsl.css" to
"C:\TODO\docs\docbook-xsl.css"
a2x: deleting C:\TODO\docs\QA.xml

Laurent


2010/11/7 Stuart Rackham <[email protected] <mailto:[email protected]>>



    On 07/11/10 22:01, Laurent Laville wrote:

        Hi Stuart,

        I've get latest revisions (commits)

        asciidoc.py
        
http://code.google.com/p/asciidoc/source/detail?spec=svnb00f876aa3fdd1f029d2d7607c354a43223fd5d6&r=00828f68cb8a8bddc7324d1ef6ad0c7f9fcbaa3f
        
<http://code.google.com/p/asciidoc/source/detail?spec=svnb00f876aa3fdd1f029d2d7607c354a43223fd5d6&r=00828f68cb8a8bddc7324d1ef6ad0c7f9fcbaa3f>
        
<http://code.google.com/p/asciidoc/source/detail?spec=svnb00f876aa3fdd1f029d2d7607c354a43223fd5d6&r=00828f68cb8a8bddc7324d1ef6ad0c7f9fcbaa3f
        
<http://code.google.com/p/asciidoc/source/detail?spec=svnb00f876aa3fdd1f029d2d7607c354a43223fd5d6&r=00828f68cb8a8bddc7324d1ef6ad0c7f9fcbaa3f>>

        filters/sources/source-highlight-filter.conf
        
http://code.google.com/p/asciidoc/source/detail?spec=svnb00f876aa3fdd1f029d2d7607c354a43223fd5d6&r=d66e74ae22fa83306a200e68ae50a942dcb85d2d
        
<http://code.google.com/p/asciidoc/source/detail?spec=svnb00f876aa3fdd1f029d2d7607c354a43223fd5d6&r=d66e74ae22fa83306a200e68ae50a942dcb85d2d>
        
<http://code.google.com/p/asciidoc/source/detail?spec=svnb00f876aa3fdd1f029d2d7607c354a43223fd5d6&r=d66e74ae22fa83306a200e68ae50a942dcb85d2d
        
<http://code.google.com/p/asciidoc/source/detail?spec=svnb00f876aa3fdd1f029d2d7607c354a43223fd5d6&r=d66e74ae22fa83306a200e68ae50a942dcb85d2d>>

        I've also removed from my pygmentize.bat script the -O
        encoding=utf-8
        so it's only
        @python.exe %~dp0pygmentize %*

        Either with

        asciidoc.conf
        [attributes]
        encoding=UTF-8

        or by putting in my file (QA.txt) header
        :encoding: utf-8

        None gave the expected result. What did I missed ?
        Still get error as encoding attribute was not given

        --------
        *** Error while highlighting:
        UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in
        position 57:
        ordinal
          not in range(128)
            (file "C:\Python27\lib\site-packages\pygments\lexer.py",
        line 148,
        in get_tokens)
        asciidoc: WARNING: QA.txt: line 203: filter non-zero exit code:
        pygmentize -f html -l php: returned 1
        --------


    Try running a2x with the --verbose option, this will display the
    actual pygmentize command executed by a2x, it should be something like:

    asciidoc: source-highlight-filter.txt: line 185: filtering:
    pygmentize -f html -l ruby -O linenos=table -O encoding=UTF-8

    Then try cutting and pasting the generated pygmentize command and
    running it manually.

    Cheers, Stuart


        Laurent


        2010/11/7 Stuart Rackham <[email protected]
        <mailto:[email protected]> <mailto:[email protected]
        <mailto:[email protected]>>>


            Hi Laurent


            On 06/11/10 23:14, Laurent Laville wrote:

                Hi all,

                Asciidoc user since version 8.5.3, I used it on a
        Windows plateform
                with Cygwin.
                Recently, I've decided to use the latest version 8.6.2
        on a native
                Windows platform (so, without Cygwin).

                I've also decided to try all cool features such as syntax
                highlighter
                with pygments.

                Install procedure :
                - download Python 2.7 from
        http://www.python.org/download/  (with
                Windows installer - binaries without source)
                - download Pygments 1.3.1 from http://pygments.org/download/

                I got the pygmentize python script commant in folder c:
                \Python27\Scripts

                First Problem :
                ==========
                Windows did not recognize pygmentize script, because
        association was
                with .py extension file

                First Solution:
                ==========
                make a pygmentize.bat with content

                     @python.exe c:\Python27\Scripts\pygmentize %*

                Second Problem:
                ============
                As I am french user, and I have comment with accents in my
                source code
                that are UTF-8 encoded, I run in trouble with encoding file
                I got these error lines
                ----------
                *** Error while highlighting:
                UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3
        in position
                57: ordinal
                  not in range(128)
                    (file "C:\Python27\lib\site-packages\pygments\lexer.py",
                line 148,
                in get_tokens)
                asciidoc: WARNING: QA.txt: line 201: filter non-zero
        exit code:
                pygmentize -f html -l php: returned 1
                ----------

                As pygments allow to change encoding  (default is iso8859-1)
                with its -
                O switch (http://pygments.org/docs/cmdline/)

                I wanted to have
                     pygmentize -f html -l php -O encoding=utf-8

                But I don't yet find a solution to give extra arguments
                Perharps a new feature for next version 8.6.3 of
        AsciiDoc and its
                source-highlight-filter.conf file


            I've passed the source file {encoding} attribute to to the
            source-highlight-filter.conf:

        
http://code.google.com/p/asciidoc/source/detail?r=d66e74ae22fa83306a200e68ae50a942dcb85d2d




                Second solution :
                ============
                Helped by an article I found on the Net
        http://skim.la/2010/02/14/how-to-run-jekyll-pygmentize-on-windows/

                Change content of my pygmentize.bat script as follow
                     @python.exe %~dp0pygmentize %* -O encoding=utf-8


                Third problem
                ==========
                Generate a PDF target with A2X toolchain, with such command

                a2x.py --icons --fop -f pdf -v -L -d book \source_folder
                \source_file.txt

                I cannot pass the XSLT transformation, and cannot
        generate the .fo
                file for FOP

                Got these error lines
                ----------
                a2x: ERROR: xsltproc  --nonet
                --stringparam callout.graphics 1 --stringparam
        navig.graphics 1 --
                stringparam admon.textlabel 0 --stringparam admon.graphics 1
                --output C:\docs\QA.fo
        C:\asciidoc-8.6.2\docbook-xsl\fo.xsl C:\docs
                \QA.xml
                returned non-zero exit status 5
                ----------

                Third Solution:
                ==========
                In my situation the  --nonet  was the problem, without
        it, XSLTproc
                can generate the target file

                I read the asciidoc a2x.py source script and put line 425
                ( self.xsltproc_opts += ' --nonet' ) in comment

                My PDF was generated

                I suggest to modify asiidoc and put the --nonet as optional
                Users as always ability to put this parameter on the
        command line
                with
                      --xsltproc-opts=XSLTPROC_OPTS


            I've done this:

        
http://code.google.com/p/asciidoc/source/detail?r=b00f876aa3fdd1f029d2d7607c354a43223fd5d6



                Hope my explains are enough clear, and will help other
        Windows
                users.

                To finish, while I tried to find a solution to got color
        syntax on
                final PDF files through the a2x toolchain, I read a cool
        article on
                the Net about Pygments :

                Pygments as syntax highlighter for DocBook documents

                Summary
        "This article explains how to use Pygments as syntax highlighter for
                DocBook documents processed with the DocBook XSL
        stylesheets in
                order
                to replace the rather poor standard XSLTHL syntax
        highlighting."

        http://lunaryorn.de/articles/docbook_pygments.html

                Enjoy, and I hope we can have a such solution with futur
        AsciiDoc
                release

                Laurent Laville


            Nice post, I develop and test on Linux so Windows does get a bit
            neglected.

            If you get a chance could you please test these changes and
        report back.


            Cheers, Stuart


            --
            You received this message because you are subscribed to the
        Google
            Groups "asciidoc" group.
            To post to this group, send email to
        [email protected] <mailto:[email protected]>
        <mailto:[email protected]
        <mailto:[email protected]>>.

            To unsubscribe from this group, send email to
        [email protected]
        <mailto:asciidoc%[email protected]>
        <mailto:asciidoc%[email protected]
        <mailto:asciidoc%[email protected]>>.

            For more options, visit this group at
        http://groups.google.com/group/asciidoc?hl=en.


        --

        You received this message because you are subscribed to the Google
        Groups "asciidoc" group.
        To post to this group, send email to [email protected]
        <mailto:[email protected]>.
        To unsubscribe from this group, send email to
        [email protected]
        <mailto:asciidoc%[email protected]>.
        For more options, visit this group at
        http://groups.google.com/group/asciidoc?hl=en.


    --
    You received this message because you are subscribed to the Google
    Groups "asciidoc" group.
    To post to this group, send email to [email protected]
    <mailto:[email protected]>.
    To unsubscribe from this group, send email to
    [email protected]
    <mailto:asciidoc%[email protected]>.
    For more options, visit this group at
    http://groups.google.com/group/asciidoc?hl=en.


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

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