Converts an HTML string to BBCode. BBCode is commonly used in the Steam forum and other bulletin boards.

html_to_bbcode(x, preserve_newlines = FALSE)

Arguments

x

A string containing HTML formatting.

preserve_newlines

If TRUE, preserves linebreaks. If FALSE, also preserves linebreaks – or so it seems.

Value

A character string containing BBCode formatted text.

Examples

string1 <- "<b>test</b>"
string2 <- "<br>\n"
string3 <- "<a href='google.com'>link</a>"

html_to_bbcode(string1)
#> [1] "[b]test[/b]"
html_to_bbcode(string2)
#> [1] "\n"
html_to_bbcode(string3)
#> [1] "[url=google.com]link[/url]"