Fix string split for unhighlighted files

Julien LepillerSun Jun 27 00:57:23+0200 2021

10b1d54

Fix string split for unhighlighted files

gitile/code.scm

4545
4646
(define (split-lines content)
4747
  (let loop ((content content) (result '()) (line '()))
48-
    (match (pk 'split-lines-content content)
48+
    (match content
4949
      ((? string? s) (string-split s #\newline))
5050
      (() (append result (list line)))
5151
      (((? string? s) content ...)

7878
                   '()))))))))
7979
8080
(define (split-tr content)
81-
  (pk 'split-tr content)
8281
  (let loop ((result '()) (lines (split-lines content)) (line-num 1))
8382
    (match lines
8483
      (() result)

gitile/highlight/utils.scm

88
99
(define (flatten-highlights highlights)
1010
  (define (flatten-highlights-aux content tokens)
11-
    (pk 'content content 'tokens tokens)
1211
    (match content
1312
      ((? string? s) (if (null? tokens)
14-
                         s
13+
                         (list s)
1514
                         `((,@tokens ,s))))
1615
      (((? symbol? token) content ...)
1716
       (flatten-highlights-aux content (cons token tokens)))
1817
      ((? list? content)
1918
       (append-map (lambda (c) (flatten-highlights-aux c tokens)) content))))
2019
21-
  (pk 'content highlights)
2220
  (flatten-highlights-aux highlights '()))
2321
2422
(define (highlights->sxml highlights)

2725
  (define (tag->class tag)
2826
    (string-append "syntax-" (symbol->string tag)))
2927
30-
  (pk 'highlights flat-highlights)
31-
3228
  (map (match-lambda
3329
         ((? string? str) str)
3430
         ((content ...)

6460
  (if tag
6561
      (lambda (tokens cursor)
6662
        (let-values (((result remainder) (consume-until empty-tokens cursor)))
67-
          (values (pk (token-add tokens (list tag (tokens->list result)))) remainder)))
63+
          (values (token-add tokens (list tag (tokens->list result))) remainder)))
6864
      consume-until))