Commits

Anonymous committed e7659ad

Add code and escaped-char

Comments (0)

Files changed (1)

                 (surrounded-by #\_ (char-seq "__")))
         (node 'strong))))
 
+;; EscapedChar =   '\\' !Newline < [-\\`|*_{}[\]()#+.!><] >
+
+(define escaped-char
+  (->> (string->char-set "-\\`|*_{}[]()#+.!><")
+       (satisfies)
+       (preceded-by (is #\\) (none-of new-line))))
+
+
+;; Ticks1 = "`" !'`'
+;; Ticks2 = "``" !'`'
+;; Ticks3 = "```" !'`'
+;; Ticks4 = "````" !'`'
+;; Ticks5 = "`````" !'`'
+
+;; Code = ( Ticks1 Sp < ( ( !'`' Nonspacechar )+ | !Ticks1 '`'+ | !( Sp Ticks1 ) ( Spacechar | Newline !BlankLine ) )+ > Sp Ticks1
+;;        | Ticks2 Sp < ( ( !'`' Nonspacechar )+ | !Ticks2 '`'+ | !( Sp Ticks2 ) ( Spacechar | Newline !BlankLine ) )+ > Sp Ticks2
+;;        | Ticks3 Sp < ( ( !'`' Nonspacechar )+ | !Ticks3 '`'+ | !( Sp Ticks3 ) ( Spacechar | Newline !BlankLine ) )+ > Sp Ticks3
+;;        | Ticks4 Sp < ( ( !'`' Nonspacechar )+ | !Ticks4 '`'+ | !( Sp Ticks4 ) ( Spacechar | Newline !BlankLine ) )+ > Sp Ticks4
+;;        | Ticks5 Sp < ( ( !'`' Nonspacechar )+ | !Ticks5 '`'+ | !( Sp Ticks5 ) ( Spacechar | Newline !BlankLine ) )+ > Sp Ticks5
+;;        )
+;;        { $$ = mk_str(yytext); $$->key = CODE; }
+
+(define code
+  (sequence* ((ticks (-> (is #\`)
+                         (repeated min: 1 max: 5 (none-of (is #\`)))
+                         (as-string)))
+              (_  space*)
+              (code (->> (any-of space-char (preceded-by new-line (none-of blank-line)))
+                         (preceded-by (none-of (preceded-by space* (char-seq ticks))))
+                         (any-of (one-or-more (preceded-by (none-of (is #\`)) non-space-char))
+                                 (preceded-by (none-of (char-seq ticks)) (one-or-more (is #\`))))
+                         (one-or-more)
+                         (as-string)
+                         (node 'code)))
+              (_ (preceded-by space* (char-seq ticks))))
+    (result code)))
+
 (define inline
   (any-of (as-string (one-or-more normal-char))
           line-end
           (strong)
           (emph)
           link
+          code
+          escaped-char
           special-char))
 
 (define inline-without-line-end