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

Dash "-" character not being escaped #223

Closed
vrybkin opened this issue Jun 27, 2018 · 4 comments
Closed

Dash "-" character not being escaped #223

vrybkin opened this issue Jun 27, 2018 · 4 comments

Comments

@vrybkin
Copy link

vrybkin commented Jun 27, 2018

Hi @haozhu233, thank you again for this wonderful package and your time. Others may have pointed this out already - but I could not find it previously - that kableExtra 0.8.0 does not currently escape the - dash character and converts it to a really ugly looking black dot. I know you can can call it with \- but sometimes it can be a pain to go through every table and replace these instances as it makes the tables less readable outside of this package. A quick markdown example is below. Curiously, this is not an issue in shiny, where the - character renders fine.

---
output: 
  html_document
---

```{r, results = "hide", message = F, warning = F}
library(knitr) # 1.20
library(magrittr)
library(kableExtra) # 0.8.0
D = data.frame(x = LETTERS[1:2], y = c("\\-", "-"))
kable(x = D, format = "html", escape = F) %>% kableExtra::kable_styling()

Any idea how to fix this downstream in the kableExtra call? If not - it would be a great feature in the future!
@haozhu233
Copy link
Owner

@vrybkin In fact, the conversion from - to that "ugly looking black dot" happens when pandoc converts from md to html: It recognizes it as the list symbol... Proof is that if you run this thing in r console and see the results in RStudio viewer, you will see the original "-". That means that unfortunately I can't do anything to help you in this case. :P

@vrybkin
Copy link
Author

vrybkin commented Jun 28, 2018

@haozhu233 Thank you for the note! That is too bad that pandoc does that. I ended up using  -  instead as it renders nicely in both shiny and markdown. \\- renders properly in markdown, but not shiny.

@haozhu233
Copy link
Owner

@vrybkin I read a note somewhere else last week that you can use -- instead - in this case. You can get a lightly longer dash which won't get converted by pandoc.

@AndrewC160
Copy link

AndrewC160 commented Jun 29, 2023

Just to add a solution to this, I have been able to add "\" to columns with "+" or "-" values to escape them manually, so:

table %>%
mutate(strand1 = paste0("\\",strand1), strand2 = paste0("\\",strand2) %>%
kable %>%
kable_styling(full_width=FALSE)

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

No branches or pull requests

3 participants