Commits

Anonymous committed 14450bb

Update to pass MarkdownTest 1.0.3

  • Participants
  • Parent commits 31602f2

Comments (0)

Files changed (1)

        (any-of (is #\newline))))
 
 (define space-new-line
-  (preceded-by space* (maybe (preceded-by new-line space*))))
+  (sequence space* (maybe (preceded-by new-line space*))))
 
 (define normal-line-end
   (preceded-by space* new-line))
           (parser input)))))))
 
 (define link-title
-  (sequence* ((delimiter (satisfies (char-set #\' #\")))
+  (sequence* ((delimiter (is #\' #\"))
               (title (-> (preceded-by
                           (is delimiter)
                           space*
        (href (preceded-by (is #\()
                           explicit-link-source))
        (title (maybe (preceded-by space+ link-title)))
-       (_ (is #\))))
+       (_ (preceded-by space* (is #\)))))
     (result `(explicit-link
               (href    ,href)
               (label . ,label)
               (title   ,title)))))
 
+(define shortcut-reference-link
+  (sequence* ((label (-> (link-label)
+                         (followed-by (none-of (is #\:))))))
+    (result `(reference-link
+              (input #\[ ,@label #\])
+              (ref   . ,label)
+              (label . ,label)))))
+
 (define reference-link
   (sequence* ((label (link-label))
               (space space-new-line)
-              (ref (link-label)))
+              (ref   (link-label)))
     (result `(reference-link
               (input #\[ ,@label #\]
                      ,space
 (define link
   (any-of explicit-link
           reference-link
+          shortcut-reference-link
           auto-link))
 
 (define (line-of char)
           space+
           (strong)
           (emph)
+          image
           link
           code
           raw-html
 (define optionally-indented-line
   (preceded-by (maybe indent) line))
 
-(define (crazy-trim line)
-  (if (equal? line "> \n")
-      line
-      (string-append (string-trim-right line) "\n")))
-
 (define verbatim-chunk
   (sequence* ((blank-lines (-> blank-line 
                                (preceded-by (result #\newline))
                                (zero-or-more)))
               (text (one-or-more non-blank-indented-line)))
-    (result (append blank-lines (map crazy-trim text)))))
+    (result (append blank-lines text))))
 
 (define verbatim
   (sequence* ((chunks (one-or-more verbatim-chunk)))
 (define (make-image ref #!optional attrs)
   `(img (@ (src ,(alist-ref 'href ref))
            (alt . ,(alist-ref 'label (or attrs ref)))
-           . ,(maybe-attr-ref 'title ref))))
+           ,(if attrs
+                (maybe-attr-ref 'title ref)
+                `((title . ,(alist-ref 'title ref)))))))
 
 (define (make-anchor ref #!optional attrs)
   `(a (@ (href ,(alist-ref 'href ref))