-
Notifications
You must be signed in to change notification settings - Fork 8
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
feature request: adding support for lists #17
Comments
Agree that this would be awesome! |
Hi I'm not familiar with 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 text
tmp <- gsub("\\\\item\\{([^}]+)\\}", "\\* \\1", text)
# \itemize{\n * whatever is here \n \item foo \n}
# -> \n * whatever is here \n \item foo \n
tmp <- gsub("\\\\itemize\\{([^}]+)\\}", "\\1", tmp)
# \item another bullet point
# -> * another bullet point
tmp <- 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 |
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. |
Created on 2021-07-22 by the reprex package (v2.0.0)
The text was updated successfully, but these errors were encountered: