Skip to content

Commit 6da7fb8

Browse files
committed
Split ExplicitLink into ExplicitLinkWithLabel(return structure) and ExplicitLink(return rdoc link format string)
Create intermediate rule ExplicitLinkWithLabel that returns `{label:, link:}`, so that Image rule does not need to re-parse rdoc link format again.
1 parent 894b2f1 commit 6da7fb8

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

lib/rdoc/markdown.kpeg

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -992,14 +992,8 @@ Strike = &{ strike? }
992992
"~~"
993993
{ strike a.join }
994994

995-
Image = "!" ExplicitLink:a
996-
{
997-
# Extract alt text and URL
998-
alt_text = a[/\{(.*?)\}/, 1] || ""
999-
url = a[/\[(.*?)\]/, 1] || ""
1000-
1001-
"rdoc-image:#{url}:#{alt_text}"
1002-
}
995+
Image = "!" ExplicitLinkWithLabel:a
996+
{ "rdoc-image:#{a[:link]}:#{a[:label]}" }
1003997

1004998
Link = ExplicitLink | ReferenceLink | AutoLink
1005999

@@ -1011,8 +1005,11 @@ ReferenceLinkDouble = Label:content < Spnl > !"[]" Label:label
10111005
ReferenceLinkSingle = Label:content < (Spnl "[]")? >
10121006
{ link_to content, content, text }
10131007

1014-
ExplicitLink = Label:l "(" @Sp Source:s Spnl Title @Sp ")"
1015-
{ "{#{l}}[#{s}]" }
1008+
ExplicitLink = ExplicitLinkWithLabel:a
1009+
{ "{#{a[:label]}}[#{a[:link]}]" }
1010+
1011+
ExplicitLinkWithLabel = Label:label "(" @Sp Source:link Spnl Title @Sp ")"
1012+
{ { label: label, link: link } }
10161013

10171014
Source = ( "<" < SourceContents > ">" | < SourceContents > )
10181015
{ text }

0 commit comments

Comments
 (0)