Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Implement auto-link

  • Loading branch information...
commit e51a41d46b7f96e07b6c4366f8c44808327b5fd5 1 parent 27451e5
Eric Hodel drbrain authored

Showing 2 changed files with 18 additions and 6 deletions. Show diff stats Hide diff stats

  1. +2 6 pegdown.kpeg
  2. +16 0 test/test_pegdown.rb
8 pegdown.kpeg
@@ -633,14 +633,10 @@ TitleDouble = "\"" < ( !( "\"" Sp ( ")" | Newline ) ) . )* > "\""
633 633 AutoLink = AutoLinkUrl | AutoLinkEmail
634 634
635 635 AutoLinkUrl = "<" < /[A-Za-z]+/ "://" ( !Newline !">" . )+ > ">"
636   - { raise " $$ = mk_link(mk_str(yytext), yytext, ""); " }
  636 + { text }
637 637
638 638 AutoLinkEmail = "<" < /[-A-Za-z0-9+_]+/ "@" ( !Newline !">" . )+ > ">"
639   - { raise ' char *mailto = malloc(strlen(yytext) + 8);
640   - sprintf(mailto, "mailto:%s", yytext);
641   - $$ = mk_link(mk_str(yytext), mailto, "");
642   - free(mailto);'
643   - }
  639 + { "mailto:#{text}" }
644 640
645 641 Reference = NonindentSpace !"[]"
646 642 Label:label ":" Spnl RefSrc:link RefTitle:title BlankLine+
16 test/test_pegdown.rb
@@ -21,6 +21,22 @@ def mu_pp obj
21 21 s.chomp
22 22 end
23 23
  24 + def test_parse_auto_link_email
  25 + doc = parse "Autolink: <nobody@example>"
  26 +
  27 + expected = doc(para("Autolink: mailto:nobody@example"))
  28 +
  29 + assert_equal expected, doc
  30 + end
  31 +
  32 + def test_parse_auto_link_url
  33 + doc = parse "Autolink: <http://example>"
  34 +
  35 + expected = doc(para("Autolink: http://example"))
  36 +
  37 + assert_equal expected, doc
  38 + end
  39 +
24 40 def test_parse_block_quote
25 41 doc = parse <<-BLOCK_QUOTE
26 42 > this is

0 comments on commit e51a41d

Please sign in to comment.
Something went wrong with that request. Please try again.