guix-devel
[Top][All Lists]
Advanced

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

Re: Communication and Design at Guix


From: Julien Lepiller
Subject: Re: Communication and Design at Guix
Date: Tue, 15 Jan 2019 18:39:35 +0100
User-agent: Roundcube Webmail/1.3.8

Le 2019-01-15 14:56, Ricardo Wurmus a écrit :
swedebugia <address@hidden> writes:

I looked into the chicken docs and their html and css. They generate
their examples from source-code with this MIT chicken egg-script:
http://code.call-cc.org/svn/chicken-eggs/release/4/colorize/trunk/colorize.scm.

To use their approach with parens highlighting we would need to either
depend on chicken and this egg or port it to guile.

Are you aware of the guile-syntax-highlight package?

Hey, I use it for my blog, but it doesn't generate the same kind
of html:

<span class="syntax-open">(</span><span class="syntax-symbol">foo</span><span class="syntax-close">)</span>

So I've just written a bit of scheme to convert that to nested
syntax-paren spans:

<span class="syntax-paren"><span class="syntax-open">(</span><span class="syntax-symbol">foo</span><span class="syntax-close">)</span></span>

(define (break-paren sxmls)
  (match sxmls
    ('() (values '() '()))
    ((('span ('@ ('class "syntax-close")) _) tag ...)
     (values '((span (@ (class "syntax-close")) ")")) tag))
    ((('span ('@ ('class "syntax-open")) _) tag ...)
     (receive (inside outside)
       (break-paren tag)
       (receive (inside2 outside2)
         (break-paren outside)
(values (cons `(span (@ (class "syntax-paren")) ,@(cons `(span (@ (class "syntax-open")) "(") inside)) inside2) outside2))))
    ((tag ...)
     (receive (inside outside)
       (break-paren (cdr tag))
       (values (cons (car tag) inside) outside)))))

(define (paren-grouper sxmls)
  (match sxmls
    ('() '())
    ((('span ('@ ('class "syntax-open")) _) tag ...)
     (receive (inside outside)
       (break-paren tag)
(cons `(span (@ (class "syntax-paren")) ,@(cons `(span (@ (class "syntax-open")) "(") inside)) (paren-grouper outside))))
    ((tag ...)
     (begin
(cons (paren-matcher (list (car tag))) (paren-grouper (cdr tag)))))))

(define (paren-matcher sxml)
  (match sxml
    ((tag ('@ attrs ...) content ...)
     `(,tag (@ ,attrs) ,@(paren-grouper content)))
    ((tag content ...)
     `(,tag ,@(paren-grouper content)))))

You're supposed to call paren-matcher on a sxml tag. It tries to find
the matching parenthesis for each opening one and wraps the content
inside a span. That's it. You need (ice-9 receive) and (ice-9 match).


Not sure how much of that is actually needed. Maybe there's already an
option to do all that? With a bit of css, the result is here:

https://lepiller.eu/ma-configuration.html



reply via email to

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