Disable ' replacement.

142 views
Skip to first unread message

Simon Ruderich

unread,
May 4, 2009, 12:55:48 PM5/4/09
to asci...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Hi,

Is there a way to disable the ' replacement to #8217;?

Thanks,
Simon
- --
+ privacy is necessary
+ using http://gnupg.org
+ public key id: 0x92FEFDB7E44C32F9
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iQIcBAEBCAAGBQJJ/x4UAAoJEJL+/bfkTDL5a30P/R4PIE31ptw9g9k2O2KQy9HR
Ju/mLs75MkZeHG9zj8MK1dJRHW6ZwEDfBS3KHJSb8wXAQJW0whApLIH1bmfH9RZB
gegQI74fNcnGj0kAugdFwHR1FpMxjkpSpBdKe0jvLu+aI2w+pU0IA+cF1PhGq2zh
dSZCP1gdvcml5kDmyq6wc6oGsMLHYJzGfOFNVHYTRTpvp5kDBnUs3kmwDRoou0lv
PFi2Qr5BEAySxlTSRrIR9papYEpm6ELm4WscqvlBZ2TcVkk7WrXTn4EwsxM0/R37
O3oZ3yOpK/r1iIgNvRKeim+y7YQBS/QL/wsV+r+sliqQlsu0A4vMJ+7gx3xpkdWv
xEuN7ahJYmhXsQ/js4f0d/aK2wJx+ZWnu+KY534a5qUX+JlpLajGGElmP9NT1uvr
paOnv2AuqWPVdpP/Rwjofq1+E/qJxN8DWqsNbEYCaLhcsbSdiAsr/rmCye6hUsnV
HkDTj6MiXq9kQKCn9zy+hAIxK4jWeBCXclVypSt7gtr89v9rcHL2+mrFUClljqaJ
ynM6R9KEUXg/G4XRwHOnqXd1aOdJLpSES3qieQ+Tw0qq1URmLC+Bhb6//fwqKnPX
nLiC3d5XtensaEsmb5EQ6er+A4fl07RyECVTtroKTzIrwVu2g/dC2VYlxDGvsdBl
W+A1Nr4w93wSr/PLwUH6
=DnQW
-----END PGP SIGNATURE-----

Stuart Rackham

unread,
May 4, 2009, 6:31:10 PM5/4/09
to asci...@googlegroups.com
Simon Ruderich wrote:
> Hi,
>
> Is there a way to disable the ' replacement to #8217;?
>
> Thanks,
> Simon

Put this in you conf file:

[replacements]
(\w)'(\w)=\1'\2


Or this in your document:

:replacements.(\w)'(\w): \1'\2


Cheers, Stuart


Simon Ruderich

unread,
May 6, 2009, 8:34:08 AM5/6/09
to asci...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

On Tue, May 05, 2009 at 10:31:10AM +1200, Stuart Rackham wrote:
> Put this in you conf file:
>
> [replacements]
> (\w)'(\w)=\1'\2
>
> Or this in your document:
>
> :replacements.(\w)'(\w): \1'\2
>
> Cheers, Stuart

Thanks, this worked fine. I have two questions though:

Would it be possible to add a backslash escape for it?

I'm using this in a AsciiDoc style table and added the
replacement rule in a config file but it didn't work. Only after
I put it in the table it worked. Is this a know limitation of
AsciiDoc style tables?

Thanks,
Simon
- --
+ privacy is necessary
+ using http://gnupg.org
+ public key id: 0x92FEFDB7E44C32F9
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iQIcBAEBCAAGBQJKAYPAAAoJEJL+/bfkTDL5QbgQAIkv4/3xDtcKYn6fbiwg7SMv
PAo7WgrNgC6hQ1KJYlxKOxAmkyHIK64o1ii1TPZuuV5NA3efK/5ZercmXhY/Ftg/
4ITZ4gZg7pOAIoVCH/7V3mPHbAZ0KRK3JUjFIw/9jVr5BCeks/1Q4Q3Y5WBrtasT
2NwC+6NkQlSpOOqw0N2+vnF/15uxZr76W18OC2d4p3vKnYuzSYgrzoxXe9Y9ntux
/lj8t+3qfNdGKOjj/Exbh8o2OvHMYEUmQRSzvY8VPgSzvQvDCqEaMyawVmPWH9KJ
rboWtaJIUxLuUx6WpZTwLdRxpeaORNpSBsn0gsASK00+q6AhOVLtj9sk7Gt0Xjc5
lpz6tfjIpZFTnaQ7gec/jIUSW/ArNGO91VHhvZQnnoa58QVQCBC+77h41RkNxG7+
gkawF0rPzanbQWFZE8kj4qGOn0mXxw56pFReyNQErqG0uQ4lEmFtazYSVU09CMjE
GTLMilFrXSc+JGj/rX0PPd0Qbxa+qmsfz4wXYdJYlN0K74VtoMftKZXJJCSoZvZ5
dJRu+OdruzDoZ0wNKCuQuJW7H/fiSaOeenSM4ATmKz6MABafocFv95xP98wkLKK5
BlWPHjh7HKhFGY+gI9ygva0YzIwMQh9z+XC6o1Y26DdZrzzCdUyzG3zcmkcEpXGa
55TjX0K83ICkG3Y3jEGK
=vBbA
-----END PGP SIGNATURE-----

