HTML parsing and metadata

The original V2 tag, attribute, text and head readers.

The Japanese V2, American V2 and European clients contain an HTML parser alongside the UGO reader. Their parser accepts a specific set of tags and attributes; it does not repair documents or create controls in the same way as a current web browser. The following behaviour was checked in those three original ARM9 programs. It has not been established for Japanese V1. [1]

Document structure

Use an explicit head followed by an explicit body. The head reader finishes at a recognised closing head tag, even if it did not encounter an opening head first. The body reader searches for its opening tag; a tested document without one faults at that entry. These permissive head rules do not make a missing body safe. Use one external stylesheet: a second stylesheet link replaces the first slot, and an embedded style block does not invoke the CSS reader. [1]

<html>
<head>
<title>Collection</title>
<link rel="stylesheet" href="collection.css">
<meta name="uppertitle" content="Collection">
</head>
<body><div class="card"><a href="recent.htm">Recent Flipnotes</a></div></body>
</html>

This is an authoring example. Its class rule must use div.card, as explained in CSS and layout. [1]

Recognised tags

The general classifier has these 49 names. Tag names are case-insensitive and require a token boundary: divx is not div. The IDs identify internal node kinds, rather than values sent in an HTTP header. [1]

TagID
html0
body1
p2
div3
table4
tr5
th6
td7
dl8
ul9
ol10
form11
address12
blockquote13
h114
h215
h316
h417
h518
h619
fieldset20
hr21
pre22
button24
img25
input26
object27
a28
abbr29
acronym30
b31
bdo32
big33
cite34
code35
dfn36
em37
i38
kbd39
label40
q41
samp42
small43
span44
strong45
sub46
sup47
tt48
var49

There is no tag at ID 23. ID 50 is an internally created text node. Separate workers recognise br, and the head scanner recognises meta, link, title and closing head. Those names therefore need not appear in the general classifier. [1]

Names absent from that classifier include li, dt, dd, table section wrappers, style, script, iframe, select, option, textarea, font, center, canvas, svg, audio, video, section and nav. Unknown wrappers are not consistently discarded: a tested list retained literal li> fragments. Use paragraphs or table rows for a list. Recognising a formatting tag does not establish a different font or a working form control. [1]

Attribute rules

  • Attribute names are case-sensitive. Write lowercase names with no space before the equals sign and double-quoted values.
  • The common class= branch stores one name, using only its first eight ASCII bytes. Letters, digits, underscore, hyphen and # are accepted name characters. Names differing only after byte eight collide.
  • A space-separated class list is not supported. On a paragraph, the remaining bytes in class="one two" can stop attribute processing.
  • Anchors recognise href, rel, target, name, accesskey, mailto, tabindex and usemap. Only href and the case-sensitive rel="flat" alter the examined node. The other names are skipped.
  • Spans accept the same eight names without installing an href. Images have their own five-name parser. Divisions and table elements use the table-family parser below. Other elements have no general attribute worker after class processing.

An unsupported attribute can discard the rest of a tag, or stop the body parser. An anchor with id before href loses its destination; putting href first retains that destination before processing stops. A division with id before class loses the class. A paragraph carrying id can stop parsing before its own text. Avoid generic id, data, ARIA and inline-style attributes in client documents. A single-quoted href retains the closing apostrophe in the tested URL; double quotes avoid this problem. [1]

Recognised form, input and button tags do not have ordinary form-control handlers. Attributes such as action, method, type, name and value can stop body parsing instead of creating a working form. For text entry, use an anchor to the native .kbd route and implement its request/continuation contract. The presence of the tag in the classifier is not evidence of browser-style input controls. [1]

Attributedivtabletrth / td
alignAlignmentAlignmentAlignmentAlignment
height / widthSkipped16-bit dimensionsSkipped16-bit dimensions
borderSkippedPositive width on all sidesSkippedSkipped
bordercolorSkippedFour side coloursSkippedSkipped
cellpadding / cellspacingSkippedTable fieldsSkippedSkipped
bgcolorSkippedBackground colourBackground colourBackground colour
backgroundSkippedSkippedSkippedSkipped
valignSkippedSkippedVertical alignmentVertical alignment
colspan / rowspanSkippedSkippedSkippedSpan counts
nowrapParsing failureParsing failureParsing failureChanges a byte before parsing fails

Alignment tokens are the case-sensitive names left, center and right. Numeric fields use decimal-prefix conversion: a percentage suffix does not enable percentage sizing. The shared nowrap skip length fails to advance past its equals sign; even a cell that changes its style byte then fails the surrounding parse. CSS white-space does not provide an alternative no-wrap implementation. [1]

Text and entities

Consecutive ASCII spaces collapse. Tabs and line feeds are skipped, so they can join adjacent words. A carriage return advances by two bytes as though CRLF follows; a lone carriage return can consume the following character. Closed comments are skipped. A body-level br inserts CRLF into its text, but the inline worker handles the token differently: a span containing Before, br and After ended with literal br>After instead of retaining the full text. Prefer separate paragraphs. [1]

Only the lowercase named entities lt, gt, amp and nbsp are recognised. Nbsp becomes ordinary U+0020 space. Other names lose their ampersand: quot and apos do not insert quotation marks. Decimal character references work in the checked text paths; hexadecimal references do not. An entity immediately before the reader's terminating delimiter can be lost, including an ampersand at the end of body text. Use literal UTF-8 text where the font supports it. [1]

The UTF-16 conversion helper handles one-, two- and three-byte UTF-8 sequences. It has no four-byte branch; the tested emoji became four question marks. Body strings remain UTF-8 until layout. This distinction describes conversion, not complete font coverage. A charset meta entry does not select another decoder in the examined head reader. [1]

Head metadata

The reader clears a 4,388-byte result before parsing. Write name before content, with both attribute names and the metadata name in lowercase. Content encountered before a name has no selected destination. The 26 recognised names are below; offsets refer to this result structure, and flags accumulate in the word at +0xC04. [1]

NameStorage or flagMeaning
upperlink+0x101Upper image or animation URL
uppertitle+0xC10UTF-16 upper title
uppersubleft+0xD10UTF-16 left subtitle
uppersubright+0xE10UTF-16 right subtitle
uppersubtop+0xF10UTF-16 top subtitle; +0x1110 becomes 1
uppersubbottom+0x1010UTF-16 bottom subtitle
uppersubtitle+0xF10Same text slot as uppersubtop; +0x1110 becomes 0
starbutton+0x302Yellow-star action URL
starbutton1+0x402 / +0x1114Action URL and 32-bit count
starbutton2+0x502 / +0x1118Action URL and 32-bit count
starbutton3+0x602 / +0x111CAction URL and 32-bit count
starbutton4+0x702 / +0x1120Action URL and 32-bit count
favoritebutton+0x802 / flag 0x001Favourite action
cutoutbutton+0x802 / flag 0x200Shares the favourite URL slot
deletebutton+0xA02Delete action URL
postchannelbutton+0x902 / flag 0x002Shared action URL
playcontrolbuttonflag 0x004Flag set by the metadata name
savebutton+0x902 / flag 0x008Shared action URL
commentbutton+0x902 / flag 0x010Shared action URL
postherebutton+0x902 / flag 0x020Shared action URL
commentherebutton+0x902 / flag 0x040Shared action URL
replybutton+0x902 / flag 0x400Shared action URL
autoscrollflag 0x080Flag set by the metadata name
bgm+0xC08Decimal content plus one, stored as a signed 16-bit value
autoplayflags 0x100 / 0x8000x100 on recognition; also 0x800 when content is decimal 1
background+0xB02 / +0xC0C / +0xC0EURL followed by 16-bit width and height

The ordinary title occupies a separate UTF-16 slot at +0x202. Its conversion capacity is 127, allowing 126 contiguous code units and a terminator. The six upper text fields have capacity 128, allowing 127 code units. These are storage limits, not estimates of visible text space. Numbered star values use URL,count; backgrounds use URL,width,height. Several action names share +0x902, and some upper subtitles share a text slot: repeated declarations can overwrite a URL or text while retaining earlier flag bits. [1]

Allocation limits

The parser allocates up to 1,024 nodes of 44 bytes and 512 styles of 80 bytes. Node allocation also checks the style count. Text and URLs share storage whose copy guard is 0xFF9C, or 65,436 bytes. A new descendant is refused when the nesting counter is already greater than 19; a new table is refused when its table counter is already greater than two, before incrementing. These guards have different meanings and do not guarantee graceful handling of every exhausted pool. See loading and resource limits before sizing a page. [1]

Research scope

The parser and metadata checks execute the original instructions in all three V2 builds. They establish stored nodes, strings and metadata, including deliberately checked failure paths. They do not establish final screen pixels, physical touch behaviour or complete network operation. Japanese V1 requires its own mapping. [1]

Sources

  1. [1] Flipnote Decompilation Project — V2 HTML parser and head metadata

← All documentation