Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

a is a String that always match to these regexp because ExplicitLink:a is created by "{#{l}}[#{s}]". #1322

Closed
ioquatix opened this issue Mar 22, 2025 · 1 comment
Assignees

Comments

@ioquatix
Copy link
Member

          `a` is a String that always match to these regexp because `ExplicitLink:a` is created by `"{#{l}}[#{s}]"`.

Perhaps it could be more simple if ExplicitLink returns structured data

  ExplicitLink =  Label:l "(" @Sp Source:s Spnl Title @Sp ")"
-                 { "{#{l}}[#{s}]" } # returns string, need to parse this string again...
+                 { { label: l, source: s } } # can return hash

(need to change Link = ExplicitLink | ReferenceLink | AutoLink to return a string if ExplicitLink returns hash)

Originally posted by @tompng in #1320 (comment)

@ioquatix ioquatix assigned ioquatix and tompng and unassigned ioquatix Mar 22, 2025
@ioquatix
Copy link
Member Author

@tompng as per our discussion, I've pulled this out into a follow-up action.

Let me know if there is anything I can do here to help. It sounds like you have a strong opinion about how to refactor this, so I'm happy to defer to you.

tompng added a commit that referenced this issue Mar 23, 2025
Create intermediate rule ExplicitLinkWithLabel that returns `{label:,
link:}`, so that Image rule does not need to re-parse rdoc link format
again.

```ruby
# Before
"[text](url)" → "{text}(url)"
"![text](url)" → Image("{text}(url)") →(parse with regexp)→ "rdoc-image:url:text"

# After
"[text](url)" → ExplicitLink({ label: 'text', link: 'url' }) → "{text}(url)"
"![text](url)" → Image({ label: 'text', link: 'url' }) → "rdoc-image:url:text"
```


#1322
@tompng tompng closed this as completed Mar 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants