pkgdown icon indicating copy to clipboard operation
pkgdown copied to clipboard

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

Open IndrajeetPatil opened this issue 3 years ago • 6 comments

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

IndrajeetPatil avatar Jan 29 '22 03:01 IndrajeetPatil

What a great username example :wink: Thanks for the reprex.

Regex https://github.com/r-lib/pkgdown/blob/25a1ab2d04c2b8251214b5189fa6735896468cd7/R/repo.R#L41 Tests https://github.com/r-lib/pkgdown/blob/25a1ab2d04c2b8251214b5189fa6735896468cd7/tests/testthat/test-repo.R?q=repo_auto_link#L12

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

maelle avatar Jan 31 '22 06:01 maelle

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 avatar Jun 01 '22 21:06 hadley

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 avatar Jun 01 '22 21:06 hadley

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 avatar Jun 01 '22 21:06 hadley

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 avatar Jun 01 '22 21:06 hadley

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

hadley avatar Jun 22 '22 22:06 hadley