Simon Ruderich

unread,
May 16, 2009, 10:43:46 AM5/16/09
to asci...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

On Wed, May 06, 2009 at 02:34:08PM +0200, Simon Ruderich wrote:
> Thanks, this worked fine. I have two questions though:
>
> Would it be possible to add a backslash escape for it?
>
> I'm using this in a AsciiDoc style table and added the
> replacement rule in a config file but it didn't work. Only after
> I put it in the table it worked. Is this a know limitation of
> AsciiDoc style tables?
>
> Thanks,
> Simon

Any news on this?

Simon
- --
+ privacy is necessary
+ using http://gnupg.org
+ public key id: 0x92FEFDB7E44C32F9
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iQIcBAEBCAAGBQJKDtEhAAoJEJL+/bfkTDL5cAIQAIB530wmjnhl0yUu4rAKH1DX
TPyq0MC+GMmUOUooIFp88Hrqj2nb9khuoOYqNj/DaMifdL3ngLJmDqXHfypJWMge
06rQqzzaz0jL7b8lJgNLcfrsHJox4Q+5r1/9326Cu3WetNe/ZtVH/7IFwV9hBTyQ
j1jV4e/1UqJRU17GiusA6dV5tUB7QoEoa2xLT8zEAcMIRxRBgdUdSXNQeH+pbH2v
gy2ZuwOOZM4MwpP02ldznxkhGHcIO2axvbb4y9yHaiAW4EWt5pMUTTebeuOEkC7I
RWKrccoxtee578TJmkW/h+9Yyox5w11ItsoeGldPnlrNk+x0HA6ob7vz64q8m2YQ
zS1aso+694zmQ7BUBz9tMDL6DhrhCXSivR6HtMdwwxtuQnmPpxHSgnNMZ7xuBKTn
t1P6g8PuPNJmO/rfFGWpjgL1NgcxSTwyWWk734TwGaH/EqhL39eN+aOYYGKspvfA
BpNFNJ8cKcP7dDPF2+mIt6X3FdqoSD4/qdo/LEBeciqzPloVzmQotbetXCZsbrYd
bT+xy6JDrGhSTP52SXKT5+DOi8aLG9/xb9/SOD9ZacM1doefSdFTf/DLybsk3EZ3
HyxuPlfBnTRu3VeKdl9tHcFNUOV7fVKw+JmNaRPtTI/na8j/NIvfpSQx/kjcrjRD
dkZvWn659Z/MLey5eij2
=uwJs
-----END PGP SIGNATURE-----

Stuart Rackham

unread,
May 17, 2009, 5:49:56 AM5/17/09
to asci...@googlegroups.com
Simon Ruderich wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
>
> On Wed, May 06, 2009 at 02:34:08PM +0200, Simon Ruderich wrote:
>> Thanks, this worked fine. I have two questions though:
>>
>> Would it be possible to add a backslash escape for it?

In asciidoc.conf replace this:

# Replace vertical typewriter apostrophe with punctuation apostrophe.
(\w)'(\w)=\1’\2

with this:

# Replace vertical typewriter apostrophe with punctuation apostrophe.
(\w)'(\w)=\1’\2
(\w)\\'(\w)=\1'\2W

I'll put it in the trunk if it works.


>>
>> I'm using this in a AsciiDoc style table and added the
>> replacement rule in a config file but it didn't work. Only after
>> I put it in the table it worked. Is this a know limitation of
>> AsciiDoc style tables?

Could you supply and example please.


Cheers, Stuart

Simon Ruderich

unread,
May 22, 2009, 6:00:09 AM5/22/09
to asci...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

On Sun, May 17, 2009 at 09:49:56PM +1200, Stuart Rackham wrote:
> In asciidoc.conf replace this:
>
> # Replace vertical typewriter apostrophe with punctuation apostrophe.
> (\w)'(\w)=\1’\2
>
> with this:
>
> # Replace vertical typewriter apostrophe with punctuation apostrophe.
> (\w)'(\w)=\1’\2
> (\w)\\'(\w)=\1'\2W
>
> I'll put it in the trunk if it works.

I had to remove the trailing W in your example.

- --- a/asciidoc/asciidoc.conf
+++ b/asciidoc/asciidoc.conf
@@ -117,6 +117,7 @@ monospacedwords=



# Replace vertical typewriter apostrophe with punctuation apostrophe.
(\w)'(\w)=\1’\2

+(\w)\\'(\w)=\1'\2

# ... Ellipsis (entity reference …)
(?<!\\)\.\.\.=&#8230;

