tests/testthat/test-6.1-backslash-escape.R

library(testthat)
library(gluedown)
library(stringr)
library(rvest)
library(glue)

test_that("md_escape prepends ASCII punctuation with a backslash (ex. 308)", {
  # https://github.github.com/gfm/#example-308
  ascii_punct <- as_glue("!\"#$%&'()*+,-./:;<=>?@[]^_`{|}~")
  n <- nchar(ascii_punct)
  md_escape(ascii_punct) %>%
    str_count("\\\\") %>%
    expect_equal(n)
})

test_that("md_escape prevents italic emphasis (ex. 311)", {
  # https://github.github.com/gfm/#example-311
  node <- md_italic("emphasis") %>%
    md_escape() %>%
    md_convert() %>%
    read_html() %>%
    html_node("em")
  expect_true(is.na(node))
})

Try the gluedown package in your browser

Any scripts or data that you put into this service are public.

gluedown documentation built on Nov. 2, 2023, 5:48 p.m.