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

Fix highlight use #523

Closed
wants to merge 3 commits into from
Closed

Conversation

romainfrancois
Copy link

This uses the simplified highlight interface where you only use the "detective" that takes a data frame and returns a data frame.

I've refrained from using dplyr functions as pkgdown does not depend on it, so there is a bit of untidy code :

  token_data <- data.frame(
    token = names(token_style), class = token_style, style = "",
    stringsAsFactors = FALSE
  )

  data <- merge( data, token_data, by = "token", all.x = TRUE, sort = FALSE )
  data$class[ is.na(data$class) ] <- ""
  data$style[ is.na(data$style) ] <- ""

  data$href <- href_tokens(data$text, data$class )

This passes the test suite on my machine:

==> devtools::test()

Loading pkgdown
Loading required package: testthat
Testing pkgdown
✔ | OK F W S | Context
✔ | 49       | as_html [0.5 s]
✔ |  1       | autolink_html [0.1 s]
✔ | 17       | build_home [9.3 s]
✔ |  4       | test-build-news.R [0.3 s]
✔ |  1       | build_site [0.8 s]
✔ |  3       | highlight
✔ | 24       | href [0.8 s]
✔ |  3       | test-html.R
✔ |  9       | Open Graph meta tags [4.8 s]
✔ |  8       | packages
✔ |  4       | remote
✔ |  4       | replay
✔ | 15       | topics [0.1 s]
✔ |  3       | tweak
✔ | 12       | util

══ Results ═════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════
Duration: 17.2 s

OK:       157
Failed:   0
Warnings: 0
Skipped:  0

You rock!
Warning message:
`encoding` is deprecated; all files now assumed to be UTF-8 

@hadley
Copy link
Member

hadley commented Mar 23, 2018

Is it possible to make it work with both dev and released highlight? Then we wouldn't need to synchronise highlight and pkgdown releases.

@hadley
Copy link
Member

hadley commented Apr 19, 2018

Bump - looking to submit to CRAN in the near future

@romainfrancois
Copy link
Author

Alright. I’ll spend some time trying to make highlight future proof enough.

Otherwise, i’ll edit this pr so that it works with the current cran version.

@hadley
Copy link
Member

hadley commented Apr 19, 2018

I think conditioning on the version of highlight would be adequate for this PR.

@hadley
Copy link
Member

hadley commented Apr 24, 2018

Let's leave this for now, and come back to it when you are working on highlight again.

@hadley hadley closed this Apr 24, 2018
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.

None yet

2 participants