Then it works fine for me. Thanks for your help.

> Could you supply and example please.

Sure. Here is one which doesn't work at the moment. I'm assuming the patch
above hasn't been applied.

Test
====


:replacements.(\w)'(\w): \1'\2

Here ' isn't converted to `&#8217;` as expected.

[cols="asciidoc"]
|==================================================================
|
- The ' is converted to `&#8217;` here which is not expected: isn't

|
:replacements.(\w)'(\w): \1'\2

- The ' isn't converted to `&#8217;` here.
|==================================================================

The problem is that the replacement at the beginning isn't passed
to the asciidoc instance which is run for the table contents.

By the way, would it be possible to not span new asciidoc
instances when doing such conversions with asciidocapi? Because
it's quite slow at the moment if you convert a file with many
such tables. It looks like asciidocapi spans a new asciidoc
instance for each table element even though it could call itself.

> Cheers, Stuart

Thanks,


Simon
- --
+ privacy is necessary
+ using http://gnupg.org
+ public key id: 0x92FEFDB7E44C32F9
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iQIcBAEBCAAGBQJKFnepAAoJEJL+/bfkTDL5D28P/R9sgiSdJIG2YTLlssXTX6/A
CYtqXwrYNFup1gIf8Sb5mvEIbiM5cnUQNIAjqdkg6EsUSQgJ2PjJhNyNQBIgtXm7
aqmLNkSNR3atKiizmp13QgMZz+22EY4T0oSn4bcI8BMXb4kzNORkhzG2WEU4aryf
VyeV++XvJIeyCDOBO3nT7aM2Fj7s/VHKnIjz49xSwW9W0Q92BIDaouPoiIYMSKeT
9El+zyC2b13/bJ6uHNFY6Serl02GSho6qk+MBM0Moc5AeMdMfWJ/zak6LAhBMUXj
hE4kCZV3LhZWuRUAFTTDo1btOk9RTuRvBzWT5bMiGK9YSH2ZPsLbs4WcoVsa5srh
CZtzJJKfsKvFTdMsI8oNWmMeRPFx4bY/mZOS2Y6/ARwEYiVHTihxSpuCjUX3A8ih
mD+S4siiE49DkedKES8TnlpJJ84anqhq+zUQjt+rMIEmsDVeTqvwvwc6ZgGScdxZ
fKankbHzXKpQeTUYZT+e9UVGm6qF+DjkV8PhTyA0JjkITHxLtgO9PIHTlI5pWCyo
kJ91JCwxQxPVfcCFl1jOy+IIe6LBIGkdqA1IAfldM9KlJfIoziDlW4Xhn2KbJ0Wg
70fGv7IHqcuub30Dg80f04YV6bHRaCJCUNsl/Imk0/G68ra0SU2FwFrgpw95pZot
RYXJ5//cRCAV/lZmEo+G
=U92o
-----END PGP SIGNATURE-----

Stuart Rackham

unread,
May 25, 2009, 12:19:51 AM5/25/09
to asci...@googlegroups.com
Simon Ruderich wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
>
> On Sun, May 17, 2009 at 09:49:56PM +1200, Stuart Rackham wrote:
>> In asciidoc.conf replace this:
>>
>> # Replace vertical typewriter apostrophe with punctuation apostrophe.
>> (\w)'(\w)=\1&#8217;\2
>>
>> with this:
>>
>> # Replace vertical typewriter apostrophe with punctuation apostrophe.
>> (\w)'(\w)=\1&#8217;\2
>> (\w)\\'(\w)=\1'\2W
>>
>> I'll put it in the trunk if it works.
>
> I had to remove the trailing W in your example.

Typo, sorry, ingrained editor -- I keep entering vi commands into the
email windows.


>
> - --- a/asciidoc/asciidoc.conf
> +++ b/asciidoc/asciidoc.conf
> @@ -117,6 +117,7 @@ monospacedwords=
>
> # Replace vertical typewriter apostrophe with punctuation apostrophe.
> (\w)'(\w)=\1&#8217;\2
> +(\w)\\'(\w)=\1'\2
>
> # ... Ellipsis (entity reference &hellip;)
> (?<!\\)\.\.\.=&#8230;
>
> Then it works fine for me. Thanks for your help.
>
>> Could you supply and example please.
>
> Sure. Here is one which doesn't work at the moment. I'm assuming the patch
> above hasn't been applied.
>
> Test
> ====
> :replacements.(\w)'(\w): \1'\2
>
> Here ' isn't converted to `&#8217;` as expected.
>
> [cols="asciidoc"]
> |==================================================================
> |
> - The ' is converted to `&#8217;` here which is not expected: isn't
>
> |
> :replacements.(\w)'(\w): \1'\2
> - The ' isn't converted to `&#8217;` here.
> |==================================================================
>
> The problem is that the replacement at the beginning isn't passed
> to the asciidoc instance which is run for the table contents.

