Spaces in Include Paths and File Names

237 views
Skip to first unread message

Josh Nylander

unread,
Aug 24, 2011, 6:34:13 PM8/24/11
to asci...@googlegroups.com
Ok, I have been all over this group and am familiar with http://www.methods.co.nz/asciidoc/faq.html#X1 however I can not get any of the following to work on Windows 7 using Python 2.7 and asciidoc v 8.6.5 (revision 1c5738e76608 ).

What should work
include::test%20it.asciidoc[]

Other attempts:
include::test it.asciidoc[]
include::test\ it.asciidoc[]
include::test/ it.asciidoc[]
include::test_it.asciidoc[]

I know spaces are "bad" but they are difficult to avoid.  Any help/ideas would be great.

Stuart Rackham

unread,
Aug 24, 2011, 7:53:56 PM8/24/11
to asci...@googlegroups.com
Hi Josh

On 25/08/11 10:34, Josh Nylander wrote:
> Ok, I have been all over this group and am familiar with
> http://www.methods.co.nz/asciidoc/faq.html#X1 however I can not get any of the
> following to work on Windows 7 using Python 2.7 and asciidoc v 8.6.5 (revision

> *1c5738e76608
> <http://code.google.com/p/asciidoc/source/detail?r=1c5738e76608f9115c104c57d798a6f876f7171f>*


> ).
>
> What should work
> include::test%20it.asciidoc[]
>
> Other attempts:
> include::test it.asciidoc[]
> include::test\ it.asciidoc[]
> include::test/ it.asciidoc[]
> include::test_it.asciidoc[]
>
> I know spaces are "bad" but they are difficult to avoid. Any help/ideas would be
> great.

