Directory naming

39 views
Skip to first unread message

Will

unread,
Jul 29, 2011, 8:36:02 AM7/29/11
to asciidoc
Hi,

I have a problem including images in my docs when the a directory in
the directory tree starts with a certain character for example 'a' or
'b'. I'm using AsciiDoc 8.6.5 under Windows XP SP3. For example:


Directory of C:\a_test

29/07/11 13:15 <DIR> .
29/07/11 13:15 <DIR> ..
29/06/11 12:52 25,623 ahm.jpg
29/07/11 13:12 108 asciidoc-directory_naming_test.txt
2 File(s) 25,731 bytes
2 Dir(s) 106,146,521,088 bytes free



asciidoc: reading: C:\bin\asciidoc-8.6.5\asciidoc.conf
asciidoc: reading: C:\bin\asciidoc-8.6.5\asciidoc.conf
asciidoc: reading: C:\a_test\asciidoc-directory_naming_test.txt
asciidoc: reading: C:\bin\asciidoc-8.6.5\xhtml11.conf
asciidoc: reading: C:\bin\asciidoc-8.6.5\filters\code\code-filter.conf
asciidoc: reading: C:\bin\asciidoc-8.6.5\filters\collapse
\collapse.conf
asciidoc: reading: C:\bin\asciidoc-8.6.5\filters\graphviz\graphviz-
filter.conf
asciidoc: reading: C:\bin\asciidoc-8.6.5\filters\latex\latex-
filter.conf
asciidoc: reading: C:\bin\asciidoc-8.6.5\filters\music\music-
filter.conf
asciidoc: reading: C:\bin\asciidoc-8.6.5\filters\source\source-
highlight-filter.conf
asciidoc: reading: C:\bin\asciidoc-8.6.5\lang-en.conf
asciidoc: writing: C:\a_test\asciidoc-directory_naming_test.xhtml
asciidoc: asciidoc-directory_naming_test.txt: line 4: evaluating:
{eval:os.path.splitext('ahm.jpg')[1][1:]}
asciidoc: asciidoc-directory_naming_test.txt: line 4: evaluating:
{eval:os.path.join("C:\a_test","","ahm.jpg")}
asciidoc: asciidoc-directory_naming_test.txt: line 4: evaluating:
{sys:python -uc "import base64,sys; base64.encode(sys.stdin,sys.
stdout)" < "C:_test\ahm.jpg"}
The filename, directory name, or volume label syntax is incorrect.
asciidoc: WARNING: asciidoc-directory_naming_test.txt: line 4:
{sys:python -uc "import base64,sys; base64.encode(sys.stdin,sys.std
out)" < "C:_test\ahm.jpg"}: non-zero exit status
asciidoc: asciidoc-directory_naming_test.txt: line 4: evaluating:
{counter:figure-number}


You can see that the directory name has been changed to c:_test\. I
guess the \a in c:\atest has been evaluated as a special character due
to the backslash. Second example (preceeding directory name with an
underscore):


Directory of C:\_a_test

29/07/11 13:15 <DIR> .
29/07/11 13:15 <DIR> ..
29/06/11 12:52 25,623 ahm.jpg
29/07/11 13:12 108 asciidoc-directory_naming_test.txt
2 File(s) 25,731 bytes
2 Dir(s) 106,145,701,888 bytes free


asciidoc: reading: C:\bin\asciidoc-8.6.5\asciidoc.conf
asciidoc: reading: C:\bin\asciidoc-8.6.5\asciidoc.conf
asciidoc: reading: C:\_a_test\asciidoc-directory_naming_test.txt
asciidoc: reading: C:\bin\asciidoc-8.6.5\xhtml11.conf
asciidoc: reading: C:\bin\asciidoc-8.6.5\filters\code\code-filter.conf
asciidoc: reading: C:\bin\asciidoc-8.6.5\filters\collapse
\collapse.conf
asciidoc: reading: C:\bin\asciidoc-8.6.5\filters\graphviz\graphviz-
filter.conf
asciidoc: reading: C:\bin\asciidoc-8.6.5\filters\latex\latex-
filter.conf
asciidoc: reading: C:\bin\asciidoc-8.6.5\filters\music\music-
filter.conf
asciidoc: reading: C:\bin\asciidoc-8.6.5\filters\source\source-
highlight-filter.conf
asciidoc: reading: C:\bin\asciidoc-8.6.5\lang-en.conf
asciidoc: writing: C:\_a_test\asciidoc-directory_naming_test.xhtml
asciidoc: asciidoc-directory_naming_test.txt: line 4: evaluating:
{eval:os.path.splitext('ahm.jpg')[1][1:]}
asciidoc: asciidoc-directory_naming_test.txt: line 4: evaluating:
{eval:os.path.join("C:\_a_test","","ahm.jpg")}
asciidoc: asciidoc-directory_naming_test.txt: line 4: evaluating:
{sys:python -uc "import base64,sys; base64.encode(sys.stdin,sys.
stdout)" < "C:\_a_test\ahm.jpg"}
asciidoc: asciidoc-directory_naming_test.txt: line 4: evaluating:
{counter:figure-number}


