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

GitHub profile link in NEWS not generated if it's the first word in the list item #2030

Closed
IndrajeetPatil opened this issue Jan 29, 2022 · 6 comments · Fixed by #2104
Closed
Labels
bug an unexpected problem or unintended behavior linking 📎

Comments

@IndrajeetPatil
Copy link
Contributor

For minimal reprex, see: https://github.com/IndrajeetPatil/minimalReprex/

The following, when rendered on the website,

# minimalReprex 0.0.0.9000

* @maelle fixed this bug in PR XYZ.

* Thanks, @maelle, for discovering this bug.

* Added a `NEWS.md` file to track changes to the package.

looks like this:

image

@maelle
Copy link
Collaborator

maelle commented Jan 31, 2022

What a great username example 😉 Thanks for the reprex.

Regex

text <- gsub("(\\s|^|\\()@([-\\w]+)", user_link, text, perl = TRUE)

Tests
expect_equal(repo_auto_link(pkg, "(@y)"), "(<a href='TEST/y'>@y</a>)")

Maybe the regex should be tweaked, or maybe this behavior is intended, I am afraid I do not know which. 😅

@maelle maelle added the bug an unexpected problem or unintended behavior label Apr 25, 2022
@hadley hadley added this to the v2.0.4 milestone May 31, 2022
@hadley
Copy link
Member

hadley commented Jun 1, 2022

I can't reproduce:

text <- "# minimalReprex 0.0.0.9000

* @maelle fixed this bug in PR XYZ.

* Thanks, @maelle, for discovering this bug.

* Added a `NEWS.md` file to track changes to the package."

pkg <- list(
  repo = list(
    url = list(
      user = "http://example.com/users/"
    )
  )
)
cat(pkgdown:::repo_auto_link(pkg, text))
#> # minimalReprex 0.0.0.9000
#> 
#> * <a href='http://example.com/users/maelle'>@maelle</a> fixed this bug in PR XYZ.
#> 
#> * Thanks, <a href='http://example.com/users/maelle'>@maelle</a>, for discovering this bug.
#> 
#> * Added a `NEWS.md` file to track changes to the package.

Created on 2022-06-01 by the reprex package (v2.0.1)

@hadley
Copy link
Member

hadley commented Jun 1, 2022

But I do see it with a fuller reprex:

pkg <- local_pkgdown_site(meta = "
  repo:
    url:
      user: https://example.com
    ")
write_lines(path = file.path(pkg$src_path, "NEWS.md"), 
"# testpackage 0.0.0.9000

* @maelle fixed this bug in PR XYZ.

* Thanks, @maelle, for discovering this bug.

* Added a `NEWS.md` file to track changes to the package."
)
cat(build_news(pkg)$html)

@hadley
Copy link
Member

hadley commented Jun 1, 2022

Oh, because the text being processed is HTML:

<div id="testpackage-0009000" class="section level2">
<h2 class="page-header" data-toc-text="0.0.0.9000">testpackage 0.0.0.9000</h2>
<ul><li><p>@maelle fixed this bug in PR XYZ.</p></li>
<li><p>Thanks, @maelle, for discovering this bug.</p></li>
<li><p>Added a <code>NEWS.md</code> file to track changes to the package.</p></li>
</ul></div>

@hadley
Copy link
Member

hadley commented Jun 1, 2022

Minimal reprex:

pkg <- list(
  repo = list(
    url = list(
      user = "http://example.com/users/"
    )
  )
)
cat(pkgdown:::repo_auto_link(pkg, "<p>@maelle</p>"))
#> <p>@maelle</p>

Created on 2022-06-01 by the reprex package (v2.0.1)

hadley added a commit that referenced this issue Jun 1, 2022
hadley added a commit that referenced this issue Jun 1, 2022
@hadley hadley reopened this Jun 22, 2022
@hadley
Copy link
Member

hadley commented Jun 22, 2022

Reopening since my fix didn't handle the case of pre-existing links (#2122) and I had to revert it.

@hadley hadley removed this from the v2.0.4 milestone Jul 12, 2022
@hadley hadley closed this as completed in b04d5c9 Mar 11, 2024
SebKrantz pushed a commit to SebKrantz/pkgdown that referenced this issue Jun 1, 2024
Fixes r-lib#2030 (not creating links at line starts) while not breaking r-lib#2122, for most common use case.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior linking 📎
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants