68 for (
size_t k = 0U; k < name_len; ++k) {
69 if ((tag[i + k] | 0x20U) != (uint8_t)name[k]) {
73 const uint8_t prev = (i == 0U) ? (uint8_t)
'<' : tag[i - 1U];
74 return !(((prev >= (uint8_t)
'a') && (prev <= (uint8_t)
'z')) ||
75 ((prev >= (uint8_t)
'A') && (prev <= (uint8_t)
'Z')));
110 if ((j >= tag_len) || (tag[j] != (uint8_t)
'=')) {
117 if ((j >= tag_len) || ((tag[j] != (uint8_t)
'"') && (tag[j] != (uint8_t)
'\''))) {
120 const uint8_t quote = tag[j];
123 while ((j < tag_len) && (tag[j] != quote)) {
160 if (tag_len < name_len) {
163 for (
size_t i = 0U; (i + name_len) <= tag_len; ++i) {
219 *out_len = (uint32_t)vlen;
246 el.
tag = (uint8_t)kind;
250 el.
id = (
const char*)&tag[off];
251 el.
id_len = (uint16_t)len;
324 return (uint8_t)(idx + 1U);
349 static const char k_kw[] =
"stylesheet";
350 const size_t k_klen =
sizeof(k_kw) - 1U;
351 for (
size_t i = 0U; (i + k_klen) <= len; i++) {
353 for (; (j < k_klen) && (rel[i + j] == (uint8_t)k_kw[j]); j++) {
395 for (uint8_t k = 0U; k < engine->
face_count; ++k) {
397 return (uint8_t)(k + 1U);
Annotation-attribute framework macros for ra8-firmware.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
Error Code Definitions for ra8-firmware.
void * memcpy(void *dst, const void *src, size_t n)
Copy memory area between non-overlapping regions.
HTML / CSS reflow + paginate engine for the ra8d2 ereader.
ra8_err_t ra8_css_parse_inline(const char *decls, uint32_t len, ra8_css_style_t *out)
Parse an inline style="..." declaration body into one style.
@ k_ra8_css_set_family
font-family was declared.
int16_t ra8_css_match_face(const ra8_css_sheet_t *sheet, const char *family, uint16_t family_len, bool want_bold, bool want_italic)
Pick the @font-face whose family + emphasis best fits a run.
ra8_css_style_t priv_reflow_tok_css_inline(const uint8_t *tag, size_t span)
Parse a just-opened tag's inline style="..." into a CSS declaration.
ra8_css_element_t priv_reflow_tok_css_element(reflow_html_tag_t kind, const uint8_t *tag, size_t span)
Build a CSS element identity from a just-opened tag's attributes.
bool priv_reflow_tok_find_attr(const uint8_t *tag, size_t tag_len, const char *name, size_t name_len, size_t *out_voff, size_t *out_vlen)
Locate a named attribute's quoted value span within a tag (no copy).
static bool internal_attr_quoted_value(const uint8_t *tag, size_t tag_len, size_t pos, size_t *vstart, size_t *vlen)
Parse = "value" after an attribute name; return the value span.
void priv_reflow_tok_capture_attr(reflow_t *engine, const uint8_t *tag, size_t tag_len, const char *name, size_t name_len, uint32_t *out_off, uint32_t *out_len)
Copy a named attribute's quoted value from a tag span into the text pool.
bool priv_reflow_tok_rel_is_stylesheet(const uint8_t *rel, size_t len)
True if a rel attribute value contains the stylesheet token.
static bool internal_attr_name_at(const uint8_t *tag, size_t i, const char *name, size_t name_len)
True iff attribute name (case-insensitive) begins at tag[i].
uint8_t priv_reflow_tok_resolve_face_slot(const reflow_t *engine, const ra8_css_style_t *comp)
Map a cascaded run's (font-family + emphasis) to an embedded face slot.
uint8_t priv_reflow_tok_intern_link(reflow_t *engine, uint32_t href_off, uint32_t href_len)
Intern an <a> href slice into the link-target table.
Test-access surface for reflow_tokenize.c internal helpers.
bool priv_reflow_tok_is_xml_whitespace(char c)
True for the ASCII characters XHTML treats as whitespace.
reflow_html_tag_t
Recognised HTML element kinds.
@ k_reflow_max_links
Max distinct <a href> per chapter.
@ k_reflow_text_pool_bytes
Bytes of text pool.
@ k_reflow_style_italic
Italic face.
@ k_reflow_style_bold
Bold face.
The identity of one element, used to match selectors.
uint16_t class_len
Length of class_str, bytes.
const char * id
id attribute bytes (NULL = none).
const char * class_str
class attribute bytes (NULL = none).
uint16_t id_len
Length of id, bytes.
uint8_t tag
reflow_html_tag_t of the element.
uint8_t names[k_ra8_css_name_pool]
class/id/font name bytes.
A declared or computed style: a presence mask plus property values.
uint16_t family_len
font-family name slice length (0 = none).
uint8_t style
reflow_font_style_t bit VALUES (bold/italic/ul).
uint8_t set
ra8_css_set_t bitmask: which properties are present.
uint16_t family_off
font-family name slice offset (valid iff set&family).
uint8_t css_face_idx
@font-face table index this blob satisfies.
uint32_t href_len
Href slice length, bytes.
uint32_t href_off
Href slice offset into the text pool.
Reflow / pagination engine state.
uint8_t text_pool[k_reflow_text_pool_bytes]
Text bytes.
ra8_css_sheet_t css
Parsed <style> rules for the chapter.
uint32_t text_pool_used
Bytes consumed in text_pool.
uint32_t link_target_count
Interned link targets.
reflow_face_t faces[k_reflow_max_faces]
Embedded @font-face set.
reflow_link_target_t link_targets[k_reflow_max_links]
Distinct hrefs.
uint8_t face_count
Embedded face count (0 = single-face).