Functions for working with HTML content. More...
Functions | |
RUAPI alloc_chars | ruHtmlEncodeText (trans_chars text) |
Return HTML compatible version of given text without any HTML wrapper tags. More... | |
RUAPI perm_chars | ruHtmlSanitizeCustom (perm_chars html, alloc_chars *htmlCopy, alloc_chars *plainTxt, ruSet excludeTags, ruSet excludeAttrs) |
Sanitizes given HTML and optionally extracts plain text. More... | |
RUAPI perm_chars | ruHtmlSanitize (perm_chars html, alloc_chars *htmlCopy, alloc_chars *plainTxt) |
Sanitizes given HTML and optionally extracts plain text. More... | |
RUAPI bool | ruHtmlTestFor (trans_chars content) |
Checks whether given buffer is HTML. More... | |
Functions for working with HTML content.
This uses https://github.com/htacg/tidy-html5
RUAPI alloc_chars ruHtmlEncodeText | ( | trans_chars | text | ) |
Return HTML compatible version of given text without any HTML wrapper tags.
This function simply replaces the following:
Character Sequence | Encoding |
---|---|
& | & |
< | < |
> | > |
2 spaces | |
\r\n | <br/>\n |
\n | <br/>\n |
\r | <br/>\n |
text | Text to HTML encode |
RUAPI perm_chars ruHtmlSanitize | ( | perm_chars | html, |
alloc_chars * | htmlCopy, | ||
alloc_chars * | plainTxt | ||
) |
Sanitizes given HTML and optionally extracts plain text.
This runs ruHtmlSanitizeCustom with the default sets.
html | HTML buf to evaluate |
htmlCopy | Where a cleaned copy if needed will be stored. Caller must free |
plainTxt | Where a plain text copy will be stored. Caller must free. |
RUAPI perm_chars ruHtmlSanitizeCustom | ( | perm_chars | html, |
alloc_chars * | htmlCopy, | ||
alloc_chars * | plainTxt, | ||
ruSet | excludeTags, | ||
ruSet | excludeAttrs | ||
) |
Sanitizes given HTML and optionally extracts plain text.
It returns a sanitized HTML copy if excluded items were found and an htmlCopy reference was given. If plainTxt reference was given it will store the extracted plain text there. At least one of htmlCopy or plainTxt must be set.
html | HTML buf to evaluate |
htmlCopy | Where a cleaned copy if needed will be stored. Caller must free |
plainTxt | Where a plain text copy will be stored. Caller must free. |
excludeTags | Optional Set of tags to filter out. Default:
|
excludeAttrs | Optional aet of attributes to filter out. Default:
|
RUAPI bool ruHtmlTestFor | ( | trans_chars | content | ) |
Checks whether given buffer is HTML.
This function checks the first 200 characters for <html and the last 20 for </html>.
content | Buffer to check |