Skip to content

Keep link targets out of meta description excerpts - #1862

Open
anyingiit wants to merge 1 commit into
ruby:masterfrom
anyingiit:excerpt-strip-link-targets
Open

anyingiit wants to merge 1 commit into
ruby:masterfrom
anyingiit:excerpt-strip-link-targets

Conversation

@anyingiit

Copy link
Copy Markdown
Contributor

Fixes #1857. The excerpt used for the description, og:description and twitter:description meta tags is matched against the raw comment text, so link URLs can leak into it. For the example in the issue, a Markdown comment Foo. followed by [Example Link](https://example.com) got the excerpt Foo. example., where example. is the domain part of the URL.

Darkfish#excerpt (also used by Aliki) now cleans up links before matching. Links become their text ([text](url) for Markdown comments, {text}[url] and text[url] for RDoc markup), Markdown images such as badges are dropped, and bare http(s)/ftp URLs are removed. The issue's example now gives Foo..

On RDoc's own documentation, only three pages get a different description. CONTRIBUTING.md and doc/configuration.md no longer end in URL or link-syntax fragments (a trailing github. and a stray [). For RDoc::TomDoc the second sentence becomes The TomDoc specification can be found at ., which is still not great but no longer mixes in text from an unrelated paragraph. Bare URLs keep their trailing punctuation, so a sentence ending in a URL still ends the sentence. All other pages are unchanged.

The excerpt used for the description meta tags is taken from the raw
comment text, so link URLs could end up in it. For example, a Markdown
comment "Foo." followed by "[Example Link](https://example.com)" got
the excerpt "Foo. example.", the second sentence being the "example."
part of the URL.

Before taking the excerpt, replace links with their text (Markdown
[text](url) for Markdown comments, {text}[url] and text[url] for RDoc
markup), drop Markdown images, and remove bare URLs.

Fixes ruby#1857
@github-actions

Copy link
Copy Markdown

Documentation preview

View the preview

Commit: 9c85568

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

markdown html excerpt includes link parts

1 participant