unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Julien Lepiller <julien@lepiller.eu>
To: guix-devel@gnu.org
Subject: Re: Communication and Design at Guix
Date: Tue, 15 Jan 2019 18:39:35 +0100	[thread overview]
Message-ID: <9a3b1cb7f2f0e4573f44f2cfe4d7a6f5@lepiller.eu> (raw)
In-Reply-To: <87won6hvnm.fsf@elephly.net>

Le 2019-01-15 14:56, Ricardo Wurmus a écrit :
> swedebugia <swedebugia@riseup.net> 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	other threads:[~2019-01-15 17:39 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-08 16:49 Communication and Design at Guix L p R n d n
2019-01-08 17:37 ` Ludovic Courtès
2019-01-09  6:11   ` swedebugia
2019-01-09 21:45     ` Ludovic Courtès
2019-01-10 12:09       ` L p R n d n
2019-01-10 13:20         ` swedebugia
2019-01-10 14:34         ` Ricardo Wurmus
2019-01-13 21:45           ` Ludovic Courtès
2019-01-14 15:02             ` L p R n d n
2019-01-15 10:36               ` zimoun
2019-01-15 18:03                 ` nly
2019-01-15 22:08                   ` Ricardo Wurmus
2019-01-16 11:00                     ` Giovanni Biscuolo
2019-01-15 22:28               ` Ludovic Courtès
2019-01-14 23:25             ` swedebugia
2019-01-15 13:56               ` Ricardo Wurmus
2019-01-15 17:39                 ` Julien Lepiller [this message]
2019-01-15 22:30                   ` Ludovic Courtès
2019-01-10 12:17     ` L p R n d n
2019-01-10 12:57   ` L p R n d n
2019-01-10 14:30     ` Ricardo Wurmus
2019-01-13 21:50     ` Ludovic Courtès
2019-01-14 14:36       ` L p R n d n
2019-01-15 22:31         ` Ludovic Courtès
2019-01-16 16:31       ` George Clemmer
2019-01-17  0:10         ` swedebugia
2019-01-17 10:58         ` L p R n d n
2019-01-17 11:10           ` Ricardo Wurmus
2019-01-17 14:08             ` swedebugia
2019-01-17 16:24               ` L p R n d n

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9a3b1cb7f2f0e4573f44f2cfe4d7a6f5@lepiller.eu \
    --to=julien@lepiller.eu \
    --cc=guix-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).