Seems to be the Python function call 'os.path.join("C:
\a_test","","ahm.jpg")' that is failing - escaping the backslashes
seems to work better:

Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.path.join("C:\a_test","","ahm.jpg")
'C:\x07_test\\ahm.jpg'
>>> os.path.join("C:\\a_test","","ahm.jpg")
'C:\\a_test\\ahm.jpg'



Is this a known issue? Is there a fix?

Cheers,
Will

LeRouge

unread,
Jul 29, 2011, 9:00:46 AM7/29/11
to asciidoc
Hi will,

On Jul 29, 8:36 am, Will <willstubb...@gmail.com> wrote:
> Hi,
>
> I have a problem including images in my docs when the a directory in
> the directory tree starts with a certain character for example 'a' or
> 'b'.  I'm using AsciiDoc 8.6.5 under Windows XP SP3.  For example:
> [snip]
> Is this a known issue?  Is there a fix?

There is one report about this here:
http://code.google.com/p/asciidoc-win32/issues/detail?id=1

lerouge

Will

unread,
Jul 29, 2011, 10:31:59 AM7/29/11
to asciidoc
Hi,

Prefixing the parameters passed to os.path.join with 'r' seems to work
as a work around as escaped characters are not processed and treated
as literals (see http://docs.python.org/reference/lexical_analysis.html).
For example, edit xhtml11.conf for [image-inlinemacro] and [image-
blockmacro]:

change:
{data-uri#}{sys3:python -uc "import base64,sys;
base64.encode(sys.stdin,sys.stdout)" <
"{eval:os.path.join("{indir={outdir}}","{imagesdir=}","{target}")}"}" /
>

to:

{data-uri#}{sys3:python -uc "import base64,sys;
base64.encode(sys.stdin,sys.stdout)" <
"{eval:os.path.join(r"{indir={outdir}}",r"{imagesdir=}",r"{target}")}"}" /
>


Cheers,
Will

Lex Trotman

unread,
Jul 29, 2011, 7:51:13 PM7/29/11
to asci...@googlegroups.com
>
> Seems to be the Python function call 'os.path.join("C:
> \a_test","","ahm.jpg")' that is failing - escaping the backslashes
> seems to work better:
>
> Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit
> (Intel)] on win32
> Type "help", "copyright", "credits" or "license" for more information.
>>>> import os
>>>> os.path.join("C:\a_test","","ahm.jpg")
> 'C:\x07_test\\ahm.jpg'
>>>> os.path.join("C:\\a_test","","ahm.jpg")
> 'C:\\a_test\\ahm.jpg'
>
>
>
> Is this a known issue?  Is there a fix?


This is correct Python string behaviour, see
http://docs.python.org/reference/lexical_analysis.html#literals

The fix is to make the strings raw strings.

You should file a bug, all the strings in all the asciidoc conf files
will have to be checked for this problem when Stuart ends his winter
hibernation :-)

Cheers
Lex

>
> Cheers,
> Will
>
> --
> You received this message because you are subscribed to the Google Groups "asciidoc" group.
> To post to this group, send email to asci...@googlegroups.com.
> To unsubscribe from this group, send email to asciidoc+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/asciidoc?hl=en.
>
>

Stuart Rackham

unread,
Aug 9, 2011, 1:41:42 AM8/9/11
to asci...@googlegroups.com

On 30/07/11 02:31, Will wrote:
> Hi,
>
> Prefixing the parameters passed to os.path.join with 'r' seems to work
> as a work around as escaped characters are not processed and treated
> as literals (see http://docs.python.org/reference/lexical_analysis.html).
> For example, edit xhtml11.conf for [image-inlinemacro] and [image-
> blockmacro]:
>
> change:
> {data-uri#}{sys3:python -uc "import base64,sys;
> base64.encode(sys.stdin,sys.stdout)"<
> "{eval:os.path.join("{indir={outdir}}","{imagesdir=}","{target}")}"}" /
>>
>
> to:
>
> {data-uri#}{sys3:python -uc "import base64,sys;
> base64.encode(sys.stdin,sys.stdout)"<
> "{eval:os.path.join(r"{indir={outdir}}",r"{imagesdir=}",r"{target}")}"}" /
>>

Thanks for reporting this Will. I think I've fixed all the relevant conf file
entries:

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

This may cause problems for Windows users who have quietly worked around the
problem by escaping path backslashes. I think the raw behavior is the correct
one though.


Cheers, Stuart

Reply all
Reply to author
Forward
0 new messages