A stand-alone single-quote is not being used in an apostrophe
punctuation context so it's not replaced by an apostrophe.


>
> By the way, would it be possible to not span new asciidoc
> instances when doing such conversions with asciidocapi? Because
> it's quite slow at the moment if you convert a file with many
> such tables. It looks like asciidocapi spans a new asciidoc
> instance for each table element even though it could call itself.

The asciidoc table style is implemented with a filter that runs asciidoc
for every cell (not the asciidocapi), it's quite slow if you're
processing a lot of cells. Only set the asciidoc style on those
columns/cells that require it, the default style is much faster. See
also 'Use tables sparingly':
http://www.methods.co.nz/asciidoc/userguide.html#_tables

Cheers, Stuart

Simon Ruderich

unread,
May 25, 2009, 6:32:20 AM5/25/09
to asci...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

On Mon, May 25, 2009 at 04:19:51PM +1200, Stuart Rackham wrote:
> Typo, sorry, ingrained editor -- I keep entering vi commands into the
> email windows.

No problem ;-)

>> Sure. Here is one which doesn't work at the moment. I'm assuming the patch
>> above hasn't been applied.
>>
>> Test
>> ====
>> :replacements.(\w)'(\w): \1'\2
>>
>> Here ' isn't converted to `&#8217;` as expected.

^^^^^


>>
>> [cols="asciidoc"]
>> |==================================================================
>> |
>> - The ' is converted to `&#8217;` here which is not expected: isn't

^^^^^


>>
>> |
>> :replacements.(\w)'(\w): \1'\2
>> - The ' isn't converted to `&#8217;` here.

^^^^^


>> |==================================================================
>>
>> The problem is that the replacement at the beginning isn't passed
>> to the asciidoc instance which is run for the table contents.
>
> A stand-alone single-quote is not being used in an apostrophe
> punctuation context so it's not replaced by an apostrophe.

Sorry, my description was not clear. Now I underlined the 's
which should or should not be replaced.

>> By the way, would it be possible to not span new asciidoc
>> instances when doing such conversions with asciidocapi? Because
>> it's quite slow at the moment if you convert a file with many
>> such tables. It looks like asciidocapi spans a new asciidoc
>> instance for each table element even though it could call itself.
>
> The asciidoc table style is implemented with a filter that runs asciidoc
> for every cell (not the asciidocapi), it's quite slow if you're
> processing a lot of cells. Only set the asciidoc style on those
> columns/cells that require it, the default style is much faster. See
> also 'Use tables sparingly':
> http://www.methods.co.nz/asciidoc/userguide.html#_tables

I see. Would it be possible to run this filter through
asciidocapi to speed up it up? I know that tables should be used
sparingly but sometimes they are necessary.

> Cheers, Stuart

Thanks,
Simon
- --
+ privacy is necessary
+ using http://gnupg.org
+ public key id: 0x92FEFDB7E44C32F9
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iQIcBAEBCAAGBQJKGnOzAAoJEJL+/bfkTDL5LFkQAJDFGa4JhTqGrgv6s4odrhZQ
ItNU/68QzAaWmBgRfMsA0r3MUclYqu0YzdsGb0whwiB1Fmq4yzgDftTSE7FX24bH
BId0PXd8YUTij4VJb8jea4kptdNYAyq0Eexcty9DCrOB5ZBVVLK9y/+hTc0Yymqa
9KLNJRv+s0Fk+UlOZHy+ToCO/KY4vq/FSCCDn3eFUYnvZOe2oG0r36swVzqz18cf
22eS+aIyzssCjFvHWN7HcUgxvECYyS2JKXpWqMueU5hjNdoAscIvuyNMx/0ZUH38
ykRHXgYIWET+s7T7efAsEf0M+wpIaQxHiO7TGw4HImM2nElwj3NMxJ2GI6tnOswy
kyqL+U2FZD4mYki+hzzqHwP0G12V0XQnK0cbkg8y7y4F5XGYVDutRHCjBoMP29hZ
ke4+Z1Izdu0NsQ7PiTQfyOIosWOJEdq5/mT0w65O7Dg2giip6CmrCxjSLROkdWti
nj5k1h7E4YcFMIxgz6kO5S1AoyIXvEdIvDN3UwGcDFXEYcCQiDdpVjEsq4KD+wy7
CMAcjto5mRSIwkLnnif4lvilI55ZZ1pPu3rKvmjaTLRH2sWDwyWthSAA/i2fwojH
fcFs/O2njIvgUNzq0a1gifB+BPr7s5/UhiwWn5EZrSBIJiLa7rbuH0eLSUbBlMkf
qIrBEx9Lujjf7PBus+U6
=+Sr9
-----END PGP SIGNATURE-----

Stuart Rackham

unread,
May 25, 2009, 3:46:20 PM5/25/09
to asci...@googlegroups.com
What version of asciidoc are you running, I'm running from the trunk,
here's what I get which is correct:

