remedy icon indicating copy to clipboard operation
remedy copied to clipboard

Feature/markdownify

Open jonocarroll opened this issue 6 years ago • 5 comments

If applied, this commit will introduce the markdownify() addin which converts HTML to markdown syntax. Refer to changes in README for examples.

Why is this change being made? I'm migrating my blog and want to update these HTML tags into native markdown. I realised it was a a fairly straightforward regex operation but wanted to formalise it into a package. I haven't seen this functionality elsewhere, but that doesn't preclude that from being the case.

jonocarroll avatar Mar 02 '19 09:03 jonocarroll

cool addition.

could you please update the function to include the following so it can be integrated into the package

  • [ ] markdownifyr.R
    • binding function must have a trailing r, ie markdownifyr (connects with hot key functionality)
    • add an example (CRAN forces examples for the addins)
example roxygen2 header
#' @title Imager
#'
#' @description Convert the selected path into an embedded image
#'
#'
#' @return a markdown image link
#' @export
#' @importFrom rstudioapi getSourceEditorContext modifyRange
#' 
#' @examples 
#' \dontrun{
#' remedy_example( 
#'     c( "https://thinkr.fr/wp-content/uploads/2015/03/thinkR1.png"), 
#'     imager
#'     )
#' }
imager <- function() {

  • [ ] addins.dcf
    • update the binding field
  • [ ] opts.R
    • add element to hotkey field in opts.R. Name of element function name without the trailing r, ie markdownify.
    • add suggested hotkey for macOS, this is for when end users add hotkeys in bulk and use remedy::remedy_opts$get("hotkeys")
  • [ ] testthat
    • add unit tests in testthat
  • [ ] covrpage
    • run covrpage covrpage::covrpage(update_badge = TRUE,vignette = TRUE) locally since ci can't run the unit tests for addins.

yonicd avatar Mar 02 '19 12:03 yonicd

Very good idea indeed.

I have a more or less fully functional regex here : https://github.com/ColinFay/backyard/blob/master/R/html_to_markdown.R

We can mix your PR and the code from there so to include more html tags.

ColinFay avatar Mar 02 '19 12:03 ColinFay

@yonicd cheers, can do. By 'update the binding field' do you mean because it should be markdownifyr? I'm proposing ALT+SHIFT+m as a hotkey since it's unused. OPTION+SHIFT+m for Mac, I guess, but I'll have to test that. I didn't add tests yet as it was an initial proposal but I can do that now.

@ColinFay neat! I was torn between bulk-processing of source and piecewise. I went with the latter as I tend to have embedded tweets and I don't think I want to convert that HTML. I currently have this set to only performing one conversion at a time, but perhaps reformatting a bulk section of text makes sense (with a warning about trying to do too much).

I'll iterate.

jonocarroll avatar Mar 02 '19 12:03 jonocarroll

yes. the binding field needs to be the function name (that's being updated with trailing r).

those hotkeys are good, it's a problem with so many to find one that makes sense and isnt in use. all the hotkeys in opts are mac centric, please dont mix with winOS.

thanks again

yonicd avatar Mar 02 '19 13:03 yonicd

I'm not sure I could even test on windows... ugh. I'm coming from linux.

jonocarroll avatar Mar 02 '19 13:03 jonocarroll