knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "README-" ) library("worldbet") inline <- "/`r convert_bet_to_entity('SIp')`/"
This micropackage converts WorldBet ASCII characters for English sounds into UTF-8 character and HTML entities.
RStudio has rich support for UTF-8 symbols. Here is how some WorldBet-to-IPA conversions look in RStudio.
library("worldbet") # that convert_bet_to_ipa("D@t") #> [1] "ðæt" # uh-oh convert_bet_to_ipa("^?o") #> [1] "ʌʔo" # water, weather (vector input) convert_bet_to_ipa(c("wA)&_r", "wED&_r")) #> [1] "wɑɾɚ" "wɛðɚ"
From the command prompt on Windows, R falls back to escape sequences during the conversions.
# that convert_bet_to_ipa("D@t") # uh-oh convert_bet_to_ipa("^?o") # water, weather (vector input) convert_bet_to_ipa(c("wA)&_r", "wED&_r"))
For RMarkdown documents, we can use HTML entities for in-text use of IPA. For example, we could write the following RMarkdown in our prose:
The word was `r inline` ("ship").
RMarkdown-to-markdown conversion then yields the following text with HTML entities instead of WorldBet symbols:
The word was /`r convert_bet_to_entity("SIp")`/ ("ship").
Finally, markdown-to-HTML conversion yields the following human-readable form of the symbols.
The word was /
r convert_bet_to_entity("SIp")
/ ("ship").
The table below shows the implementation of the WorldBet used in the package.
library("dplyr") as_literal <- function(xs) sprintf("`%s`", xs) worldbet_key %>% mutate(HTML_Entity = as_literal(Entity), WorldBet = as_literal(WorldBet)) %>% select(WorldBet, IPA = Entity, `HTML Entity` = HTML_Entity) %>% knitr::kable(.)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.