-
Notifications
You must be signed in to change notification settings - Fork 440
Image alt tag header formatting #1320
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
Conversation
d53617f
to
9ef4934
Compare
{ | ||
# Extract alt text and URL | ||
alt_text = a[/\{(.*?)\}/, 1] || "" | ||
url = a[/\[(.*?)\]/, 1] || "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we do this in a follow-up PR? I think it's out of scope for this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense 👍
Co-authored-by: Stan Lo <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Thanks everyone! |
This allows us to parse the alt text from Markdown images, formatting a header text correctly (using the alt text).
Without this PR, if a Markdown file has an image instead of a title, that image will be used in the table of contents, which is unreadable and undesirable.
Used in rack/rack#2313.