Permalink
Browse files

Implement images in a crappy way

  • Loading branch information...
1 parent 2632f71 commit 27451e5a0b707ef60dc4bde2f00bc841ed38d280 @drbrain drbrain committed Oct 30, 2011
Showing with 15 additions and 15 deletions.
  1. +7 −15 pegdown.kpeg
  2. +8 −0 test/test_pegdown.rb
View
@@ -5,6 +5,7 @@
# Limitations:
#
# * Link titles are not used
+# * Image links are not always generated correctly
require 'rubygems'
require 'rdoc'
@@ -600,14 +601,8 @@ StrongUl = TwoUlOpen
TwoUlClose:l { a << l }
{ a }
-Image = "!" ( ExplicitLink | ReferenceLink )
- { raise 'if ($$->key == LINK) {
- $$->key = IMAGE;
- } else {
- element *result;
- result = $$;
- $$->children = cons(mk_str("!"), result->children);
- } ' }
+Image = "!" ( ExplicitLink | ReferenceLink ):a
+ { a }
Link = ExplicitLink | ReferenceLink | AutoLink
@@ -620,19 +615,16 @@ ReferenceLinkSingle = Label:content < (Spnl "[]")? >
{ link_to content }
ExplicitLink = Label:l Spnl "(" Sp Source:s Spnl Title:t Sp ")"
- { raise '$$ = mk_link(l->children, s->contents.str, t->contents.str);
- free_element(s);
- free_element(t);
- free(l);' }
+ { s }
Source = ( "<" < SourceContents > ">" | < SourceContents > )
- { raise " $$ = mk_str(yytext); " }
+ { text }
SourceContents = ( ( !"(" !")" !">" Nonspacechar )+ | "(" SourceContents ")")*
| ""
-Title = ( TitleSingle | TitleDouble | < "" > )
- { raise " $$ = mk_str(yytext); " }
+Title = ( TitleSingle | TitleDouble | < "" > ):a
+ { a }
TitleSingle = "'" < ( !( "'" Sp ( ")" | Newline ) ) . )* > "'"
View
@@ -177,6 +177,14 @@ def test_parse_html_address_no_html
assert_equal expected, doc
end
+ def test_parse_image
+ doc = parse "image ![alt text](path/to/image.jpg)"
+
+ expected = doc(para("image path/to/image.jpg"))
+
+ assert_equal expected, doc
+ end
+
def test_parse_line_braek
doc = parse "Some text \nwith extra lines"

0 comments on commit 27451e5

Please sign in to comment.