$ echo "The ' isn't converted"|asciidoc -s -
<div class="paragraph"><p>The ' isn&#8217;t converted</p></div>


>
>>> By the way, would it be possible to not span new asciidoc
>>> instances when doing such conversions with asciidocapi? Because
>>> it's quite slow at the moment if you convert a file with many
>>> such tables. It looks like asciidocapi spans a new asciidoc
>>> instance for each table element even though it could call itself.
>> The asciidoc table style is implemented with a filter that runs asciidoc
>> for every cell (not the asciidocapi), it's quite slow if you're
>> processing a lot of cells. Only set the asciidoc style on those
>> columns/cells that require it, the default style is much faster. See
>> also 'Use tables sparingly':
>> http://www.methods.co.nz/asciidoc/userguide.html#_tables
>
> I see. Would it be possible to run this filter through
> asciidocapi to speed up it up? I know that tables should be used
> sparingly but sometimes they are necessary.

Possible yes, but it would mean coding a special asciidoc filter into
asciidoc.py (the current implementation just uses the standard filter
mechanism so it's just a conf file entry). Just how much of a
performance benefit would have to be determined by running a benchmark.
An asciidoc filter might be useful for other stuff -- I'll have a think
about it.

Cheers, Stuart

Simon Ruderich

unread,
May 26, 2009, 3:33:06 AM5/26/09
to asci...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

On Tue, May 26, 2009 at 07:46:20AM +1200, Stuart Rackham wrote:
> What version of asciidoc are you running, I'm running from the trunk,
> here's what I get which is correct:
>
> $ echo "The ' isn't converted"|asciidoc -s -
> <div class="paragraph"><p>The ' isn&#8217;t converted</p></div>

Hi,

Sorry again, I didn't describe my problem correctly. With the
current trunk this replacement works, but my problem is that
replacement rules defined at the beginning of a document are not
available in AsciiDoc tables.

This is a better example:

Test
====
:replacements.TEST: YEAH

Here the replacement works: TEST

[cols="asciidoc"]
|==================================================================
|
- Here the replacement doesn't work: TEST
|
:replacements.TEST: YEAH
- Here the replacement works again: TEST
|==================================================================

This gives me (on trunk) the following result:

Test

Here the replacement works: YEAH

+------------------------------------------------------------------------+
| * Here the replacement doesn’t work: TEST |
|------------------------------------------------------------------------|
| * Here the replacement works again: YEAH |
+------------------------------------------------------------------------+

Last updated 2009-05-26 09:11:20 CEST

My problem is that the replacement rule isn't propagated to the
AsciiDoc table cell. The TEST in the first row should also have
been replaced by YEAH.

Thanks,
Simon
- --
+ privacy is necessary
+ using http://gnupg.org
+ public key id: 0x92FEFDB7E44C32F9
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iQIcBAEBCAAGBQJKG5syAAoJEJL+/bfkTDL5uNIP/iaEQCgYMSYdlH30NmIEU7WY
x5ly1nc6FunmHOu+6sfO+vVt6cihKMeBcJD4OPaD1Y6rqA6Jobw6D8GgXJxAvjX4
ShxajcjS1BBIrNlW3ZvgxVpkCKejKhKFc6Y7vUJv4q5Xsed6DWVd/17zX4yrf6Ed
Gv7Z1jdpPz+3I8pMebwVxYFQhOPDRxndOCIgLw4IFgYYnf0LMh0xEoSDRHZ9TPi6
xKF762CYGHbgs++lJLaHv93P9AY7xExGFRdT13wzrjhsicQc84H7iy4ZDp49T1Zi
qt7P6uKdh5Yj561k/hFQeaeIUcVtjBkm94OdVUlP7kiIlV9Cx7kMbDKJpK23XTXG
8X+af3MBERhib9R+UVYVDcq2YfnsZ9JeA46w2bZf4CJaVQ9fCOG0oXCC8X2BeNza
cort58TAwZQ1mXOIZcXRX2IVqls7bTr9Hbka+QTNg0QbepboCzzR5KG3IZLpDwQY
dw9VTkIcxpe7E33VkCJufivW3crj4LS/2w4QYDj8jjMeroxbt9XGYU63DQcLE9z9
M1S7eMN0iE4hRcQdgcR3aNoNuWJh9mJ3PzNbf4lbhub11H6wgpqwb/4UAobLhZmg
oDA7lbF2FM06wTcQrkFawUZFA7Y9P0bw9V/C7aEcblqvjzPkjfRlV0zGP6PB/nm8
XhvcitZ5vRfR33Acx7Qv
=egnU
-----END PGP SIGNATURE-----

Stuart Rackham

unread,
May 26, 2009, 5:16:20 AM5/26/09
to asci...@googlegroups.com
Ok, I understand now. The reason for this behavior is that the contents
of asciidoc styled cells are processed by separate asciidoc filter
processes which are passed only the cell contents but nothing else from
the enclosing document. Depending on your point of view this could be
classed as a feature or a limitation.

Cheers, Stuart

Simon Ruderich

unread,
May 27, 2009, 6:05:24 AM5/27/09
to asci...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

On Tue, May 26, 2009 at 09:16:20PM +1200, Stuart Rackham wrote:
> Ok, I understand now. The reason for this behavior is that the contents
> of asciidoc styled cells are processed by separate asciidoc filter
> processes which are passed only the cell contents but nothing else from
> the enclosing document. Depending on your point of view this could be
> classed as a feature or a limitation.
>
> Cheers, Stuart

Thanks. Would it be possible to pass the settings from the
document or this too complicated?

Simon
- --
+ privacy is necessary
+ using http://gnupg.org
+ public key id: 0x92FEFDB7E44C32F9
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iQIcBAEBCAAGBQJKHRBkAAoJEJL+/bfkTDL5f3gP/1GwIu6EQ/NlA2I/Rl0QbRAw
gF5QUK2eQ+tOfItCjwyexG2dQCTOkZutFGoyONhrS5Je2YcJKg5o+MM13bP69bty
TaHsYCxGT4XcK8qexMTSbUMxIMVxhQg0EeB8b2OJckXyQ8VgwD1EYZuDsqDKvu1N
s5v8kGIC/eC0Pmwx8YVTJxvAJPIxYhF0DNbfTiod92UPFD84CFubO2O09YoQIInw
4cpd77MIwmzlYs6VHYijcjIOMK+N8BOH1EC2SQfzWog2jEggKh34spOHYqR6KIZj
Tnh02oG41soU5aDIL9it8pmfV52PDmM69uJhzEKs1dS5OLHbXobHvZDIl4Z9ybcH
QBaJpFiaCxmR/BK2ybxLJxaE2U+ObuGNxVLMf8cnWtD9wiXf3KrfleKBIw5w5Ezk
K8T+tjE9C0xo8xvWIsatoW05O/QL8JlaJ8wAHTa7fA4PtAry0IPIweGPHEIvALWk
jqam0q5QV7oVVsSmR2pe+YOwbCmpHKp2ElqE7xq1I645pqOU8Bgzx8/JdkoG991E
OOpmO5c9y3CTbqAuctVDNBxj7IBlpRWmtQ0oWrX5Ry8NAX6OQ+qjMzUxVXqQ5agK
KN7ScAJ+zRAee5yC7bqoNEOi4VWsHulQXnlLMYqlTXnISxREXAnDsQLI7cXgom+5
CS+csX6RP/RJqEWUjbX/
=XCaA
-----END PGP SIGNATURE-----

Stuart Rackham

unread,
May 27, 2009, 9:32:43 PM5/27/09
to asci...@googlegroups.com
Simon Ruderich wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
>
> On Tue, May 26, 2009 at 09:16:20PM +1200, Stuart Rackham wrote:
>> Ok, I understand now. The reason for this behavior is that the contents
>> of asciidoc styled cells are processed by separate asciidoc filter
>> processes which are passed only the cell contents but nothing else from
>> the enclosing document. Depending on your point of view this could be
>> classed as a feature or a limitation.
>>
>> Cheers, Stuart
>
> Thanks. Would it be possible to pass the settings from the
> document or this too complicated?

It would be messy and not a common enough use case to warrant the effort.

Cheers, Stuart

Simon Ruderich

unread,
Apr 24, 2011, 2:35:54 PM4/24/11
to asci...@googlegroups.com
On Tue, May 26, 2009 at 09:16:20PM +1200, Stuart Rackham wrote:
> Simon Ruderich wrote:
>> [snip]

>>
>> Test
>> ====
>> :replacements.TEST: YEAH
>>
>> Here the replacement works: TEST
>>
>> [cols="asciidoc"]
>> |==================================================================
>> |
>> - Here the replacement doesn't work: TEST
>> |
>> :replacements.TEST: YEAH
>> - Here the replacement works again: TEST
>> |==================================================================
>>
>> [snip]

>>
>> My problem is that the replacement rule isn't propagated to the
>> AsciiDoc table cell. The TEST in the first row should also have
>> been replaced by YEAH.

Hi all,

I just had a similar problem - but this time the problem is that
configuration files aren't passed to the asciidoc process. The
following patches fixes the issue and works fine for me, but I'm
not sure if this is the right way to do it - my knowledge of
AsciiDoc internals is minimal.

What do you think?

Regards,
Simon
---
asciidoc.conf | 4 ++--
asciidoc.py | 15 +++++++++++----
doc/asciidoc.txt | 1 +
3 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/asciidoc.conf b/asciidoc.conf
index f2db428..843b1e6 100644
--- a/asciidoc.conf
+++ b/asciidoc.conf
@@ -515,7 +515,7 @@ emphasis-style=tags="emphasis"
strong-style=tags="strong"
monospaced-style=tags="monospaced"
header-style=tags="header"
-asciidoc-style=tags="asciidoc",subs=[],filter='python "{asciidoc-file}" -b {backend}{lang? -a "lang={lang}@"}{icons? -a icons -a "iconsdir={iconsdir}"}{imagesdir? -a "imagesdir={imagesdir}"}{data-uri? -a data-uri} -a "indir={indir}"{trace? -a "trace={trace}"} -s -'
+asciidoc-style=tags="asciidoc",subs=[],filter='python "{asciidoc-file}" -b {backend}{asciidoc-conffiles}{lang? -a "lang={lang}@"}{icons? -a icons -a "iconsdir={iconsdir}"}{imagesdir? -a "imagesdir={imagesdir}"}{data-uri? -a data-uri} -a "indir={indir}"{trace? -a "trace={trace}"} -s -'

[tabledef-nested]
# Same as [tabledef-default] but with different delimiter and separator.
@@ -529,7 +529,7 @@ emphasis-style=tags="emphasis"
strong-style=tags="strong"
monospaced-style=tags="monospaced"
header-style=tags="header"
-asciidoc-style=tags="asciidoc",subs=[],filter='python "{asciidoc-file}" -b {backend}{lang? -a "lang={lang}@"} -s -'
+asciidoc-style=tags="asciidoc",subs=[],filter='python "{asciidoc-file}" -b {backend}{asciidoc-conffiles}{lang? -a "lang={lang}@"} -s -'

#----------------------------------------
# Common block and macro markup templates
diff --git a/asciidoc.py b/asciidoc.py
index 9ba0c8f..94d9a6b 100755
--- a/asciidoc.py
+++ b/asciidoc.py
@@ -1336,6 +1336,7 @@ class Document(object):
self.has_errors = False # Set true if processing errors were flagged.
self.has_warnings = False # Set true if warnings were flagged.
self.safe = False # Default safe mode.
+ self.conffiles = [] # Extra config files used for this document.
def update_attributes(self,attrs=None):
"""
Set implicit attributes and attributes in 'attrs'.
@@ -1347,6 +1348,9 @@ class Document(object):
self.attributes['asciidoc-file'] = APP_FILE
self.attributes['asciidoc-dir'] = APP_DIR
self.attributes['asciidoc-confdir'] = CONF_DIR
+ self.attributes['asciidoc-conffiles'] = ''
+ for conffile in self.conffiles:
+ self.attributes['asciidoc-conffiles'] += ' --conf-file "%s"' % conffile
self.attributes['user-dir'] = USER_DIR
if config.verbose:
self.attributes['verbose'] = ''
@@ -5560,6 +5564,7 @@ def asciidoc(backend, doctype, confiles, infile, outfile, options):
config.load_file(f, include=include, exclude=exclude)
else:
raise EAsciiDoc,'configuration file %s missing' % f
+ return files

try:
if doctype not in (None,'article','manpage','book'):
@@ -5576,14 +5581,14 @@ def asciidoc(backend, doctype, confiles, infile, outfile, options):
# available are in the global asciidoc.conf
if not config.load_from_dirs('asciidoc.conf',include=['attributes']):
raise EAsciiDoc,'configuration file asciidoc.conf missing'
- load_conffiles(include=['attributes'])
+ document.conffiles = load_conffiles(include=['attributes'])
config.load_from_dirs('asciidoc.conf')
if infile != '<stdin>':
indir = os.path.dirname(infile)
config.load_file('asciidoc.conf', indir,
include=['attributes','titles','specialchars'])
else:
- load_conffiles(include=['attributes','titles','specialchars'])
+ document.conffiles = load_conffiles(include=['attributes','titles','specialchars'])
document.update_attributes()
# Check the infile exists.
if infile != '<stdin>':
@@ -5617,8 +5622,10 @@ def asciidoc(backend, doctype, confiles, infile, outfile, options):
config.load_filters([indir])
# Load document specific configuration files.
f = os.path.splitext(infile)[0]
- config.load_file(f + '.conf')
- config.load_file(f + '-' + document.backend + '.conf')
+ if config.load_file(f + '.conf'):
+ document.conffiles.append(f + '.conf')
+ if config.load_file(f + '-' + document.backend + '.conf'):
+ document.conffiles.append(f + '-' + document.backend + '.conf')
load_conffiles()
# Build outfile name.
if outfile is None:
diff --git a/doc/asciidoc.txt b/doc/asciidoc.txt
index 671f65c..7df90d7 100644
--- a/doc/asciidoc.txt
+++ b/doc/asciidoc.txt
@@ -4141,6 +4141,7 @@ predefined intrinsic attributes:

{amp} ampersand (&) character entity
{asciidoc-confdir} the asciidoc(1) global configuration directory
+ {asciidoc-conffiles} used to pass extra config files to asciidoc filters
{asciidoc-dir} the asciidoc(1) application directory
{asciidoc-file} the full path name of the asciidoc(1) script
{asciidoc-version} the version of asciidoc(1)
--
1.7.4.5

--
+ privacy is necessary

+ using gnupg http://gnupg.org

Stuart Rackham

unread,
Apr 29, 2011, 8:38:41 AM4/29/11
to asci...@googlegroups.com

It's a great idea, I've enhanced it a little to include attributes passed on the
command-line plus those set in the source file header and I've changed the name
to asciidoc-args to reflect this.

Because asciidoc filters will not be called until the body of the document has
been processed I moved the asciidoc-args generation to after all the pre-processing.

I haven't given it much of a test, could you please check that the attached
patch hasn't broken your patch.


Cheers, Stuart

>
> Regards,
> Simon
> ---

asciidoc-args.patch

Stuart Rackham

unread,
Apr 29, 2011, 3:22:05 PM4/29/11
to asci...@googlegroups.com
One more tweak, because including the parsed {asciidoc-conffiles} is redundant
as we're now passing it in as an attribute the code.

Cheers, Stuart


On 25/04/11 06:35, Simon Ruderich wrote:

asciidoc-args.patch

Simon Ruderich

unread,
Apr 30, 2011, 11:17:44 AM4/30/11
to asci...@googlegroups.com
On Sat, Apr 30, 2011 at 12:38:41AM +1200, Stuart Rackham wrote:
> It's a great idea, I've enhanced it a little to include attributes passed on
> the command-line plus those set in the source file header and I've changed
> the name to asciidoc-args to reflect this.
>
> Because asciidoc filters will not be called until the body of the document
> has been processed I moved the asciidoc-args generation to after all the
> pre-processing.
>
> I haven't given it much of a test, could you please check that the attached
> patch hasn't broken your patch.

Hi Stuart,

Thank you for your enhancements. Works great for me (I tested the
patch you committed to hg) except one issue I found while adding
the tests (see below).

The test differs between my and your patch:

diff --git a/tests/data/testcases-html4.html b/tests/data/testcases-html4.html
index 051d466..43337de 100644
--- a/tests/data/testcases-html4.html
+++ b/tests/data/testcases-html4.html
@@ -669,7 +669,7 @@ frame="border"
cellspacing="0" cellpadding="4">
<tbody>
<tr>
-<td align="left" width="100%" valign="top"><div><ul>
+<td align="left" width="100%" valign="top"><div><p><b>Test Cases</b></p><ul>
<li>
<p>
a
@@ -686,8 +686,8 @@ c
</p>
</li>
</ul>
-<p>Test file specific configuration files work in asciidoc columns:</p>
-<p>TEST_REPLACEMENT</p></div></td>
+<p><b>Test Cases</b><br>Test file specific configuration files work in asciidoc columns:</p>
+<p><b>Test Cases</b><br>test-replacement</p></div></td>
</tr>
</tbody>
</table>

(Same for the other formats.)

Looks like the :title: attribute to me. I don't think it should
be set for the call.

Attached is a patch to test the feature.

Regards,
Simon
---
tests/data/testcases.conf | 2 ++
tests/data/testcases.txt | 15 +++++++++++++++
2 files changed, 17 insertions(+), 0 deletions(-)
create mode 100644 tests/data/testcases.conf

diff --git a/tests/data/testcases.conf b/tests/data/testcases.conf
new file mode 100644
index 0000000..6bc039c
--- /dev/null
+++ b/tests/data/testcases.conf
@@ -0,0 +1,2 @@
+[replacements]
+test-replacement=TEST_REPLACEMENT
diff --git a/tests/data/testcases.txt b/tests/data/testcases.txt
index 455dfb1..f3b1413 100644
--- a/tests/data/testcases.txt
+++ b/tests/data/testcases.txt
@@ -589,6 +589,21 @@ hard + 1min really hard taking the HR up to 160).

|=========================================================

+Table with embedded asciidoc
+----------------------------
+
+[cols="asciidoc"]
+|====
+|
+- a
+- b
+- c
+
+Test file specific configuration files work in asciidoc columns:
+
+test-replacement
+|====
+
Floating tables and images
--------------------------
.Simple table
--
1.7.5

Stuart Rackham

unread,
Apr 30, 2011, 11:43:39 PM4/30/11
to asci...@googlegroups.com

Hi Simon, thanks for reporting these problems and the test, I've added the test
and hopefully fixed the problems (could you please check and report back):

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


Cheers, Stuart

Simon Ruderich

unread,
May 1, 2011, 8:37:01 AM5/1/11
to asci...@googlegroups.com
On Sun, May 01, 2011 at 03:43:39PM +1200, Stuart Rackham wrote:
> Hi Simon, thanks for reporting these problems and the test, I've added the
> test and hopefully fixed the problems (could you please check and report
> back):
>
> http://code.google.com/p/asciidoc/source/detail?r=7fec4d2a67ea81161efefb67a088f02c65e6da01
>
> Cheers, Stuart

Hi Stuart,

Thanks for your quick help and patch, works perfectly for me.

Regards,
Simon

Reply all
Reply to author
Forward
0 new messages