Spaces are not allowed in the macro target (see
http://www.methods.co.nz/asciidoc/userguide.html#_macros), but I take your point
that they are difficult to avoid. It would be easy to remove the restriction on
block macros (diff attached), though would result in a warning if existing
documents had lines like '<name>::<target>[<attrlist>]' and the target had spaces.

A work-around would be to define an attribute for the file name e.g.

:test-file: test it.asciidoc
include::{test-file}[]


Cheers, Stuart


>
> --
> You received this message because you are subscribed to the Google Groups
> "asciidoc" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/asciidoc/-/UMpuraE7K4MJ.
> 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.

spaces-in-blockmacro-targets.patch

Lex Trotman

unread,
Aug 24, 2011, 8:05:32 PM8/24/11
to asci...@googlegroups.com
On 25 August 2011 09:56, Stuart Rackham <srac...@gmail.com> wrote:
>
>
> On 25/08/11 11:53, Lex Trotman wrote:

>>
>> On 25 August 2011 08:34, Josh Nylander<jo...@nylanderfamily.org>  wrote:
>>>
>>> Ok, I have been all over this group and
>>> am familiar with http://www.methods.co.nz/asciidoc/faq.html#X1 however I
>>> can
>>> not get any of the following to work on Windows 7 using Python 2.7 and
>>> asciidoc v 8.6.5 (revision 1c5738e76608 ).
>>> What should work
>>> include::test%20it.asciidoc[]
>>
>> This won't work because the operating system doesn't think of
>> filenames as URLs so the %20 isn't converted to space.

>>
>>> Other attempts:
>>> include::test it.asciidoc[]
>>> include::test\ it.asciidoc[]
>>> include::test/ it.asciidoc[]
>>> include::test_it.asciidoc[]
>>>
>>> I know spaces are "bad" but they are difficult to avoid.  Any help/ideas
>>> would be great.
>>>
>>
>> System macro syntax requires that the target not contain spaces.  You
>> could try re-defining the syntax of the include macro, but since this
>> is used inside asciidoc that might be risky.
>>
>> My recommended way is to define an attribute that is a space and use
>> that in the target.  Defining an attribute as space is a bit tricky,
>> but:
>>
>> :sp: {eval:' '}
>>
>> works and then you can do
>>
>> include::test{sp}it.txt[]
>
> Hi Lex
>
> I like your way better than my suggestion.
>
> Cheers, Stuart

Hi Stuart,

Maybe {space} or {sp} could be made an intrinsic attribute to avoid
the messy define?

Cheers
Lex

>
>>
>> Cheers
>> Lex


>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "asciidoc" group.

Stuart Rackham

unread,
Aug 24, 2011, 8:34:59 PM8/24/11
to asci...@googlegroups.com

That's a good idea. The {sp} attribute doesn't work with non-builtin block
macros such as image::[] because the attributes are processed before the macro
is processed. This can be fixed but I'm wondering whether not to just remove the
'no-spaces' restriction in block macros, any thoughts?

Cheers, Stuart

Lex Trotman

unread,
Aug 24, 2011, 7:53:15 PM8/24/11
to asci...@googlegroups.com
On 25 August 2011 08:34, Josh Nylander <jo...@nylanderfamily.org> wrote:
> Ok, I have been all over this group and
> am familiar with http://www.methods.co.nz/asciidoc/faq.html#X1 however I can
> not get any of the following to work on Windows 7 using Python 2.7 and
> asciidoc v 8.6.5 (revision 1c5738e76608 ).
> What should work
> include::test%20it.asciidoc[]

This won't work because the operating system doesn't think of


filenames as URLs so the %20 isn't converted to space.

> Other attempts:


> include::test it.asciidoc[]
> include::test\ it.asciidoc[]
> include::test/ it.asciidoc[]
> include::test_it.asciidoc[]
>
> I know spaces are "bad" but they are difficult to avoid.  Any help/ideas
> would be great.
>

System macro syntax requires that the target not contain spaces. You


could try re-defining the syntax of the include macro, but since this
is used inside asciidoc that might be risky.

My recommended way is to define an attribute that is a space and use
that in the target. Defining an attribute as space is a bit tricky,
but:

:sp: {eval:' '}

works and then you can do

include::test{sp}it.txt[]

Cheers
Lex

Stuart Rackham

unread,
Aug 24, 2011, 7:56:33 PM8/24/11
to asci...@googlegroups.com

On 25/08/11 11:53, Lex Trotman wrote:

Hi Lex

I like your way better than my suggestion.

Cheers, Stuart

>
> Cheers
> Lex
>

Lex Trotman

unread,
Aug 24, 2011, 9:03:54 PM8/24/11
to asci...@googlegroups.com
[...]

> That's a good idea. The {sp} attribute doesn't work with non-builtin block
> macros such as image::[] because the attributes are processed before the
> macro is processed. This can be fixed but I'm wondering whether not to just
> remove the 'no-spaces' restriction in block macros, any thoughts?

My first two thoughts are:

1. {sp} might also be useful elsewhere to insert a space where its
otherwise not allowed, although its use is probably rare enough to
leave it to the user to define.

2. removing the no-spaces restriction would mean that the only
distinction between a block macro and a labeled list item is the [ ]
on the macro. Labeled list values with [ ] in them can go on the next
line I guess. So that looks workable.

Cheers
Lex

Stuart Rackham

unread,
Aug 24, 2011, 11:18:57 PM8/24/11
to asci...@googlegroups.com

On 25/08/11 13:03, Lex Trotman wrote:
> [...]
>> That's a good idea. The {sp} attribute doesn't work with non-builtin block
>> macros such as image::[] because the attributes are processed before the
>> macro is processed. This can be fixed but I'm wondering whether not to just
>> remove the 'no-spaces' restriction in block macros, any thoughts?
>
> My first two thoughts are:
>
> 1. {sp} might also be useful elsewhere to insert a space where its
> otherwise not allowed, although its use is probably rare enough to
> leave it to the user to define.
>
> 2. removing the no-spaces restriction would mean that the only
> distinction between a block macro and a labeled list item is the [ ]
> on the macro. Labeled list values with [ ] in them can go on the next
> line I guess. So that looks workable.

Yeah, I think you're right, I've just added the {sp} attribute:

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


Cheers, Stuart

Josh Nylander

unread,
Aug 25, 2011, 4:13:39 PM8/25/11
to asci...@googlegroups.com

Thanks for everyone's help, the :sp: {eval:' '} works well.  As I am new to AsciiDoc, should I add this to a config file somewhere or just add it to every document?

Stuart Rackham

unread,
Aug 25, 2011, 4:17:54 PM8/25/11
to asci...@googlegroups.com

That's right, you won't need to if you're running off the trunk as sp is defined
by default (this will also be in the next release of AsciiDoc).

Cheers, Stuart


>
> --
> You received this message because you are subscribed to the Google Groups
> "asciidoc" group.

> To view this discussion on the web visit

> https://groups.google.com/d/msg/asciidoc/-/W5ErQHaQQ_UJ.

Reply all
Reply to author
Forward
0 new messages