File tree 1 file changed +19
-3
lines changed
1 file changed +19
-3
lines changed Original file line number Diff line number Diff line change 54
54
(result `(verbatim (info ,(string-trim-both info))
55
55
(code ,@code-lines)))))))
56
56
57
+ (define (dashes->spaces string )
58
+ (string-map (lambda (c ) (if (char=? c #\- ) #\space c)) string))
59
+
60
+ (define (spaces->dashes string )
61
+ (string-map (lambda (c ) (if (char=? c #\space ) #\- c)) string))
62
+
63
+ (define (coloring-type-string->symbol string )
64
+ (let ((string (dashes->spaces string)))
65
+ (let loop ((names (coloring-type-names)))
66
+ (and (not (null? names))
67
+ (if (string-ci= string (cdar names))
68
+ (caar names)
69
+ (loop (cdr names)))))))
70
+
57
71
(define fenced-code-block-conversion-rules*
58
72
`((verbatim
59
73
. ,(lambda (_ contents )
63
77
(code (alist-ref 'code contents))
64
78
(code* (string-intersperse code " " ))
65
79
(raw-lang (car info))
66
- (lang-str (string-downcase raw-lang))
67
- (lang-sym (string->symbol lang-str)))
80
+ (lang-sym (coloring-type-string->symbol raw-lang))
81
+ (lang-dashed (spaces->dashes
82
+ (string-downcase raw-lang))))
68
83
(if (coloring-type-exists? lang-sym)
69
84
`(pre (code (@ (class ,(string-append
70
- " colorize language-" lang-str)))
85
+ " colorize"
86
+ " language-" lang-dashed)))
71
87
,@(->> code*
72
88
(html-colorize lang-sym)
73
89
(html->sxml)
You can’t perform that action at this time.
0 commit comments