Update syntax-highlight to latest version

Julien LepillerTue Aug 24 23:16:23+0200 2021

73e93db

Update syntax-highlight to latest version

Makefile.am

1111
    gitile/handler.scm \
1212
    gitile/pages.scm \
1313
    gitile/repo.scm \
14-
	gitile/highlight/gitignore.scm \
15-
	gitile/highlight/shell.scm \
16-
	gitile/highlight/utils.scm
14+
	gitile/highlight/shell.scm
1715
1816
jsdir=$(datadir)/gitile/assets/js
1917
cssdir=$(datadir)/gitile/assets/css

gitile/code.scm

2020
  #:use-module (ice-9 match)
2121
  #:use-module (syntax-highlight)
2222
  #:use-module (syntax-highlight scheme)
23-
  #:use-module (gitile highlight gitignore)
23+
  #:use-module (syntax-highlight gitignore)
2424
  #:use-module (gitile highlight shell)
25-
  #:use-module ((gitile highlight utils) #:prefix gitile:)
2625
  #:export (display-code
2726
            display-formatted-code))
2827

3938
                         ("bootstrap" "shell")
4039
                         (_ "unknown"))))))
4140
    `(table (@ (class ,(string-append "file-content language-" language)))
42-
       ,@(split-tr (gitile:highlights->sxml (highlight-code content language))))))
41+
       ,@(split-tr (highlights->sxml (highlight-code content language))))))
4342
4443
(define (display-formatted-code content language)
45-
  (gitile:highlights->sxml (highlight-code content language)))
44+
  (highlights->sxml (highlight-code content language)))
4645
4746
(define (highlight-code content language)
4847
  (match language

gitile/highlight/css.scm unknown status 2

1-
(define-module (gitile highlight css)
2-
  #:use-module (ice-9 match)
3-
  #:use-module (srfi srfi-1)
4-
  #:use-module (srfi srfi-11)
5-
  #:use-module (srfi srfi-26)
6-
  #:use-module (syntax-highlight lexers)
7-
  #:export (lex-css))
8-
9-
(define %css-units
10-
  '("cm" "mm" "in" "px" "pt" "pc" "em" "ex" "ch" "rem" "vw" "vh" "vmin" "vmax" "%"))
11-
12-
(define %css-functions
13-
  '("url" "attr" "calc" "cubic-bezier" "hsl" "hsla" "linear-gradient"
14-
    "radial-gradient" "repeating-linear-gradient" "repeating-radial-gradient"
15-
    "rgb" "rgba" "var"))
16-
17-
(define lex-css-whitespace
18-
  (lex-char-set char-set:whitespace))
19-
20-
(define lex-comment
21-
  (lex-tag 'comment (lex-delimited "/*" #:until "*/")))
22-
23-
(define lex-whitespace
24-
  (lex-any
25-
    lex-css-whitespace
26-
    lex-comment))
27-
28-
(define lex-number
29-
  (lex-all
30-
    (lex-char-set char-set:digit)
31-
    (lex-maybe
32-
      (lex-all
33-
        (lex-string ".")
34-
        (lex-char-set char-set:digit)))))
35-
36-
(define lex-css-string
37-
  (lex-any
38-
    (lex-tag 'string (lex-delimited "\""))
39-
    (lex-tag 'string (lex-delimited "'"))))
40-
41-
(define lex-selector
42-
  (lex-any
43-
    (lex-all (lex-string ".") (lex-tag 'class (lex-char-set char-set:letter+digit)))
44-
    (lex-all (lex-string "#") (lex-tag 'id (lex-char-set char-set:letter+digit)))
45-
    (lex-all (lex-string "[")
46-
             (lex-tag 'attr (lex-char-set char-set:letter))
47-
             (lex-any (map lex-string '("=" "~=" "|=" "^=" "$=" "*=")))
48-
             (lex-tag 'value (lex-any lex-css-string
49-
                                      (lex-char-set
50-
                                        (char-set-adjoin char-set:letter+digit #\_))))
51-
             (lex-string "]"))
52-
    (lex-all (lex-string "[")
53-
             (lex-tag 'attr (lex-char-set char-set:letter))
54-
             (lex-string "]"))
55-
    (lex-tag 'selector (lex-all (lex-string "::") (lex-char-set char-set:letter+digit)))
56-
    (lex-tag 'selector (lex-all (lex-string ":") (lex-char-set char-set:letter+digit)))))
57-
58-
(define lex-size
59-
  (lex-tag 'size (lex-all lex-number (lex-any (map lex-string %css-units)))))
60-
61-
(define lex-base-property-value
62-
  (lex-any
63-
    (lex-tag 'size (lex-all lex-number (lex-any (map lex-string %css-units))))
64-
    (lex-tag 'number lex-number)
65-
    (lex-tag 'keyword (lex-char-set (char-set-adjoin char-set:letter #\-)))
66-
    (lex-all (lex-string "#") (lex-tag 'color (lex-char-set (string->char-set "0123456789abcdefABCDEF"))))
67-
    lex-css-string))
68-
69-
(define lex-expression
70-
  (lex-all
71-
    lex-base-property-value
72-
    (lex-zero-or-more
73-
      (lex-all
74-
        lex-whitespace
75-
        (lex-any* (map lex-string '("+" "-" "*" "/")))
76-
        lex-whitespace
77-
        lex-base-property-value))))
78-
79-
(define lex-property-value
80-
  (lex-any
81-
    lex-base-property-value
82-
    (lex-all
83-
      (lex-tag 'function (map lex-string %css-functions))
84-
      (lex-string "(")
85-
      (lex-zero-or-more
86-
        (lex-any
87-
          lex-whitespace
88-
          (lex-string ",")
89-
          lex-expression))
90-
      (lex-string ")"))))
91-
92-
(define lex-property
93-
  (lex-all
94-
    (lex-tag 'property (lex-char-set (char-set-adjoin char-set:letter #\-)))
95-
    lex-whitespace
96-
    (lex-string ":")
97-
    lex-whitespace
98-
    (lex-zero-or-more
99-
      (lex-any
100-
        lex-property-value
101-
        lex-whitespace
102-
        (lex-string ",")
103-
        lex-whitespace))
104-
    (lex-maybe (lex-string ";"))))
105-
106-
(define lex-css
107-
  (lex-consume
108-
    (lex-any
109-
      lex-whitespace
110-
      lex-css-string
111-
      (lex-tag 'tag (lex-any (lex-char-set char-set:letter+digit) (lex-string "*")))
112-
      (lex-tag 'operator (lex-any (map lex-string '(">" "+" "~"))))
113-
      (lex-tag 'selector lex-selector)
114-
      (lex-all (lex-string "(")
115-
               (lex-any lex-selector (lex-char-set char-set:digit))
116-
               (lex-string ")"))
117-
      (lex-string ",")
118-
      (lex-all (lex-string "{")
119-
               (lex-zero-or-more
120-
                 (lex-any
121-
                   lex-whitespace
122-
                   lex-comment
123-
                   lex-property))
124-
               (lex-string "}")))))

gitile/highlight/gitignore.scm unknown status 2

1-
;;;; Copyright (C) 2021 Julien Lepiller <julien@lepiller.eu>
2-
;;;;
3-
;;;; SPDX-License-Identifier: AGPL-3.0-or-later
4-
;;;;
5-
;;;; This program is free software: you can redistribute it and/or modify
6-
;;;; it under the terms of the GNU Affero General Public License as published by
7-
;;;; the Free Software Foundation, either version 3 of the License, or
8-
;;;; (at your option) any later version.
9-
;;;;
10-
;;;; This program is distributed in the hope that it will be useful,
11-
;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12-
;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13-
;;;; GNU Affero General Public License for more details.
14-
;;;;
15-
;;;; You should have received a copy of the GNU Affero General Public License
16-
;;;; along with this program.  If not, see <https://www.gnu.org/licenses/>.
17-
;;;;
18-
19-
(define-module (gitile highlight gitignore)
20-
  #:use-module (ice-9 match)
21-
  #:use-module (srfi srfi-1)
22-
  #:use-module (srfi srfi-11)
23-
  #:use-module (srfi srfi-26)
24-
  #:use-module (syntax-highlight lexers)
25-
  #:use-module (gitile highlight utils)
26-
  #:export (lex-gitignore))
27-
28-
(define lex-line
29-
  (lex-consume-until
30-
    (lex-string "\n")
31-
    (lex-any
32-
      (lex-tag 'special (apply lex-any (map lex-string '("*" "**" "?"))))
33-
      (lex-tag 'range (lex-delimited "[" #:until "]"))
34-
      (apply lex-any (map lex-string '("\\!" "\\*" "\\\\" "\\?")))
35-
      (lex-char-set (char-set-complement (char-set #\newline #\\ #\* #\?))))
36-
    #:tag 'line))
37-
38-
(define lex-gitignore
39-
  (lex-consume
40-
    (lex-any (lex-tag 'comment (lex-delimited "#" #:until "\n"))
41-
             (lex-tag 'special (lex-string "!"))
42-
             lex-line)))

gitile/highlight/shell.scm

2222
  #:use-module (srfi srfi-11)
2323
  #:use-module (srfi srfi-26)
2424
  #:use-module (syntax-highlight lexers)
25-
  #:use-module (gitile highlight utils)
2625
  #:export (%shell-builtins
2726
            %shell-keywords
2827
            make-shell-lexer

gitile/highlight/utils.scm unknown status 2

1-
;;;; Copyright (C) 2021 Julien Lepiller <julien@lepiller.eu>
2-
;;;;
3-
;;;; SPDX-License-Identifier: AGPL-3.0-or-later
4-
;;;;
5-
;;;; This program is free software: you can redistribute it and/or modify
6-
;;;; it under the terms of the GNU Affero General Public License as published by
7-
;;;; the Free Software Foundation, either version 3 of the License, or
8-
;;;; (at your option) any later version.
9-
;;;;
10-
;;;; This program is distributed in the hope that it will be useful,
11-
;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12-
;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13-
;;;; GNU Affero General Public License for more details.
14-
;;;;
15-
;;;; You should have received a copy of the GNU Affero General Public License
16-
;;;; along with this program.  If not, see <https://www.gnu.org/licenses/>.
17-
;;;;
18-
19-
(define-module (gitile highlight utils)
20-
  #:use-module (ice-9 match)
21-
  #:use-module (srfi srfi-1)
22-
  #:use-module (srfi srfi-11)
23-
  #:use-module (syntax-highlight lexers)
24-
  #:export (highlights->sxml
25-
            lex-consume-until))
26-
27-
(define (flatten-highlights highlights)
28-
  (define (flatten-highlights-aux content tokens)
29-
    (match content
30-
      ((? string? s) (if (null? tokens)
31-
                         (list s)
32-
                         `((,@tokens ,s))))
