chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] ssax/sxml and lowdown transforms


From: Moritz Heidkamp
Subject: Re: [Chicken-users] ssax/sxml and lowdown transforms
Date: Sat, 06 Jun 2015 20:06:46 +0200

Hi Markus,

On  6 June 2015 18:12 CEST, Markus Espenhain <address@hidden> wrote:

> I’m still new to chicken and scheme so please bear with me :)

no need to apologize, this list is exactly the right place for questions
like that :-) Welcome to CHICKEN!


> I had some trouble to mange some sxml transforms
>
> The first - what would a transform rule look like to transform
>
>     (foo ((bar) (baz)))
>
> into
>
>     ((bar) (baz))

I suggest to do it this way:

    (pre-post-order* '(foo ((bar) (baz)))
                      `((foo . ,(lambda (_ x) (car x)))
                        ,@alist-conv-rules*))

Check Peter's tutorial on SXML transformations to understand how it
works: http://www.more-magic.net/docs/scheme/sxslt.pdf -- note that it
uses `pre-post-order' rather than `pre-post-order*' which has a slightly
different API. It's generally recommended to use the latter at least
with CHICKEN due to its argument list length limitation.


> lowdown returns all spaces in a extra spaces list - for example:
>
>     (paragraph "this" (#\space) "is" (#\space #\space) "text")
>
> How would one match these 'spaces' nodes and transform them into a single 
> space instead
>
>     (#\space) -> " "
>     (#\space #\space) -> " "
>
> or alternatively
>
>     (#\space \#space) -> "  "

In case you are unfamiliar with the #\space thing: these are just space
character objects. The reason for these being characters rather than
strings is that the parser works on the character level and it just
passes these through as it finds them in the input. It would require an
extra conversion step to turn them into a string. This is generally not
a problem as most of the SXML tools cope with characters just fine even
though this is not part of the spec. There was some discussion recently
to change Lowdown to emit proper SXML. I'm open to this, it's just not a
pressing need of my own and I didn't find the spare time to do it,
yet. You could look into this and send me a patch if you like!

Anyway, if you want to turn those characters into strings in your own
code for now, you'd have to do a custom tree walk. Alternatively, use an
SXML transformation rule for each node type which can contain text and
do the conversion there. My question is: Why do you want to do this in
the first place? :-)


> ps @the-lowdown-authors - It would be cool if a lowdown 'user' could
> register custom inline hooks (and also block hooks!). I saw the
> lowdown-extra, which creates two inline hooks but the inline-hook
> parameter is not exported … or at least I did not know how to import +
> call inline-hook :)

This is not part of the public API, yet, I only added enough to make
`lowdown-extra' possible. But you are very welcome to give it a try :-)
Just `(use lowdown-lolevel)' in your module to import
`inline-hook'. Check `lowdown-extra.scm' for how to use it. A
`block-hook' would definitely be nice to have, too, I agree. This is
just another thing which has not come up so far.

Hope that helps!
Moritz

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]