Anonymous avatar Anonymous committed a25dc56

Move inline-note html conversion rules to lowdown-extra

Comments (0)

Files changed (2)

lowdown-extra.scm

 (module lowdown-extra
 
-(enable-lowdown-extra! inline-note)
+(enable-lowdown-extra!
+ inline-note
+ lowdown-extra-html-conversion-rules*)
 
 (import chicken scheme)
-(use comparse lowdown-lolevel clojurian-syntax)
+(use comparse lowdown lowdown-lolevel clojurian-syntax)
 
 (define inline-note
   (enclosed-by (char-seq "^[")
                     (node 'inline-note))
                (char-seq "]")))
 
+(define lowdown-extra-html-conversion-rules*
+  `((inline-note . ,(lambda (_ contents)
+                      `(span (@ (class "note")) . ,contents)))))
+
 (define (enable-lowdown-extra!)
   (inline-hook (cons inline-note (inline-hook)))
+  (markdown-html-conversion-rules*
+   (append lowdown-extra-html-conversion-rules*
+           (markdown-html-conversion-rules*)))
   (void))
 
 )
 
 (module lowdown
 
-(markdown->sxml markdown->sxml* markdown-sxml->html-sxml markdown->html)
+(markdown->sxml
+ markdown->sxml*
+ markdown-sxml->html-sxml
+ markdown->html
+ markdown-html-conversion-rules*)
 
 (import chicken scheme)
 (use data-structures srfi-1 clojurian-syntax comparse
       . ,(alist-ref 'label (or attrs ref))))
 
 (define markdown-html-conversion-rules*
-  `((explicit-link . ,(lambda (_ attrs)
-                        (make-anchor attrs)))
-    (reference-link . ,(lambda (_ attrs)
-                         (call-with-reference attrs make-anchor)))
-    (auto-link . ,(lambda (_ attrs)
-                    `(a (@ (href . ,(alist-ref 'href attrs)))
-                        . ,(alist-ref 'label attrs))))
-    (image . ,(lambda (_ attrs)
-                (make-image attrs)))
-    (reference-image . ,(lambda (_ attrs)
-                          (call-with-reference attrs make-image)))
-    (verbatim . ,(lambda (_ contents)
-                   `(pre (code . ,contents))))
-    (bullet-list . ,(lambda (_ items)
-                      `(ul . ,items)))
-    (ordered-list . ,(lambda (_ items)
-                       `(ol . ,items)))
-    (item . ,(lambda (_ contents)
-               `(li . ,contents)))
-    (heading . ,(lambda (_ contents)
-                  (cons (->> (number->string (car contents))
-                             (string-append "h")
-                             (string->symbol))
-                        (cdr contents))))
-    (paragraph . ,(lambda (_ contents)
-                    `(p . ,contents)))
-    (emphasis . ,(lambda (_ text)
-                   `(em . ,text)))
-    (strong . ,(lambda (_ text)
-                 `(strong . ,text)))
-    (html-element . ,(lambda (_ contents)
-                       contents))
-    (comment . ,(lambda (_ contents)
-                  (list #\< "!--" contents "--" #\> #\newline)))
-    (inline-note . ,(lambda (_ contents)
-                      `(span (@ (class "note")) . ,contents)))
-    . ,alist-conv-rules*))
+  (make-parameter
+   `((explicit-link . ,(lambda (_ attrs)
+                         (make-anchor attrs)))
+     (reference-link . ,(lambda (_ attrs)
+                          (call-with-reference attrs make-anchor)))
+     (auto-link . ,(lambda (_ attrs)
+                     `(a (@ (href . ,(alist-ref 'href attrs)))
+                         . ,(alist-ref 'label attrs))))
+     (image . ,(lambda (_ attrs)
+                 (make-image attrs)))
+     (reference-image . ,(lambda (_ attrs)
+                           (call-with-reference attrs make-image)))
+     (verbatim . ,(lambda (_ contents)
+                    `(pre (code . ,contents))))
+     (bullet-list . ,(lambda (_ items)
+                       `(ul . ,items)))
+     (ordered-list . ,(lambda (_ items)
+                        `(ol . ,items)))
+     (item . ,(lambda (_ contents)
+                `(li . ,contents)))
+     (heading . ,(lambda (_ contents)
+                   (cons (->> (number->string (car contents))
+                              (string-append "h")
+                              (string->symbol))
+                         (cdr contents))))
+     (paragraph . ,(lambda (_ contents)
+                     `(p . ,contents)))
+     (emphasis . ,(lambda (_ text)
+                    `(em . ,text)))
+     (strong . ,(lambda (_ text)
+                  `(strong . ,text)))
+     (html-element . ,(lambda (_ contents)
+                        contents))
+     (comment . ,(lambda (_ contents)
+                   (list #\< "!--" contents "--" #\> #\newline)))
+     . ,alist-conv-rules*)))
 
 (define (ref->alist-entry ref)
   (cons (car (alist-ref 'label (cdr ref)))
 (define (markdown-sxml->html-sxml markdown-sxml)
   (receive (refs sxml) (partition reference-element? markdown-sxml)
     (parameterize ((references (map ref->alist-entry refs)))
-      (pre-post-order* sxml markdown-html-conversion-rules*))))
+      (pre-post-order* sxml (markdown-html-conversion-rules*)))))
 
 (define (markdown->sxml* #!optional (input (current-input-port)) (memoize? #t))
   (parse document input memoize: memoize?))
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.