ropensci / tinkr

Convert (R)Markdown files to XML, edit them, write them back as (R)Markdown
https://docs.ropensci.org/tinkr
GNU General Public License v3.0
57 stars 3 forks source link

subscript text is converted to strikethrough text #99

Open zkamvar opened 1 year ago

zkamvar commented 1 year ago

This may be a commonmark problem but it appears that it treats a single pair of ~ as strikethrough text even though it prints a double pair.

txt <- "log~10~"
xml <- tinkr::yarn$new(textConnection(txt))
xml$show()
#> log~~10~~

xml$body |> as.character() |> writeLines()
#> <?xml version="1.0" encoding="UTF-8"?>
#> <!DOCTYPE document SYSTEM "CommonMark.dtd">
#> <document xmlns="http://commonmark.org/xml/1.0">
#>   <paragraph>
#>     <text xml:space="preserve">log</text>
#>     <strikethrough>
#>       <text xml:space="preserve">10</text>
#>     </strikethrough>
#>   </paragraph>
#> </document>

Created on 2023-06-19 with reprex v2.0.2

zkamvar commented 1 year ago

This was first observed in https://github.com/datacarpentry/R-ecology-lesson/issues/859

zkamvar commented 6 months ago

I've opened https://github.com/r-lib/commonmark/pull/31 to fix this upstream, but the downside is that tildes will be escaped :/