33-
      (((? symbol? token) content ...)
34-
       (flatten-highlights-aux content (cons token tokens)))
35-
      ((? list? content)
36-
       (append-map (lambda (c) (flatten-highlights-aux c tokens)) content))))
37-
38-
  (flatten-highlights-aux highlights '()))
39-
40-
(define (highlights->sxml highlights)
41-
  (define flat-highlights (flatten-highlights highlights))
42-
43-
  (define (tag->class tag)
44-
    (string-append "syntax-" (symbol->string tag)))
45-
46-
  (map (match-lambda
47-
         ((? string? str) str)
48-
         ((content ...)
49-
          (let loop ((tags '()) (text "") (content content))
50-
            (match content
51-
             (() `(span (@ (class ,(string-join (map tag->class tags) " "))) ,text))
52-
             (((? symbol? tag) content ...)
53-
              (loop (cons tag tags) text content))
54-
             (((? string? s) content ...)
55-
              (loop tags (string-append text s) content))))))
56-
       flat-highlights))
57-
58-
(define* (lex-consume-until until lexer #:key (tag #f))
59-
  "Return a lexer that always succeeds with a list of as many consecutive
60-
successful applications of LEXER as possible, consuming the entire input text,
61-
or until a successful match of UNTIL, whichever comes first.  Sections of text
62-
that could not be lexed are returned as plain strings."
63-
  (define (substring* cursor start)
64-
    (substring (cursor-text cursor) start (cursor-position cursor)))
65-
66-
  (define (consume-until tokens cursor)
67-
    (if (cursor-end? cursor)
68-
        (values tokens cursor)
69-
        (let-values (((result remainder) (until tokens cursor)))
70-
          (if result
71-
              (values result remainder)
72-
              (let-values (((result remainder) (lexer tokens cursor)))
73-
                (if result
74-
                    (consume-until result remainder)
75-
                    (values (token-add tokens (cursor->string cursor))
76-
                            (move-cursor-to-end cursor))))))))
77-
78-
  (if tag
79-
      (lambda (tokens cursor)
80-
        (let-values (((result remainder) (consume-until empty-tokens cursor)))
81-
          (values (token-add tokens (list tag (tokens->list result))) remainder)))
82-
      consume-until))

guix.scm

2020
             (guix licenses)
2121
             (guix build-system gnu)
2222
             (guix git-download)
23+
             (guix git)
2324
             (gnu packages autotools)
2425
             (gnu packages gnupg)
2526
             (gnu packages guile)

3536
              (method git-fetch)
3637
              (uri (git-reference
3738
                     (url "https://git.dthompson.us/guile-syntax-highlight.git")
38-
                     (commit "51727cbb7fc05ef743aab2d7b16314ea1ed790e4")))
39-
              (file-name (git-file-name "guile-syntax-highlight" "0.1.51727cb"))
39+
                     (commit "897fa5156ff41588e0d281eb00e4e94de63ccd8a")))
40+
              (file-name (git-file-name "guile-syntax-highlight" "0.1.897fa51"))
4041
              (sha256
4142
               (base32
42-
                "1cvacy4y5qxajygb1qg8hvhjdf2xnnwnm5j918cabsi8wfwchig7"))))
43+
                "18zlg4mkgd3swgv2ggfz91ivnnzc0zhvc9ybgrxg1y762va9hyvj"))))
4344
    (native-inputs
4445
     `(("autoconf" ,autoconf)
4546
       ("automake" ,automake)

4950
(package
5051
  (name "gitile")
5152
  (version "0.1")
52-
  (source #f)
53+
  (source (git-checkout (url (dirname (current-filename)))))
5354
  (build-system gnu-build-system)
5455
  (propagated-inputs
5556
   `(("guile-commonmark" ,guile-commonmark)