You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
library(roxygen2md)
text<- c(
"Here are the items:\\itemize{\\item{item-1}\\item{item-2} }"
)
text#> [1] "Here are the items:\n \\itemize{\n \\item{item-1}\n \\item{item-2}\n }"
markdownify(text)
#> [1] "Here are the items:\n \\itemize{\n \\item{item-1}\n \\item{item-2}\n }"
Hi I'm not familiar with rex so I don't make a PR but here's some base R regexes to fix some very simple cases if someone wants to build on that:
text<- c(
"#' Here are the items:#' \\itemize{#' \\item{item-1}#' \\item{item-2}#' }#' And another list:#' \\itemize{#' \\item item-1 with some very#' long text#' \\item item-2#' }"
)
cat(text)
#> #' Here are the items:#> #' \itemize{#> #' \item{item-1}#> #' \item{item-2}#> #' }#> #' And another list:#> #' \itemize{#> #' \item item-1 with some very#> #' long text#> #' \item item-2#> #' }# \item{here's some text} # -> * here's some texttmp<- gsub("\\\\item\\{([^}]+)\\}", "\\* \\1", text)
# \itemize{\n * whatever is here \n \item foo \n} # -> \n * whatever is here \n \item foo \ntmp<- gsub("\\\\itemize\\{([^}]+)\\}", "\\1", tmp)
# \item another bullet point# -> * another bullet pointtmp<- gsub("\\\\item ", "\\* ", tmp)
cat(tmp)
#> #' Here are the items:#> #' #> #' * item-1#> #' * item-2#> #' #> #' And another list:#> #' #> #' * item-1 with some very#> #' long text#> #' * item-2#> #'
Note that the example above won't work with \\item \\strong{item-2} for example so it should come as the last step of the conversion process (if implemented as-is).
In addition to the caveats you mentioned, I think the function will also need to deal with the recursive case where the list items may themselves contain lists.
Activity
danielinteractive commentedon Jul 6, 2022
Agree that this would be awesome!
etiennebacher commentedon Sep 22, 2023
Hi I'm not familiar with
rexso I don't make a PR but here's some base R regexes to fix some very simple cases if someone wants to build on that:Note that the example above won't work with
\\item \\strong{item-2}for example so it should come as the last step of the conversion process (if implemented as-is).IndrajeetPatil commentedon Sep 22, 2023
That's a great start, Etienne! Thanks.
In addition to the caveats you mentioned, I think the function will also need to deal with the recursive case where the list items may themselves contain lists.