Permalink
Browse files

Implement multiple referenced links

  • Loading branch information...
1 parent e82a036 commit 681f6342cb0721a20490874bd18e51c2627fdbcb @drbrain drbrain committed Oct 30, 2011
Showing with 18 additions and 2 deletions.
  1. +2 −2 pegdown.kpeg
  2. +16 −0 test/test_pegdown.rb
View
4 pegdown.kpeg
@@ -587,8 +587,8 @@ ReferenceLink = ReferenceLinkDouble | ReferenceLinkSingle
ReferenceLinkDouble = Label:content < Spnl > !"[]" Label:label
{ if ref = @references[label] then
"{#{content}}[#{ref}]"
- else # TODO multiple unlinked
- ref = ""
+ else
+ ref = @unlinked[label] || ""
@unlinked[label] = ref
["{#{content}}[", ref, "]"]
end
View
16 test/test_pegdown.rb
@@ -140,6 +140,22 @@ def test_parse_link_reference
assert_equal expected, doc
end
+ def test_parse_link_reference_many
+ doc = parse <<-MD
+This is [an example][id] reference-style link.
+
+And [another][id].
+
+[id]: http://example.com "Optional Title Here"
+ MD
+
+ expected = doc(
+ para("This is {an example}[http://example.com] reference-style link."),
+ para("And {another}[http://example.com]."))
+
+ assert_equal expected, doc
+ end
+
def test_parse_list_bullet
doc = parse <<-MD
* one

0 comments on commit 681f634

Please sign in to comment.