aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2025-01-18 23:14:56 +0100
committerbptato <nincsnevem662@gmail.com>2025-01-18 23:14:56 +0100
commitddd639280d93da1ae51af18fe22fdd315fc2d42d (patch)
tree2391813d5c00c0c62634fd50a31fd3bf8405cfc7 /lib
parentcb1ec272443328c80d9e4bfb17f4853ff2745b16 (diff)
parent93f31143b25349ed071c6f564ecce45a5c2b351c (diff)
downloadchawan-ddd639280d93da1ae51af18fe22fdd315fc2d42d.tar.gz
Add 'lib/chame0/' from commit '93f31143b25349ed071c6f564ecce45a5c2b351c'
git-subtree-dir: lib/chame0 git-subtree-mainline: cb1ec272443328c80d9e4bfb17f4853ff2745b16 git-subtree-split: 93f31143b25349ed071c6f564ecce45a5c2b351c
Diffstat (limited to 'lib')
-rw-r--r--lib/chame0/.gitignore3
-rw-r--r--lib/chame0/.gitmodules6
-rw-r--r--lib/chame0/Makefile17
-rw-r--r--lib/chame0/NEWS107
-rw-r--r--lib/chame0/README.md98
-rw-r--r--lib/chame0/UNLICENSE24
-rw-r--r--lib/chame0/chame.nimble13
-rw-r--r--lib/chame0/chame/dombuilder.nim15
-rw-r--r--lib/chame0/chame/entity_gen.nim767
-rw-r--r--lib/chame0/chame/htmlparser.nim2727
-rw-r--r--lib/chame0/chame/htmlparseriface.nim343
-rw-r--r--lib/chame0/chame/htmltokenizer.nim1422
-rw-r--r--lib/chame0/chame/minidom.nim497
-rw-r--r--lib/chame0/chame/minidom_cs.nim165
-rw-r--r--lib/chame0/chame/res/entity.json2233
-rw-r--r--lib/chame0/chame/res/genentity.nim49
-rw-r--r--lib/chame0/chame/tags.nim197
-rw-r--r--lib/chame0/chame/tokstate.nim32
-rw-r--r--lib/chame0/chame/version.nim3
-rw-r--r--lib/chame0/doc/.index.md18
-rw-r--r--lib/chame0/doc/manual.md273
-rwxr-xr-xlib/chame0/gendoc.sh25
m---------lib/chame0/test/chagashi6
-rw-r--r--lib/chame0/test/config.nims1
-rw-r--r--lib/chame0/test/custom.dat23
-rw-r--r--lib/chame0/test/eprint.nim22
-rw-r--r--lib/chame0/test/gtrsim.dat46
m---------lib/chame0/test/html5lib-tests0
-rw-r--r--lib/chame0/test/latin1.dat13
-rw-r--r--lib/chame0/test/shared/tree_common.nim334
-rw-r--r--lib/chame0/test/sjis.dat23
-rw-r--r--lib/chame0/test/test1.nim92
-rw-r--r--lib/chame0/test/tokenizer.nim275
-rw-r--r--lib/chame0/test/tree.nim215
-rw-r--r--lib/chame0/test/tree_charset.nim50
-rw-r--r--lib/chame0/test/tree_misc.nim39
-rw-r--r--lib/chame0/todo4
-rwxr-xr-xlib/chame0/updver59
38 files changed, 10236 insertions, 0 deletions
diff --git a/lib/chame0/.gitignore b/lib/chame0/.gitignore
new file mode 100644
index 00000000..6ae8e507
--- /dev/null
+++ b/lib/chame0/.gitignore
@@ -0,0 +1,3 @@
+/test/*
+!/test/*.*
+/.obj/
diff --git a/lib/chame0/.gitmodules b/lib/chame0/.gitmodules
new file mode 100644
index 00000000..847256c9
--- /dev/null
+++ b/lib/chame0/.gitmodules
@@ -0,0 +1,6 @@
+[submodule "tests/html5lib-tests"]
+ path = test/html5lib-tests
+ url = https://github.com/html5lib/html5lib-tests.git
+[submodule "test/chagashi"]
+ path = test/chagashi
+ url = https://git.sr.ht/~bptato/chagashi
diff --git a/lib/chame0/Makefile b/lib/chame0/Makefile
new file mode 100644
index 00000000..2b28e9ff
--- /dev/null
+++ b/lib/chame0/Makefile
@@ -0,0 +1,17 @@
+NIM ?= nim
+FLAGS += -p:. -p:test/chagashi --import:test/eprint
+
+.PHONY: all
+all: test
+
+.PHONY: test
+test:
+ $(NIM) r $(FLAGS) test/test1.nim
+ $(NIM) r $(FLAGS) test/tree.nim
+ $(NIM) r $(FLAGS) test/tokenizer.nim
+ $(NIM) r $(FLAGS) test/tree_charset.nim
+ $(NIM) r $(FLAGS) test/tree_misc.nim
+
+.PHONY: submodule
+submodule:
+ git submodule update --init
diff --git a/lib/chame0/NEWS b/lib/chame0/NEWS
new file mode 100644
index 00000000..fbee6687
--- /dev/null
+++ b/lib/chame0/NEWS
@@ -0,0 +1,107 @@
+1.0.3 (2025.01.03)
+* Conform to strict defs
+
+1.0.2 (2024.11.22)
+* Minor optimizations
+* Minor documentation updates
+
+1.0.1 (2024.07.28)
+* Minor optimization
+* Add test directory to skipDirs
+
+1.0.0 (2024.06.13)
+* Drop support for parse error handling
+* Switch from legacy character decoder library to Chagashi
+* Return PRES_SCRIPT for the SVG script element too
+First stable version.
+
+0.14.5 (2024.04.09)
+* Fix broken parsing of HTML entities starting with a lower `z'
+* Fix nimble test execution on old Nim versions
+* Various refactorings: reduce duplicated code, get rid of some dead code,
+ move some atom mappings to compile time
+
+0.14.4 (2024.03.03)
+* Clean up tokenizeEOF so that it's compiled correctly on old Nim + ARM
+
+0.14.3 (2024.02.21)
+* Fix another instance of the same bug
+
+0.14.2 (2024.02.21)
+* Fix a character reference parsing bug: e.g. in `&g<a>', the <
+ character was being flushed as text instead of being interpreted as
+ markup.
+
+0.14.1 (2024.02.08)
+* Fix associateWithFormImpl callback regression (it was not being called for
+ input elements)
+* Misc refactorings
+
+0.14.0 (2024.02.07)
+
+* The "bag of pointers" interface design has been dropped
+* Tag and attribute names are now treated as interned strings (a user-defined
+ "Atom" type)
+* Support processing of embedded SVG/MathML elements
+* Chakasu has been made an optional dependency
+* std/streams no longer used by htmlparser; now it supports chunked parsing
+ instead
+* All tokenizer + tree builder tests passed in html5lib-tests
+
+Rough migration guide from the previous API:
+
+Users of minidom
+
+* nodeType is no longer supported, use the of operator to distinguish
+ between node types.
+* minidom now only supports UTF-8; if you need support for other
+ charsets, use minidom_cs.
+* localName is now an MAtom; to get the stringified local name, use
+ localNameStr.
+* attrs is now a seq of Attribute tuples. Linear search this seq to find
+ specific attributes.
+* minidom now contains several MAtom fields; to convert these to
+ strings, call document.atomToStr(atom).
+
+Users of htmlparser
+
+* The NodeType enum has been removed. Either copy-paste the enum
+ definition from a previous version, or (more efficient) use the `of`
+ operator to distinguish between types.
+* Use of an AtomFactory is now required for consumers of htmlparser. The
+ easiest fix is to copy-paste the implementation found in minidom.
+* Your DOM builder should be generic over a Handle and an Atom. Example:
+ `DOMBuilder[Node, MAtom]`
+* You no longer have to copy function pointers into your DOM builder.
+* It is recommended to add `include chame/htmlparseriface` to your DOM
+ builder module. See the htmlparseriface documentation for details.
+
+Switching to the new interface:
+
+* Add `Impl` to the name of all your procedure implementations.
+* If you included chame/htmlparseriface, replace all parameters of your
+ procedures containing `DOMBuilder[MyHandle]` with `MyDOMBuilder`.
+* setCharacterSet -> setEncodingImpl that takes a string label.
+* getLocalNameImpl now must return an Atom. getTagType is no longer used.
+* insertBeforeImpl must take an `Option[Handle]`
+* addAttrsIfMissingImpl is now mandatory, and must take a `Table[Atom, string]`
+* getNamespaceImpl is now mandatory.
+* getDocumentImpl must be implemented, and must return the Handle of the
+ document.
+* tagTypeToAtomImpl, atomToTagTypeImpl, strToAtomImpl must all be implemented.
+* createHTMLElementImpl must be implemented, and must return the handle of a new
+ `<html>` element.
+* createElement -> createElementForTokenImpl, the signature has changed
+ significantly. localName is the 2-in-1 replacement for both tagType and
+ localName. Also, you probably have to convert attributes from htmlAttrs &
+ xmlAttrs to your own internal representation.
+* finish is no longer called at the end of parsing. Call it yourself.
+
+Event loop changes:
+
+* parseHTML is now split into three parts: initHTML5Parser, parseChunk, finish.
+* If you implement scripting and/or character sets other than UTF-8, see
+ doc/manual.md for handling parseChunk's result. Otherwise, it is safe to
+ discard it.
+* Do not forget to call finish after having parsed the entire document (first
+ for the parser, then for your own DOM builder).
diff --git a/lib/chame0/README.md b/lib/chame0/README.md
new file mode 100644
index 00000000..32904cf7
--- /dev/null
+++ b/lib/chame0/README.md
@@ -0,0 +1,98 @@
+# Chame: an HTML5 parser library in Nim
+
+## Usage
+
+Include Chame in your project using either Nimble or as a git submodule.
+
+```
+requires "chame"
+# optional, if you want support for charsets other than UTF-8
+requires "chagashi"
+```
+
+Then, check the [documentation](https://chawan.net/doc/chame/) for a
+description of the API.
+
+Note: only Nim 1.6.10+ is supported.
+
+## Features
+
+* Full compliance with the WHATWG HTML parsing standard
+* Passes all tokenizer and tree builder tests in html5lib-tests (except for ones
+ requiring JS)
+* Includes a minimal DOM implementation
+* No mandatory dependencies other than the Nim standard library
+* Optional character encoding support (see [minidom_cs](chame/minidom_cs.nim))
+* String interning support for tag and attribute names
+* Support for chunked parsing
+* document.write (no actual implementation here, but it's possible to implement
+ it on top of Chame)
+
+## Manual
+
+There is a manual available at [doc/manual.md](doc/manual.md).
+
+## To-do
+
+At this point the library is complete. The only remaining tasks are
+optimization-related.
+
+Also, a small module for basic minidom utilities is planned.
+
+## Bugs, feedback, etc.
+
+Feedback, complaints, etc. are accepted at
+[SourceHut](https://todo.sr.ht/~bptato/chawan) or the Nim forum
+[thread](https://forum.nim-lang.org/t/10963).
+
+## FAQ
+
+### Does Chame include a DOM, JavaScript, CSS, ...?
+
+Chame just parses HTML and calls the callbacks supplied to it. JavaScript,
+DOM manipulation, etc. are technically outside the scope of this project.
+
+However, Chame includes a minimal DOM interface (intuitively named minidom)
+for demonstration and testing purposes. This only implements the very basics
+needed for the parser to function (and for the tests to pass), and does not
+have any convenience functions (like querySelector, getElementById, etc.)
+
+Please refer to the [Chawan](https://sr.ht/~bptato/chawan/) web browser for
+an example of a complete DOM implementation that depends on Chame.
+
+Also see [CSS3Selectors](https://github.com/Niminem/CSS3Selectors/), a CSS
+selector library for Chame's minidom which allows you to run querySelector
+like you can in JS.
+
+If you implement a DOM library based on Chame, please notify me, so that I
+can redirect users to it in this section.
+
+### I read the manual, but it's too complex, I don't understand anything, help
+
+Just call minidom.parseHTML on an std/stream.Stream object and forget about
+everything else. Chances are this is enough for whatever you want to do.
+
+### How do I implement speculative parsing?
+
+No idea. Let me know if you figure something out.
+
+### How do you pronounce Chame?
+
+It is an acronym of "**Cha**wan HT**M**L (aitch-tee-e**m-e**l)." Accordingly, it is
+pronounced as "cha-meh."
+
+## Thanks
+
+[SerenityOS](https://serenityos.org/)'s HTML parser has been used as a
+reference when I found some parts of the specification unclear.
+
+Servo's HTML parser [html5ever](https://github.com/servo/html5ever) has been
+the main inspiration for Chame's API.
+
+Finally, thanks to the standard writers for writing a very detailed
+specification of the HTML5 parsing algorithm. The bulk of Chame is a direct
+translation of this algorithm into Nim.
+
+## License
+
+Chame is dedicated to the public domain. See the UNLICENSE file for details.
diff --git a/lib/chame0/UNLICENSE b/lib/chame0/UNLICENSE
new file mode 100644
index 00000000..68a49daa
--- /dev/null
+++ b/lib/chame0/UNLICENSE
@@ -0,0 +1,24 @@
+This is free and unencumbered software released into the public domain.
+
+Anyone is free to copy, modify, publish, use, compile, sell, or
+distribute this software, either in source code form or as a compiled
+binary, for any purpose, commercial or non-commercial, and by any
+means.
+
+In jurisdictions that recognize copyright laws, the author or authors
+of this software dedicate any and all copyright interest in the
+software to the public domain. We make this dedication for the benefit
+of the public at large and to the detriment of our heirs and
+successors. We intend this dedication to be an overt act of
+relinquishment in perpetuity of all present and future rights to this
+software under copyright law.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+For more information, please refer to <http://unlicense.org/>
diff --git a/lib/chame0/chame.nimble b/lib/chame0/chame.nimble
new file mode 100644
index 00000000..190507ea
--- /dev/null
+++ b/lib/chame0/chame.nimble
@@ -0,0 +1,13 @@
+# Package
+
+version = "1.0.3"
+author = "bptato"
+description = "HTML5 parser for Chawan"
+license = "Unlicense"
+skipDirs = @["test"]
+
+# Dependencies
+
+requires "nim >= 1.6.10"
+when declared(taskRequires):
+ taskRequires "test", "chagashi >= 0.5.0"
diff --git a/lib/chame0/chame/dombuilder.nim b/lib/chame0/chame/dombuilder.nim
new file mode 100644
index 00000000..5497b2d0
--- /dev/null
+++ b/lib/chame0/chame/dombuilder.nim
@@ -0,0 +1,15 @@
+import tags
+
+type
+ SetEncodingResult* = enum
+ SET_ENCODING_CONTINUE, SET_ENCODING_STOP
+
+ ParsedAttr*[Atom] = tuple
+ prefix: NamespacePrefix
+ namespace: Namespace
+ name: Atom
+ value: string
+
+ DOMBuilderBase* = ref object of RootObj
+
+ DOMBuilder*[Handle, Atom] = ref object of DOMBuilderBase
diff --git a/lib/chame0/chame/entity_gen.nim b/lib/chame0/chame/entity_gen.nim
new file mode 100644
index 00000000..2e3f6e58
--- /dev/null
+++ b/lib/chame0/chame/entity_gen.nim
@@ -0,0 +1,767 @@
+type Z = cstring
+const entityMap*: array[2231, Z] = [
+"AElig:\xC3\x86","AElig;:\xC3\x86","AMP:&","AMP;:&","Aacute:\xC3\x81",
+"Aacute;:\xC3\x81","Abreve;:\xC4\x82","Acirc:\xC3\x82","Acirc;:\xC3\x82",
+"Acy;:\xD0\x90","Afr;:\xF0\x9D\x94\x84","Agrave:\xC3\x80","Agrave;:\xC3\x80",
+"Alpha;:\xCE\x91","Amacr;:\xC4\x80","And;:\xE2\xA9\x93","Aogon;:\xC4\x84",
+"Aopf;:\xF0\x9D\x94\xB8","ApplyFunction;:\xE2\x81\xA1","Aring:\xC3\x85",
+"Aring;:\xC3\x85","Ascr;:\xF0\x9D\x92\x9C","Assign;:\xE2\x89\x94",
+"Atilde:\xC3\x83","Atilde;:\xC3\x83","Auml:\xC3\x84","Auml;:\xC3\x84",
+"Backslash;:\xE2\x88\x96","Barv;:\xE2\xAB\xA7","Barwed;:\xE2\x8C\x86",
+"Bcy;:\xD0\x91","Because;:\xE2\x88\xB5","Bernoullis;:\xE2\x84\xAC",
+"Beta;:\xCE\x92","Bfr;:\xF0\x9D\x94\x85","Bopf;:\xF0\x9D\x94\xB9",
+"Breve;:\xCB\x98","Bscr;:\xE2\x84\xAC","Bumpeq;:\xE2\x89\x8E","CHcy;:\xD0\xA7",
+"COPY:\xC2\xA9","COPY;:\xC2\xA9","Cacute;:\xC4\x86","Cap;:\xE2\x8B\x92",
+"CapitalDifferentialD;:\xE2\x85\x85","Cayleys;:\xE2\x84\xAD","Ccaron;:\xC4\x8C",
+"Ccedil:\xC3\x87","Ccedil;:\xC3\x87","Ccirc;:\xC4\x88","Cconint;:\xE2\x88\xB0",
+"Cdot;:\xC4\x8A","Cedilla;:\xC2\xB8","CenterDot;:\xC2\xB7","Cfr;:\xE2\x84\xAD",
+"Chi;:\xCE\xA7","CircleDot;:\xE2\x8A\x99","CircleMinus;:\xE2\x8A\x96",
+"CirclePlus;:\xE2\x8A\x95","CircleTimes;:\xE2\x8A\x97",
+"ClockwiseContourIntegral;:\xE2\x88\xB2","CloseCurlyDoubleQuote;:\xE2\x80\x9D",
+"CloseCurlyQuote;:\xE2\x80\x99","Colon;:\xE2\x88\xB7","Colone;:\xE2\xA9\xB4",
+"Congruent;:\xE2\x89\xA1","Conint;:\xE2\x88\xAF",
+"ContourIntegral;:\xE2\x88\xAE","Copf;:\xE2\x84\x82","Coproduct;:\xE2\x88\x90",
+"CounterClockwiseContourIntegral;:\xE2\x88\xB3","Cross;:\xE2\xA8\xAF",
+"Cscr;:\xF0\x9D\x92\x9E","Cup;:\xE2\x8B\x93","CupCap;:\xE2\x89\x8D",
+"DD;:\xE2\x85\x85","DDotrahd;:\xE2\xA4\x91","DJcy;:\xD0\x82","DScy;:\xD0\x85",
+"DZcy;:\xD0\x8F","Dagger;:\xE2\x80\xA1","Darr;:\xE2\x86\xA1",
+"Dashv;:\xE2\xAB\xA4","Dcaron;:\xC4\x8E","Dcy;:\xD0\x94","Del;:\xE2\x88\x87",
+"Delta;:\xCE\x94","Dfr;:\xF0\x9D\x94\x87","DiacriticalAcute;:\xC2\xB4",
+"DiacriticalDot;:\xCB\x99","DiacriticalDoubleAcute;:\xCB\x9D",
+"DiacriticalGrave;:`","DiacriticalTilde;:\xCB\x9C","Diamond;:\xE2\x8B\x84",
+"DifferentialD;:\xE2\x85\x86","Dopf;:\xF0\x9D\x94\xBB","Dot;:\xC2\xA8",
+"DotDot;:\xE2\x83\x9C","DotEqual;:\xE2\x89\x90",
+"DoubleContourIntegral;:\xE2\x88\xAF","DoubleDot;:\xC2\xA8",
+"DoubleDownArrow;:\xE2\x87\x93","DoubleLeftArrow;:\xE2\x87\x90",
+"DoubleLeftRightArrow;:\xE2\x87\x94","DoubleLeftTee;:\xE2\xAB\xA4",
+"DoubleLongLeftArrow;:\xE2\x9F\xB8","DoubleLongLeftRightArrow;:\xE2\x9F\xBA",
+"DoubleLongRightArrow;:\xE2\x9F\xB9","DoubleRightArrow;:\xE2\x87\x92",
+"DoubleRightTee;:\xE2\x8A\xA8","DoubleUpArrow;:\xE2\x87\x91",
+"DoubleUpDownArrow;:\xE2\x87\x95","DoubleVerticalBar;:\xE2\x88\xA5",
+"DownArrow;:\xE2\x86\x93","DownArrowBar;:\xE2\xA4\x93",
+"DownArrowUpArrow;:\xE2\x87\xB5","DownBreve;:\xCC\x91",
+"DownLeftRightVector;:\xE2\xA5\x90","DownLeftTeeVector;:\xE2\xA5\x9E",
+"DownLeftVector;:\xE2\x86\xBD","DownLeftVectorBar;:\xE2\xA5\x96",
+"DownRightTeeVector;:\xE2\xA5\x9F","DownRightVector;:\xE2\x87\x81",
+"DownRightVectorBar;:\xE2\xA5\x97","DownTee;:\xE2\x8A\xA4",
+"DownTeeArrow;:\xE2\x86\xA7","Downarrow;:\xE2\x87\x93","Dscr;:\xF0\x9D\x92\x9F",
+"Dstrok;:\xC4\x90","ENG;:\xC5\x8A","ETH:\xC3\x90","ETH;:\xC3\x90",
+"Eacute:\xC3\x89","Eacute;:\xC3\x89","Ecaron;:\xC4\x9A","Ecirc:\xC3\x8A",
+"Ecirc;:\xC3\x8A","Ecy;:\xD0\xAD","Edot;:\xC4\x96","Efr;:\xF0\x9D\x94\x88",
+"Egrave:\xC3\x88","Egrave;:\xC3\x88","Element;:\xE2\x88\x88","Emacr;:\xC4\x92",
+"EmptySmallSquare;:\xE2\x97\xBB","EmptyVerySmallSquare;:\xE2\x96\xAB",
+"Eogon;:\xC4\x98","Eopf;:\xF0\x9D\x94\xBC","Epsilon;:\xCE\x95",
+"Equal;:\xE2\xA9\xB5","EqualTilde;:\xE2\x89\x82","Equilibrium;:\xE2\x87\x8C",
+"Escr;:\xE2\x84\xB0","Esim;:\xE2\xA9\xB3","Eta;:\xCE\x97","Euml:\xC3\x8B",
+"Euml;:\xC3\x8B","Exists;:\xE2\x88\x83","ExponentialE;:\xE2\x85\x87",
+"Fcy;:\xD0\xA4","Ffr;:\xF0\x9D\x94\x89","FilledSmallSquare;:\xE2\x97\xBC",
+"FilledVerySmallSquare;:\xE2\x96\xAA","Fopf;:\xF0\x9D\x94\xBD",
+"ForAll;:\xE2\x88\x80","Fouriertrf;:\xE2\x84\xB1","Fscr;:\xE2\x84\xB1",
+"GJcy;:\xD0\x83","GT:>","GT;:>","Gamma;:\xCE\x93","Gammad;:\xCF\x9C",
+"Gbreve;:\xC4\x9E","Gcedil;:\xC4\xA2","Gcirc;:\xC4\x9C","Gcy;:\xD0\x93",
+"Gdot;:\xC4\xA0","Gfr;:\xF0\x9D\x94\x8A","Gg;:\xE2\x8B\x99",
+"Gopf;:\xF0\x9D\x94\xBE","GreaterEqual;:\xE2\x89\xA5",
+"GreaterEqualLess;:\xE2\x8B\x9B","GreaterFullEqual;:\xE2\x89\xA7",
+"GreaterGreater;:\xE2\xAA\xA2","GreaterLess;:\xE2\x89\xB7",
+"GreaterSlantEqual;:\xE2\xA9\xBE","GreaterTilde;:\xE2\x89\xB3",
+"Gscr;:\xF0\x9D\x92\xA2","Gt;:\xE2\x89\xAB","HARDcy;:\xD0\xAA",
+"Hacek;:\xCB\x87","Hat;:^","Hcirc;:\xC4\xA4","Hfr;:\xE2\x84\x8C",
+"HilbertSpace;:\xE2\x84\x8B","Hopf;:\xE2\x84\x8D",
+"HorizontalLine;:\xE2\x94\x80","Hscr;:\xE2\x84\x8B","Hstrok;:\xC4\xA6",
+"HumpDownHump;:\xE2\x89\x8E","HumpEqual;:\xE2\x89\x8F","IEcy;:\xD0\x95",
+"IJlig;:\xC4\xB2","IOcy;:\xD0\x81","Iacute:\xC3\x8D","Iacute;:\xC3\x8D",
+"Icirc:\xC3\x8E","Icirc;:\xC3\x8E","Icy;:\xD0\x98","Idot;:\xC4\xB0",
+"Ifr;:\xE2\x84\x91","Igrave:\xC3\x8C","Igrave;:\xC3\x8C","Im;:\xE2\x84\x91",
+"Imacr;:\xC4\xAA","ImaginaryI;:\xE2\x85\x88","Implies;:\xE2\x87\x92",
+"Int;:\xE2\x88\xAC","Integral;:\xE2\x88\xAB","Intersection;:\xE2\x8B\x82",
+"InvisibleComma;:\xE2\x81\xA3","InvisibleTimes;:\xE2\x81\xA2","Iogon;:\xC4\xAE",
+"Iopf;:\xF0\x9D\x95\x80","Iota;:\xCE\x99","Iscr;:\xE2\x84\x90",
+"Itilde;:\xC4\xA8","Iukcy;:\xD0\x86","Iuml:\xC3\x8F","Iuml;:\xC3\x8F",
+"Jcirc;:\xC4\xB4","Jcy;:\xD0\x99","Jfr;:\xF0\x9D\x94\x8D",
+"Jopf;:\xF0\x9D\x95\x81","Jscr;:\xF0\x9D\x92\xA5","Jsercy;:\xD0\x88",
+"Jukcy;:\xD0\x84","KHcy;:\xD0\xA5","KJcy;:\xD0\x8C","Kappa;:\xCE\x9A",
+"Kcedil;:\xC4\xB6","Kcy;:\xD0\x9A","Kfr;:\xF0\x9D\x94\x8E",
+"Kopf;:\xF0\x9D\x95\x82","Kscr;:\xF0\x9D\x92\xA6","LJcy;:\xD0\x89","LT:<",
+"LT;:<","Lacute;:\xC4\xB9","Lambda;:\xCE\x9B","Lang;:\xE2\x9F\xAA",
+"Laplacetrf;:\xE2\x84\x92","Larr;:\xE2\x86\x9E","Lcaron;:\xC4\xBD",
+"Lcedil;:\xC4\xBB","Lcy;:\xD0\x9B","LeftAngleBracket;:\xE2\x9F\xA8",
+"LeftArrow;:\xE2\x86\x90","LeftArrowBar;:\xE2\x87\xA4",
+"LeftArrowRightArrow;:\xE2\x87\x86","LeftCeiling;:\xE2\x8C\x88",
+"LeftDoubleBracket;:\xE2\x9F\xA6","LeftDownTeeVector;:\xE2\xA5\xA1",
+"LeftDownVector;:\xE2\x87\x83","LeftDownVectorBar;:\xE2\xA5\x99",
+"LeftFloor;:\xE2\x8C\x8A","LeftRightArrow;:\xE2\x86\x94",
+"LeftRightVector;:\xE2\xA5\x8E","LeftTee;:\xE2\x8A\xA3",
+"LeftTeeArrow;:\xE2\x86\xA4","LeftTeeVector;:\xE2\xA5\x9A",
+"LeftTriangle;:\xE2\x8A\xB2","LeftTriangleBar;:\xE2\xA7\x8F",
+"LeftTriangleEqual;:\xE2\x8A\xB4","LeftUpDownVector;:\xE2\xA5\x91",
+"LeftUpTeeVector;:\xE2\xA5\xA0","LeftUpVector;:\xE2\x86\xBF",
+"LeftUpVectorBar;:\xE2\xA5\x98","LeftVector;:\xE2\x86\xBC",
+"LeftVectorBar;:\xE2\xA5\x92","Leftarrow;:\xE2\x87\x90",
+"Leftrightarrow;:\xE2\x87\x94","LessEqualGreater;:\xE2\x8B\x9A",
+"LessFullEqual;:\xE2\x89\xA6","LessGreater;:\xE2\x89\xB6",
+"LessLess;:\xE2\xAA\xA1","LessSlantEqual;:\xE2\xA9\xBD",
+"LessTilde;:\xE2\x89\xB2","Lfr;:\xF0\x9D\x94\x8F","Ll;:\xE2\x8B\x98",
+"Lleftarrow;:\xE2\x87\x9A","Lmidot;:\xC4\xBF","LongLeftArrow;:\xE2\x9F\xB5",
+"LongLeftRightArrow;:\xE2\x9F\xB7","LongRightArrow;:\xE2\x9F\xB6",
+"Longleftarrow;:\xE2\x9F\xB8","Longleftrightarrow;:\xE2\x9F\xBA",
+"Longrightarrow;:\xE2\x9F\xB9","Lopf;:\xF0\x9D\x95\x83",
+"LowerLeftArrow;:\xE2\x86\x99","LowerRightArrow;:\xE2\x86\x98",
+"Lscr;:\xE2\x84\x92","Lsh;:\xE2\x86\xB0","Lstrok;:\xC5\x81","Lt;:\xE2\x89\xAA",
+"Map;:\xE2\xA4\x85","Mcy;:\xD0\x9C","MediumSpace;:\xE2\x81\x9F",
+"Mellintrf;:\xE2\x84\xB3","Mfr;:\xF0\x9D\x94\x90","MinusPlus;:\xE2\x88\x93",
+"Mopf;:\xF0\x9D\x95\x84","Mscr;:\xE2\x84\xB3","Mu;:\xCE\x9C","NJcy;:\xD0\x8A",
+"Nacute;:\xC5\x83","Ncaron;:\xC5\x87","Ncedil;:\xC5\x85","Ncy;:\xD0\x9D",
+"NegativeMediumSpace;:\xE2\x80\x8B","NegativeThickSpace;:\xE2\x80\x8B",
+"NegativeThinSpace;:\xE2\x80\x8B","NegativeVeryThinSpace;:\xE2\x80\x8B",
+"NestedGreaterGreater;:\xE2\x89\xAB","NestedLessLess;:\xE2\x89\xAA",
+"NewLine;:\x0A","Nfr;:\xF0\x9D\x94\x91","NoBreak;:\xE2\x81\xA0",
+"NonBreakingSpace;:\xC2\xA0","Nopf;:\xE2\x84\x95","Not;:\xE2\xAB\xAC",
+"NotCongruent;:\xE2\x89\xA2","NotCupCap;:\xE2\x89\xAD",
+"NotDoubleVerticalBar;:\xE2\x88\xA6","NotElement;:\xE2\x88\x89",
+"NotEqual;:\xE2\x89\xA0","NotEqualTilde;:\xE2\x89\x82\xCC\xB8",
+"NotExists;:\xE2\x88\x84","NotGreater;:\xE2\x89\xAF",
+"NotGreaterEqual;:\xE2\x89\xB1","NotGreaterFullEqual;:\xE2\x89\xA7\xCC\xB8",
+"NotGreaterGreater;:\xE2\x89\xAB\xCC\xB8","NotGreaterLess;:\xE2\x89\xB9",
+"NotGreaterSlantEqual;:\xE2\xA9\xBE\xCC\xB8","NotGreaterTilde;:\xE2\x89\xB5",
+"NotHumpDownHump;:\xE2\x89\x8E\xCC\xB8","NotHumpEqual;:\xE2\x89\x8F\xCC\xB8",
+"NotLeftTriangle;:\xE2\x8B\xAA","NotLeftTriangleBar;:\xE2\xA7\x8F\xCC\xB8",
+"NotLeftTriangleEqual;:\xE2\x8B\xAC","NotLess;:\xE2\x89\xAE",
+"NotLessEqual;:\xE2\x89\xB0","NotLessGreater;:\xE2\x89\xB8",
+"NotLessLess;:\xE2\x89\xAA\xCC\xB8","NotLessSlantEqual;:\xE2\xA9\xBD\xCC\xB8",
+"NotLessTilde;:\xE2\x89\xB4","NotNestedGreaterGreater;:\xE2\xAA\xA2\xCC\xB8",
+"NotNestedLessLess;:\xE2\xAA\xA1\xCC\xB8","NotPrecedes;:\xE2\x8A\x80",
+"NotPrecedesEqual;:\xE2\xAA\xAF\xCC\xB8","NotPrecedesSlantEqual;:\xE2\x8B\xA0",
+"NotReverseElement;:\xE2\x88\x8C","NotRightTriangle;:\xE2\x8B\xAB",
+"NotRightTriangleBar;:\xE2\xA7\x90\xCC\xB8",
+"NotRightTriangleEqual;:\xE2\x8B\xAD","NotSquareSubset;:\xE2\x8A\x8F\xCC\xB8",
+"NotSquareSubsetEqual;:\xE2\x8B\xA2","NotSquareSuperset;:\xE2\x8A\x90\xCC\xB8",
+"NotSquareSupersetEqual;:\xE2\x8B\xA3","NotSubset;:\xE2\x8A\x82\xE2\x83\x92",
+"NotSubsetEqual;:\xE2\x8A\x88","NotSucceeds;:\xE2\x8A\x81",
+"NotSucceedsEqual;:\xE2\xAA\xB0\xCC\xB8","NotSucceedsSlantEqual;:\xE2\x8B\xA1",
+"NotSucceedsTilde;:\xE2\x89\xBF\xCC\xB8",
+"NotSuperset;:\xE2\x8A\x83\xE2\x83\x92","NotSupersetEqual;:\xE2\x8A\x89",
+"NotTilde;:\xE2\x89\x81","NotTildeEqual;:\xE2\x89\x84",
+"NotTildeFullEqual;:\xE2\x89\x87","NotTildeTilde;:\xE2\x89\x89",
+"NotVerticalBar;:\xE2\x88\xA4","Nscr;:\xF0\x9D\x92\xA9","Ntilde:\xC3\x91",
+"Ntilde;:\xC3\x91","Nu;:\xCE\x9D","OElig;:\xC5\x92","Oacute:\xC3\x93",
+"Oacute;:\xC3\x93","Ocirc:\xC3\x94","Ocirc;:\xC3\x94","Ocy;:\xD0\x9E",
+"Odblac;:\xC5\x90","Ofr;:\xF0\x9D\x94\x92","Ograve:\xC3\x92","Ograve;:\xC3\x92",
+"Omacr;:\xC5\x8C","Omega;:\xCE\xA9","Omicron;:\xCE\x9F",
+"Oopf;:\xF0\x9D\x95\x86","OpenCurlyDoubleQuote;:\xE2\x80\x9C",
+"OpenCurlyQuote;:\xE2\x80\x98","Or;:\xE2\xA9\x94","Oscr;:\xF0\x9D\x92\xAA",
+"Oslash:\xC3\x98","Oslash;:\xC3\x98","Otilde:\xC3\x95","Otilde;:\xC3\x95",
+"Otimes;:\xE2\xA8\xB7","Ouml:\xC3\x96","Ouml;:\xC3\x96","OverBar;:\xE2\x80\xBE",
+"OverBrace;:\xE2\x8F\x9E","OverBracket;:\xE2\x8E\xB4",
+"OverParenthesis;:\xE2\x8F\x9C","PartialD;:\xE2\x88\x82","Pcy;:\xD0\x9F",
+"Pfr;:\xF0\x9D\x94\x93","Phi;:\xCE\xA6","Pi;:\xCE\xA0","PlusMinus;:\xC2\xB1",
+"Poincareplane;:\xE2\x84\x8C","Popf;:\xE2\x84\x99","Pr;:\xE2\xAA\xBB",
+"Precedes;:\xE2\x89\xBA","PrecedesEqual;:\xE2\xAA\xAF",
+"PrecedesSlantEqual;:\xE2\x89\xBC","PrecedesTilde;:\xE2\x89\xBE",
+"Prime;:\xE2\x80\xB3","Product;:\xE2\x88\x8F","Proportion;:\xE2\x88\xB7",
+"Proportional;:\xE2\x88\x9D","Pscr;:\xF0\x9D\x92\xAB","Psi;:\xCE\xA8","QUOT:\"",
+"QUOT;:\"","Qfr;:\xF0\x9D\x94\x94","Qopf;:\xE2\x84\x9A",
+"Qscr;:\xF0\x9D\x92\xAC","RBarr;:\xE2\xA4\x90","REG:\xC2\xAE","REG;:\xC2\xAE",
+"Racute;:\xC5\x94","Rang;:\xE2\x9F\xAB","Rarr;:\xE2\x86\xA0",
+"Rarrtl;:\xE2\xA4\x96","Rcaron;:\xC5\x98","Rcedil;:\xC5\x96","Rcy;:\xD0\xA0",
+"Re;:\xE2\x84\x9C","ReverseElement;:\xE2\x88\x8B",
+"ReverseEquilibrium;:\xE2\x87\x8B","ReverseUpEquilibrium;:\xE2\xA5\xAF",
+"Rfr;:\xE2\x84\x9C","Rho;:\xCE\xA1","RightAngleBracket;:\xE2\x9F\xA9",
+"RightArrow;:\xE2\x86\x92","RightArrowBar;:\xE2\x87\xA5",
+"RightArrowLeftArrow;:\xE2\x87\x84","RightCeiling;:\xE2\x8C\x89",
+"RightDoubleBracket;:\xE2\x9F\xA7","RightDownTeeVector;:\xE2\xA5\x9D",
+"RightDownVector;:\xE2\x87\x82","RightDownVectorBar;:\xE2\xA5\x95",
+"RightFloor;:\xE2\x8C\x8B","RightTee;:\xE2\x8A\xA2",
+"RightTeeArrow;:\xE2\x86\xA6","RightTeeVector;:\xE2\xA5\x9B",
+"RightTriangle;:\xE2\x8A\xB3","RightTriangleBar;:\xE2\xA7\x90",
+"RightTriangleEqual;:\xE2\x8A\xB5","RightUpDownVector;:\xE2\xA5\x8F",
+"RightUpTeeVector;:\xE2\xA5\x9C","RightUpVector;:\xE2\x86\xBE",
+"RightUpVectorBar;:\xE2\xA5\x94","RightVector;:\xE2\x87\x80",
+"RightVectorBar;:\xE2\xA5\x93","Rightarrow;:\xE2\x87\x92","Ropf;:\xE2\x84\x9D",
+"RoundImplies;:\xE2\xA5\xB0","Rrightarrow;:\xE2\x87\x9B","Rscr;:\xE2\x84\x9B",
+"Rsh;:\xE2\x86\xB1","RuleDelayed;:\xE2\xA7\xB4","SHCHcy;:\xD0\xA9",
+"SHcy;:\xD0\xA8","SOFTcy;:\xD0\xAC","Sacute;:\xC5\x9A","Sc;:\xE2\xAA\xBC",
+"Scaron;:\xC5\xA0","Scedil;:\xC5\x9E","Scirc;:\xC5\x9C","Scy;:\xD0\xA1",
+"Sfr;:\xF0\x9D\x94\x96","ShortDownArrow;:\xE2\x86\x93",
+"ShortLeftArrow;:\xE2\x86\x90","ShortRightArrow;:\xE2\x86\x92",
+"ShortUpArrow;:\xE2\x86\x91","Sigma;:\xCE\xA3","SmallCircle;:\xE2\x88\x98",
+"Sopf;:\xF0\x9D\x95\x8A","Sqrt;:\xE2\x88\x9A","Square;:\xE2\x96\xA1",
+"SquareIntersection;:\xE2\x8A\x93","SquareSubset;:\xE2\x8A\x8F",
+"SquareSubsetEqual;:\xE2\x8A\x91","SquareSuperset;:\xE2\x8A\x90",
+"SquareSupersetEqual;:\xE2\x8A\x92","SquareUnion;:\xE2\x8A\x94",
+"Sscr;:\xF0\x9D\x92\xAE","Star;:\xE2\x8B\x86","Sub;:\xE2\x8B\x90",
+"Subset;:\xE2\x8B\x90","SubsetEqual;:\xE2\x8A\x86","Succeeds;:\xE2\x89\xBB",
+"SucceedsEqual;:\xE2\xAA\xB0","SucceedsSlantEqual;:\xE2\x89\xBD",
+"SucceedsTilde;:\xE2\x89\xBF","SuchThat;:\xE2\x88\x8B","Sum;:\xE2\x88\x91",
+"Sup;:\xE2\x8B\x91","Superset;:\xE2\x8A\x83","SupersetEqual;:\xE2\x8A\x87",
+"Supset;:\xE2\x8B\x91","THORN:\xC3\x9E","THORN;:\xC3\x9E","TRADE;:\xE2\x84\xA2",
+"TSHcy;:\xD0\x8B","TScy;:\xD0\xA6","Tab;:\x09","Tau;:\xCE\xA4",
+"Tcaron;:\xC5\xA4","Tcedil;:\xC5\xA2","Tcy;:\xD0\xA2","Tfr;:\xF0\x9D\x94\x97",
+"Therefore;:\xE2\x88\xB4","Theta;:\xCE\x98",
+"ThickSpace;:\xE2\x81\x9F\xE2\x80\x8A","ThinSpace;:\xE2\x80\x89",
+"Tilde;:\xE2\x88\xBC","TildeEqual;:\xE2\x89\x83","TildeFullEqual;:\xE2\x89\x85",
+"TildeTilde;:\xE2\x89\x88","Topf;:\xF0\x9D\x95\x8B","TripleDot;:\xE2\x83\x9B",
+"Tscr;:\xF0\x9D\x92\xAF","Tstrok;:\xC5\xA6","Uacute:\xC3\x9A",
+"Uacute;:\xC3\x9A","Uarr;:\xE2\x86\x9F","Uarrocir;:\xE2\xA5\x89",
+"Ubrcy;:\xD0\x8E","Ubreve;:\xC5\xAC","Ucirc:\xC3\x9B","Ucirc;:\xC3\x9B",
+"Ucy;:\xD0\xA3","Udblac;:\xC5\xB0","Ufr;:\xF0\x9D\x94\x98","Ugrave:\xC3\x99",
+"Ugrave;:\xC3\x99","Umacr;:\xC5\xAA","UnderBar;:_","UnderBrace;:\xE2\x8F\x9F",
+"UnderBracket;:\xE2\x8E\xB5","UnderParenthesis;:\xE2\x8F\x9D",
+"Union;:\xE2\x8B\x83","UnionPlus;:\xE2\x8A\x8E","Uogon;:\xC5\xB2",
+"Uopf;:\xF0\x9D\x95\x8C","UpArrow;:\xE2\x86\x91","UpArrowBar;:\xE2\xA4\x92",
+"UpArrowDownArrow;:\xE2\x87\x85","UpDownArrow;:\xE2\x86\x95",
+"UpEquilibrium;:\xE2\xA5\xAE","UpTee;:\xE2\x8A\xA5","UpTeeArrow;:\xE2\x86\xA5",
+"Uparrow;:\xE2\x87\x91","Updownarrow;:\xE2\x87\x95",
+"UpperLeftArrow;:\xE2\x86\x96","UpperRightArrow;:\xE2\x86\x97","Upsi;:\xCF\x92",
+"Upsilon;:\xCE\xA5","Uring;:\xC5\xAE","Uscr;:\xF0\x9D\x92\xB0",
+"Utilde;:\xC5\xA8","Uuml:\xC3\x9C","Uuml;:\xC3\x9C","VDash;:\xE2\x8A\xAB",
+"Vbar;:\xE2\xAB\xAB","Vcy;:\xD0\x92","Vdash;:\xE2\x8A\xA9",
+"Vdashl;:\xE2\xAB\xA6","Vee;:\xE2\x8B\x81","Verbar;:\xE2\x80\x96",
+"Vert;:\xE2\x80\x96","VerticalBar;:\xE2\x88\xA3","VerticalLine;:|",
+"VerticalSeparator;:\xE2\x9D\x98","VerticalTilde;:\xE2\x89\x80",
+"VeryThinSpace;:\xE2\x80\x8A","Vfr;:\xF0\x9D\x94\x99","Vopf;:\xF0\x9D\x95\x8D",
+"Vscr;:\xF0\x9D\x92\xB1","Vvdash;:\xE2\x8A\xAA","Wcirc;:\xC5\xB4",
+"Wedge;:\xE2\x8B\x80","Wfr;:\xF0\x9D\x94\x9A","Wopf;:\xF0\x9D\x95\x8E",
+"Wscr;:\xF0\x9D\x92\xB2","Xfr;:\xF0\x9D\x94\x9B","Xi;:\xCE\x9E",
+"Xopf;:\xF0\x9D\x95\x8F","Xscr;:\xF0\x9D\x92\xB3","YAcy;:\xD0\xAF",
+"YIcy;:\xD0\x87","YUcy;:\xD0\xAE","Yacute:\xC3\x9D","Yacute;:\xC3\x9D",
+"Ycirc;:\xC5\xB6","Ycy;:\xD0\xAB","Yfr;:\xF0\x9D\x94\x9C",
+"Yopf;:\xF0\x9D\x95\x90","Yscr;:\xF0\x9D\x92\xB4","Yuml;:\xC5\xB8",
+"ZHcy;:\xD0\x96","Zacute;:\xC5\xB9","Zcaron;:\xC5\xBD","Zcy;:\xD0\x97",
+"Zdot;:\xC5\xBB","ZeroWidthSpace;:\xE2\x80\x8B","Zeta;:\xCE\x96",
+"Zfr;:\xE2\x84\xA8","Zopf;:\xE2\x84\xA4","Zscr;:\xF0\x9D\x92\xB5",
+"aacute:\xC3\xA1","aacute;:\xC3\xA1","abreve;:\xC4\x83","ac;:\xE2\x88\xBE",
+"acE;:\xE2\x88\xBE\xCC\xB3","acd;:\xE2\x88\xBF","acirc:\xC3\xA2",
+"acirc;:\xC3\xA2","acute:\xC2\xB4","acute;:\xC2\xB4","acy;:\xD0\xB0",
+"aelig:\xC3\xA6","aelig;:\xC3\xA6","af;:\xE2\x81\xA1","afr;:\xF0\x9D\x94\x9E",
+"agrave:\xC3\xA0","agrave;:\xC3\xA0","alefsym;:\xE2\x84\xB5",
+"aleph;:\xE2\x84\xB5","alpha;:\xCE\xB1","amacr;:\xC4\x81","amalg;:\xE2\xA8\xBF",
+"amp:&","amp;:&","and;:\xE2\x88\xA7","andand;:\xE2\xA9\x95",
+"andd;:\xE2\xA9\x9C","andslope;:\xE2\xA9\x98","andv;:\xE2\xA9\x9A",
+"ang;:\xE2\x88\xA0","ange;:\xE2\xA6\xA4","angle;:\xE2\x88\xA0",
+"angmsd;:\xE2\x88\xA1","angmsdaa;:\xE2\xA6\xA8","angmsdab;:\xE2\xA6\xA9",
+"angmsdac;:\xE2\xA6\xAA","angmsdad;:\xE2\xA6\xAB","angmsdae;:\xE2\xA6\xAC",
+"angmsdaf;:\xE2\xA6\xAD","angmsdag;:\xE2\xA6\xAE","angmsdah;:\xE2\xA6\xAF",
+"angrt;:\xE2\x88\x9F","angrtvb;:\xE2\x8A\xBE","angrtvbd;:\xE2\xA6\x9D",
+"angsph;:\xE2\x88\xA2","angst;:\xC3\x85","angzarr;:\xE2\x8D\xBC",
+"aogon;:\xC4\x85","aopf;:\xF0\x9D\x95\x92","ap;:\xE2\x89\x88",
+"apE;:\xE2\xA9\xB0","apacir;:\xE2\xA9\xAF","ape;:\xE2\x89\x8A",
+"apid;:\xE2\x89\x8B","apos;:\'","approx;:\xE2\x89\x88","approxeq;:\xE2\x89\x8A",
+"aring:\xC3\xA5","aring;:\xC3\xA5","ascr;:\xF0\x9D\x92\xB6","ast;:*",
+"asymp;:\xE2\x89\x88","asympeq;:\xE2\x89\x8D","atilde:\xC3\xA3",
+"atilde;:\xC3\xA3","auml:\xC3\xA4","auml;:\xC3\xA4","awconint;:\xE2\x88\xB3",
+"awint;:\xE2\xA8\x91","bNot;:\xE2\xAB\xAD","backcong;:\xE2\x89\x8C",
+"backepsilon;:\xCF\xB6","backprime;:\xE2\x80\xB5","backsim;:\xE2\x88\xBD",
+"backsimeq;:\xE2\x8B\x8D","barvee;:\xE2\x8A\xBD","barwed;:\xE2\x8C\x85",
+"barwedge;:\xE2\x8C\x85","bbrk;:\xE2\x8E\xB5","bbrktbrk;:\xE2\x8E\xB6",
+"bcong;:\xE2\x89\x8C","bcy;:\xD0\xB1","bdquo;:\xE2\x80\x9E",
+"becaus;:\xE2\x88\xB5","because;:\xE2\x88\xB5","bemptyv;:\xE2\xA6\xB0",
+"bepsi;:\xCF\xB6","bernou;:\xE2\x84\xAC","beta;:\xCE\xB2","beth;:\xE2\x84\xB6",
+"between;:\xE2\x89\xAC","bfr;:\xF0\x9D\x94\x9F","bigcap;:\xE2\x8B\x82",
+"bigcirc;:\xE2\x97\xAF","bigcup;:\xE2\x8B\x83","bigodot;:\xE2\xA8\x80",
+"bigoplus;:\xE2\xA8\x81","bigotimes;:\xE2\xA8\x82","bigsqcup;:\xE2\xA8\x86",
+"bigstar;:\xE2\x98\x85","bigtriangledown;:\xE2\x96\xBD",
+"bigtriangleup;:\xE2\x96\xB3","biguplus;:\xE2\xA8\x84","bigvee;:\xE2\x8B\x81",
+"bigwedge;:\xE2\x8B\x80","bkarow;:\xE2\xA4\x8D","blacklozenge;:\xE2\xA7\xAB",
+"blacksquare;:\xE2\x96\xAA","blacktriangle;:\xE2\x96\xB4",
+"blacktriangledown;:\xE2\x96\xBE","blacktriangleleft;:\xE2\x97\x82",
+"blacktriangleright;:\xE2\x96\xB8","blank;:\xE2\x90\xA3","blk12;:\xE2\x96\x92",
+"blk14;:\xE2\x96\x91","blk34;:\xE2\x96\x93","block;:\xE2\x96\x88",
+"bne;:=\xE2\x83\xA5","bnequiv;:\xE2\x89\xA1\xE2\x83\xA5","bnot;:\xE2\x8C\x90",
+"bopf;:\xF0\x9D\x95\x93","bot;:\xE2\x8A\xA5","bottom;:\xE2\x8A\xA5",
+"bowtie;:\xE2\x8B\x88","boxDL;:\xE2\x95\x97","boxDR;:\xE2\x95\x94",
+"boxDl;:\xE2\x95\x96","boxDr;:\xE2\x95\x93","boxH;:\xE2\x95\x90",
+"boxHD;:\xE2\x95\xA6","boxHU;:\xE2\x95\xA9","boxHd;:\xE2\x95\xA4",
+"boxHu;:\xE2\x95\xA7","boxUL;:\xE2\x95\x9D","boxUR;:\xE2\x95\x9A",
+"boxUl;:\xE2\x95\x9C","boxUr;:\xE2\x95\x99","boxV;:\xE2\x95\x91",
+"boxVH;:\xE2\x95\xAC","boxVL;:\xE2\x95\xA3","boxVR;:\xE2\x95\xA0",
+"boxVh;:\xE2\x95\xAB","boxVl;:\xE2\x95\xA2","boxVr;:\xE2\x95\x9F",
+"boxbox;:\xE2\xA7\x89","boxdL;:\xE2\x95\x95","boxdR;:\xE2\x95\x92",
+"boxdl;:\xE2\x94\x90","boxdr;:\xE2\x94\x8C","boxh;:\xE2\x94\x80",
+"boxhD;:\xE2\x95\xA5","boxhU;:\xE2\x95\xA8","boxhd;:\xE2\x94\xAC",
+"boxhu;:\xE2\x94\xB4","boxminus;:\xE2\x8A\x9F","boxplus;:\xE2\x8A\x9E",
+"boxtimes;:\xE2\x8A\xA0","boxuL;:\xE2\x95\x9B","boxuR;:\xE2\x95\x98",
+"boxul;:\xE2\x94\x98","boxur;:\xE2\x94\x94","boxv;:\xE2\x94\x82",
+"boxvH;:\xE2\x95\xAA","boxvL;:\xE2\x95\xA1","boxvR;:\xE2\x95\x9E",
+"boxvh;:\xE2\x94\xBC","boxvl;:\xE2\x94\xA4","boxvr;:\xE2\x94\x9C",
+"bprime;:\xE2\x80\xB5","breve;:\xCB\x98","brvbar:\xC2\xA6","brvbar;:\xC2\xA6",
+"bscr;:\xF0\x9D\x92\xB7","bsemi;:\xE2\x81\x8F","bsim;:\xE2\x88\xBD",
+"bsime;:\xE2\x8B\x8D","bsol;:\\","bsolb;:\xE2\xA7\x85","bsolhsub;:\xE2\x9F\x88",
+"bull;:\xE2\x80\xA2","bullet;:\xE2\x80\xA2","bump;:\xE2\x89\x8E",
+"bumpE;:\xE2\xAA\xAE","bumpe;:\xE2\x89\x8F","bumpeq;:\xE2\x89\x8F",
+"cacute;:\xC4\x87","cap;:\xE2\x88\xA9","capand;:\xE2\xA9\x84",
+"capbrcup;:\xE2\xA9\x89","capcap;:\xE2\xA9\x8B","capcup;:\xE2\xA9\x87",
+"capdot;:\xE2\xA9\x80","caps;:\xE2\x88\xA9\xEF\xB8\x80","caret;:\xE2\x81\x81",
+"caron;:\xCB\x87","ccaps;:\xE2\xA9\x8D","ccaron;:\xC4\x8D","ccedil:\xC3\xA7",
+"ccedil;:\xC3\xA7","ccirc;:\xC4\x89","ccups;:\xE2\xA9\x8C",
+"ccupssm;:\xE2\xA9\x90","cdot;:\xC4\x8B","cedil:\xC2\xB8","cedil;:\xC2\xB8",
+"cemptyv;:\xE2\xA6\xB2","cent:\xC2\xA2","cent;:\xC2\xA2","centerdot;:\xC2\xB7",
+"cfr;:\xF0\x9D\x94\xA0","chcy;:\xD1\x87","check;:\xE2\x9C\x93",
+"checkmark;:\xE2\x9C\x93","chi;:\xCF\x87","cir;:\xE2\x97\x8B",
+"cirE;:\xE2\xA7\x83","circ;:\xCB\x86","circeq;:\xE2\x89\x97",
+"circlearrowleft;:\xE2\x86\xBA","circlearrowright;:\xE2\x86\xBB",
+"circledR;:\xC2\xAE","circledS;:\xE2\x93\x88","circledast;:\xE2\x8A\x9B",
+"circledcirc;:\xE2\x8A\x9A","circleddash;:\xE2\x8A\x9D","cire;:\xE2\x89\x97",
+"cirfnint;:\xE2\xA8\x90","cirmid;:\xE2\xAB\xAF","cirscir;:\xE2\xA7\x82",
+"clubs;:\xE2\x99\xA3","clubsuit;:\xE2\x99\xA3","colon;::",
+"colone;:\xE2\x89\x94","coloneq;:\xE2\x89\x94","comma;:,","commat;:@",
+"comp;:\xE2\x88\x81","compfn;:\xE2\x88\x98","complement;:\xE2\x88\x81",
+"complexes;:\xE2\x84\x82","cong;:\xE2\x89\x85","congdot;:\xE2\xA9\xAD",
+"conint;:\xE2\x88\xAE","copf;:\xF0\x9D\x95\x94","coprod;:\xE2\x88\x90",
+"copy:\xC2\xA9","copy;:\xC2\xA9","copysr;:\xE2\x84\x97","crarr;:\xE2\x86\xB5",
+"cross;:\xE2\x9C\x97","cscr;:\xF0\x9D\x92\xB8","csub;:\xE2\xAB\x8F",
+"csube;:\xE2\xAB\x91","csup;:\xE2\xAB\x90","csupe;:\xE2\xAB\x92",
+"ctdot;:\xE2\x8B\xAF","cudarrl;:\xE2\xA4\xB8","cudarrr;:\xE2\xA4\xB5",
+"cuepr;:\xE2\x8B\x9E","cuesc;:\xE2\x8B\x9F","cularr;:\xE2\x86\xB6",
+"cularrp;:\xE2\xA4\xBD","cup;:\xE2\x88\xAA","cupbrcap;:\xE2\xA9\x88",
+"cupcap;:\xE2\xA9\x86","cupcup;:\xE2\xA9\x8A","cupdot;:\xE2\x8A\x8D",
+"cupor;:\xE2\xA9\x85","cups;:\xE2\x88\xAA\xEF\xB8\x80","curarr;:\xE2\x86\xB7",
+"curarrm;:\xE2\xA4\xBC","curlyeqprec;:\xE2\x8B\x9E","curlyeqsucc;:\xE2\x8B\x9F",
+"curlyvee;:\xE2\x8B\x8E","curlywedge;:\xE2\x8B\x8F","curren:\xC2\xA4",
+"curren;:\xC2\xA4","curvearrowleft;:\xE2\x86\xB6",
+"curvearrowright;:\xE2\x86\xB7","cuvee;:\xE2\x8B\x8E","cuwed;:\xE2\x8B\x8F",
+"cwconint;:\xE2\x88\xB2","cwint;:\xE2\x88\xB1","cylcty;:\xE2\x8C\xAD",
+"dArr;:\xE2\x87\x93","dHar;:\xE2\xA5\xA5","dagger;:\xE2\x80\xA0",
+"daleth;:\xE2\x84\xB8","darr;:\xE2\x86\x93","dash;:\xE2\x80\x90",
+"dashv;:\xE2\x8A\xA3","dbkarow;:\xE2\xA4\x8F","dblac;:\xCB\x9D",
+"dcaron;:\xC4\x8F","dcy;:\xD0\xB4","dd;:\xE2\x85\x86","ddagger;:\xE2\x80\xA1",
+"ddarr;:\xE2\x87\x8A","ddotseq;:\xE2\xA9\xB7","deg:\xC2\xB0","deg;:\xC2\xB0",
+"delta;:\xCE\xB4","demptyv;:\xE2\xA6\xB1","dfisht;:\xE2\xA5\xBF",
+"dfr;:\xF0\x9D\x94\xA1","dharl;:\xE2\x87\x83","dharr;:\xE2\x87\x82",
+"diam;:\xE2\x8B\x84","diamond;:\xE2\x8B\x84","diamondsuit;:\xE2\x99\xA6",
+"diams;:\xE2\x99\xA6","die;:\xC2\xA8","digamma;:\xCF\x9D","disin;:\xE2\x8B\xB2",
+"div;:\xC3\xB7","divide:\xC3\xB7","divide;:\xC3\xB7",
+"divideontimes;:\xE2\x8B\x87","divonx;:\xE2\x8B\x87","djcy;:\xD1\x92",
+"dlcorn;:\xE2\x8C\x9E","dlcrop;:\xE2\x8C\x8D","dollar;:$",
+"dopf;:\xF0\x9D\x95\x95","dot;:\xCB\x99","doteq;:\xE2\x89\x90",
+"doteqdot;:\xE2\x89\x91","dotminus;:\xE2\x88\xB8","dotplus;:\xE2\x88\x94",
+"dotsquare;:\xE2\x8A\xA1","doublebarwedge;:\xE2\x8C\x86",
+"downarrow;:\xE2\x86\x93","downdownarrows;:\xE2\x87\x8A",
+"downharpoonleft;:\xE2\x87\x83","downharpoonright;:\xE2\x87\x82",
+"drbkarow;:\xE2\xA4\x90","drcorn;:\xE2\x8C\x9F","drcrop;:\xE2\x8C\x8C",
+"dscr;:\xF0\x9D\x92\xB9","dscy;:\xD1\x95","dsol;:\xE2\xA7\xB6",
+"dstrok;:\xC4\x91","dtdot;:\xE2\x8B\xB1","dtri;:\xE2\x96\xBF",
+"dtrif;:\xE2\x96\xBE","duarr;:\xE2\x87\xB5","duhar;:\xE2\xA5\xAF",
+"dwangle;:\xE2\xA6\xA6","dzcy;:\xD1\x9F","dzigrarr;:\xE2\x9F\xBF",
+"eDDot;:\xE2\xA9\xB7","eDot;:\xE2\x89\x91","eacute:\xC3\xA9","eacute;:\xC3\xA9",
+"easter;:\xE2\xA9\xAE","ecaron;:\xC4\x9B","ecir;:\xE2\x89\x96","ecirc:\xC3\xAA",
+"ecirc;:\xC3\xAA","ecolon;:\xE2\x89\x95","ecy;:\xD1\x8D","edot;:\xC4\x97",
+"ee;:\xE2\x85\x87","efDot;:\xE2\x89\x92","efr;:\xF0\x9D\x94\xA2",
+"eg;:\xE2\xAA\x9A","egrave:\xC3\xA8","egrave;:\xC3\xA8","egs;:\xE2\xAA\x96",
+"egsdot;:\xE2\xAA\x98","el;:\xE2\xAA\x99","elinters;:\xE2\x8F\xA7",
+"ell;:\xE2\x84\x93","els;:\xE2\xAA\x95","elsdot;:\xE2\xAA\x97",
+"emacr;:\xC4\x93","empty;:\xE2\x88\x85","emptyset;:\xE2\x88\x85",
+"emptyv;:\xE2\x88\x85","emsp13;:\xE2\x80\x84","emsp14;:\xE2\x80\x85",
+"emsp;:\xE2\x80\x83","eng;:\xC5\x8B","ensp;:\xE2\x80\x82","eogon;:\xC4\x99",
+"eopf;:\xF0\x9D\x95\x96","epar;:\xE2\x8B\x95","eparsl;:\xE2\xA7\xA3",
+"eplus;:\xE2\xA9\xB1","epsi;:\xCE\xB5","epsilon;:\xCE\xB5","epsiv;:\xCF\xB5",
+"eqcirc;:\xE2\x89\x96","eqcolon;:\xE2\x89\x95","eqsim;:\xE2\x89\x82",
+"eqslantgtr;:\xE2\xAA\x96","eqslantless;:\xE2\xAA\x95","equals;:=",
+"equest;:\xE2\x89\x9F","equiv;:\xE2\x89\xA1","equivDD;:\xE2\xA9\xB8",
+"eqvparsl;:\xE2\xA7\xA5","erDot;:\xE2\x89\x93","erarr;:\xE2\xA5\xB1",
+"escr;:\xE2\x84\xAF","esdot;:\xE2\x89\x90","esim;:\xE2\x89\x82","eta;:\xCE\xB7",
+"eth:\xC3\xB0","eth;:\xC3\xB0","euml:\xC3\xAB","euml;:\xC3\xAB",
+"euro;:\xE2\x82\xAC","excl;:!","exist;:\xE2\x88\x83",
+"expectation;:\xE2\x84\xB0","exponentiale;:\xE2\x85\x87",
+"fallingdotseq;:\xE2\x89\x92","fcy;:\xD1\x84","female;:\xE2\x99\x80",
+"ffilig;:\xEF\xAC\x83","fflig;:\xEF\xAC\x80","ffllig;:\xEF\xAC\x84",
+"ffr;:\xF0\x9D\x94\xA3","filig;:\xEF\xAC\x81","fjlig;:fj","flat;:\xE2\x99\xAD",
+"fllig;:\xEF\xAC\x82","fltns;:\xE2\x96\xB1","fnof;:\xC6\x92",
+"fopf;:\xF0\x9D\x95\x97","forall;:\xE2\x88\x80","fork;:\xE2\x8B\x94",
+"forkv;:\xE2\xAB\x99","fpartint;:\xE2\xA8\x8D","frac12:\xC2\xBD",
+"frac12;:\xC2\xBD","frac13;:\xE2\x85\x93","frac14:\xC2\xBC","frac14;:\xC2\xBC",
+"frac15;:\xE2\x85\x95","frac16;:\xE2\x85\x99","frac18;:\xE2\x85\x9B",
+"frac23;:\xE2\x85\x94","frac25;:\xE2\x85\x96","frac34:\xC2\xBE",
+"frac34;:\xC2\xBE","frac35;:\xE2\x85\x97","frac38;:\xE2\x85\x9C",
+"frac45;:\xE2\x85\x98","frac56;:\xE2\x85\x9A","frac58;:\xE2\x85\x9D",
+"frac78;:\xE2\x85\x9E","frasl;:\xE2\x81\x84","frown;:\xE2\x8C\xA2",
+"fscr;:\xF0\x9D\x92\xBB","gE;:\xE2\x89\xA7","gEl;:\xE2\xAA\x8C",
+"gacute;:\xC7\xB5","gamma;:\xCE\xB3","gammad;:\xCF\x9D","gap;:\xE2\xAA\x86",
+"gbreve;:\xC4\x9F","gcirc;:\xC4\x9D","gcy;:\xD0\xB3","gdot;:\xC4\xA1",
+"ge;:\xE2\x89\xA5","gel;:\xE2\x8B\x9B","geq;:\xE2\x89\xA5","geqq;:\xE2\x89\xA7",
+"geqslant;:\xE2\xA9\xBE","ges;:\xE2\xA9\xBE","gescc;:\xE2\xAA\xA9",
+"gesdot;:\xE2\xAA\x80","gesdoto;:\xE2\xAA\x82","gesdotol;:\xE2\xAA\x84",
+"gesl;:\xE2\x8B\x9B\xEF\xB8\x80","gesles;:\xE2\xAA\x94","gfr;:\xF0\x9D\x94\xA4",
+"gg;:\xE2\x89\xAB","ggg;:\xE2\x8B\x99","gimel;:\xE2\x84\xB7","gjcy;:\xD1\x93",
+"gl;:\xE2\x89\xB7","glE;:\xE2\xAA\x92","gla;:\xE2\xAA\xA5","glj;:\xE2\xAA\xA4",
+"gnE;:\xE2\x89\xA9","gnap;:\xE2\xAA\x8A","gnapprox;:\xE2\xAA\x8A",
+"gne;:\xE2\xAA\x88","gneq;:\xE2\xAA\x88","gneqq;:\xE2\x89\xA9",
+"gnsim;:\xE2\x8B\xA7","gopf;:\xF0\x9D\x95\x98","grave;:`","gscr;:\xE2\x84\x8A",
+"gsim;:\xE2\x89\xB3","gsime;:\xE2\xAA\x8E","gsiml;:\xE2\xAA\x90","gt:>","gt;:>",
+"gtcc;:\xE2\xAA\xA7","gtcir;:\xE2\xA9\xBA","gtdot;:\xE2\x8B\x97",
+"gtlPar;:\xE2\xA6\x95","gtquest;:\xE2\xA9\xBC","gtrapprox;:\xE2\xAA\x86",
+"gtrarr;:\xE2\xA5\xB8","gtrdot;:\xE2\x8B\x97","gtreqless;:\xE2\x8B\x9B",
+"gtreqqless;:\xE2\xAA\x8C","gtrless;:\xE2\x89\xB7","gtrsim;:\xE2\x89\xB3",
+"gvertneqq;:\xE2\x89\xA9\xEF\xB8\x80","gvnE;:\xE2\x89\xA9\xEF\xB8\x80",
+"hArr;:\xE2\x87\x94","hairsp;:\xE2\x80\x8A","half;:\xC2\xBD",
+"hamilt;:\xE2\x84\x8B","hardcy;:\xD1\x8A","harr;:\xE2\x86\x94",
+"harrcir;:\xE2\xA5\x88","harrw;:\xE2\x86\xAD","hbar;:\xE2\x84\x8F",
+"hcirc;:\xC4\xA5","hearts;:\xE2\x99\xA5","heartsuit;:\xE2\x99\xA5",
+"hellip;:\xE2\x80\xA6","hercon;:\xE2\x8A\xB9","hfr;:\xF0\x9D\x94\xA5",
+"hksearow;:\xE2\xA4\xA5","hkswarow;:\xE2\xA4\xA6","hoarr;:\xE2\x87\xBF",
+"homtht;:\xE2\x88\xBB","hookleftarrow;:\xE2\x86\xA9",
+"hookrightarrow;:\xE2\x86\xAA","hopf;:\xF0\x9D\x95\x99","horbar;:\xE2\x80\x95",
+"hscr;:\xF0\x9D\x92\xBD","hslash;:\xE2\x84\x8F","hstrok;:\xC4\xA7",
+"hybull;:\xE2\x81\x83","hyphen;:\xE2\x80\x90","iacute:\xC3\xAD",
+"iacute;:\xC3\xAD","ic;:\xE2\x81\xA3","icirc:\xC3\xAE","icirc;:\xC3\xAE",
+"icy;:\xD0\xB8","iecy;:\xD0\xB5","iexcl:\xC2\xA1","iexcl;:\xC2\xA1",
+"iff;:\xE2\x87\x94","ifr;:\xF0\x9D\x94\xA6","igrave:\xC3\xAC",
+"igrave;:\xC3\xAC","ii;:\xE2\x85\x88","iiiint;:\xE2\xA8\x8C",
+"iiint;:\xE2\x88\xAD","iinfin;:\xE2\xA7\x9C","iiota;:\xE2\x84\xA9",
+"ijlig;:\xC4\xB3","imacr;:\xC4\xAB","image;:\xE2\x84\x91",
+"imagline;:\xE2\x84\x90","imagpart;:\xE2\x84\x91","imath;:\xC4\xB1",
+"imof;:\xE2\x8A\xB7","imped;:\xC6\xB5","in;:\xE2\x88\x88",
+"incare;:\xE2\x84\x85","infin;:\xE2\x88\x9E","infintie;:\xE2\xA7\x9D",
+"inodot;:\xC4\xB1","int;:\xE2\x88\xAB","intcal;:\xE2\x8A\xBA",
+"integers;:\xE2\x84\xA4","intercal;:\xE2\x8A\xBA","intlarhk;:\xE2\xA8\x97",
+"intprod;:\xE2\xA8\xBC","iocy;:\xD1\x91","iogon;:\xC4\xAF",
+"iopf;:\xF0\x9D\x95\x9A","iota;:\xCE\xB9","iprod;:\xE2\xA8\xBC",
+"iquest:\xC2\xBF","iquest;:\xC2\xBF","iscr;:\xF0\x9D\x92\xBE",
+"isin;:\xE2\x88\x88","isinE;:\xE2\x8B\xB9","isindot;:\xE2\x8B\xB5",
+"isins;:\xE2\x8B\xB4","isinsv;:\xE2\x8B\xB3","isinv;:\xE2\x88\x88",
+"it;:\xE2\x81\xA2","itilde;:\xC4\xA9","iukcy;:\xD1\x96","iuml:\xC3\xAF",
+"iuml;:\xC3\xAF","jcirc;:\xC4\xB5","jcy;:\xD0\xB9","jfr;:\xF0\x9D\x94\xA7",
+"jmath;:\xC8\xB7","jopf;:\xF0\x9D\x95\x9B","jscr;:\xF0\x9D\x92\xBF",
+"jsercy;:\xD1\x98","jukcy;:\xD1\x94","kappa;:\xCE\xBA","kappav;:\xCF\xB0",
+"kcedil;:\xC4\xB7","kcy;:\xD0\xBA","kfr;:\xF0\x9D\x94\xA8","kgreen;:\xC4\xB8",
+"khcy;:\xD1\x85","kjcy;:\xD1\x9C","kopf;:\xF0\x9D\x95\x9C",
+"kscr;:\xF0\x9D\x93\x80","lAarr;:\xE2\x87\x9A","lArr;:\xE2\x87\x90",
+"lAtail;:\xE2\xA4\x9B","lBarr;:\xE2\xA4\x8E","lE;:\xE2\x89\xA6",
+"lEg;:\xE2\xAA\x8B","lHar;:\xE2\xA5\xA2","lacute;:\xC4\xBA",
+"laemptyv;:\xE2\xA6\xB4","lagran;:\xE2\x84\x92","lambda;:\xCE\xBB",
+"lang;:\xE2\x9F\xA8","langd;:\xE2\xA6\x91","langle;:\xE2\x9F\xA8",
+"lap;:\xE2\xAA\x85","laquo:\xC2\xAB","laquo;:\xC2\xAB","larr;:\xE2\x86\x90",
+"larrb;:\xE2\x87\xA4","larrbfs;:\xE2\xA4\x9F","larrfs;:\xE2\xA4\x9D",
+"larrhk;:\xE2\x86\xA9","larrlp;:\xE2\x86\xAB","larrpl;:\xE2\xA4\xB9",
+"larrsim;:\xE2\xA5\xB3","larrtl;:\xE2\x86\xA2","lat;:\xE2\xAA\xAB",
+"latail;:\xE2\xA4\x99","late;:\xE2\xAA\xAD","lates;:\xE2\xAA\xAD\xEF\xB8\x80",
+"lbarr;:\xE2\xA4\x8C","lbbrk;:\xE2\x9D\xB2","lbrace;:{","lbrack;:[",
+"lbrke;:\xE2\xA6\x8B","lbrksld;:\xE2\xA6\x8F","lbrkslu;:\xE2\xA6\x8D",
+"lcaron;:\xC4\xBE","lcedil;:\xC4\xBC","lceil;:\xE2\x8C\x88","lcub;:{",
+"lcy;:\xD0\xBB","ldca;:\xE2\xA4\xB6","ldquo;:\xE2\x80\x9C",
+"ldquor;:\xE2\x80\x9E","ldrdhar;:\xE2\xA5\xA7","ldrushar;:\xE2\xA5\x8B",
+"ldsh;:\xE2\x86\xB2","le;:\xE2\x89\xA4","leftarrow;:\xE2\x86\x90",
+"leftarrowtail;:\xE2\x86\xA2","leftharpoondown;:\xE2\x86\xBD",
+"leftharpoonup;:\xE2\x86\xBC","leftleftarrows;:\xE2\x87\x87",
+"leftrightarrow;:\xE2\x86\x94","leftrightarrows;:\xE2\x87\x86",
+"leftrightharpoons;:\xE2\x87\x8B","leftrightsquigarrow;:\xE2\x86\xAD",
+"leftthreetimes;:\xE2\x8B\x8B","leg;:\xE2\x8B\x9A","leq;:\xE2\x89\xA4",
+"leqq;:\xE2\x89\xA6","leqslant;:\xE2\xA9\xBD","les;:\xE2\xA9\xBD",
+"lescc;:\xE2\xAA\xA8","lesdot;:\xE2\xA9\xBF","lesdoto;:\xE2\xAA\x81",
+"lesdotor;:\xE2\xAA\x83","lesg;:\xE2\x8B\x9A\xEF\xB8\x80",
+"lesges;:\xE2\xAA\x93","lessapprox;:\xE2\xAA\x85","lessdot;:\xE2\x8B\x96",
+"lesseqgtr;:\xE2\x8B\x9A","lesseqqgtr;:\xE2\xAA\x8B","lessgtr;:\xE2\x89\xB6",
+"lesssim;:\xE2\x89\xB2","lfisht;:\xE2\xA5\xBC","lfloor;:\xE2\x8C\x8A",
+"lfr;:\xF0\x9D\x94\xA9","lg;:\xE2\x89\xB6","lgE;:\xE2\xAA\x91",
+"lhard;:\xE2\x86\xBD","lharu;:\xE2\x86\xBC","lharul;:\xE2\xA5\xAA",
+"lhblk;:\xE2\x96\x84","ljcy;:\xD1\x99","ll;:\xE2\x89\xAA","llarr;:\xE2\x87\x87",
+"llcorner;:\xE2\x8C\x9E","llhard;:\xE2\xA5\xAB","lltri;:\xE2\x97\xBA",
+"lmidot;:\xC5\x80","lmoust;:\xE2\x8E\xB0","lmoustache;:\xE2\x8E\xB0",
+"lnE;:\xE2\x89\xA8","lnap;:\xE2\xAA\x89","lnapprox;:\xE2\xAA\x89",
+"lne;:\xE2\xAA\x87","lneq;:\xE2\xAA\x87","lneqq;:\xE2\x89\xA8",
+"lnsim;:\xE2\x8B\xA6","loang;:\xE2\x9F\xAC","loarr;:\xE2\x87\xBD",
+"lobrk;:\xE2\x9F\xA6","longleftarrow;:\xE2\x9F\xB5",
+"longleftrightarrow;:\xE2\x9F\xB7","longmapsto;:\xE2\x9F\xBC",
+"longrightarrow;:\xE2\x9F\xB6","looparrowleft;:\xE2\x86\xAB",
+"looparrowright;:\xE2\x86\xAC","lopar;:\xE2\xA6\x85","lopf;:\xF0\x9D\x95\x9D",
+"loplus;:\xE2\xA8\xAD","lotimes;:\xE2\xA8\xB4","lowast;:\xE2\x88\x97",
+"lowbar;:_","loz;:\xE2\x97\x8A","lozenge;:\xE2\x97\x8A","lozf;:\xE2\xA7\xAB",
+"lpar;:(","lparlt;:\xE2\xA6\x93","lrarr;:\xE2\x87\x86","lrcorner;:\xE2\x8C\x9F",
+"lrhar;:\xE2\x87\x8B","lrhard;:\xE2\xA5\xAD","lrm;:\xE2\x80\x8E",
+"lrtri;:\xE2\x8A\xBF","lsaquo;:\xE2\x80\xB9","lscr;:\xF0\x9D\x93\x81",
+"lsh;:\xE2\x86\xB0","lsim;:\xE2\x89\xB2","lsime;:\xE2\xAA\x8D",
+"lsimg;:\xE2\xAA\x8F","lsqb;:[","lsquo;:\xE2\x80\x98","lsquor;:\xE2\x80\x9A",
+"lstrok;:\xC5\x82","lt:<","lt;:<","ltcc;:\xE2\xAA\xA6","ltcir;:\xE2\xA9\xB9",
+"ltdot;:\xE2\x8B\x96","lthree;:\xE2\x8B\x8B","ltimes;:\xE2\x8B\x89",
+"ltlarr;:\xE2\xA5\xB6","ltquest;:\xE2\xA9\xBB","ltrPar;:\xE2\xA6\x96",
+"ltri;:\xE2\x97\x83","ltrie;:\xE2\x8A\xB4","ltrif;:\xE2\x97\x82",
+"lurdshar;:\xE2\xA5\x8A","luruhar;:\xE2\xA5\xA6",
+"lvertneqq;:\xE2\x89\xA8\xEF\xB8\x80","lvnE;:\xE2\x89\xA8\xEF\xB8\x80",
+"mDDot;:\xE2\x88\xBA","macr:\xC2\xAF","macr;:\xC2\xAF","male;:\xE2\x99\x82",
+"malt;:\xE2\x9C\xA0","maltese;:\xE2\x9C\xA0","map;:\xE2\x86\xA6",
+"mapsto;:\xE2\x86\xA6","mapstodown;:\xE2\x86\xA7","mapstoleft;:\xE2\x86\xA4",
+"mapstoup;:\xE2\x86\xA5","marker;:\xE2\x96\xAE","mcomma;:\xE2\xA8\xA9",
+"mcy;:\xD0\xBC","mdash;:\xE2\x80\x94","measuredangle;:\xE2\x88\xA1",
+"mfr;:\xF0\x9D\x94\xAA","mho;:\xE2\x84\xA7","micro:\xC2\xB5","micro;:\xC2\xB5",
+"mid;:\xE2\x88\xA3","midast;:*","midcir;:\xE2\xAB\xB0","middot:\xC2\xB7",
+"middot;:\xC2\xB7","minus;:\xE2\x88\x92","minusb;:\xE2\x8A\x9F",
+"minusd;:\xE2\x88\xB8","minusdu;:\xE2\xA8\xAA","mlcp;:\xE2\xAB\x9B",
+"mldr;:\xE2\x80\xA6","mnplus;:\xE2\x88\x93","models;:\xE2\x8A\xA7",
+"mopf;:\xF0\x9D\x95\x9E","mp;:\xE2\x88\x93","mscr;:\xF0\x9D\x93\x82",
+"mstpos;:\xE2\x88\xBE","mu;:\xCE\xBC","multimap;:\xE2\x8A\xB8",
+"mumap;:\xE2\x8A\xB8","nGg;:\xE2\x8B\x99\xCC\xB8",
+"nGt;:\xE2\x89\xAB\xE2\x83\x92","nGtv;:\xE2\x89\xAB\xCC\xB8",
+"nLeftarrow;:\xE2\x87\x8D","nLeftrightarrow;:\xE2\x87\x8E",
+"nLl;:\xE2\x8B\x98\xCC\xB8","nLt;:\xE2\x89\xAA\xE2\x83\x92",
+"nLtv;:\xE2\x89\xAA\xCC\xB8","nRightarrow;:\xE2\x87\x8F","nVDash;:\xE2\x8A\xAF",
+"nVdash;:\xE2\x8A\xAE","nabla;:\xE2\x88\x87","nacute;:\xC5\x84",
+"nang;:\xE2\x88\xA0\xE2\x83\x92","nap;:\xE2\x89\x89",
+"napE;:\xE2\xA9\xB0\xCC\xB8","napid;:\xE2\x89\x8B\xCC\xB8","napos;:\xC5\x89",
+"napprox;:\xE2\x89\x89","natur;:\xE2\x99\xAE","natural;:\xE2\x99\xAE",
+"naturals;:\xE2\x84\x95","nbsp:\xC2\xA0","nbsp;:\xC2\xA0",
+"nbump;:\xE2\x89\x8E\xCC\xB8","nbumpe;:\xE2\x89\x8F\xCC\xB8",
+"ncap;:\xE2\xA9\x83","ncaron;:\xC5\x88","ncedil;:\xC5\x86",
+"ncong;:\xE2\x89\x87","ncongdot;:\xE2\xA9\xAD\xCC\xB8","ncup;:\xE2\xA9\x82",
+"ncy;:\xD0\xBD","ndash;:\xE2\x80\x93","ne;:\xE2\x89\xA0","neArr;:\xE2\x87\x97",
+"nearhk;:\xE2\xA4\xA4","nearr;:\xE2\x86\x97","nearrow;:\xE2\x86\x97",
+"nedot;:\xE2\x89\x90\xCC\xB8","nequiv;:\xE2\x89\xA2","nesear;:\xE2\xA4\xA8",
+"nesim;:\xE2\x89\x82\xCC\xB8","nexist;:\xE2\x88\x84","nexists;:\xE2\x88\x84",
+"nfr;:\xF0\x9D\x94\xAB","ngE;:\xE2\x89\xA7\xCC\xB8","nge;:\xE2\x89\xB1",
+"ngeq;:\xE2\x89\xB1","ngeqq;:\xE2\x89\xA7\xCC\xB8",
+"ngeqslant;:\xE2\xA9\xBE\xCC\xB8","nges;:\xE2\xA9\xBE\xCC\xB8",
+"ngsim;:\xE2\x89\xB5","ngt;:\xE2\x89\xAF","ngtr;:\xE2\x89\xAF",
+"nhArr;:\xE2\x87\x8E","nharr;:\xE2\x86\xAE","nhpar;:\xE2\xAB\xB2",
+"ni;:\xE2\x88\x8B","nis;:\xE2\x8B\xBC","nisd;:\xE2\x8B\xBA","niv;:\xE2\x88\x8B",
+"njcy;:\xD1\x9A","nlArr;:\xE2\x87\x8D","nlE;:\xE2\x89\xA6\xCC\xB8",
+"nlarr;:\xE2\x86\x9A","nldr;:\xE2\x80\xA5","nle;:\xE2\x89\xB0",
+"nleftarrow;:\xE2\x86\x9A","nleftrightarrow;:\xE2\x86\xAE","nleq;:\xE2\x89\xB0",
+"nleqq;:\xE2\x89\xA6\xCC\xB8","nleqslant;:\xE2\xA9\xBD\xCC\xB8",
+"nles;:\xE2\xA9\xBD\xCC\xB8","nless;:\xE2\x89\xAE","nlsim;:\xE2\x89\xB4",
+"nlt;:\xE2\x89\xAE","nltri;:\xE2\x8B\xAA","nltrie;:\xE2\x8B\xAC",
+"nmid;:\xE2\x88\xA4","nopf;:\xF0\x9D\x95\x9F","not:\xC2\xAC","not;:\xC2\xAC",
+"notin;:\xE2\x88\x89","notinE;:\xE2\x8B\xB9\xCC\xB8",
+"notindot;:\xE2\x8B\xB5\xCC\xB8","notinva;:\xE2\x88\x89",
+"notinvb;:\xE2\x8B\xB7","notinvc;:\xE2\x8B\xB6","notni;:\xE2\x88\x8C",
+"notniva;:\xE2\x88\x8C","notnivb;:\xE2\x8B\xBE","notnivc;:\xE2\x8B\xBD",
+"npar;:\xE2\x88\xA6","nparallel;:\xE2\x88\xA6",
+"nparsl;:\xE2\xAB\xBD\xE2\x83\xA5","npart;:\xE2\x88\x82\xCC\xB8",
+"npolint;:\xE2\xA8\x94","npr;:\xE2\x8A\x80","nprcue;:\xE2\x8B\xA0",
+"npre;:\xE2\xAA\xAF\xCC\xB8","nprec;:\xE2\x8A\x80",
+"npreceq;:\xE2\xAA\xAF\xCC\xB8","nrArr;:\xE2\x87\x8F","nrarr;:\xE2\x86\x9B",
+"nrarrc;:\xE2\xA4\xB3\xCC\xB8","nrarrw;:\xE2\x86\x9D\xCC\xB8",
+"nrightarrow;:\xE2\x86\x9B","nrtri;:\xE2\x8B\xAB","nrtrie;:\xE2\x8B\xAD",
+"nsc;:\xE2\x8A\x81","nsccue;:\xE2\x8B\xA1","nsce;:\xE2\xAA\xB0\xCC\xB8",
+"nscr;:\xF0\x9D\x93\x83","nshortmid;:\xE2\x88\xA4",
+"nshortparallel;:\xE2\x88\xA6","nsim;:\xE2\x89\x81","nsime;:\xE2\x89\x84",
+"nsimeq;:\xE2\x89\x84","nsmid;:\xE2\x88\xA4","nspar;:\xE2\x88\xA6",
+"nsqsube;:\xE2\x8B\xA2","nsqsupe;:\xE2\x8B\xA3","nsub;:\xE2\x8A\x84",
+"nsubE;:\xE2\xAB\x85\xCC\xB8","nsube;:\xE2\x8A\x88",
+"nsubset;:\xE2\x8A\x82\xE2\x83\x92","nsubseteq;:\xE2\x8A\x88",
+"nsubseteqq;:\xE2\xAB\x85\xCC\xB8","nsucc;:\xE2\x8A\x81",
+"nsucceq;:\xE2\xAA\xB0\xCC\xB8","nsup;:\xE2\x8A\x85",
+"nsupE;:\xE2\xAB\x86\xCC\xB8","nsupe;:\xE2\x8A\x89",
+"nsupset;:\xE2\x8A\x83\xE2\x83\x92","nsupseteq;:\xE2\x8A\x89",
+"nsupseteqq;:\xE2\xAB\x86\xCC\xB8","ntgl;:\xE2\x89\xB9","ntilde:\xC3\xB1",
+"ntilde;:\xC3\xB1","ntlg;:\xE2\x89\xB8","ntriangleleft;:\xE2\x8B\xAA",
+"ntrianglelefteq;:\xE2\x8B\xAC","ntriangleright;:\xE2\x8B\xAB",
+"ntrianglerighteq;:\xE2\x8B\xAD","nu;:\xCE\xBD","num;:#","numero;:\xE2\x84\x96",
+"numsp;:\xE2\x80\x87","nvDash;:\xE2\x8A\xAD","nvHarr;:\xE2\xA4\x84",
+"nvap;:\xE2\x89\x8D\xE2\x83\x92","nvdash;:\xE2\x8A\xAC",
+"nvge;:\xE2\x89\xA5\xE2\x83\x92","nvgt;:>\xE2\x83\x92","nvinfin;:\xE2\xA7\x9E",
+"nvlArr;:\xE2\xA4\x82","nvle;:\xE2\x89\xA4\xE2\x83\x92","nvlt;:<\xE2\x83\x92",
+"nvltrie;:\xE2\x8A\xB4\xE2\x83\x92","nvrArr;:\xE2\xA4\x83",
+"nvrtrie;:\xE2\x8A\xB5\xE2\x83\x92","nvsim;:\xE2\x88\xBC\xE2\x83\x92",
+"nwArr;:\xE2\x87\x96","nwarhk;:\xE2\xA4\xA3","nwarr;:\xE2\x86\x96",
+"nwarrow;:\xE2\x86\x96","nwnear;:\xE2\xA4\xA7","oS;:\xE2\x93\x88",
+"oacute:\xC3\xB3","oacute;:\xC3\xB3","oast;:\xE2\x8A\x9B","ocir;:\xE2\x8A\x9A",
+"ocirc:\xC3\xB4","ocirc;:\xC3\xB4","ocy;:\xD0\xBE","odash;:\xE2\x8A\x9D",
+"odblac;:\xC5\x91","odiv;:\xE2\xA8\xB8","odot;:\xE2\x8A\x99",
+"odsold;:\xE2\xA6\xBC","oelig;:\xC5\x93","ofcir;:\xE2\xA6\xBF",
+"ofr;:\xF0\x9D\x94\xAC","ogon;:\xCB\x9B","ograve:\xC3\xB2","ograve;:\xC3\xB2",
+"ogt;:\xE2\xA7\x81","ohbar;:\xE2\xA6\xB5","ohm;:\xCE\xA9","oint;:\xE2\x88\xAE",
+"olarr;:\xE2\x86\xBA","olcir;:\xE2\xA6\xBE","olcross;:\xE2\xA6\xBB",
+"oline;:\xE2\x80\xBE","olt;:\xE2\xA7\x80","omacr;:\xC5\x8D","omega;:\xCF\x89",
+"omicron;:\xCE\xBF","omid;:\xE2\xA6\xB6","ominus;:\xE2\x8A\x96",
+"oopf;:\xF0\x9D\x95\xA0","opar;:\xE2\xA6\xB7","operp;:\xE2\xA6\xB9",
+"oplus;:\xE2\x8A\x95","or;:\xE2\x88\xA8","orarr;:\xE2\x86\xBB",
+"ord;:\xE2\xA9\x9D","order;:\xE2\x84\xB4","orderof;:\xE2\x84\xB4",
+"ordf:\xC2\xAA","ordf;:\xC2\xAA","ordm:\xC2\xBA","ordm;:\xC2\xBA",
+"origof;:\xE2\x8A\xB6","oror;:\xE2\xA9\x96","orslope;:\xE2\xA9\x97",
+"orv;:\xE2\xA9\x9B","oscr;:\xE2\x84\xB4","oslash:\xC3\xB8","oslash;:\xC3\xB8",
+"osol;:\xE2\x8A\x98","otilde:\xC3\xB5","otilde;:\xC3\xB5",
+"otimes;:\xE2\x8A\x97","otimesas;:\xE2\xA8\xB6","ouml:\xC3\xB6",
+"ouml;:\xC3\xB6","ovbar;:\xE2\x8C\xBD","par;:\xE2\x88\xA5","para:\xC2\xB6",
+"para;:\xC2\xB6","parallel;:\xE2\x88\xA5","parsim;:\xE2\xAB\xB3",
+"parsl;:\xE2\xAB\xBD","part;:\xE2\x88\x82","pcy;:\xD0\xBF","percnt;:%",
+"period;:.","permil;:\xE2\x80\xB0","perp;:\xE2\x8A\xA5","pertenk;:\xE2\x80\xB1",
+"pfr;:\xF0\x9D\x94\xAD","phi;:\xCF\x86","phiv;:\xCF\x95","phmmat;:\xE2\x84\xB3",
+"phone;:\xE2\x98\x8E","pi;:\xCF\x80","pitchfork;:\xE2\x8B\x94","piv;:\xCF\x96",
+"planck;:\xE2\x84\x8F","planckh;:\xE2\x84\x8E","plankv;:\xE2\x84\x8F","plus;:+",
+"plusacir;:\xE2\xA8\xA3","plusb;:\xE2\x8A\x9E","pluscir;:\xE2\xA8\xA2",
+"plusdo;:\xE2\x88\x94","plusdu;:\xE2\xA8\xA5","pluse;:\xE2\xA9\xB2",
+"plusmn:\xC2\xB1","plusmn;:\xC2\xB1","plussim;:\xE2\xA8\xA6",
+"plustwo;:\xE2\xA8\xA7","pm;:\xC2\xB1","pointint;:\xE2\xA8\x95",
+"popf;:\xF0\x9D\x95\xA1","pound:\xC2\xA3","pound;:\xC2\xA3","pr;:\xE2\x89\xBA",
+"prE;:\xE2\xAA\xB3","prap;:\xE2\xAA\xB7","prcue;:\xE2\x89\xBC",
+"pre;:\xE2\xAA\xAF","prec;:\xE2\x89\xBA","precapprox;:\xE2\xAA\xB7",
+"preccurlyeq;:\xE2\x89\xBC","preceq;:\xE2\xAA\xAF","precnapprox;:\xE2\xAA\xB9",
+"precneqq;:\xE2\xAA\xB5","precnsim;:\xE2\x8B\xA8","precsim;:\xE2\x89\xBE",
+"prime;:\xE2\x80\xB2","primes;:\xE2\x84\x99","prnE;:\xE2\xAA\xB5",
+"prnap;:\xE2\xAA\xB9","prnsim;:\xE2\x8B\xA8","prod;:\xE2\x88\x8F",
+"profalar;:\xE2\x8C\xAE","profline;:\xE2\x8C\x92","profsurf;:\xE2\x8C\x93",
+"prop;:\xE2\x88\x9D","propto;:\xE2\x88\x9D","prsim;:\xE2\x89\xBE",
+"prurel;:\xE2\x8A\xB0","pscr;:\xF0\x9D\x93\x85","psi;:\xCF\x88",
+"puncsp;:\xE2\x80\x88","qfr;:\xF0\x9D\x94\xAE","qint;:\xE2\xA8\x8C",
+"qopf;:\xF0\x9D\x95\xA2","qprime;:\xE2\x81\x97","qscr;:\xF0\x9D\x93\x86",
+"quaternions;:\xE2\x84\x8D","quatint;:\xE2\xA8\x96","quest;:?",
+"questeq;:\xE2\x89\x9F","quot:\"","quot;:\"","rAarr;:\xE2\x87\x9B",
+"rArr;:\xE2\x87\x92","rAtail;:\xE2\xA4\x9C","rBarr;:\xE2\xA4\x8F",
+"rHar;:\xE2\xA5\xA4","race;:\xE2\x88\xBD\xCC\xB1","racute;:\xC5\x95",
+"radic;:\xE2\x88\x9A","raemptyv;:\xE2\xA6\xB3","rang;:\xE2\x9F\xA9",
+"rangd;:\xE2\xA6\x92","range;:\xE2\xA6\xA5","rangle;:\xE2\x9F\xA9",
+"raquo:\xC2\xBB","raquo;:\xC2\xBB","rarr;:\xE2\x86\x92","rarrap;:\xE2\xA5\xB5",
+"rarrb;:\xE2\x87\xA5","rarrbfs;:\xE2\xA4\xA0","rarrc;:\xE2\xA4\xB3",
+"rarrfs;:\xE2\xA4\x9E","rarrhk;:\xE2\x86\xAA","rarrlp;:\xE2\x86\xAC",
+"rarrpl;:\xE2\xA5\x85","rarrsim;:\xE2\xA5\xB4","rarrtl;:\xE2\x86\xA3",
+"rarrw;:\xE2\x86\x9D","ratail;:\xE2\xA4\x9A","ratio;:\xE2\x88\xB6",
+"rationals;:\xE2\x84\x9A","rbarr;:\xE2\xA4\x8D","rbbrk;:\xE2\x9D\xB3",
+"rbrace;:}","rbrack;:]","rbrke;:\xE2\xA6\x8C","rbrksld;:\xE2\xA6\x8E",
+"rbrkslu;:\xE2\xA6\x90","rcaron;:\xC5\x99","rcedil;:\xC5\x97",
+"rceil;:\xE2\x8C\x89","rcub;:}","rcy;:\xD1\x80","rdca;:\xE2\xA4\xB7",
+"rdldhar;:\xE2\xA5\xA9","rdquo;:\xE2\x80\x9D","rdquor;:\xE2\x80\x9D",
+"rdsh;:\xE2\x86\xB3","real;:\xE2\x84\x9C","realine;:\xE2\x84\x9B",
+"realpart;:\xE2\x84\x9C","reals;:\xE2\x84\x9D","rect;:\xE2\x96\xAD",
+"reg:\xC2\xAE","reg;:\xC2\xAE","rfisht;:\xE2\xA5\xBD","rfloor;:\xE2\x8C\x8B",
+"rfr;:\xF0\x9D\x94\xAF","rhard;:\xE2\x87\x81","rharu;:\xE2\x87\x80",
+"rharul;:\xE2\xA5\xAC","rho;:\xCF\x81","rhov;:\xCF\xB1",
+"rightarrow;:\xE2\x86\x92","rightarrowtail;:\xE2\x86\xA3",
+"rightharpoondown;:\xE2\x87\x81","rightharpoonup;:\xE2\x87\x80",
+"rightleftarrows;:\xE2\x87\x84","rightleftharpoons;:\xE2\x87\x8C",
+"rightrightarrows;:\xE2\x87\x89","rightsquigarrow;:\xE2\x86\x9D",
+"rightthreetimes;:\xE2\x8B\x8C","ring;:\xCB\x9A","risingdotseq;:\xE2\x89\x93",
+"rlarr;:\xE2\x87\x84","rlhar;:\xE2\x87\x8C","rlm;:\xE2\x80\x8F",
+"rmoust;:\xE2\x8E\xB1","rmoustache;:\xE2\x8E\xB1","rnmid;:\xE2\xAB\xAE",
+"roang;:\xE2\x9F\xAD","roarr;:\xE2\x87\xBE","robrk;:\xE2\x9F\xA7",
+"ropar;:\xE2\xA6\x86","ropf;:\xF0\x9D\x95\xA3","roplus;:\xE2\xA8\xAE",
+"rotimes;:\xE2\xA8\xB5","rpar;:)","rpargt;:\xE2\xA6\x94",
+"rppolint;:\xE2\xA8\x92","rrarr;:\xE2\x87\x89","rsaquo;:\xE2\x80\xBA",
+"rscr;:\xF0\x9D\x93\x87","rsh;:\xE2\x86\xB1","rsqb;:]","rsquo;:\xE2\x80\x99",
+"rsquor;:\xE2\x80\x99","rthree;:\xE2\x8B\x8C","rtimes;:\xE2\x8B\x8A",
+"rtri;:\xE2\x96\xB9","rtrie;:\xE2\x8A\xB5","rtrif;:\xE2\x96\xB8",
+"rtriltri;:\xE2\xA7\x8E","ruluhar;:\xE2\xA5\xA8","rx;:\xE2\x84\x9E",
+"sacute;:\xC5\x9B","sbquo;:\xE2\x80\x9A","sc;:\xE2\x89\xBB","scE;:\xE2\xAA\xB4",
+"scap;:\xE2\xAA\xB8","scaron;:\xC5\xA1","sccue;:\xE2\x89\xBD",
+"sce;:\xE2\xAA\xB0","scedil;:\xC5\x9F","scirc;:\xC5\x9D","scnE;:\xE2\xAA\xB6",
+"scnap;:\xE2\xAA\xBA","scnsim;:\xE2\x8B\xA9","scpolint;:\xE2\xA8\x93",
+"scsim;:\xE2\x89\xBF","scy;:\xD1\x81","sdot;:\xE2\x8B\x85",
+"sdotb;:\xE2\x8A\xA1","sdote;:\xE2\xA9\xA6","seArr;:\xE2\x87\x98",
+"searhk;:\xE2\xA4\xA5","searr;:\xE2\x86\x98","searrow;:\xE2\x86\x98",
+"sect:\xC2\xA7","sect;:\xC2\xA7","semi;:;","seswar;:\xE2\xA4\xA9",
+"setminus;:\xE2\x88\x96","setmn;:\xE2\x88\x96","sext;:\xE2\x9C\xB6",
+"sfr;:\xF0\x9D\x94\xB0","sfrown;:\xE2\x8C\xA2","sharp;:\xE2\x99\xAF",
+"shchcy;:\xD1\x89","shcy;:\xD1\x88","shortmid;:\xE2\x88\xA3",
+"shortparallel;:\xE2\x88\xA5","shy:\xC2\xAD","shy;:\xC2\xAD","sigma;:\xCF\x83",
+"sigmaf;:\xCF\x82","sigmav;:\xCF\x82","sim;:\xE2\x88\xBC",
+"simdot;:\xE2\xA9\xAA","sime;:\xE2\x89\x83","simeq;:\xE2\x89\x83",
+"simg;:\xE2\xAA\x9E","simgE;:\xE2\xAA\xA0","siml;:\xE2\xAA\x9D",
+"simlE;:\xE2\xAA\x9F","simne;:\xE2\x89\x86","simplus;:\xE2\xA8\xA4",
+"simrarr;:\xE2\xA5\xB2","slarr;:\xE2\x86\x90","smallsetminus;:\xE2\x88\x96",
+"smashp;:\xE2\xA8\xB3","smeparsl;:\xE2\xA7\xA4","smid;:\xE2\x88\xA3",
+"smile;:\xE2\x8C\xA3","smt;:\xE2\xAA\xAA","smte;:\xE2\xAA\xAC",
+"smtes;:\xE2\xAA\xAC\xEF\xB8\x80","softcy;:\xD1\x8C","sol;:/",
+"solb;:\xE2\xA7\x84","solbar;:\xE2\x8C\xBF","sopf;:\xF0\x9D\x95\xA4",
+"spades;:\xE2\x99\xA0","spadesuit;:\xE2\x99\xA0","spar;:\xE2\x88\xA5",
+"sqcap;:\xE2\x8A\x93","sqcaps;:\xE2\x8A\x93\xEF\xB8\x80","sqcup;:\xE2\x8A\x94",
+"sqcups;:\xE2\x8A\x94\xEF\xB8\x80","sqsub;:\xE2\x8A\x8F","sqsube;:\xE2\x8A\x91",
+"sqsubset;:\xE2\x8A\x8F","sqsubseteq;:\xE2\x8A\x91","sqsup;:\xE2\x8A\x90",
+"sqsupe;:\xE2\x8A\x92","sqsupset;:\xE2\x8A\x90","sqsupseteq;:\xE2\x8A\x92",
+"squ;:\xE2\x96\xA1","square;:\xE2\x96\xA1","squarf;:\xE2\x96\xAA",
+"squf;:\xE2\x96\xAA","srarr;:\xE2\x86\x92","sscr;:\xF0\x9D\x93\x88",
+"ssetmn;:\xE2\x88\x96","ssmile;:\xE2\x8C\xA3","sstarf;:\xE2\x8B\x86",
+"star;:\xE2\x98\x86","starf;:\xE2\x98\x85","straightepsilon;:\xCF\xB5",
+"straightphi;:\xCF\x95","strns;:\xC2\xAF","sub;:\xE2\x8A\x82",
+"subE;:\xE2\xAB\x85","subdot;:\xE2\xAA\xBD","sube;:\xE2\x8A\x86",
+"subedot;:\xE2\xAB\x83","submult;:\xE2\xAB\x81","subnE;:\xE2\xAB\x8B",
+"subne;:\xE2\x8A\x8A","subplus;:\xE2\xAA\xBF","subrarr;:\xE2\xA5\xB9",
+"subset;:\xE2\x8A\x82","subseteq;:\xE2\x8A\x86","subseteqq;:\xE2\xAB\x85",
+"subsetneq;:\xE2\x8A\x8A","subsetneqq;:\xE2\xAB\x8B","subsim;:\xE2\xAB\x87",
+"subsub;:\xE2\xAB\x95","subsup;:\xE2\xAB\x93","succ;:\xE2\x89\xBB",
+"succapprox;:\xE2\xAA\xB8","succcurlyeq;:\xE2\x89\xBD","succeq;:\xE2\xAA\xB0",
+"succnapprox;:\xE2\xAA\xBA","succneqq;:\xE2\xAA\xB6","succnsim;:\xE2\x8B\xA9",
+"succsim;:\xE2\x89\xBF","sum;:\xE2\x88\x91","sung;:\xE2\x99\xAA",
+"sup1:\xC2\xB9","sup1;:\xC2\xB9","sup2:\xC2\xB2","sup2;:\xC2\xB2",
+"sup3:\xC2\xB3","sup3;:\xC2\xB3","sup;:\xE2\x8A\x83","supE;:\xE2\xAB\x86",
+"supdot;:\xE2\xAA\xBE","supdsub;:\xE2\xAB\x98","supe;:\xE2\x8A\x87",
+"supedot;:\xE2\xAB\x84","suphsol;:\xE2\x9F\x89","suphsub;:\xE2\xAB\x97",
+"suplarr;:\xE2\xA5\xBB","supmult;:\xE2\xAB\x82","supnE;:\xE2\xAB\x8C",
+"supne;:\xE2\x8A\x8B","supplus;:\xE2\xAB\x80","supset;:\xE2\x8A\x83",
+"supseteq;:\xE2\x8A\x87","supseteqq;:\xE2\xAB\x86","supsetneq;:\xE2\x8A\x8B",
+"supsetneqq;:\xE2\xAB\x8C","supsim;:\xE2\xAB\x88","supsub;:\xE2\xAB\x94",
+"supsup;:\xE2\xAB\x96","swArr;:\xE2\x87\x99","swarhk;:\xE2\xA4\xA6",
+"swarr;:\xE2\x86\x99","swarrow;:\xE2\x86\x99","swnwar;:\xE2\xA4\xAA",
+"szlig:\xC3\x9F","szlig;:\xC3\x9F","target;:\xE2\x8C\x96","tau;:\xCF\x84",
+"tbrk;:\xE2\x8E\xB4","tcaron;:\xC5\xA5","tcedil;:\xC5\xA3","tcy;:\xD1\x82",
+"tdot;:\xE2\x83\x9B","telrec;:\xE2\x8C\x95","tfr;:\xF0\x9D\x94\xB1",
+"there4;:\xE2\x88\xB4","therefore;:\xE2\x88\xB4","theta;:\xCE\xB8",
+"thetasym;:\xCF\x91","thetav;:\xCF\x91","thickapprox;:\xE2\x89\x88",
+"thicksim;:\xE2\x88\xBC","thinsp;:\xE2\x80\x89","thkap;:\xE2\x89\x88",
+"thksim;:\xE2\x88\xBC","thorn:\xC3\xBE","thorn;:\xC3\xBE","tilde;:\xCB\x9C",
+"times:\xC3\x97","times;:\xC3\x97","timesb;:\xE2\x8A\xA0",
+"timesbar;:\xE2\xA8\xB1","timesd;:\xE2\xA8\xB0","tint;:\xE2\x88\xAD",
+"toea;:\xE2\xA4\xA8","top;:\xE2\x8A\xA4","topbot;:\xE2\x8C\xB6",
+"topcir;:\xE2\xAB\xB1","topf;:\xF0\x9D\x95\xA5","topfork;:\xE2\xAB\x9A",
+"tosa;:\xE2\xA4\xA9","tprime;:\xE2\x80\xB4","trade;:\xE2\x84\xA2",
+"triangle;:\xE2\x96\xB5","triangledown;:\xE2\x96\xBF",
+"triangleleft;:\xE2\x97\x83","trianglelefteq;:\xE2\x8A\xB4",
+"triangleq;:\xE2\x89\x9C","triangleright;:\xE2\x96\xB9",
+"trianglerighteq;:\xE2\x8A\xB5","tridot;:\xE2\x97\xAC","trie;:\xE2\x89\x9C",
+"triminus;:\xE2\xA8\xBA","triplus;:\xE2\xA8\xB9","trisb;:\xE2\xA7\x8D",
+"tritime;:\xE2\xA8\xBB","trpezium;:\xE2\x8F\xA2","tscr;:\xF0\x9D\x93\x89",
+"tscy;:\xD1\x86","tshcy;:\xD1\x9B","tstrok;:\xC5\xA7","twixt;:\xE2\x89\xAC",
+"twoheadleftarrow;:\xE2\x86\x9E","twoheadrightarrow;:\xE2\x86\xA0",
+"uArr;:\xE2\x87\x91","uHar;:\xE2\xA5\xA3","uacute:\xC3\xBA","uacute;:\xC3\xBA",
+"uarr;:\xE2\x86\x91","ubrcy;:\xD1\x9E","ubreve;:\xC5\xAD","ucirc:\xC3\xBB",
+"ucirc;:\xC3\xBB","ucy;:\xD1\x83","udarr;:\xE2\x87\x85","udblac;:\xC5\xB1",
+"udhar;:\xE2\xA5\xAE","ufisht;:\xE2\xA5\xBE","ufr;:\xF0\x9D\x94\xB2",
+"ugrave:\xC3\xB9","ugrave;:\xC3\xB9","uharl;:\xE2\x86\xBF",
+"uharr;:\xE2\x86\xBE","uhblk;:\xE2\x96\x80","ulcorn;:\xE2\x8C\x9C",
+"ulcorner;:\xE2\x8C\x9C","ulcrop;:\xE2\x8C\x8F","ultri;:\xE2\x97\xB8",
+"umacr;:\xC5\xAB","uml:\xC2\xA8","uml;:\xC2\xA8","uogon;:\xC5\xB3",
+"uopf;:\xF0\x9D\x95\xA6","uparrow;:\xE2\x86\x91","updownarrow;:\xE2\x86\x95",
+"upharpoonleft;:\xE2\x86\xBF","upharpoonright;:\xE2\x86\xBE",
+"uplus;:\xE2\x8A\x8E","upsi;:\xCF\x85","upsih;:\xCF\x92","upsilon;:\xCF\x85",
+"upuparrows;:\xE2\x87\x88","urcorn;:\xE2\x8C\x9D","urcorner;:\xE2\x8C\x9D",
+"urcrop;:\xE2\x8C\x8E","uring;:\xC5\xAF","urtri;:\xE2\x97\xB9",
+"uscr;:\xF0\x9D\x93\x8A","utdot;:\xE2\x8B\xB0","utilde;:\xC5\xA9",
+"utri;:\xE2\x96\xB5","utrif;:\xE2\x96\xB4","uuarr;:\xE2\x87\x88",
+"uuml:\xC3\xBC","uuml;:\xC3\xBC","uwangle;:\xE2\xA6\xA7","vArr;:\xE2\x87\x95",
+"vBar;:\xE2\xAB\xA8","vBarv;:\xE2\xAB\xA9","vDash;:\xE2\x8A\xA8",
+"vangrt;:\xE2\xA6\x9C","varepsilon;:\xCF\xB5","varkappa;:\xCF\xB0",
+"varnothing;:\xE2\x88\x85","varphi;:\xCF\x95","varpi;:\xCF\x96",
+"varpropto;:\xE2\x88\x9D","varr;:\xE2\x86\x95","varrho;:\xCF\xB1",
+"varsigma;:\xCF\x82","varsubsetneq;:\xE2\x8A\x8A\xEF\xB8\x80",
+"varsubsetneqq;:\xE2\xAB\x8B\xEF\xB8\x80",
+"varsupsetneq;:\xE2\x8A\x8B\xEF\xB8\x80",
+"varsupsetneqq;:\xE2\xAB\x8C\xEF\xB8\x80","vartheta;:\xCF\x91",
+"vartriangleleft;:\xE2\x8A\xB2","vartriangleright;:\xE2\x8A\xB3",
+"vcy;:\xD0\xB2","vdash;:\xE2\x8A\xA2","vee;:\xE2\x88\xA8",
+"veebar;:\xE2\x8A\xBB","veeeq;:\xE2\x89\x9A","vellip;:\xE2\x8B\xAE","verbar;:|",
+"vert;:|","vfr;:\xF0\x9D\x94\xB3","vltri;:\xE2\x8A\xB2",
+"vnsub;:\xE2\x8A\x82\xE2\x83\x92","vnsup;:\xE2\x8A\x83\xE2\x83\x92",
+"vopf;:\xF0\x9D\x95\xA7","vprop;:\xE2\x88\x9D","vrtri;:\xE2\x8A\xB3",
+"vscr;:\xF0\x9D\x93\x8B","vsubnE;:\xE2\xAB\x8B\xEF\xB8\x80",
+"vsubne;:\xE2\x8A\x8A\xEF\xB8\x80","vsupnE;:\xE2\xAB\x8C\xEF\xB8\x80",
+"vsupne;:\xE2\x8A\x8B\xEF\xB8\x80","vzigzag;:\xE2\xA6\x9A","wcirc;:\xC5\xB5",
+"wedbar;:\xE2\xA9\x9F","wedge;:\xE2\x88\xA7","wedgeq;:\xE2\x89\x99",
+"weierp;:\xE2\x84\x98","wfr;:\xF0\x9D\x94\xB4","wopf;:\xF0\x9D\x95\xA8",
+"wp;:\xE2\x84\x98","wr;:\xE2\x89\x80","wreath;:\xE2\x89\x80",
+"wscr;:\xF0\x9D\x93\x8C","xcap;:\xE2\x8B\x82","xcirc;:\xE2\x97\xAF",
+"xcup;:\xE2\x8B\x83","xdtri;:\xE2\x96\xBD","xfr;:\xF0\x9D\x94\xB5",
+"xhArr;:\xE2\x9F\xBA","xharr;:\xE2\x9F\xB7","xi;:\xCE\xBE",
+"xlArr;:\xE2\x9F\xB8","xlarr;:\xE2\x9F\xB5","xmap;:\xE2\x9F\xBC",
+"xnis;:\xE2\x8B\xBB","xodot;:\xE2\xA8\x80","xopf;:\xF0\x9D\x95\xA9",
+"xoplus;:\xE2\xA8\x81","xotime;:\xE2\xA8\x82","xrArr;:\xE2\x9F\xB9",
+"xrarr;:\xE2\x9F\xB6","xscr;:\xF0\x9D\x93\x8D","xsqcup;:\xE2\xA8\x86",
+"xuplus;:\xE2\xA8\x84","xutri;:\xE2\x96\xB3","xvee;:\xE2\x8B\x81",
+"xwedge;:\xE2\x8B\x80","yacute:\xC3\xBD","yacute;:\xC3\xBD","yacy;:\xD1\x8F",
+"ycirc;:\xC5\xB7","ycy;:\xD1\x8B","yen:\xC2\xA5","yen;:\xC2\xA5",
+"yfr;:\xF0\x9D\x94\xB6","yicy;:\xD1\x97","yopf;:\xF0\x9D\x95\xAA",
+"yscr;:\xF0\x9D\x93\x8E","yucy;:\xD1\x8E","yuml:\xC3\xBF","yuml;:\xC3\xBF",
+"zacute;:\xC5\xBA","zcaron;:\xC5\xBE","zcy;:\xD0\xB7","zdot;:\xC5\xBC",
+"zeetrf;:\xE2\x84\xA8","zeta;:\xCE\xB6","zfr;:\xF0\x9D\x94\xB7",
+"zhcy;:\xD0\xB6","zigrarr;:\xE2\x87\x9D","zopf;:\xF0\x9D\x95\xAB",
+"zscr;:\xF0\x9D\x93\x8F","zwj;:\xE2\x80\x8D","zwnj;:\xE2\x80\x8C",
+]
+
+const charMap*: array[char, int] = [
+-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
+-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
+-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,26,38,74,128,158,166,188,200,229,236,244,
+304,313,385,414,433,438,483,523,546,586,603,608,612,623,633,-1,-1,-1,-1,-1,-1,
+702,818,917,983,1050,1089,1149,1177,1233,1241,1251,1405,1445,1613,1674,1743,
+1754,1858,2016,2074,2126,2168,2179,2203,2217,2230,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
+-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
+-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
+-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
+-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
+-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
+]
diff --git a/lib/chame0/chame/htmlparser.nim b/lib/chame0/chame/htmlparser.nim
new file mode 100644
index 00000000..87ab81f4
--- /dev/null
+++ b/lib/chame0/chame/htmlparser.nim
@@ -0,0 +1,2727 @@
+import std/macros
+import std/options
+import std/strutils
+import std/tables
+
+import dombuilder
+import htmltokenizer
+import tags
+import tokstate
+
+# Generics break without exporting macros. Maybe a compiler bug?
+export macros
+
+# Export these so that htmlparseriface works seamlessly.
+export dombuilder
+export options
+export tags
+
+# Export tokstate too; it is needed for fragment parsing.
+export tokstate
+
+# Heavily inspired by html5ever's TreeSink design.
+type
+ HTML5ParserOpts*[Handle, Atom] = object
+ isIframeSrcdoc*: bool
+ ## Is the document an iframe srcdoc?
+ scripting*: bool
+ ## Is scripting enabled for this document?
+ ctx*: Option[OpenElementInit[Handle, Atom]]
+ ## Context element for fragment parsing. When set to some Handle,
+ ## the fragment case is used while parsing.
+ ##
+ ## `token` must be a valid starting token for this element.
+ initialTokenizerState*: TokenizerState
+ ## The initial tokenizer state; by default, this is DATA.
+ openElementsInit*: seq[OpenElementInit[Handle, Atom]]
+ ## Initial state of the stack of open elements. By default, the stack
+ ## starts out empty.
+ ## Note: if this is initialized to a non-empty sequence, the parser will
+ ## start by resetting the insertion mode appropriately.
+ formInit*: Option[Handle]
+ ## Initial state of the parser's form pointer.
+ pushInTemplate*: bool
+ ## When set to true, the "in template" insertion mode is pushed to the
+ ## stack of template insertion modes on parser start.
+
+ OpenElement*[Handle, Atom] = tuple
+ element: Handle
+ token: Token[Atom] ## the element's start tag token; must not be nil.
+
+ OpenElementInit*[Handle, Atom] = tuple
+ element: Handle
+ startTagName: Atom ## the element's start tag token's name.
+
+type
+ QualifiedName[Atom] = tuple
+ prefix: NamespacePrefix
+ namespace: Namespace
+ localName: Atom
+
+ HTML5Parser*[Handle, Atom] = object
+ quirksMode: QuirksMode
+ dombuilder: DOMBuilder[Handle, Atom]
+ opts: HTML5ParserOpts[Handle, Atom]
+ ctx: Option[OpenElement[Handle, Atom]]
+ openElements: seq[OpenElement[Handle, Atom]]
+ insertionMode: InsertionMode
+ oldInsertionMode: InsertionMode
+ templateModes: seq[InsertionMode]
+ head: Option[OpenElement[Handle, Atom]]
+ tokenizer: Tokenizer[Handle, Atom]
+ form: Option[Handle]
+ fosterParenting: bool
+ # Handle is an element. nil => marker
+ activeFormatting: seq[(Option[Handle], Token[Atom])]
+ framesetOk: bool
+ ignoreLF: bool
+ pendingTableChars: string
+ pendingTableCharsWhitespace: bool
+ caseTable: Table[Atom, Atom]
+ adjustedTable: Table[Atom, Atom]
+ foreignTable: Table[Atom, QualifiedName[Atom]]
+
+ AdjustedInsertionLocation[Handle] = tuple[
+ inside: Handle,
+ before: Option[Handle]
+ ]
+
+# 13.2.4.1
+ InsertionMode = enum
+ INITIAL, BEFORE_HTML, BEFORE_HEAD, IN_HEAD, IN_HEAD_NOSCRIPT, AFTER_HEAD,
+ IN_BODY, TEXT, IN_TABLE, IN_TABLE_TEXT, IN_CAPTION, IN_COLUMN_GROUP,
+ IN_TABLE_BODY, IN_ROW, IN_CELL, IN_SELECT, IN_SELECT_IN_TABLE, IN_TEMPLATE,
+ AFTER_BODY, IN_FRAMESET, AFTER_FRAMESET, AFTER_AFTER_BODY,
+ AFTER_AFTER_FRAMESET
+
+type ParseResult* = enum
+ ## Result of parsing the passed chunk.
+ ## PRES_CONTINUE is returned when it is OK to continue parsing.
+ ##
+ ## PRES_STOP is returned when the parser has been stopped from
+ ## setEncodingImpl.
+ ##
+ ## PRES_SCRIPT is returned when a script end tag is encountered. For
+ ## implementations that do not support scripting, this can be treated
+ ## equivalently to PRES_CONTINUE.
+ ##
+ ## Implementations that *do* support scripting and implement `document.write`
+ ## can instead use PRES_SCRIPT to process string injected into the input
+ ## stream by `document.write` before continuing with parsing from the
+ ## network stream. In this case, script elements should be stored in e.g. the
+ ## DOM builder from `elementPoppedImpl`, and processed accordingly after
+ ## PRES_SCRIPT has been returned.
+ PRES_CONTINUE
+ PRES_STOP
+ PRES_SCRIPT
+
+# DOMBuilder interface functions
+proc strToAtom[Handle, Atom](parser: HTML5Parser[Handle, Atom], s: string):
+ Atom =
+ mixin strToAtomImpl
+ return parser.dombuilder.strToAtomImpl(s)
+
+proc tagTypeToAtom[Handle, Atom](parser: HTML5Parser[Handle, Atom],
+ tagType: TagType): Atom =
+ mixin tagTypeToAtomImpl
+ return parser.dombuilder.tagTypeToAtomImpl(tagType)
+
+# Declared as extern, because Nim 1.6.10 does not recognize it in macros
+# otherwise.
+proc atomToTagType*[Handle, Atom](parser: HTML5Parser[Handle, Atom],
+ atom: Atom): TagType =
+ mixin atomToTagTypeImpl
+ return parser.dombuilder.atomToTagTypeImpl(atom)
+
+proc setQuirksMode[Handle, Atom](parser: var HTML5Parser[Handle, Atom],
+ mode: QuirksMode) =
+ mixin setQuirksModeImpl
+ parser.quirksMode = mode
+ when compiles(parser.dombuilder.setQuirksModeImpl(mode)):
+ parser.dombuilder.setQuirksModeImpl(mode)
+
+proc setEncoding(parser: var HTML5Parser, cs: string): SetEncodingResult =
+ mixin setEncodingImpl
+ when compiles(parser.dombuilder.setEncodingImpl(cs)):
+ return parser.dombuilder.setEncodingImpl(cs)
+ else:
+ return SET_ENCODING_CONTINUE
+
+proc getDocument[Handle, Atom](parser: HTML5Parser[Handle, Atom]): Handle =
+ mixin getDocumentImpl
+ return parser.dombuilder.getDocumentImpl()
+
+proc getParentNode[Handle, Atom](parser: HTML5Parser[Handle, Atom],
+ handle: Handle): Option[Handle] =
+ mixin getParentNodeImpl
+ return parser.dombuilder.getParentNodeImpl(handle)
+
+proc getLocalName[Handle, Atom](parser: HTML5Parser[Handle, Atom],
+ handle: Handle): Atom =
+ mixin getLocalNameImpl
+ return parser.dombuilder.getLocalNameImpl(handle)
+
+proc getNamespace[Handle, Atom](parser: HTML5Parser[Handle, Atom],
+ handle: Handle): Namespace =
+ mixin getNamespaceImpl
+ return parser.dombuilder.getNamespaceImpl(handle)
+
+proc getTemplateContent[Handle, Atom](parser: HTML5Parser[Handle, Atom],
+ handle: Handle): Handle =
+ mixin getTemplateContentImpl
+ return parser.dombuilder.getTemplateContentImpl(handle)
+
+proc getTagType[Handle, Atom](parser: HTML5Parser[Handle, Atom],
+ handle: Handle): TagType =
+ if parser.getNamespace(handle) != Namespace.HTML:
+ return TAG_UNKNOWN
+ return parser.atomToTagType(parser.getLocalName(handle))
+
+proc createHTMLElement[Handle, Atom](parser: HTML5Parser[Handle, Atom]):
+ Handle =
+ mixin createHTMLElementImpl
+ return parser.dombuilder.createHTMLElementImpl()
+
+proc createComment[Handle, Atom](parser: HTML5Parser[Handle, Atom],
+ text: string): Handle =
+ mixin createCommentImpl
+ return parser.dombuilder.createCommentImpl(text)
+
+proc createDocumentType[Handle, Atom](parser: HTML5Parser[Handle, Atom],
+ name, publicId, systemId: string): Handle =
+ mixin createDocumentTypeImpl
+ return parser.dombuilder.createDocumentTypeImpl(name, publicId, systemId)
+
+proc insertBefore[Handle, Atom](parser: HTML5Parser[Handle, Atom],
+ parent, child: Handle, before: Option[Handle]) =
+ mixin insertBeforeImpl
+ parser.dombuilder.insertBeforeImpl(parent, child, before)
+
+proc insertText[Handle, Atom](parser: HTML5Parser[Handle, Atom], parent: Handle,
+ text: string, before: Option[Handle]) =
+ mixin insertTextImpl
+ parser.dombuilder.insertTextImpl(parent, text, before)
+
+proc remove[Handle, Atom](parser: HTML5Parser[Handle, Atom], child: Handle) =
+ mixin removeImpl
+ parser.dombuilder.removeImpl(child)
+
+proc moveChildren[Handle, Atom](parser: HTML5Parser[Handle, Atom], handleFrom,
+ handleTo: Handle) =
+ mixin moveChildrenImpl
+ parser.dombuilder.moveChildrenImpl(handleFrom, handleTo)
+
+proc addAttrsIfMissing[Handle, Atom](parser: HTML5Parser[Handle, Atom],
+ element: Handle, attrs: Table[Atom, string]) =
+ mixin addAttrsIfMissingImpl
+ parser.dombuilder.addAttrsIfMissingImpl(element, attrs)
+
+proc setScriptAlreadyStarted[Handle, Atom](parser: HTML5Parser[Handle, Atom],
+ script: Handle) =
+ mixin setScriptAlreadyStartedImpl
+ when compiles(parser.dombuilder.setScriptAlreadyStartedImpl(script)):
+ parser.dombuilder.setScriptAlreadyStartedImpl(script)
+
+proc associateWithForm[Handle, Atom](parser: HTML5Parser[Handle, Atom],
+ element, form, intendedParent: Handle) =
+ mixin associateWithFormImpl
+ when compiles(parser.dombuilder.associateWithFormImpl(element, form,
+ intendedParent)):
+ parser.dombuilder.associateWithFormImpl(element, form, intendedParent)
+
+# Parser
+func fragment(parser: HTML5Parser): bool =
+ return parser.ctx.isSome
+
+# https://html.spec.whatwg.org/multipage/parsing.html#reset-the-insertion-mode-appropriately
+proc resetInsertionMode(parser: var HTML5Parser) =
+ template switch_insertion_mode_and_return(mode: InsertionMode) =
+ parser.insertionMode = mode
+ return
+ for i in countdown(parser.openElements.high, 0):
+ var node = parser.openElements[i]
+ let last = i == 0
+ if parser.fragment:
+ node = parser.ctx.get
+ let tagType = parser.getTagType(node.element)
+ case tagType
+ of TAG_SELECT:
+ if not last:
+ for j in countdown(parser.openElements.high, 1):
+ let ancestor = parser.openElements[j].element
+ case parser.getTagType(ancestor)
+ of TAG_TEMPLATE: break
+ of TAG_TABLE: switch_insertion_mode_and_return IN_SELECT_IN_TABLE
+ else: discard
+ switch_insertion_mode_and_return IN_SELECT
+ of TAG_TD, TAG_TH:
+ if not last:
+ switch_insertion_mode_and_return IN_CELL
+ of TAG_TR: switch_insertion_mode_and_return IN_ROW
+ of TAG_TBODY, TAG_THEAD, TAG_TFOOT:
+ switch_insertion_mode_and_return IN_TABLE_BODY
+ of TAG_CAPTION:
+ switch_insertion_mode_and_return IN_CAPTION
+ of TAG_COLGROUP: switch_insertion_mode_and_return IN_COLUMN_GROUP
+ of TAG_TABLE: switch_insertion_mode_and_return IN_TABLE
+ of TAG_TEMPLATE: switch_insertion_mode_and_return parser.templateModes[^1]
+ of TAG_HEAD:
+ if not last:
+ switch_insertion_mode_and_return IN_HEAD
+ of TAG_BODY: switch_insertion_mode_and_return IN_BODY
+ of TAG_FRAMESET: switch_insertion_mode_and_return IN_FRAMESET
+ of TAG_HTML:
+ if parser.head.isNone:
+ switch_insertion_mode_and_return BEFORE_HEAD
+ else:
+ switch_insertion_mode_and_return AFTER_HEAD
+ else: discard
+ if last:
+ switch_insertion_mode_and_return IN_BODY
+
+func currentNodeToken[Handle, Atom](parser: HTML5Parser[Handle, Atom]):
+ OpenElement[Handle, Atom] =
+ return parser.openElements[^1]
+
+func currentNode[Handle, Atom](parser: HTML5Parser[Handle, Atom]): Handle =
+ return parser.currentNodeToken.element
+
+func currentToken[Handle, Atom](parser: HTML5Parser[Handle, Atom]):
+ Token[Atom] =
+ return parser.currentNodeToken.token
+
+func adjustedCurrentNodeToken[Handle, Atom](parser: HTML5Parser[Handle, Atom]):
+ OpenElement[Handle, Atom] =
+ if parser.fragment and parser.openElements.len == 1:
+ return parser.ctx.get
+ else:
+ return parser.currentNodeToken
+
+func adjustedCurrentNode[Handle, Atom](parser: HTML5Parser[Handle, Atom]):
+ Handle =
+ return parser.adjustedCurrentNodeToken.element
+
+proc lastElementOfTag[Handle, Atom](parser: HTML5Parser[Handle, Atom],
+ tagType: TagType): tuple[element: Option[Handle], pos: int] =
+ for i in countdown(parser.openElements.high, 0):
+ let element = parser.openElements[i].element
+ if parser.getTagType(element) == tagType:
+ return (some(element), i)
+ return (none(Handle), -1)
+
+func last_child_of[Handle](n: Handle): AdjustedInsertionLocation[Handle] =
+ (n, none(Handle))
+
+func last_child_of[Handle, Atom](n: OpenElement[Handle, Atom]):
+ AdjustedInsertionLocation[Handle] =
+ last_child_of(n.element)
+
+# https://html.spec.whatwg.org/multipage/#appropriate-place-for-inserting-a-node
+proc appropriatePlaceForInsert[Handle, Atom](parser: HTML5Parser[Handle, Atom],
+ target: Handle): AdjustedInsertionLocation[Handle] =
+ assert parser.getTagType(parser.openElements[0].element) == TAG_HTML
+ let targetTagType = parser.getTagType(target)
+ const FosterTagTypes = {TAG_TABLE, TAG_TBODY, TAG_TFOOT, TAG_THEAD, TAG_TR}
+ if parser.fosterParenting and targetTagType in FosterTagTypes:
+ let lastTemplate = parser.lastElementOfTag(TAG_TEMPLATE)
+ let lastTable = parser.lastElementOfTag(TAG_TABLE)
+ if lastTemplate.element.isSome and
+ (lastTable.element.isNone or lastTable.pos < lastTemplate.pos):
+ let content = parser.getTemplateContent(lastTemplate.element.get)
+ return last_child_of(content)
+ if lastTable.element.isNone:
+ return last_child_of(parser.openElements[0].element)
+ let parentNode = parser.getParentNode(lastTable.element.get)
+ if parentNode.isSome:
+ return (parentNode.get, lastTable.element)
+ let previousElement = parser.openElements[lastTable.pos - 1]
+ result = last_child_of(previousElement.element)
+ else:
+ result = last_child_of(target)
+ if parser.getTagType(result.inside) == TAG_TEMPLATE:
+ result = (parser.getTemplateContent(result.inside), none(Handle))
+
+proc appropriatePlaceForInsert[Handle, Atom](parser: HTML5Parser[Handle, Atom]):
+ AdjustedInsertionLocation[Handle] =
+ parser.appropriatePlaceForInsert(parser.currentNode)
+
+proc hasElement[Handle, Atom](parser: HTML5Parser[Handle, Atom],
+ tags: set[TagType]): bool =
+ for (element, _) in parser.openElements:
+ if parser.getTagType(element) in tags:
+ return true
+ return false
+
+proc hasElement[Handle, Atom](parser: HTML5Parser[Handle, Atom],
+ tag: TagType): bool =
+ return parser.hasElement({tag})
+
+const Scope = {
+ TAG_APPLET, TAG_CAPTION, TAG_HTML, TAG_TABLE, TAG_TD, TAG_TH, TAG_MARQUEE,
+ TAG_OBJECT, TAG_TEMPLATE # (+ SVG, MathML)
+}
+
+proc hasElementInScopeWithXML[Handle, Atom](parser: HTML5Parser[Handle, Atom],
+ target: Handle, list: set[TagType]): bool =
+ for i in countdown(parser.openElements.high, 0):
+ let element = parser.openElements[i].element
+ if element == target:
+ return true
+ let localName = parser.getLocalName(element)
+ let tagType = parser.atomToTagType(localName)
+ case parser.getNamespace(element)
+ of Namespace.HTML:
+ {.linearScanEnd.}
+ if tagType in list:
+ return false
+ of Namespace.MATHML:
+ const elements = {
+ TAG_MI, TAG_MO, TAG_MN, TAG_MS, TAG_MTEXT, TAG_ANNOTATION_XML
+ }
+ if tagType in elements:
+ return false
+ of Namespace.SVG:
+ const elements = {TAG_FOREIGN_OBJECT, TAG_DESC, TAG_TITLE}
+ if tagType in elements:
+ return false
+ else: discard
+ return false
+
+proc hasElementInScopeWithXML[Handle, Atom](parser: HTML5Parser[Handle, Atom],
+ target: set[TagType], list: set[TagType]): bool =
+ for i in countdown(parser.openElements.high, 0):
+ let element = parser.openElements[i].element
+ let tagType = parser.atomToTagType(parser.getLocalName(element))
+ case parser.getNamespace(element)
+ of Namespace.HTML:
+ if tagType in target:
+ return true
+ if tagType in list:
+ return false
+ of Namespace.MATHML:
+ const elements = {
+ TAG_MI, TAG_MO, TAG_MN, TAG_MS, TAG_MTEXT, TAG_ANNOTATION_XML
+ }
+ if tagType in elements:
+ return false
+ of Namespace.SVG:
+ const elements = {TAG_FOREIGN_OBJECT, TAG_DESC, TAG_TITLE}
+ if tagType in elements:
+ return false
+ else: discard
+ return false
+
+proc hasElementInScope[Handle, Atom](parser: HTML5Parser[Handle, Atom],
+ target: Handle): bool =
+ return parser.hasElementInScopeWithXML(target, Scope)
+
+proc hasElementInScope[Handle, Atom](parser: HTML5Parser[Handle, Atom],
+ target: set[TagType]): bool =
+ return parser.hasElementInScopeWithXML(target, Scope)
+
+proc hasElementInScope[Handle, Atom](parser: HTML5Parser[Handle, Atom],
+ target: TagType): bool =
+ return parser.hasElementInScope({target})
+
+proc hasElementInScope[Handle, Atom](parser: HTML5Parser[Handle, Atom],
+ localName: Atom): bool =
+ let target = parser.atomToTagType(localName)
+ return parser.hasElementInScope(target)
+
+proc hasElementInListItemScope[Handle, Atom](parser: HTML5Parser[Handle, Atom],
+ target: TagType): bool =
+ const ListItemScope = Scope + {TAG_OL, TAG_UL}
+ return parser.hasElementInScopeWithXML({target}, ListItemScope)
+
+proc hasElementInButtonScope[Handle, Atom](parser: HTML5Parser[Handle, Atom],
+ target: TagType): bool =
+ const ButtonScope = Scope + {TAG_BUTTON}
+ return parser.hasElementInScopeWithXML({target}, ButtonScope)
+
+# Note: these do not include the "Scope" tags.
+proc hasElementInSpecificScope[Handle, Atom](parser: HTML5Parser[Handle, Atom],
+ target: Handle, list: set[TagType]): bool =
+ for i in countdown(parser.openElements.high, 0):
+ let element = parser.openElements[i].element
+ if element == target:
+ return true
+ if parser.getTagType(element) in list:
+ return false
+ assert false
+ return false
+
+proc hasElementInSpecificScope[Handle, Atom](parser: HTML5Parser[Handle, Atom],
+ target: set[TagType], list: set[TagType]): bool =
+ for i in countdown(parser.openElements.high, 0):
+ let tagType = parser.getTagType(parser.openElements[i].element)
+ if tagType in target:
+ return true
+ if tagType in list:
+ return false
+ assert false
+ return false
+
+const TableScope = {TAG_HTML, TAG_TABLE, TAG_TEMPLATE}
+proc hasElementInTableScope[Handle, Atom](parser: HTML5Parser[Handle, Atom],
+ target: TagType): bool =
+ return parser.hasElementInSpecificScope({target}, TableScope)
+
+proc hasElementInTableScope[Handle, Atom](parser: HTML5Parser[Handle, Atom],
+ target: set[TagType]): bool =
+ return parser.hasElementInSpecificScope(target, TableScope)
+
+proc hasElementInSelectScope[Handle, Atom](parser: HTML5Parser[Handle, Atom],
+ target: TagType): bool =
+ for i in countdown(parser.openElements.high, 0):
+ let tagType = parser.getTagType(parser.openElements[i].element)
+ if tagType == target:
+ return true
+ if tagType notin {TAG_OPTION, TAG_OPTGROUP}:
+ return false
+ assert false
+ return false
+
+proc createElementForToken[Handle, Atom](parser: HTML5Parser[Handle, Atom],
+ localName: Atom, namespace: Namespace, intendedParent: Handle,
+ htmlAttrs: Table[Atom, string], xmlAttrs: seq[ParsedAttr[Atom]]): Handle =
+ mixin createElementForTokenImpl
+ let element = parser.dombuilder.createElementForTokenImpl(
+ localName, namespace, intendedParent, htmlAttrs, xmlAttrs
+ )
+ let tagType = parser.atomToTagType(localName)
+ if namespace == Namespace.HTML and tagType in FormAssociatedElements and
+ parser.form.isSome and not parser.hasElement(TAG_TEMPLATE) and
+ (tagType notin ListedElements or
+ parser.tagTypeToAtom(TAG_FORM) notin htmlAttrs):
+ parser.associateWithForm(element, parser.form.get, intendedParent)
+ return element
+
+proc createElementForToken[Handle, Atom](parser: HTML5Parser[Handle, Atom],
+ token: Token, namespace: Namespace, intendedParent: Handle): Handle =
+ # attrs not adjusted
+ return parser.createElementForToken(token.tagname, namespace, intendedParent,
+ token.attrs, @[])
+
+proc createHTMLElementForToken[Handle, Atom](parser: HTML5Parser[Handle, Atom],
+ token: Token, intendedParent: Handle): Handle =
+ # attrs not adjusted
+ return parser.createElementForToken(
+ token.tagname, Namespace.HTML, intendedParent, token.attrs, @[]
+ )
+
+proc pushElement[Handle, Atom](parser: var HTML5Parser[Handle, Atom],
+ node: Handle, token: Token[Atom]) =
+ parser.openElements.add((node, token))
+ let node = parser.adjustedCurrentNode()
+ parser.tokenizer.hasnonhtml = parser.getNamespace(node) != Namespace.HTML
+
+proc popElement[Handle, Atom](parser: var HTML5Parser[Handle, Atom]): Handle =
+ mixin elementPoppedImpl
+ result = parser.openElements.pop().element
+ when compiles(parser.dombuilder.elementPoppedImpl(result)):
+ parser.dombuilder.elementPoppedImpl(result)
+ if parser.openElements.len == 0:
+ parser.tokenizer.hasnonhtml = false
+ else:
+ let node = parser.adjustedCurrentNode()
+ parser.tokenizer.hasnonhtml = parser.getNamespace(node) != Namespace.HTML
+
+template pop_current_node = discard parser.popElement()
+
+proc insert[Handle, Atom](parser: HTML5Parser[Handle, Atom],
+ location: AdjustedInsertionLocation[Handle], node: Handle) =
+ parser.insertBefore(location.inside, node, location.before)
+
+proc append[Handle, Atom](parser: HTML5Parser[Handle, Atom], parent, node: Handle) =
+ parser.insertBefore(parent, node, none(Handle))
+
+proc insertForeignElement[Handle, Atom](parser: var HTML5Parser[Handle, Atom],
+ token: Token, localName: Atom, namespace: Namespace, stackOnly: bool,
+ xmlAttrs: seq[ParsedAttr[Atom]]): Handle =
+ let location = parser.appropriatePlaceForInsert()
+ let parent = location.inside
+ let element = parser.createElementForToken(localName, namespace, parent,
+ token.attrs, xmlAttrs)
+ if not stackOnly:
+ parser.insert(location, element)
+ parser.pushElement(element, token)
+ return element
+
+proc insertForeignElement[Handle, Atom](parser: var HTML5Parser[Handle, Atom],
+ token: Token, namespace: Namespace, stackOnly: bool): Handle =
+ parser.insertForeignElement(token, token.tagname, namespace, stackOnly, @[])
+
+proc insertHTMLElement[Handle, Atom](parser: var HTML5Parser[Handle, Atom],
+ token: Token): Handle =
+ return parser.insertForeignElement(token, Namespace.HTML, false)
+
+# Note: adjustMathMLAttributes and adjustSVGAttributes both include the "adjust
+# foreign attributes" step as well.
+proc adjustMathMLAttributes[Handle, Atom](parser: var HTML5Parser[Handle, Atom],
+ htmlAttrs: var Table[Atom, string], xmlAttrs: var seq[ParsedAttr[Atom]]) =
+ var deleted: seq[Atom] = @[]
+ for k, v in htmlAttrs.mpairs:
+ parser.foreignTable.withValue(k, p):
+ xmlAttrs.add((p[].prefix, p[].namespace, p[].localName, v))
+ deleted.add(k)
+ var v: string = ""
+ if htmlAttrs.pop(parser.tagTypeToAtom(TAG_DEFINITION_URL), v):
+ htmlAttrs[parser.strToAtom("definitionURL")] = v
+ for k in deleted:
+ htmlAttrs.del(k)
+
+proc adjustSVGAttributes[Handle, Atom](parser: var HTML5Parser[Handle, Atom],
+ htmlAttrs: var Table[Atom, string], xmlAttrs: var seq[ParsedAttr[Atom]]) =
+ var deleted: seq[Atom] = @[]
+ for k, v in htmlAttrs:
+ parser.foreignTable.withValue(k, p):
+ xmlAttrs.add((p[].prefix, p[].namespace, p[].localName, v))
+ deleted.add(k)
+ for k, ak in parser.adjustedTable:
+ var v: string = ""
+ if htmlAttrs.pop(k, v):
+ htmlAttrs[ak] = v
+ for k in deleted:
+ htmlAttrs.del(k)
+
+proc insertCharacter(parser: var HTML5Parser, data: string) =
+ let location = parser.appropriatePlaceForInsert()
+ if location.inside == parser.getDocument():
+ return
+ parser.insertText(location.inside, data, location.before)
+
+proc insertComment[Handle, Atom](parser: var HTML5Parser[Handle, Atom],
+ token: Token, position: AdjustedInsertionLocation[Handle]) =
+ let comment = parser.createComment(token.data)
+ parser.insert(position, comment)
+
+proc insertComment(parser: var HTML5Parser, token: Token) =
+ let position = parser.appropriatePlaceForInsert()
+ parser.insertComment(token, position)
+
+const PublicIdentifierEquals = [
+ "-//W3O//DTD W3 HTML Strict 3.0//EN//",
+ "-/W3C/DTD HTML 4.0 Transitional/EN",
+ "HTML"
+]
+
+const PublicIdentifierStartsWith = [
+ "+//Silmaril//dtd html Pro v0r11 19970101//",
+ "-//AS//DTD HTML 3.0 asWedit + extensions//",
+ "-//AdvaSoft Ltd//DTD HTML 3.0 asWedit + extensions//",
+ "-//IETF//DTD HTML 2.0 Level 1//",
+ "-//IETF//DTD HTML 2.0 Level 2//",
+ "-//IETF//DTD HTML 2.0 Strict Level 1//",
+ "-//IETF//DTD HTML 2.0 Strict Level 2//",
+ "-//IETF//DTD HTML 2.0 Strict//",
+ "-//IETF//DTD HTML 2.0//",
+ "-//IETF//DTD HTML 2.1E//",
+ "-//IETF//DTD HTML 3.0//",
+ "-//IETF//DTD HTML 3.2 Final//",
+ "-//IETF//DTD HTML 3.2//",
+ "-//IETF//DTD HTML 3//",
+ "-//IETF//DTD HTML Level 0//",
+ "-//IETF//DTD HTML Level 1//",
+ "-//IETF//DTD HTML Level 2//",
+ "-//IETF//DTD HTML Level 3//",
+ "-//IETF//DTD HTML Strict Level 0//",
+ "-//IETF//DTD HTML Strict Level 1//",
+ "-//IETF//DTD HTML Strict Level 2//",
+ "-//IETF//DTD HTML Strict Level 3//",
+ "-//IETF//DTD HTML Strict//",
+ "-//IETF//DTD HTML//",
+ "-//Metrius//DTD Metrius Presentational//",
+ "-//Microsoft//DTD Internet Explorer 2.0 HTML Strict//",
+ "-//Microsoft//DTD Internet Explorer 2.0 HTML//",
+ "-//Microsoft//DTD Internet Explorer 2.0 Tables//",
+ "-//Microsoft//DTD Internet Explorer 3.0 HTML Strict//",
+ "-//Microsoft//DTD Internet Explorer 3.0 HTML//",
+ "-//Microsoft//DTD Internet Explorer 3.0 Tables//",
+ "-//Netscape Comm. Corp.//DTD HTML//",
+ "-//Netscape Comm. Corp.//DTD Strict HTML//",
+ "-//O'Reilly and Associates//DTD HTML 2.0//",
+ "-//O'Reilly and Associates//DTD HTML Extended 1.0//",
+ "-//O'Reilly and Associates//DTD HTML Extended Relaxed 1.0//",
+ "-//SQ//DTD HTML 2.0 HoTMetaL + extensions//",
+ "-//SoftQuad Software//DTD HoTMetaL PRO 6.0::19990601::extensions to HTML 4.0//",
+ "-//SoftQuad//DTD HoTMetaL PRO 4.0::19971010::extensions to HTML 4.0//",
+ "-//Spyglass//DTD HTML 2.0 Extended//",
+ "-//Sun Microsystems Corp.//DTD HotJava HTML//",
+ "-//Sun Microsystems Corp.//DTD HotJava Strict HTML//",
+ "-//W3C//DTD HTML 3 1995-03-24//",
+ "-//W3C//DTD HTML 3.2 Draft//",
+ "-//W3C//DTD HTML 3.2 Final//",
+ "-//W3C//DTD HTML 3.2//",
+ "-//W3C//DTD HTML 3.2S Draft//",
+ "-//W3C//DTD HTML 4.0 Frameset//",
+ "-//W3C//DTD HTML 4.0 Transitional//",
+ "-//W3C//DTD HTML Experimental 19960712//",
+ "-//W3C//DTD HTML Experimental 970421//",
+ "-//W3C//DTD W3 HTML//",
+ "-//W3O//DTD W3 HTML 3.0//",
+ "-//WebTechs//DTD Mozilla HTML 2.0//",
+ "-//WebTechs//DTD Mozilla HTML//",
+]
+
+const SystemIdentifierMissingAndPublicIdentifierStartsWith = [
+ "-//W3C//DTD HTML 4.01 Frameset//",
+ "-//W3C//DTD HTML 4.01 Transitional//"
+]
+
+const PublicIdentifierStartsWithLimited = [
+ "-//W3C//DTD XHTML 1.0 Frameset//",
+ "-//W3C//DTD XHTML 1.0 Transitional//"
+]
+
+const SystemIdentifierNotMissingAndPublicIdentifierStartsWith = [
+ "-//W3C//DTD HTML 4.01 Frameset//",
+ "-//W3C//DTD HTML 4.01 Transitional//"
+]
+
+func startsWithNoCase(str, prefix: string): bool =
+ if str.len < prefix.len:
+ return false
+ # prefix.len is always lower
+ var i = 0
+ while i != prefix.len:
+ if str[i].toLowerAscii() != prefix[i].toLowerAscii():
+ return false
+ inc i
+ true
+
+func equalsIgnoreCase(s1, s2: string): bool {.inline.} =
+ return s1.cmpIgnoreCase(s2) == 0
+
+func quirksConditions(token: Token): bool =
+ if token.quirks:
+ return true
+ if token.name.get("") != "html":
+ return true
+ if token.sysid.get("") == "http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd":
+ return true
+ if token.pubid.isSome:
+ let pubid = token.pubid.get
+ for id in PublicIdentifierEquals:
+ if pubid.equalsIgnoreCase(id):
+ return true
+ for id in PublicIdentifierStartsWith:
+ if pubid.startsWithNoCase(id):
+ return true
+ if token.sysid.isNone:
+ for id in SystemIdentifierMissingAndPublicIdentifierStartsWith:
+ if pubid.startsWithNoCase(id):
+ return true
+ return false
+
+func limitedQuirksConditions(token: Token): bool =
+ if token.pubid.isNone: return false
+ for id in PublicIdentifierStartsWithLimited:
+ if token.pubid.get.startsWithNoCase(id):
+ return true
+ if token.sysid.isNone: return false
+ for id in SystemIdentifierNotMissingAndPublicIdentifierStartsWith:
+ if token.pubid.get.startsWithNoCase(id):
+ return true
+ return false
+
+# 13.2.6.2
+proc genericRawtextElementParsingAlgorithm(parser: var HTML5Parser, token: Token) =
+ discard parser.insertHTMLElement(token)
+ parser.tokenizer.state = RAWTEXT
+ parser.oldInsertionMode = parser.insertionMode
+ parser.insertionMode = TEXT
+
+proc genericRCDATAElementParsingAlgorithm(parser: var HTML5Parser, token: Token) =
+ discard parser.insertHTMLElement(token)
+ parser.tokenizer.state = RCDATA
+ parser.oldInsertionMode = parser.insertionMode
+ parser.insertionMode = TEXT
+
+# Pop all elements, including the specified tag.
+proc popElementsIncl(parser: var HTML5Parser, tags: set[TagType]) =
+ while parser.getTagType(parser.popElement()) notin tags:
+ discard
+
+proc popElementsIncl(parser: var HTML5Parser, tag: TagType) =
+ parser.popElementsIncl({tag})
+
+# Pop all elements, including the specified element.
+proc popElementsIncl[Handle, Atom](parser: var HTML5Parser[Handle, Atom],
+ handle: Handle) =
+ while parser.popElement() != handle:
+ discard
+
+# https://html.spec.whatwg.org/multipage/parsing.html#closing-elements-that-have-implied-end-tags
+proc generateImpliedEndTags(parser: var HTML5Parser) =
+ const tags = {
+ TAG_DD, TAG_DT, TAG_LI, TAG_OPTGROUP, TAG_OPTION, TAG_P, TAG_RB, TAG_RP,
+ TAG_RT, TAG_RTC
+ }
+ while parser.getTagType(parser.currentNode) in tags:
+ discard parser.popElement()
+
+proc generateImpliedEndTags(parser: var HTML5Parser, exclude: TagType) =
+ let tags = {
+ TAG_DD, TAG_DT, TAG_LI, TAG_OPTGROUP, TAG_OPTION, TAG_P, TAG_RB, TAG_RP,
+ TAG_RT, TAG_RTC
+ } - {exclude}
+ while parser.getTagType(parser.currentNode) in tags:
+ discard parser.popElement()
+
+proc generateImpliedEndTagsThoroughly(parser: var HTML5Parser) =
+ const tags = {
+ TAG_CAPTION, TAG_COLGROUP, TAG_DD, TAG_DT, TAG_LI, TAG_OPTGROUP,
+ TAG_OPTION, TAG_P, TAG_RB, TAG_RP, TAG_RT, TAG_RTC, TAG_TBODY, TAG_TD,
+ TAG_TFOOT, TAG_TH, TAG_THEAD, TAG_TR
+ }
+ while parser.getTagType(parser.currentNode) in tags:
+ discard parser.popElement()
+
+# https://html.spec.whatwg.org/multipage/parsing.html#push-onto-the-list-of-active-formatting-elements
+proc pushOntoActiveFormatting[Handle, Atom](parser: var HTML5Parser[Handle, Atom],
+ element: Handle, token: Token) =
+ var count = 0
+ for i in countdown(parser.activeFormatting.high, 0):
+ let it = parser.activeFormatting[i]
+ if it[0].isNone: # marker
+ break
+ if it[1].tagname != token.tagname:
+ continue
+ if parser.getNamespace(it[0].get) != parser.getNamespace(element):
+ continue
+ if it[1].attrs != token.attrs:
+ continue
+ inc count
+ if count == 3:
+ parser.activeFormatting.delete(i)
+ break
+ parser.activeFormatting.add((some(element), token))
+
+proc findOpenElement[Handle, Atom](parser: var HTML5Parser[Handle, Atom],
+ element: Handle): int =
+ for i, it in parser.openElements:
+ if it.element == element:
+ return i
+ return -1
+
+proc reconstructActiveFormatting[Handle, Atom](parser: var HTML5Parser[Handle, Atom]) =
+ type State = enum
+ REWIND, ADVANCE, CREATE
+ if parser.activeFormatting.len == 0 or
+ parser.activeFormatting[^1][0].isNone or
+ parser.findOpenElement(parser.activeFormatting[^1][0].get) != -1:
+ return
+ var i = parser.activeFormatting.high
+ template entry: Option[Handle] = (parser.activeFormatting[i][0])
+ var state = REWIND
+ while true:
+ case state
+ of REWIND:
+ if i == 0:
+ state = CREATE
+ continue
+ dec i
+ if entry.isSome and parser.findOpenElement(entry.get) == -1:
+ continue
+ state = ADVANCE
+ of ADVANCE:
+ inc i
+ state = CREATE
+ of CREATE:
+ let element = parser.insertHTMLElement(parser.activeFormatting[i][1])
+ parser.activeFormatting[i] = (
+ some(element), parser.activeFormatting[i][1]
+ )
+ if i != parser.activeFormatting.high:
+ state = ADVANCE
+ continue
+ break
+
+proc clearActiveFormattingTillMarker(parser: var HTML5Parser) =
+ while parser.activeFormatting.len > 0 and
+ parser.activeFormatting.pop()[0].isSome:
+ discard
+
+proc isMathMLIntegrationPoint[Handle, Atom](parser: HTML5Parser[Handle, Atom],
+ element: Handle): bool =
+ if parser.getNamespace(element) != Namespace.MATHML:
+ return false
+ let tagType = parser.atomToTagType(parser.getLocalName(element))
+ return tagType in {TAG_MI, TAG_MO, TAG_MN, TAG_MS, TAG_MTEXT}
+
+proc isHTMLIntegrationPoint[Handle, Atom](parser: HTML5Parser[Handle, Atom],
+ oe: OpenElement[Handle, Atom]): bool =
+ let (element, token) = oe
+ let localName = parser.getLocalName(element)
+ let namespace = parser.getNamespace(element)
+ let tagType = parser.atomToTagType(localName)
+ if namespace == Namespace.MATHML:
+ if tagType == TAG_ANNOTATION_XML:
+ token.attrs.withValue(parser.tagTypeToAtom(TAG_ENCODING), p):
+ return p[].equalsIgnoreCase("text/html") or
+ p[].equalsIgnoreCase("application/xhtml+xml")
+ elif namespace == Namespace.SVG:
+ return tagType in {TAG_FOREIGN_OBJECT, TAG_DESC, TAG_TITLE}
+ return false
+
+const AsciiWhitespace = {' ', '\n', '\r', '\t', '\f'}
+
+func until(s: string, c1, c2: char, starti: int): string =
+ result = ""
+ for i in starti ..< s.len:
+ if s[i] == c1 or s[i] == c2:
+ break
+ result &= s[i]
+
+func extractEncFromMeta(s: string): string =
+ var i = 0
+ while true: # Loop:
+ var j = 0
+ while i < s.len:
+ template check(c: static char) =
+ if s[i].toLowerAscii() == c:
+ inc j
+ else:
+ j = 0
+ case j
+ of 0: check 'c'
+ of 1: check 'h'
+ of 2: check 'a'
+ of 3: check 'r'
+ of 4: check 's'
+ of 5: check 'e'
+ of 6: check 't'
+ of 7:
+ inc j
+ break
+ else: discard
+ inc i
+ if j < 7: return ""
+ while i < s.len and s[i] in AsciiWhitespace: inc i
+ if i >= s.len or s[i] != '=': continue
+ while i < s.len and s[i] in AsciiWhitespace: inc i
+ break
+ inc i
+ if i >= s.len: return ""
+ if s[i] in {'"', '\''}:
+ let s2 = s.until('"', '\'', i + 1)
+ if s2.len == 0 or s2[^1] != s[i]:
+ return ""
+ return s2
+ return s.until(';', ' ', i)
+
+# Find a node in the list of active formatting elements, or return -1.
+func findLastActiveFormatting[Handle, Atom](parser: var HTML5Parser[Handle, Atom],
+ node: Handle): int =
+ for i in countdown(parser.activeFormatting.high, 0):
+ let it = parser.activeFormatting[i][0]
+ if it.isSome and it.get == node:
+ return i
+ return -1
+
+# > the last element in the list of active formatting elements that:
+# > is between the end of the list and the last marker in the list, if any,
+# > or the start of the list otherwise, and has the tag name subject.
+func findLastActiveFormattingAfterMarker(parser: var HTML5Parser,
+ token: Token): int =
+ for i in countdown(parser.activeFormatting.high, 0):
+ let it = parser.activeFormatting[i][1]
+ if it == nil:
+ break # marker
+ if it.tagname == token.tagname:
+ return i
+ return -1
+
+proc findLastActiveFormattingAfterMarker(parser: var HTML5Parser,
+ tagType: TagType): int =
+ for i in countdown(parser.activeFormatting.high, 0):
+ let it = parser.activeFormatting[i][0]
+ if it.isNone:
+ break
+ if parser.getTagType(it.get) == tagType:
+ return i
+ return -1
+
+#https://html.spec.whatwg.org/multipage/parsing.html#the-stack-of-open-elements
+const SpecialElements = {
+ TAG_ADDRESS, TAG_APPLET, TAG_AREA, TAG_ARTICLE, TAG_ASIDE, TAG_BASE,
+ TAG_BASEFONT, TAG_BGSOUND, TAG_BLOCKQUOTE, TAG_BODY, TAG_BR, TAG_BUTTON,
+ TAG_CAPTION, TAG_CENTER, TAG_COL, TAG_COLGROUP, TAG_DD, TAG_DETAILS, TAG_DIR,
+ TAG_DIV, TAG_DL, TAG_DT, TAG_EMBED, TAG_FIELDSET, TAG_FIGCAPTION, TAG_FIGURE,
+ TAG_FOOTER, TAG_FORM, TAG_FRAME, TAG_FRAMESET, TAG_H1, TAG_H2, TAG_H3, TAG_H4,
+ TAG_H5, TAG_H6, TAG_HEAD, TAG_HEADER, TAG_HGROUP, TAG_HR, TAG_HTML,
+ TAG_IFRAME, TAG_IMG, TAG_INPUT, TAG_KEYGEN, TAG_LI, TAG_LINK, TAG_LISTING,
+ TAG_MAIN, TAG_MARQUEE, TAG_MENU, TAG_META, TAG_NAV, TAG_NOEMBED, TAG_NOFRAMES,
+ TAG_NOSCRIPT, TAG_OBJECT, TAG_OL, TAG_P, TAG_PARAM, TAG_PLAINTEXT, TAG_PRE,
+ TAG_SCRIPT, TAG_SEARCH, TAG_SECTION, TAG_SELECT, TAG_SOURCE, TAG_STYLE,
+ TAG_SUMMARY, TAG_TABLE, TAG_TBODY, TAG_TD, TAG_TEMPLATE, TAG_TEXTAREA,
+ TAG_TFOOT, TAG_TH, TAG_THEAD, TAG_TITLE, TAG_TR, TAG_TRACK, TAG_UL, TAG_WBR,
+ TAG_XMP
+}
+
+proc isSpecialElement[Handle, Atom](parser: HTML5Parser[Handle, Atom],
+ element: Handle): bool =
+ let tagType = parser.atomToTagType(parser.getLocalName(element))
+ case parser.getNamespace(element)
+ of Namespace.HTML:
+ {.linearScanEnd.}
+ return tagType in SpecialElements
+ of Namespace.MATHML:
+ const elements = {
+ TAG_MI, TAG_MO, TAG_MN, TAG_MS, TAG_MTEXT, TAG_ANNOTATION_XML
+ }
+ return tagType in elements
+ of Namespace.SVG:
+ return tagType in {TAG_FOREIGN_OBJECT, TAG_DESC, TAG_TITLE}
+ else:
+ return false
+
+# > Let furthestBlock be the topmost node in the stack of open elements that
+# > is lower in the stack than formattingElement, and is an element in the
+# > special category. There might not be one.
+proc findFurthestBlockAfter(parser: HTML5Parser, stackIndex: int): int =
+ for i in stackIndex ..< parser.openElements.len:
+ if parser.isSpecialElement(parser.openElements[i].element):
+ return i
+ return -1
+
+proc findLastActiveFormatting[Handle, Atom](parser: var HTML5Parser[Handle, Atom],
+ tagTypes: set[TagType]): int =
+ for i in countdown(parser.activeFormatting.high, 0):
+ let it = parser.activeFormatting[i][0]
+ if it.isSome and parser.getTagType(it.get) in tagTypes:
+ return i
+ return -1
+
+# If true is returned, call "any other end tag".
+proc adoptionAgencyAlgorithm[Handle, Atom](parser: var HTML5Parser[Handle, Atom],
+ token: Token): bool =
+ if parser.currentToken.tagname == token.tagname and
+ parser.findLastActiveFormatting(parser.currentNode) == -1:
+ pop_current_node
+ return false
+ for i in 0 ..< 8: # outer loop
+ var formattingIndex = parser.findLastActiveFormattingAfterMarker(token)
+ if formattingIndex == -1:
+ # no such element
+ return true
+ let formatting = parser.activeFormatting[formattingIndex][0].get
+ let stackIndex = parser.findOpenElement(formatting)
+ if stackIndex < 0:
+ parser.activeFormatting.delete(formattingIndex)
+ return false
+ if not parser.hasElementInScope(formatting):
+ return false
+ var furthestBlockIndex = parser.findFurthestBlockAfter(stackIndex)
+ if furthestBlockIndex == -1:
+ parser.popElementsIncl(formatting)
+ parser.activeFormatting.delete(formattingIndex)
+ return false
+ let furthestBlock = parser.openElements[furthestBlockIndex].element
+ let commonAncestor = parser.openElements[stackIndex - 1].element
+ var bookmark = formattingIndex
+ var node = furthestBlock
+ var aboveNode = parser.openElements[furthestBlockIndex - 1].element
+ var lastNode = furthestBlock
+ var j = 0
+ while true:
+ inc j
+ node = aboveNode
+ if node == formatting:
+ break
+ let nodeStackIndex = parser.findOpenElement(node)
+ var nodeFormattingIndex = parser.findLastActiveFormatting(node)
+ if j > 3 and nodeFormattingIndex >= 0:
+ parser.activeFormatting.delete(nodeFormattingIndex)
+ if nodeFormattingIndex < bookmark:
+ dec bookmark # a previous node got deleted, so decrement bookmark
+ nodeFormattingIndex = -1 # deleted, so set to -1
+ if nodeFormattingIndex < 0:
+ aboveNode = parser.openElements[nodeStackIndex - 1].element
+ parser.openElements.delete(nodeStackIndex)
+ if nodeStackIndex < furthestBlockIndex:
+ dec furthestBlockIndex
+ let element = parser.openElements[furthestBlockIndex].element
+ assert furthestBlock == element
+ continue
+ let tok = parser.activeFormatting[nodeFormattingIndex][1]
+ let element = parser.createHTMLElementForToken(tok, commonAncestor)
+ parser.activeFormatting[nodeFormattingIndex] = (some(element), tok)
+ parser.openElements[nodeStackIndex] = (element, tok)
+ aboveNode = parser.openElements[nodeStackIndex - 1].element
+ node = element
+ if lastNode == furthestBlock:
+ bookmark = nodeFormattingIndex + 1
+ parser.remove(lastNode)
+ parser.append(node, lastNode)
+ lastNode = node
+ parser.remove(lastNode)
+ let location = parser.appropriatePlaceForInsert(commonAncestor)
+ parser.insert(location, lastNode)
+ let token = parser.activeFormatting[formattingIndex][1]
+ let element = parser.createHTMLElementForToken(token, furthestBlock)
+ parser.moveChildren(furthestBlock, element)
+ parser.append(furthestBlock, element)
+ parser.activeFormatting.insert((some(element), token), bookmark)
+ if formattingIndex >= bookmark:
+ inc formattingIndex # increment because of insert
+ parser.activeFormatting.delete(formattingIndex)
+ parser.openElements.insert((element, token), furthestBlockIndex + 1)
+ parser.openElements.delete(stackIndex)
+ return false
+
+proc closeP(parser: var HTML5Parser, sure = false) =
+ if sure or parser.hasElementInButtonScope(TAG_P):
+ parser.generateImpliedEndTags(TAG_P)
+ parser.popElementsIncl(TAG_P)
+
+proc newStartTagToken[Handle, Atom](parser: HTML5Parser[Handle, Atom],
+ t: TagType): Token[Atom] =
+ return Token[Atom](t: START_TAG, tagname: parser.tagTypeToAtom(t))
+
+# Following is an implementation of the state (?) machine defined in
+# https://html.spec.whatwg.org/multipage/parsing.html#parsing-main-inhtml
+# It uses the ad-hoc pattern matching macro `match' to apply the following
+# transformations:
+# * First, pairs of patterns and actions are stored in tuples (and `discard'
+# statements...)
+# * These pairs are then assigned to token types, later mapped to legs of the
+# first case statement.
+# * Another case statement is constructed where needed, e.g. for switching on
+# characters/tags/etc.
+# * Finally, the whole thing is wrapped in a named block, to implement a
+# pseudo-goto by breaking out only when the else statement needn't be
+# executed.
+#
+# For example, the following code:
+#
+# match token:
+# TokenType.COMMENT => (block: echo "comment")
+# ("<p>", "<a>", "</div>") => (block: echo "p, a or closing div")
+# ("<div>", "</p>") => (block: anything_else)
+# (TokenType.START_TAG, TokenType.END_TAG) => (block: assert false, "invalid")
+# other => (block: echo "anything else")
+#
+# (effectively) generates this:
+#
+# block inside_not_else:
+# case token.t
+# of TokenType.COMMENT:
+# echo "comment"
+# break inside_not_else
+# of TokenType.START_TAG:
+# case parser.atomToTagName(token.tagname)
+# of {TAG_P, TAG_A}:
+# echo "p, a or closing div"
+# break inside_not_else
+# of TAG_DIV: discard
+# else:
+# assert false
+# break inside_not_else
+# of TokenType.END_TAG:
+# case parser.atomToTagName(token.tagname)
+# of TAG_DIV:
+# echo "p, a or closing div"
+# break inside_not_else
+# of TAG_P: discard
+# else:
+# assert false
+# break inside_not_else
+# else: discard
+# echo "anything else"
+#
+# This duplicates any code that applies for several token types, except for the
+# else branch.
+type
+ OfBranch = (seq[NimNode], NimNode)
+
+ OfBranchStore = object
+ ofBranches: seq[OfBranch]
+ defaultBranch: NimNode
+ painted: bool
+
+ PatternType = enum
+ ptTokenType, ptTagType, ptOther, ptCombined
+
+ Pattern = object
+ case t: PatternType
+ of ptTokenType:
+ tokt: TokenType
+ of ptTagType:
+ isend: bool
+ tagt: TagType
+ of ptCombined:
+ children: seq[Pattern]
+ of ptOther: discard
+
+const TagTypeMap = block:
+ var map: Table[string, TagType]
+ for tt in TagType:
+ map[$tt] = tt
+ map
+
+proc toPattern(s: string): Pattern =
+ if s == "_":
+ return Pattern(t: ptOther)
+ assert s[0] == '<' and s[^1] == '>'
+ let isend = s[1] == '/'
+ let i = if not isend: 1 else: 2
+ let tagType = TagTypeMap[s[i..^2]]
+ assert tagType != TAG_UNKNOWN
+ return Pattern(t: ptTagType, isend: isend, tagt: tagType)
+
+proc toPattern(tt: TokenType): Pattern =
+ return Pattern(t: ptTokenType, tokt: tt)
+
+proc toPattern(s: tuple): Pattern =
+ result = Pattern(t: ptCombined)
+ for _, x in s.fieldPairs:
+ result.children.add(toPattern(x))
+
+macro toNimNode(p: untyped): NimNode =
+ return p
+
+type MatchBuilder = object
+ # Stores 'of' branches
+ ofBranches: array[TokenType, OfBranchStore]
+ # Stores 'else', 'elif' branches
+ defaultBranch: NimNode
+
+func tokenBranchOn(tok: TokenType): NimNode =
+ assert tok in {START_TAG, END_TAG}
+ return quote do:
+ (
+ let tokenTagType {.inject.} = parser.atomToTagType(token.tagname);
+ tokenTagType
+ )
+
+proc addToCase(tokenCase: NimNode, branch: OfBranch) =
+ if branch[0].len == 1:
+ tokenCase.add(newNimNode(nnkOfBranch).add(branch[0][0]).add(branch[1]))
+ else:
+ var curly = newNimNode(nnkCurly)
+ for node in branch[0]:
+ curly.add(node)
+ tokenCase.add(newNimNode(nnkOfBranch).add(curly).add(branch[1]))
+
+func findAction(ofBranches: seq[OfBranch], action: NimNode): int =
+ for i, branch in ofBranches:
+ if branch[1] == action:
+ return i
+ return -1
+
+proc buildBranches(builder: var MatchBuilder, patterns: openArray[Pattern],
+ lambdas: NimNode) =
+ for i in 0 ..< patterns.len:
+ let pattern = patterns[i]
+ let lambda = lambdas[i]
+ const noAction = {nnkSym, nnkEmpty, nnkFormalParams}
+ let action = lambda.findChild(it.kind notin noAction)
+ var patterns = @[pattern]
+ while patterns.len > 0:
+ let pattern = patterns.pop()
+ case pattern.t
+ of ptTokenType:
+ builder.ofBranches[pattern.tokt].defaultBranch = action
+ builder.ofBranches[pattern.tokt].painted = true
+ of ptTagType:
+ let tt = int(pattern.tagt)
+ let tokt = if not pattern.isend: START_TAG else: END_TAG
+ let i = builder.ofBranches[tokt].ofBranches.findAction(action)
+ if i != -1:
+ builder.ofBranches[tokt].ofBranches[i][0].add(quote do: TagType(`tt`))
+ else:
+ let tup = (@[(quote do: TagType(`tt`))], action)
+ builder.ofBranches[tokt].ofBranches.add(tup)
+ builder.ofBranches[tokt].painted = true
+ of ptCombined:
+ for child in pattern.children:
+ patterns.add(child)
+ of ptOther:
+ builder.defaultBranch = action
+
+proc generateCaseStmts(builder: MatchBuilder, token: NimNode): NimNode =
+ let mainCase = newNimNode(nnkCaseStmt).add(quote do: `token`.t)
+ for tt in TokenType:
+ let ofBranch = newNimNode(nnkOfBranch).add(quote do: TokenType(`tt`))
+ let tokenCase = newNimNode(nnkCaseStmt)
+ if builder.ofBranches[tt].defaultBranch != nil:
+ if builder.ofBranches[tt].ofBranches.len > 0:
+ tokenCase.add(tokenBranchOn(tt))
+ for branch in builder.ofBranches[tt].ofBranches:
+ tokenCase.addToCase(branch)
+ tokenCase.add(newNimNode(nnkElse)
+ .add(builder.ofBranches[tt].defaultBranch))
+ ofBranch.add(tokenCase)
+ mainCase.add(ofBranch)
+ else:
+ ofBranch.add(builder.ofBranches[tt].defaultBranch)
+ mainCase.add(ofBranch)
+ elif builder.ofBranches[tt].ofBranches.len > 0:
+ tokenCase.add(tokenBranchOn(tt))
+ for branch in builder.ofBranches[tt].ofBranches:
+ tokenCase.addToCase(branch)
+ ofBranch.add(tokenCase)
+ tokenCase.add(newNimNode(nnkElse).add(quote do: discard))
+ mainCase.add(ofBranch)
+ return mainCase
+
+macro match0(token: Token, patterns: static openArray[Pattern],
+ lambdas: seq[NimNode]) =
+ var builder = MatchBuilder()
+ builder.buildBranches(patterns, lambdas)
+ let mainCase = builder.generateCaseStmts(token)
+ for t in TokenType:
+ if not builder.ofBranches[t].painted:
+ mainCase.add(newNimNode(nnkElse).add(quote do: discard))
+ break
+ var stmts = newStmtList().add(mainCase)
+ for stmt in builder.defaultBranch:
+ stmts.add(stmt)
+ result = newBlockStmt(ident("inside_not_else"), stmts)
+
+macro match(token: Token, bodyIn: untyped): untyped =
+ result = newStmtList()
+ var patterns = newTree(nnkBracket)
+ var lambdas: seq[NimNode] = @[]
+ for child in bodyIn:
+ if unlikely(child.kind != nnkInfix or child[0].strVal != "=>"):
+ error("=> expected")
+ let sel = child[1]
+ let body = child[2]
+ let pattern = quote do:
+ toPattern(`sel`)
+ let lambda0 = quote do:
+ toNimNode:
+ `body`
+ break inside_not_else
+ patterns.add(pattern)
+ lambdas.add(lambda0)
+ result = quote do:
+ match0(`token`, `patterns`, `lambdas`)
+
+proc processInHTMLContent[Handle, Atom](parser: var HTML5Parser[Handle, Atom],
+ token: Token, insertionMode: InsertionMode): ParseResult =
+ template other: string = "_"
+
+ template reprocess(tok: Token) =
+ return parser.processInHTMLContent(tok, parser.insertionMode)
+
+ template reprocess(mode: InsertionMode): ParseResult =
+ parser.processInHTMLContent(token, mode)
+
+ case insertionMode
+ of INITIAL:
+ match token:
+ TokenType.CHARACTER_WHITESPACE => (block: discard)
+ TokenType.COMMENT => (block:
+ parser.insertComment(token, last_child_of(parser.getDocument()))
+ )
+ TokenType.DOCTYPE => (block:
+ let doctype = parser.createDocumentType(token.name.get(""),
+ token.pubid.get(""), token.sysid.get(""))
+ parser.append(parser.getDocument(), doctype)
+ if not parser.opts.isIframeSrcdoc:
+ if quirksConditions(token):
+ parser.setQuirksMode(QUIRKS)
+ elif limitedQuirksConditions(token):
+ parser.setQuirksMode(LIMITED_QUIRKS)
+ parser.insertionMode = BEFORE_HTML
+ )
+ other => (block:
+ parser.setQuirksMode(QUIRKS)
+ parser.insertionMode = BEFORE_HTML
+ reprocess token
+ )
+
+ of BEFORE_HTML:
+ match token:
+ (TokenType.DOCTYPE, TokenType.END_TAG,
+ TokenType.CHARACTER_WHITESPACE) => (block: discard)
+ TokenType.COMMENT => (block:
+ parser.insertComment(token, last_child_of(parser.getDocument()))
+ )
+ "<html>" => (block:
+ let intendedParent = parser.getDocument()
+ let element = parser.createHTMLElementForToken(token, intendedParent)
+ parser.append(parser.getDocument(), element)
+ parser.pushElement(element, token)
+ parser.insertionMode = BEFORE_HEAD
+ )
+ ("</head>", "</body>", "</html>", "</br>", other) => (block:
+ let element = parser.createHTMLElement()
+ parser.append(parser.getDocument(), element)
+ let html = parser.newStartTagToken(TAG_HTML)
+ parser.pushElement(element, html)
+ parser.insertionMode = BEFORE_HEAD
+ reprocess token
+ )
+
+ of BEFORE_HEAD:
+ match token:
+ (TokenType.CHARACTER_WHITESPACE, TokenType.DOCTYPE,
+ TokenType.END_TAG) => (block: discard)
+ TokenType.COMMENT => (block: parser.insertComment(token))
+ "<html>" => (block: return reprocess IN_BODY)
+ "<head>" => (block:
+ parser.head = some((parser.insertHTMLElement(token), token))
+ parser.insertionMode = IN_HEAD
+ )
+ ("</head>", "</body>", "</html>", "</br>", other) => (block:
+ let head = parser.newStartTagToken(TAG_HEAD)
+ parser.head = some((parser.insertHTMLElement(head), head))
+ parser.insertionMode = IN_HEAD
+ reprocess token
+ )
+
+ of IN_HEAD:
+ match token:
+ TokenType.CHARACTER_WHITESPACE => (block:
+ parser.insertCharacter(token.s)
+ )
+ TokenType.COMMENT => (block: parser.insertComment(token))
+ TokenType.DOCTYPE => (block: discard)
+ "<html>" => (block: return reprocess IN_BODY)
+ ("<base>", "<basefont>", "<bgsound>", "<link>") => (block:
+ discard parser.insertHTMLElement(token)
+ pop_current_node
+ )
+ "<meta>" => (block:
+ discard parser.insertHTMLElement(token)
+ pop_current_node
+ token.attrs.withValue(parser.tagTypeToAtom(TAG_CHARSET), p):
+ case parser.setEncoding(p[])
+ of SET_ENCODING_CONTINUE:
+ discard
+ of SET_ENCODING_STOP:
+ return PRES_STOP
+ do:
+ token.attrs.withValue(parser.tagTypeToAtom(TAG_HTTP_EQUIV), p):
+ if p[].equalsIgnoreCase("Content-Type"):
+ token.attrs.withValue(parser.tagTypeToAtom(TAG_CONTENT), p2):
+ let cs = extractEncFromMeta(p2[])
+ if cs != "":
+ case parser.setEncoding(cs)
+ of SET_ENCODING_CONTINUE:
+ discard
+ of SET_ENCODING_STOP:
+ return PRES_STOP
+ )
+ "<title>" => (block: parser.genericRCDATAElementParsingAlgorithm(token))
+ "<noscript>" => (block:
+ if not parser.opts.scripting:
+ discard parser.insertHTMLElement(token)
+ parser.insertionMode = IN_HEAD_NOSCRIPT
+ else:
+ parser.genericRawtextElementParsingAlgorithm(token)
+ )
+ ("<noframes>", "<style>") => (block:
+ parser.genericRawtextElementParsingAlgorithm(token)
+ )
+ "<script>" => (block:
+ let location = parser.appropriatePlaceForInsert()
+ let element = parser.createElementForToken(token, Namespace.HTML,
+ location.inside)
+ if parser.fragment:
+ parser.setScriptAlreadyStarted(element)
+ parser.insert(location, element)
+ parser.pushElement(element, token)
+ parser.tokenizer.state = SCRIPT_DATA
+ parser.oldInsertionMode = parser.insertionMode
+ parser.insertionMode = TEXT
+ )
+ "</head>" => (block:
+ pop_current_node
+ parser.insertionMode = AFTER_HEAD
+ )
+ "<template>" => (block:
+ discard parser.insertHTMLElement(token)
+ parser.activeFormatting.add((none(Handle), nil))
+ parser.framesetOk = false
+ parser.insertionMode = IN_TEMPLATE
+ parser.templateModes.add(IN_TEMPLATE)
+ )
+ "</template>" => (block:
+ if parser.hasElement(TAG_TEMPLATE):
+ parser.generateImpliedEndTagsThoroughly()
+ parser.popElementsIncl(TAG_TEMPLATE)
+ parser.clearActiveFormattingTillMarker()
+ discard parser.templateModes.pop()
+ parser.resetInsertionMode()
+ )
+ ("<head>", TokenType.END_TAG) => (block: discard)
+ ("</body>", "</html>", "</br>", other) => (block:
+ pop_current_node
+ parser.insertionMode = AFTER_HEAD
+ reprocess token
+ )
+
+ of IN_HEAD_NOSCRIPT:
+ match token:
+ (TokenType.DOCTYPE, "<head>", "<noscript>", TokenType.END_TAG) => (block:
+ discard
+ )
+ "<html>" => (block: return reprocess IN_BODY)
+ "</noscript>" => (block:
+ pop_current_node
+ parser.insertionMode = IN_HEAD
+ )
+ (TokenType.CHARACTER_WHITESPACE, TokenType.COMMENT,
+ "<basefont>", "<bgsound>", "<link>", "<meta>", "<noframes>",
+ "<style>") => (block:
+ return reprocess IN_HEAD
+ )
+ ("</br>", other) => (block:
+ pop_current_node
+ parser.insertionMode = IN_HEAD
+ reprocess token
+ )
+
+ of AFTER_HEAD:
+ match token:
+ TokenType.CHARACTER_WHITESPACE => (block:
+ parser.insertCharacter(token.s)
+ )
+ TokenType.COMMENT => (block: parser.insertComment(token))
+ (TokenType.DOCTYPE, "<head>", TokenType.END_TAG) => (block: discard)
+ "<html>" => (block: return reprocess IN_BODY)
+ "<body>" => (block:
+ discard parser.insertHTMLElement(token)
+ parser.framesetOk = false
+ parser.insertionMode = IN_BODY
+ )
+ "<frameset>" => (block:
+ discard parser.insertHTMLElement(token)
+ parser.insertionMode = IN_FRAMESET
+ )
+ ("<base>", "<basefont>", "<bgsound>", "<link>", "<meta>", "<noframes>",
+ "<script>", "<style>", "<template>", "<title>") => (block:
+ let (head, headTok) = parser.head.get
+ parser.pushElement(head, headTok)
+ result = reprocess IN_HEAD
+ if (let i = parser.findOpenElement(head); i != -1):
+ parser.openElements.delete(i)
+ )
+ "</template>" => (block: return reprocess IN_HEAD)
+ ("</body>", "</html>", "</br>", other) => (block:
+ discard parser.insertHTMLElement(parser.newStartTagToken(TAG_BODY))
+ parser.insertionMode = IN_BODY
+ reprocess token
+ )
+
+ of IN_BODY:
+ template any_other_start_tag() =
+ parser.reconstructActiveFormatting()
+ discard parser.insertHTMLElement(token)
+
+ template any_other_end_tag(tokenTagType: TagType) =
+ for i in countdown(parser.openElements.high, 0):
+ let (node, itToken) = parser.openElements[i]
+ if itToken.tagname == token.tagname:
+ parser.generateImpliedEndTags(tokenTagType)
+ parser.popElementsIncl(node)
+ break
+ elif parser.isSpecialElement(node):
+ return
+
+ match token:
+ TokenType.CHARACTER_WHITESPACE => (block:
+ parser.reconstructActiveFormatting()
+ parser.insertCharacter(token.s)
+ )
+ (TokenType.CHARACTER_NULL, TokenType.DOCTYPE) => (block: discard)
+ TokenType.CHARACTER => (block:
+ parser.reconstructActiveFormatting()
+ parser.insertCharacter(token.s)
+ parser.framesetOk = false
+ )
+ TokenType.COMMENT => (block: parser.insertComment(token))
+ "<html>" => (block:
+ if not parser.hasElement(TAG_TEMPLATE):
+ parser.addAttrsIfMissing(parser.openElements[0].element, token.attrs)
+ )
+ ("<base>", "<basefont>", "<bgsound>", "<link>", "<meta>", "<noframes>",
+ "<script>", "<style>", "<template>", "<title>",
+ "</template>") => (block:
+ return reprocess IN_HEAD
+ )
+ "<body>" => (block:
+ if parser.openElements.len == 1 or
+ parser.getTagType(parser.openElements[1].element) != TAG_BODY or
+ parser.hasElement(TAG_TEMPLATE):
+ discard
+ else:
+ parser.framesetOk = false
+ parser.addAttrsIfMissing(parser.openElements[1].element, token.attrs)
+ )
+ "<frameset>" => (block:
+ if parser.openElements.len == 1 or
+ parser.getTagType(parser.openElements[1].element) != TAG_BODY or
+ not parser.framesetOk:
+ discard
+ else:
+ parser.remove(parser.openElements[1].element)
+ while parser.openElements.len > 1:
+ pop_current_node
+ discard parser.insertHTMLElement(token)
+ parser.insertionMode = IN_FRAMESET
+ )
+ TokenType.EOF => (block:
+ if parser.templateModes.len > 0:
+ return reprocess IN_TEMPLATE
+ # stop
+ )
+ "</body>" => (block:
+ if parser.hasElementInScope(TAG_BODY):
+ parser.insertionMode = AFTER_BODY
+ )
+ "</html>" => (block:
+ if parser.hasElementInScope(TAG_BODY):
+ parser.insertionMode = AFTER_BODY
+ reprocess token
+ )
+ ("<address>", "<article>", "<aside>", "<blockquote>", "<center>",
+ "<details>", "<dialog>", "<dir>", "<div>", "<dl>", "<fieldset>",
+ "<figcaption>", "<figure>", "<footer>", "<header>", "<hgroup>", "<main>",
+ "<menu>", "<nav>", "<ol>", "<p>", "<search>", "<section>", "<summary>",
+ "<ul>") => (block:
+ parser.closeP()
+ discard parser.insertHTMLElement(token)
+ )
+ ("<h1>", "<h2>", "<h3>", "<h4>", "<h5>", "<h6>") => (block:
+ parser.closeP()
+ if parser.getTagType(parser.currentNode) in HTagTypes:
+ pop_current_node
+ discard parser.insertHTMLElement(token)
+ )
+ ("<pre>", "<listing>") => (block:
+ parser.closeP()
+ discard parser.insertHTMLElement(token)
+ parser.ignoreLF = true
+ parser.framesetOk = false
+ )
+ "<form>" => (block:
+ let hasTemplate = parser.hasElement(TAG_TEMPLATE)
+ if parser.form.isNone or hasTemplate:
+ parser.closeP()
+ let element = parser.insertHTMLElement(token)
+ if not hasTemplate:
+ parser.form = some(element)
+ )
+ "<li>" => (block:
+ parser.framesetOk = false
+ for i in countdown(parser.openElements.high, 0):
+ let node = parser.openElements[i].element
+ let tagType = parser.getTagType(node)
+ case tagType
+ of TAG_LI:
+ parser.generateImpliedEndTags(TAG_LI)
+ parser.popElementsIncl(TAG_LI)
+ break
+ of TAG_ADDRESS, TAG_DIV, TAG_P:
+ discard
+ elif parser.isSpecialElement(node):
+ break
+ else: discard
+ parser.closeP()
+ discard parser.insertHTMLElement(token)
+ )
+ ("<dd>", "<dt>") => (block:
+ parser.framesetOk = false
+ for i in countdown(parser.openElements.high, 0):
+ let node = parser.openElements[i].element
+ let tagType = parser.getTagType(node)
+ case tagType
+ of TAG_DD:
+ parser.generateImpliedEndTags(TAG_DD)
+ parser.popElementsIncl(TAG_DD)
+ break
+ of TAG_DT:
+ parser.generateImpliedEndTags(TAG_DT)
+ parser.popElementsIncl(TAG_DT)
+ break
+ of TAG_ADDRESS, TAG_DIV, TAG_P:
+ discard
+ elif parser.isSpecialElement(node):
+ break
+ else: discard
+ parser.closeP()
+ discard parser.insertHTMLElement(token)
+ )
+ "<plaintext>" => (block:
+ parser.closeP()
+ discard parser.insertHTMLElement(token)
+ parser.tokenizer.state = PLAINTEXT
+ )
+ "<button>" => (block:
+ if parser.hasElementInScope(TAG_BUTTON):
+ parser.generateImpliedEndTags()
+ parser.popElementsIncl(TAG_BUTTON)
+ parser.reconstructActiveFormatting()
+ discard parser.insertHTMLElement(token)
+ parser.framesetOk = false
+ )
+ ("</address>", "</article>", "</aside>", "</blockquote>", "</button>",
+ "</center>", "</details>", "</dialog>", "</dir>", "</div>", "</dl>",
+ "</fieldset>", "</figcaption>", "</figure>", "</footer>", "</header>",
+ "</hgroup>", "</listing>", "</main>", "</menu>", "</nav>", "</ol>",
+ "</pre>", "</search>", "</section>", "</summary>", "</ul>") => (block:
+ if parser.hasElementInScope(token.tagname):
+ parser.generateImpliedEndTags()
+ parser.popElementsIncl(tokenTagType)
+ )
+ "</form>" => (block:
+ if not parser.hasElement(TAG_TEMPLATE):
+ let form = parser.form
+ parser.form = none(Handle)
+ if form.isNone or not parser.hasElementInScope(form.get):
+ return
+ let node = form.get
+ parser.generateImpliedEndTags()
+ let i = parser.findOpenElement(node)
+ parser.openElements.delete(i)
+ else:
+ if parser.hasElementInScope(TAG_FORM):
+ parser.generateImpliedEndTags()
+ parser.popElementsIncl(TAG_FORM)
+ )
+ "</p>" => (block:
+ if not parser.hasElementInButtonScope(TAG_P):
+ discard parser.insertHTMLElement(parser.newStartTagToken(TAG_P))
+ parser.closeP(sure = true)
+ )
+ "</li>" => (block:
+ if parser.hasElementInListItemScope(TAG_LI):
+ parser.generateImpliedEndTags(TAG_LI)
+ parser.popElementsIncl(TAG_LI)
+ )
+ ("</dd>", "</dt>") => (block:
+ if parser.hasElementInScope(tokenTagType):
+ parser.generateImpliedEndTags(tokenTagType)
+ parser.popElementsIncl(tokenTagType)
+ )
+ ("</h1>", "</h2>", "</h3>", "</h4>", "</h5>", "</h6>") => (block:
+ if parser.hasElementInScope(HTagTypes):
+ parser.generateImpliedEndTags()
+ parser.popElementsIncl(HTagTypes)
+ )
+ "<a>" => (block:
+ let i = parser.findLastActiveFormattingAfterMarker(TAG_A)
+ if i != -1:
+ let anchor = parser.activeFormatting[i][0].get
+ if parser.adoptionAgencyAlgorithm(token):
+ any_other_end_tag tokenTagType
+ return
+ let j = parser.findLastActiveFormatting(anchor)
+ if j != -1:
+ parser.activeFormatting.delete(j)
+ let k = parser.findOpenElement(anchor)
+ if k != -1:
+ parser.openElements.delete(k)
+ parser.reconstructActiveFormatting()
+ let element = parser.insertHTMLElement(token)
+ parser.pushOntoActiveFormatting(element, token)
+ )
+ ("<b>", "<big>", "<code>", "<em>", "<font>", "<i>", "<s>", "<small>",
+ "<strike>", "<strong>", "<tt>", "<u>") => (block:
+ parser.reconstructActiveFormatting()
+ let element = parser.insertHTMLElement(token)
+ parser.pushOntoActiveFormatting(element, token)
+ )
+ "<nobr>" => (block:
+ parser.reconstructActiveFormatting()
+ if parser.hasElementInScope(TAG_NOBR):
+ if parser.adoptionAgencyAlgorithm(token):
+ any_other_end_tag tokenTagType
+ return
+ parser.reconstructActiveFormatting()
+ let element = parser.insertHTMLElement(token)
+ parser.pushOntoActiveFormatting(element, token)
+ )
+ ("</a>", "</b>", "</big>", "</code>", "</em>", "</font>", "</i>",
+ "</nobr>", "</s>", "</small>", "</strike>", "</strong>", "</tt>",
+ "</u>") => (block:
+ if parser.adoptionAgencyAlgorithm(token):
+ any_other_end_tag tokenTagType
+ return
+ )
+ ("<applet>", "<marquee>", "<object>") => (block:
+ parser.reconstructActiveFormatting()
+ discard parser.insertHTMLElement(token)
+ parser.activeFormatting.add((none(Handle), nil))
+ parser.framesetOk = false
+ )
+ ("</applet>", "</marquee>", "</object>") => (block:
+ if parser.hasElementInScope(tokenTagType):
+ parser.generateImpliedEndTags()
+ parser.popElementsIncl(tokenTagType)
+ parser.clearActiveFormattingTillMarker()
+ )
+ "<table>" => (block:
+ if parser.quirksMode != QUIRKS:
+ parser.closeP()
+ discard parser.insertHTMLElement(token)
+ parser.framesetOk = false
+ parser.insertionMode = IN_TABLE
+ )
+ "</br>" => (block: reprocess parser.newStartTagToken(TAG_BR))
+ ("<area>", "<br>", "<embed>", "<img>", "<keygen>", "<wbr>") => (block:
+ parser.reconstructActiveFormatting()
+ discard parser.insertHTMLElement(token)
+ pop_current_node
+ parser.framesetOk = false
+ )
+ "<input>" => (block:
+ parser.reconstructActiveFormatting()
+ discard parser.insertHTMLElement(token)
+ pop_current_node
+ token.attrs.withValue(parser.tagTypeToAtom(TAG_TYP), p):
+ if not p[].equalsIgnoreCase("hidden"):
+ parser.framesetOk = false
+ do:
+ parser.framesetOk = false
+ )
+ ("<param>", "<source>", "<track>") => (block:
+ discard parser.insertHTMLElement(token)
+ pop_current_node
+ )
+ "<hr>" => (block:
+ parser.closeP()
+ discard parser.insertHTMLElement(token)
+ pop_current_node
+ parser.framesetOk = false
+ )
+ "<image>" => (block:
+ token.tagname = parser.tagTypeToAtom(TAG_IMG)
+ reprocess token
+ )
+ "<textarea>" => (block:
+ discard parser.insertHTMLElement(token)
+ parser.ignoreLF = true
+ parser.tokenizer.state = RCDATA
+ parser.oldInsertionMode = parser.insertionMode
+ parser.framesetOk = false
+ parser.insertionMode = TEXT
+ )
+ "<xmp>" => (block:
+ parser.closeP()
+ parser.reconstructActiveFormatting()
+ parser.framesetOk = false
+ parser.genericRawtextElementParsingAlgorithm(token)
+ )
+ "<iframe>" => (block:
+ parser.framesetOk = false
+ parser.genericRawtextElementParsingAlgorithm(token)
+ )
+ "<noembed>" => (block:
+ parser.genericRawtextElementParsingAlgorithm(token)
+ )
+ "<noscript>" => (block:
+ if parser.opts.scripting:
+ parser.genericRawtextElementParsingAlgorithm(token)
+ else:
+ any_other_start_tag
+ )
+ "<select>" => (block:
+ parser.reconstructActiveFormatting()
+ discard parser.insertHTMLElement(token)
+ parser.framesetOk = false
+ const TableInsertionModes = {
+ IN_TABLE, IN_CAPTION, IN_TABLE_BODY, IN_ROW, IN_CELL
+ }
+ if parser.insertionMode in TableInsertionModes:
+ parser.insertionMode = IN_SELECT_IN_TABLE
+ else:
+ parser.insertionMode = IN_SELECT
+ )
+ ("<optgroup>", "<option>") => (block:
+ if parser.getTagType(parser.currentNode) == TAG_OPTION:
+ pop_current_node
+ parser.reconstructActiveFormatting()
+ discard parser.insertHTMLElement(token)
+ )
+ ("<rb>", "<rtc>") => (block:
+ if parser.hasElementInScope(TAG_RUBY):
+ parser.generateImpliedEndTags()
+ discard parser.insertHTMLElement(token)
+ )
+ ("<rp>", "<rt>") => (block:
+ if parser.hasElementInScope(TAG_RUBY):
+ parser.generateImpliedEndTags(TAG_RTC)
+ discard parser.insertHTMLElement(token)
+ )
+ "<math>" => (block:
+ parser.reconstructActiveFormatting()
+ var xmlAttrs: seq[ParsedAttr[Atom]] = @[]
+ parser.adjustMathMLAttributes(token.attrs, xmlAttrs)
+ discard parser.insertForeignElement(token, token.tagname,
+ Namespace.MATHML, false, xmlAttrs)
+ if token.selfclosing:
+ pop_current_node
+ )
+ "<svg>" => (block:
+ parser.reconstructActiveFormatting()
+ var xmlAttrs: seq[ParsedAttr[Atom]] = @[]
+ parser.adjustSVGAttributes(token.attrs, xmlAttrs)
+ discard parser.insertForeignElement(token, token.tagname, Namespace.SVG,
+ false, xmlAttrs)
+ if token.selfclosing:
+ pop_current_node
+ )
+ ("<caption>", "<col>", "<colgroup>", "<frame>", "<head>", "<tbody>",
+ "<td>", "<tfoot>", "<th>", "<thead>", "<tr>") => (block:
+ discard
+ )
+ TokenType.START_TAG => (block: any_other_start_tag)
+ TokenType.END_TAG => (block:
+ let tokenTagType = parser.atomToTagType(token.tagname)
+ any_other_end_tag tokenTagType
+ )
+
+ of TEXT:
+ match token:
+ TokenType.CHARACTER_NULL => (block:
+ # "This can never be a U+0000 NULL character; the tokenizer converts
+ # those to U+FFFD REPLACEMENT CHARACTER characters."
+ assert false
+ )
+ (TokenType.CHARACTER, TokenType.CHARACTER_WHITESPACE) => (block:
+ parser.insertCharacter(token.s)
+ )
+ TokenType.EOF => (block:
+ if parser.getTagType(parser.currentNode) == TAG_SCRIPT:
+ parser.setScriptAlreadyStarted(parser.currentNode)
+ pop_current_node
+ parser.insertionMode = parser.oldInsertionMode
+ reprocess token
+ )
+ TokenType.END_TAG => (block:
+ pop_current_node
+ parser.insertionMode = parser.oldInsertionMode
+ if parser.opts.scripting:
+ if parser.atomToTagType(token.tagname) == TAG_SCRIPT:
+ return PRES_SCRIPT
+ )
+
+ of IN_TABLE:
+ template clear_the_stack_back_to_a_table_context() =
+ const tags = {TAG_TABLE, TAG_TEMPLATE, TAG_HTML}
+ while parser.getTagType(parser.currentNode) notin tags:
+ pop_current_node
+
+ match token:
+ (TokenType.CHARACTER, TokenType.CHARACTER_WHITESPACE,
+ TokenType.CHARACTER_NULL) => (block:
+ const CanHaveText = {
+ TAG_TABLE, TAG_TBODY, TAG_TFOOT, TAG_THEAD, TAG_TR
+ }
+ if parser.getTagType(parser.currentNode) in CanHaveText:
+ parser.pendingTableChars = ""
+ parser.pendingTableCharsWhitespace = true
+ parser.oldInsertionMode = parser.insertionMode
+ parser.insertionMode = IN_TABLE_TEXT
+ reprocess token
+ else: # anything else
+ parser.fosterParenting = true
+ result = reprocess IN_BODY
+ parser.fosterParenting = false
+ )
+ TokenType.COMMENT => (block: parser.insertComment(token))
+ TokenType.DOCTYPE => (block: discard)
+ "<caption>" => (block:
+ clear_the_stack_back_to_a_table_context
+ parser.activeFormatting.add((none(Handle), nil))
+ discard parser.insertHTMLElement(token)
+ parser.insertionMode = IN_CAPTION
+ )
+ "<colgroup>" => (block:
+ clear_the_stack_back_to_a_table_context
+ let colgroupTok = parser.newStartTagToken(TAG_COLGROUP)
+ discard parser.insertHTMLElement(colgroupTok)
+ parser.insertionMode = IN_COLUMN_GROUP
+ )
+ "<col>" => (block:
+ clear_the_stack_back_to_a_table_context
+ let colgroupTok = parser.newStartTagToken(TAG_COLGROUP)
+ discard parser.insertHTMLElement(colgroupTok)
+ parser.insertionMode = IN_COLUMN_GROUP
+ reprocess token
+ )
+ ("<tbody>", "<tfoot>", "<thead>") => (block:
+ clear_the_stack_back_to_a_table_context
+ discard parser.insertHTMLElement(token)
+ parser.insertionMode = IN_TABLE_BODY
+ )
+ ("<td>", "<th>", "<tr>") => (block:
+ clear_the_stack_back_to_a_table_context
+ discard parser.insertHTMLElement(parser.newStartTagToken(TAG_TBODY))
+ parser.insertionMode = IN_TABLE_BODY
+ reprocess token
+ )
+ "<table>" => (block:
+ if parser.hasElementInTableScope(TAG_TABLE):
+ parser.popElementsIncl(TAG_TABLE)
+ parser.resetInsertionMode()
+ reprocess token
+ )
+ "</table>" => (block:
+ if parser.hasElementInTableScope(TAG_TABLE):
+ parser.popElementsIncl(TAG_TABLE)
+ parser.resetInsertionMode()
+ )
+ ("</body>", "</caption>", "</col>", "</colgroup>", "</html>", "</tbody>",
+ "</td>", "</tfoot>", "</th>", "</thead>", "</tr>") => (block: discard)
+ ("<style>", "<script>", "<template>", "</template>") => (block:
+ return reprocess IN_HEAD
+ )
+ "<input>" => (block:
+ token.attrs.withValue(parser.tagTypeToAtom(TAG_TYP), p):
+ if not p[].equalsIgnoreCase("hidden"):
+ # anything else
+ parser.fosterParenting = true
+ result = reprocess IN_BODY
+ parser.fosterParenting = false
+ else:
+ discard parser.insertHTMLElement(token)
+ pop_current_node
+ do:
+ # anything else
+ parser.fosterParenting = true
+ result = reprocess IN_BODY
+ parser.fosterParenting = false
+ )
+ "<form>" => (block:
+ if parser.form.isNone and not parser.hasElement(TAG_TEMPLATE):
+ parser.form = some(parser.insertHTMLElement(token))
+ pop_current_node
+ )
+ TokenType.EOF => (block: return reprocess IN_BODY)
+ other => (block:
+ parser.fosterParenting = true
+ result = reprocess IN_BODY
+ parser.fosterParenting = false
+ )
+
+ of IN_TABLE_TEXT:
+ match token:
+ TokenType.CHARACTER_NULL => (block: discard)
+ TokenType.CHARACTER_WHITESPACE => (block:
+ parser.pendingTableChars &= token.s
+ )
+ TokenType.CHARACTER => (block:
+ parser.pendingTableCharsWhitespace = false
+ parser.pendingTableChars &= token.s
+ )
+ other => (block:
+ if not parser.pendingTableCharsWhitespace:
+ # I *think* this is effectively the same thing the specification
+ # wants...
+ parser.fosterParenting = true
+ parser.reconstructActiveFormatting()
+ parser.insertCharacter(parser.pendingTableChars)
+ parser.framesetOk = false
+ parser.fosterParenting = false
+ else:
+ parser.insertCharacter(parser.pendingTableChars)
+ parser.insertionMode = parser.oldInsertionMode
+ reprocess token
+ )
+
+ of IN_CAPTION:
+ match token:
+ "</caption>" => (block:
+ if parser.hasElementInTableScope(TAG_CAPTION):
+ parser.generateImpliedEndTags()
+ parser.popElementsIncl(TAG_CAPTION)
+ parser.clearActiveFormattingTillMarker()
+ parser.insertionMode = IN_TABLE
+ )
+ ("<caption>", "<col>", "<colgroup>", "<tbody>", "<td>", "<tfoot>",
+ "<th>", "<thead>", "<tr>", "</table>") => (block:
+ if parser.hasElementInTableScope(TAG_CAPTION):
+ parser.generateImpliedEndTags()
+ parser.popElementsIncl(TAG_CAPTION)
+ parser.clearActiveFormattingTillMarker()
+ parser.insertionMode = IN_TABLE
+ reprocess token
+ )
+ ("</body>", "</col>", "</colgroup>", "</html>", "</tbody>", "</td>",
+ "</tfoot>", "</th>", "</thead>", "</tr>") => (block: discard)
+ other => (block: return reprocess IN_BODY)
+
+ of IN_COLUMN_GROUP:
+ match token:
+ TokenType.CHARACTER_WHITESPACE => (block:
+ parser.insertCharacter(token.s)
+ )
+ TokenType.COMMENT => (block: parser.insertComment(token))
+ (TokenType.DOCTYPE, "</col>") => (block: discard)
+ "<html>" => (block: return reprocess IN_BODY)
+ "<col>" => (block:
+ discard parser.insertHTMLElement(token)
+ pop_current_node
+ )
+ "</colgroup>" => (block:
+ if parser.getTagType(parser.currentNode) == TAG_COLGROUP:
+ pop_current_node
+ parser.insertionMode = IN_TABLE
+ )
+ ("<template>", "</template>") => (block: return reprocess IN_HEAD)
+ TokenType.EOF => (block: return reprocess IN_BODY)
+ other => (block:
+ if parser.getTagType(parser.currentNode) == TAG_COLGROUP:
+ pop_current_node
+ parser.insertionMode = IN_TABLE
+ reprocess token
+ )
+
+ of IN_TABLE_BODY:
+ template clear_the_stack_back_to_a_table_body_context() =
+ const tags = {TAG_TBODY, TAG_TFOOT, TAG_THEAD, TAG_TEMPLATE, TAG_HTML}
+ while parser.getTagType(parser.currentNode) notin tags:
+ pop_current_node
+
+ match token:
+ "<tr>" => (block:
+ clear_the_stack_back_to_a_table_body_context
+ discard parser.insertHTMLElement(token)
+ parser.insertionMode = IN_ROW
+ )
+ ("<th>", "<td>") => (block:
+ clear_the_stack_back_to_a_table_body_context
+ discard parser.insertHTMLElement(parser.newStartTagToken(TAG_TR))
+ parser.insertionMode = IN_ROW
+ reprocess token
+ )
+ ("</tbody>", "</tfoot>", "</thead>") => (block:
+ if parser.hasElementInTableScope(tokenTagType):
+ clear_the_stack_back_to_a_table_body_context
+ pop_current_node
+ parser.insertionMode = IN_TABLE
+ )
+ ("<caption>", "<col>", "<colgroup>", "<tbody>", "<tfoot>", "<thead>",
+ "</table>") => (block:
+ if parser.hasElementInTableScope({TAG_TBODY, TAG_THEAD, TAG_TFOOT}):
+ clear_the_stack_back_to_a_table_body_context
+ pop_current_node
+ parser.insertionMode = IN_TABLE
+ reprocess token
+ )
+ ("</body>", "</caption>", "</col>", "</colgroup>", "</html>", "</td>",
+ "</th>", "</tr>") => (block: discard)
+ other => (block: return reprocess IN_TABLE)
+
+ of IN_ROW:
+ template clear_the_stack_back_to_a_table_row_context() =
+ while parser.getTagType(parser.currentNode) notin {TAG_TR, TAG_TEMPLATE, TAG_HTML}:
+ pop_current_node
+
+ match token:
+ ("<th>", "<td>") => (block:
+ clear_the_stack_back_to_a_table_row_context
+ discard parser.insertHTMLElement(token)
+ parser.insertionMode = IN_CELL
+ parser.activeFormatting.add((none(Handle), nil))
+ )
+ "</tr>" => (block:
+ if parser.hasElementInTableScope(TAG_TR):
+ clear_the_stack_back_to_a_table_row_context
+ pop_current_node
+ parser.insertionMode = IN_TABLE_BODY
+ )
+ ("<caption>", "<col>", "<colgroup>", "<tbody>", "<tfoot>", "<thead>",
+ "<tr>", "</table>") => (block:
+ if parser.hasElementInTableScope(TAG_TR):
+ clear_the_stack_back_to_a_table_row_context
+ pop_current_node
+ parser.insertionMode = IN_TABLE_BODY
+ reprocess token
+ )
+ ("</tbody>", "</tfoot>", "</thead>") => (block:
+ if parser.hasElementInTableScope({tokenTagType, TAG_TR}):
+ clear_the_stack_back_to_a_table_row_context
+ pop_current_node
+ parser.insertionMode = IN_TABLE_BODY
+ reprocess token
+ )
+ ("</body>", "</caption>", "</col>", "</colgroup>", "</html>", "</td>",
+ "</th>") => (block: discard)
+ other => (block: return reprocess IN_TABLE)
+
+ of IN_CELL:
+ template close_cell() =
+ parser.generateImpliedEndTags()
+ parser.popElementsIncl({TAG_TD, TAG_TH})
+ parser.clearActiveFormattingTillMarker()
+ parser.insertionMode = IN_ROW
+
+ match token:
+ ("</td>", "</th>") => (block:
+ if parser.hasElementInTableScope(tokenTagType):
+ parser.generateImpliedEndTags()
+ parser.popElementsIncl(tokenTagType)
+ parser.clearActiveFormattingTillMarker()
+ parser.insertionMode = IN_ROW
+ )
+ ("<caption>", "<col>", "<colgroup>", "<tbody>", "<td>", "<tfoot>",
+ "<th>", "<thead>", "<tr>") => (block:
+ if parser.hasElementInTableScope({TAG_TD, TAG_TH}):
+ close_cell
+ reprocess token
+ )
+ ("</body>", "</caption>", "</col>", "</colgroup>", "</html>") => (block:
+ discard
+ )
+ ("</table>", "</tbody>", "</tfoot>", "</thead>", "</tr>") => (block:
+ if parser.hasElementInTableScope(tokenTagType):
+ close_cell
+ reprocess token
+ )
+ other => (block: return reprocess IN_BODY)
+
+ of IN_SELECT:
+ match token:
+ (TokenType.CHARACTER, TokenType.CHARACTER_WHITESPACE) => (block:
+ parser.insertCharacter(token.s)
+ )
+ TokenType.COMMENT => (block: parser.insertComment(token))
+ "<html>" => (block: return reprocess IN_BODY)
+ "<option>" => (block:
+ if parser.getTagType(parser.currentNode) == TAG_OPTION:
+ pop_current_node
+ discard parser.insertHTMLElement(token)
+ )
+ "<optgroup>" => (block:
+ if parser.getTagType(parser.currentNode) == TAG_OPTION:
+ pop_current_node
+ if parser.getTagType(parser.currentNode) == TAG_OPTGROUP:
+ pop_current_node
+ discard parser.insertHTMLElement(token)
+ )
+ "<hr>" => (block:
+ if parser.getTagType(parser.currentNode) == TAG_OPTION:
+ pop_current_node
+ if parser.getTagType(parser.currentNode) == TAG_OPTGROUP:
+ pop_current_node
+ discard parser.insertHTMLElement(token)
+ pop_current_node
+ )
+ "</optgroup>" => (block:
+ if parser.getTagType(parser.currentNode) == TAG_OPTION:
+ if parser.openElements.len > 1:
+ let tagType = parser.getTagType(parser.openElements[^2].element)
+ if tagType == TAG_OPTGROUP:
+ pop_current_node
+ if parser.getTagType(parser.currentNode) == TAG_OPTGROUP:
+ pop_current_node
+ )
+ "</option>" => (block:
+ if parser.getTagType(parser.currentNode) == TAG_OPTION:
+ pop_current_node
+ )
+ "</select>" => (block:
+ if parser.hasElementInSelectScope(TAG_SELECT):
+ parser.popElementsIncl(TAG_SELECT)
+ parser.resetInsertionMode()
+ )
+ "<select>" => (block:
+ if parser.hasElementInSelectScope(TAG_SELECT):
+ parser.popElementsIncl(TAG_SELECT)
+ parser.resetInsertionMode()
+ )
+ ("<input>", "<keygen>", "<textarea>") => (block:
+ if parser.hasElementInSelectScope(TAG_SELECT):
+ parser.popElementsIncl(TAG_SELECT)
+ parser.resetInsertionMode()
+ reprocess token
+ )
+ ("<script>", "<template>", "</template>") => (block:
+ return reprocess IN_HEAD
+ )
+ TokenType.EOF => (block: return reprocess IN_BODY)
+ other => (block: discard)
+
+ of IN_SELECT_IN_TABLE:
+ match token:
+ ("<caption>", "<table>", "<tbody>", "<tfoot>", "<thead>", "<tr>", "<td>",
+ "<th>") => (block:
+ parser.popElementsIncl(TAG_SELECT)
+ parser.resetInsertionMode()
+ reprocess token
+ )
+ ("</caption>", "</table>", "</tbody>", "</tfoot>", "</thead>", "</tr>",
+ "</td>", "</th>") => (block:
+ if parser.hasElementInTableScope(tokenTagType):
+ parser.popElementsIncl(TAG_SELECT)
+ parser.resetInsertionMode()
+ reprocess token
+ )
+ other => (block: return reprocess IN_SELECT)
+
+ of IN_TEMPLATE:
+ match token:
+ (TokenType.CHARACTER, TokenType.CHARACTER_WHITESPACE,
+ TokenType.CHARACTER_NULL, TokenType.DOCTYPE) => (block:
+ return reprocess IN_BODY
+ )
+ ("<base>", "<basefont>", "<bgsound>", "<link>", "<meta>", "<noframes>",
+ "<script>", "<style>", "<template>", "<title>", "</template>") => (block:
+ return reprocess IN_HEAD
+ )
+ ("<caption>", "<colgroup>", "<tbody>", "<tfoot>", "<thead>") => (block:
+ discard parser.templateModes.pop()
+ parser.templateModes.add(IN_TABLE)
+ parser.insertionMode = IN_TABLE
+ reprocess token
+ )
+ "<col>" => (block:
+ discard parser.templateModes.pop()
+ parser.templateModes.add(IN_COLUMN_GROUP)
+ parser.insertionMode = IN_COLUMN_GROUP
+ reprocess token
+ )
+ "<tr>" => (block:
+ discard parser.templateModes.pop()
+ parser.templateModes.add(IN_TABLE_BODY)
+ parser.insertionMode = IN_TABLE_BODY
+ reprocess token
+ )
+ ("<td>", "<th>") => (block:
+ discard parser.templateModes.pop()
+ parser.templateModes.add(IN_ROW)
+ parser.insertionMode = IN_ROW
+ reprocess token
+ )
+ TokenType.START_TAG => (block:
+ discard parser.templateModes.pop()
+ parser.templateModes.add(IN_BODY)
+ parser.insertionMode = IN_BODY
+ reprocess token
+ )
+ TokenType.END_TAG => (block: discard)
+ TokenType.EOF => (block:
+ if not parser.hasElement(TAG_TEMPLATE):
+ discard # stop
+ else:
+ parser.popElementsIncl(TAG_TEMPLATE)
+ parser.clearActiveFormattingTillMarker()
+ discard parser.templateModes.pop()
+ parser.resetInsertionMode()
+ reprocess token
+ )
+
+ of AFTER_BODY:
+ match token:
+ TokenType.CHARACTER_WHITESPACE => (block:
+ return reprocess IN_BODY
+ )
+ TokenType.COMMENT => (block:
+ parser.insertComment(token, last_child_of(parser.openElements[0]))
+ )
+ TokenType.DOCTYPE => (block: discard)
+ "<html>" => (block: return reprocess IN_BODY)
+ "</html>" => (block:
+ if not parser.fragment:
+ parser.insertionMode = AFTER_AFTER_BODY
+ )
+ TokenType.EOF => (block: discard) # stop
+ other => (block:
+ parser.insertionMode = IN_BODY
+ reprocess token
+ )
+
+ of IN_FRAMESET:
+ match token:
+ TokenType.CHARACTER_WHITESPACE => (block:
+ parser.insertCharacter(token.s)
+ )
+ TokenType.COMMENT => (block: parser.insertComment(token))
+ TokenType.DOCTYPE => (block: discard)
+ "<html>" => (block: return reprocess IN_BODY)
+ "<frameset>" => (block: discard parser.insertHTMLElement(token))
+ "</frameset>" => (block:
+ if parser.getTagType(parser.currentNode) != TAG_HTML:
+ pop_current_node
+ if not parser.fragment and
+ parser.getTagType(parser.currentNode) != TAG_FRAMESET:
+ parser.insertionMode = AFTER_FRAMESET
+ )
+ "<frame>" => (block:
+ discard parser.insertHTMLElement(token)
+ pop_current_node
+ )
+ "<noframes>" => (block: return reprocess IN_HEAD)
+ TokenType.EOF => (block:
+ # stop
+ )
+ other => (block: discard)
+
+ of AFTER_FRAMESET:
+ match token:
+ TokenType.CHARACTER_WHITESPACE => (block:
+ parser.insertCharacter(token.s)
+ )
+ TokenType.COMMENT => (block: parser.insertComment(token))
+ "<html>" => (block: return reprocess IN_BODY)
+ "</html>" => (block: parser.insertionMode = AFTER_AFTER_FRAMESET)
+ "<noframes>" => (block: return reprocess IN_HEAD)
+ other => (block: discard)
+
+ of AFTER_AFTER_BODY:
+ match token:
+ TokenType.COMMENT => (block:
+ parser.insertComment(token, last_child_of(parser.getDocument()))
+ )
+ (TokenType.DOCTYPE, TokenType.CHARACTER_WHITESPACE, "<html>") => (block:
+ return reprocess IN_BODY
+ )
+ TokenType.EOF => (block: discard) # stop
+ other => (block:
+ parser.insertionMode = IN_BODY
+ reprocess token
+ )
+
+ of AFTER_AFTER_FRAMESET:
+ match token:
+ TokenType.COMMENT => (block:
+ parser.insertComment(token, last_child_of(parser.getDocument()))
+ )
+ (TokenType.DOCTYPE, TokenType.CHARACTER_WHITESPACE, "<html>") => (block:
+ return reprocess IN_BODY
+ )
+ "<noframes>" => (block: return reprocess IN_HEAD)
+ other => (block: discard)
+ return PRES_CONTINUE
+
+proc processInForeignContent[Handle, Atom](
+ parser: var HTML5Parser[Handle, Atom], token: Token): ParseResult =
+ template script_end_tag() =
+ pop_current_node
+ return PRES_SCRIPT
+
+ template any_other_start_tag() =
+ let namespace = parser.getNamespace(parser.adjustedCurrentNode)
+ var tagname = token.tagname
+ var xmlAttrs: seq[ParsedAttr[Atom]] = @[]
+ if namespace == Namespace.SVG:
+ parser.caseTable.withValue(tagname, p):
+ tagname = p[]
+ parser.adjustSVGAttributes(token.attrs, xmlAttrs)
+ elif namespace == Namespace.MATHML:
+ parser.adjustMathMLAttributes(token.attrs, xmlAttrs)
+ discard parser.insertForeignElement(token, tagname, namespace, false,
+ xmlAttrs)
+ if token.selfclosing:
+ if namespace == Namespace.SVG and
+ parser.atomToTagType(token.tagname) == TAG_SCRIPT:
+ script_end_tag
+ else:
+ pop_current_node
+
+ template any_other_end_tag() =
+ for i in countdown(parser.openElements.high, 0): # loop
+ if i == 0: # fragment case
+ assert parser.fragment
+ break
+ let (node, nodeToken) = parser.openElements[i]
+ if i != parser.openElements.high and
+ parser.getNamespace(node) == Namespace.HTML:
+ return parser.processInHTMLContent(token, parser.insertionMode)
+ if nodeToken.tagname == token.tagname:
+ # Compare the start tag token, since it is guaranteed to be lower case.
+ # (The local name might have been adjusted to a non-lower-case string.)
+ parser.popElementsIncl(node)
+ break
+
+ match token:
+ TokenType.CHARACTER_NULL => (block: parser.insertCharacter("\uFFFD"))
+ TokenType.CHARACTER_WHITESPACE => (block: parser.insertCharacter(token.s))
+ TokenType.CHARACTER => (block:
+ parser.insertCharacter(token.s)
+ parser.framesetOk = false
+ )
+ TokenType.COMMENT => (block: parser.insertComment(token))
+ TokenType.DOCTYPE => (block: discard)
+ ("<b>", "<big>", "<blockquote>", "<body>", "<br>", "<center>", "<code>",
+ "<dd>", "<div>", "<dl>", "<dt>", "<em>", "<embed>", "<h1>", "<h2>",
+ "<h3>", "<h4>", "<h5>", "<h6>", "<head>", "<hr>", "<i>", "<img>", "<li>",
+ "<listing>", "<menu>", "<meta>", "<nobr>", "<ol>", "<p>", "<pre>",
+ "<ruby>", "<s>", "<small>", "<span>", "<strong>", "<strike>", "<sub>",
+ "<sup>", "<table>", "<tt>", "<u>", "<ul>", "<var>",
+ "<font>", # only if has "color", "face", or "size"
+ "</br>", "</p>") => (block:
+ if parser.atomToTagType(token.tagname) == TAG_FONT:
+ let atColor = parser.tagTypeToAtom(TAG_COLOR)
+ let atFace = parser.tagTypeToAtom(TAG_FACE)
+ let atSize = parser.tagTypeToAtom(TAG_SIZE)
+ if atColor notin token.attrs and atFace notin token.attrs and
+ atSize notin token.attrs:
+ any_other_start_tag
+ return
+ while not parser.isMathMLIntegrationPoint(parser.currentNode) and
+ not parser.isHTMLIntegrationPoint(parser.currentNodeToken) and
+ parser.getNamespace(parser.currentNode) != Namespace.HTML:
+ pop_current_node
+ return parser.processInHTMLContent(token, parser.insertionMode)
+ )
+ TokenType.START_TAG => (block:
+ any_other_start_tag
+ )
+ "</script>" => (block:
+ let namespace = parser.getNamespace(parser.currentNode)
+ let localName = parser.currentToken.tagname
+ # Any atom corresponding to the string "script" must have the same
+ # value as TAG_SCRIPT, so this is correct.
+ if namespace == Namespace.SVG and
+ parser.atomToTagType(localName) == TAG_SCRIPT:
+ script_end_tag
+ else:
+ any_other_end_tag
+ )
+ TokenType.END_TAG => (block: any_other_end_tag)
+ return PRES_CONTINUE
+
+proc processToken[Handle, Atom](parser: var HTML5Parser[Handle, Atom],
+ token: Token[Atom]): ParseResult =
+ if parser.ignoreLF:
+ parser.ignoreLF = false
+ if token.t == CHARACTER_WHITESPACE:
+ if token.s[0] == '\n':
+ if token.s.len == 1:
+ return PRES_CONTINUE
+ else:
+ token.s.delete(0..0)
+ if parser.openElements.len == 0 or
+ parser.getNamespace(parser.adjustedCurrentNode) == Namespace.HTML:
+ return parser.processInHTMLContent(token, parser.insertionMode)
+ let oe = parser.adjustedCurrentNodeToken
+ let oeTagType = parser.atomToTagType(oe.token.tagname)
+ let namespace = parser.getNamespace(oe.element)
+ const CharacterToken = {CHARACTER, CHARACTER_WHITESPACE, CHARACTER_NULL}
+ let mmlnoatoms = {TAG_MGLYPH, TAG_MALIGNMARK}
+ let ismmlip = parser.isMathMLIntegrationPoint(oe.element)
+ let ishtmlip = parser.isHTMLIntegrationPoint(oe)
+ if token.t == START_TAG and (
+ let tagType = parser.atomToTagType(token.tagname)
+ ismmlip and tagType notin mmlnoatoms or ishtmlip or
+ namespace == Namespace.MATHML and oeTagType == TAG_ANNOTATION_XML and
+ tagType == TAG_SVG
+ ) or token.t in CharacterToken and (ismmlip or ishtmlip):
+ return parser.processInHTMLContent(token, parser.insertionMode)
+ return parser.processInForeignContent(token)
+
+const CaseTable = {
+ "altglyph": "altGlyph",
+ "altglyphdef": "altGlyphDef",
+ "altglyphitem": "altGlyphItem",
+ "animatecolor": "animateColor",
+ "animatemotion": "animateMotion",
+ "animatetransform": "animateTransform",
+ "clippath": "clipPath",
+ "feblend": "feBlend",
+ "fecolormatrix": "feColorMatrix",
+ "fecomponenttransfer": "feComponentTransfer",
+ "fecomposite": "feComposite",
+ "feconvolvematrix": "feConvolveMatrix",
+ "fediffuselighting": "feDiffuseLighting",
+ "fedisplacementmap": "feDisplacementMap",
+ "fedistantlight": "feDistantLight",
+ "fedropshadow": "feDropShadow",
+ "feflood": "feFlood",
+ "fefunca": "feFuncA",
+ "fefuncb": "feFuncB",
+ "fefuncg": "feFuncG",
+ "fefuncr": "feFuncR",
+ "fegaussianblur": "feGaussianBlur",
+ "feimage": "feImage",
+ "femerge": "feMerge",
+ "femergenode": "feMergeNode",
+ "femorphology": "feMorphology",
+ "feoffset": "feOffset",
+ "fepointlight": "fePointLight",
+ "fespecularlighting": "feSpecularLighting",
+ "fespotlight": "feSpotLight",
+ "fetile": "feTile",
+ "feturbulence": "feTurbulence",
+ "foreignobject": "foreignObject",
+ "glyphref": "glyphRef",
+ "lineargradient": "linearGradient",
+ "radialgradient": "radialGradient",
+ "textpath": "textPath",
+}
+
+proc createCaseTable[Handle, Atom](parser: var HTML5Parser[Handle, Atom]) =
+ for (k, v) in CaseTable:
+ let ka = parser.strToAtom(k)
+ let va = parser.strToAtom(v)
+ parser.caseTable[ka] = va
+
+const AdjustedTable = {
+ "attributename": "attributeName",
+ "attributetype": "attributeType",
+ "basefrequency": "baseFrequency",
+ "baseprofile": "baseProfile",
+ "calcmode": "calcMode",
+ "clippathunits": "clipPathUnits",
+ "diffuseconstant": "diffuseConstant",
+ "edgemode": "edgeMode",
+ "filterunits": "filterUnits",
+ "glyphref": "glyphRef",
+ "gradienttransform": "gradientTransform",
+ "gradientunits": "gradientUnits",
+ "kernelmatrix": "kernelMatrix",
+ "kernelunitlength": "kernelUnitLength",
+ "keypoints": "keyPoints",
+ "keysplines": "keySplines",
+ "keytimes": "keyTimes",
+ "lengthadjust": "lengthAdjust",
+ "limitingconeangle": "limitingConeAngle",
+ "markerheight": "markerHeight",
+ "markerunits": "markerUnits",
+ "markerwidth": "markerWidth",
+ "maskcontentunits": "maskContentUnits",
+ "maskunits": "maskUnits",
+ "numoctaves": "numOctaves",
+ "pathlength": "pathLength",
+ "patterncontentunits": "patternContentUnits",
+ "patterntransform": "patternTransform",
+ "patternunits": "patternUnits",
+ "pointsatx": "pointsAtX",
+ "pointsaty": "pointsAtY",
+ "pointsatz": "pointsAtZ",
+ "preservealpha": "preserveAlpha",
+ "preserveaspectratio": "preserveAspectRatio",
+ "primitiveunits": "primitiveUnits",
+ "refx": "refX",
+ "refy": "refY",
+ "repeatcount": "repeatCount",
+ "repeatdur": "repeatDur",
+ "requiredextensions": "requiredExtensions",
+ "requiredfeatures": "requiredFeatures",
+ "specularconstant": "specularConstant",
+ "specularexponent": "specularExponent",
+ "spreadmethod": "spreadMethod",
+ "startoffset": "startOffset",
+ "stddeviation": "stdDeviation",
+ "stitchtiles": "stitchTiles",
+ "surfacescale": "surfaceScale",
+ "systemlanguage": "systemLanguage",
+ "tablevalues": "tableValues",
+ "targetx": "targetX",
+ "targety": "targetY",
+ "textlength": "textLength",
+ "viewbox": "viewBox",
+ "viewtarget": "viewTarget",
+ "xchannelselector": "xChannelSelector",
+ "ychannelselector": "yChannelSelector",
+ "zoomandpan": "zoomAndPan",
+}
+
+proc createAdjustedTable[Handle, Atom](parser: var HTML5Parser[Handle, Atom]) =
+ for (k, v) in AdjustedTable:
+ let ka = parser.strToAtom(k)
+ let va = parser.strToAtom(v)
+ parser.adjustedTable[ka] = va
+
+const ForeignTable = {
+ "xlink:actuate": (PREFIX_XLINK, "actuate", Namespace.XLINK),
+ "xlink:arcrole": (PREFIX_XLINK, "arcrole", Namespace.XLINK),
+ "xlink:href": (PREFIX_XLINK, "href", Namespace.XLINK),
+ "xlink:role": (PREFIX_XLINK, "role", Namespace.XLINK),
+ "xlink:show": (PREFIX_XLINK, "show", Namespace.XLINK),
+ "xlink:title": (PREFIX_XLINK, "title", Namespace.XLINK),
+ "xlink:type": (PREFIX_XLINK, "type", Namespace.XLINK),
+ "xml:lang": (PREFIX_XML, "lang", Namespace.XML),
+ "xml:space": (PREFIX_XML, "space", Namespace.XML),
+ "xmlns": (NO_PREFIX, "xmlns", Namespace.XMLNS),
+ "xmlns:xlink": (PREFIX_XMLNS, "xlink", Namespace.XMLNS),
+}
+
+proc createForeignTable[Handle, Atom](parser: var HTML5Parser[Handle, Atom]) =
+ for (oldName, qualName) in ForeignTable:
+ let (prefix, newName, ns) = qualName
+ let oldNameAtom = parser.strToAtom(oldName)
+ let newNameAtom = parser.strToAtom(newName)
+ parser.foreignTable[oldNameAtom] = (prefix, ns, newNameAtom)
+
+proc initHTML5Parser*[Handle, Atom](dombuilder: DOMBuilder[Handle, Atom],
+ opts: HTML5ParserOpts[Handle, Atom]): HTML5Parser[Handle, Atom] =
+ ## Create and initialize a new HTML5Parser object from dombuilder `dombuilder`
+ ## and parser options `opts`.
+ ##
+ ## The generic `Handle` must be the node handle type of the DOM builder. The
+ ## generic `Atom` must be the interned string type of the DOM builder.
+ var parser = HTML5Parser[Handle, Atom](
+ dombuilder: dombuilder,
+ opts: opts,
+ form: opts.formInit,
+ framesetOk: true
+ )
+ if opts.ctx.isSome:
+ let ctxInit = opts.ctx.get
+ let ctx: OpenElement[Handle, Atom] = (ctxInit.element, Token[Atom](
+ t: START_TAG,
+ tagname: ctxInit.startTagName
+ ))
+ parser.ctx = some(ctx)
+ for (element, tagName) in opts.openElementsInit:
+ let it = (element, Token[Atom](t: START_TAG, tagname: tagName))
+ parser.openElements.add(it)
+ parser.createCaseTable()
+ parser.createAdjustedTable()
+ parser.createForeignTable()
+ if opts.pushInTemplate:
+ parser.templateModes.add(IN_TEMPLATE)
+ if opts.openElementsInit.len > 0:
+ parser.resetInsertionMode()
+ let tokstate = opts.initialTokenizerState
+ parser.tokenizer = newTokenizer[Handle, Atom](dombuilder, tokstate)
+ return parser
+
+proc parseChunk*[Handle, Atom](parser: var HTML5Parser[Handle, Atom],
+ inputBuf: openArray[char]): ParseResult =
+ ## Parse a chunk of characters stored in `inputBuf` with `parser`.
+ var running = true
+ parser.tokenizer.inputBufIdx = 0
+ while running:
+ running = parser.tokenizer.tokenize(inputBuf) != trDone
+ for i, token in parser.tokenizer.tokqueue:
+ let pres = parser.processToken(token)
+ if pres != PRES_CONTINUE:
+ assert pres != PRES_SCRIPT or i == parser.tokenizer.tokqueue.high
+ return pres
+ return PRES_CONTINUE
+
+func getInsertionPoint*(parser: HTML5Parser): int =
+ return parser.tokenizer.inputBufIdx
+
+proc finish*[Handle, Atom](parser: var HTML5Parser[Handle, Atom]) =
+ ## Finish parsing the document associated with `parser`.
+ ## This will process an EOF token, and pop all elements from the stack of
+ ## open elements one by one.
+ var running = true
+ while running:
+ running = parser.tokenizer.finish() != trDone
+ for token in parser.tokenizer.tokqueue:
+ let pres = parser.processToken(token)
+ assert pres == PRES_CONTINUE
+ # pres == PRES_SCRIPT: this is unreachable.
+ # * Tokenizer's tokenizeEOF() can not emit end tag tokens, ergo no
+ # </script> will be processed here.
+ # * In some cases, tokenize() is called before tokenizeEOF(), to flush
+ # characters stuck in the internal peekBuf. This can happen if:
+ # 1. eatStr returns esrRetry in a previous pass. Here, peekBuf can
+ # contain any prefix of strings passed to eatStr/NoCase(), which
+ # crucially is never a potential </script> tag (or indeed,
+ # nothing that can start with </).
+ # 2. The "named character reference" state is interrupted. In this
+ # case, peekBuf is a prefix of at least one named character reference;
+ # obviously these can not be </script> tags either, since they
+ # all match the regex `&[a-zA-Z]+'.
+ # pres == PRES_STOP: unreachable for reasons almost identical to those
+ # outlined in PRES_SCRIPT. PRES_STOP can only be returned after a <meta>
+ # tag is processed; just like with end tags, the tokenizer cannot emit
+ # start tags in finish().
+ discard parser.processInHTMLContent(Token[Atom](t: EOF), parser.insertionMode)
+ while parser.openElements.len > 0:
+ pop_current_node
diff --git a/lib/chame0/chame/htmlparseriface.nim b/lib/chame0/chame/htmlparseriface.nim
new file mode 100644
index 00000000..5be4c536
--- /dev/null
+++ b/lib/chame0/chame/htmlparseriface.nim
@@ -0,0 +1,343 @@
+when defined(nimdocdummy):
+ ## Interface definitions for htmlparser.
+ ##
+ ## This exists to make implementing the DOMBuilder interface less painful. Two
+ ## categories of hooks exist:
+ ## 1. Mandatory hooks: these must be implemented by all users, or Chame will
+ ## not compile.
+ ## 2. Optional hooks: these may be omitted if your DOM does not need
+ ## them. (You do not have to do anything special for this, just don't
+ ## implement them.)
+ ##
+ ## Usage:
+ ## 1. Put a type clause with your generic types in your DOM builder interface:
+ ## ```nim
+ ## type
+ ## DOMBuilderImpl = MyDOMBuilder
+ ## AtomImpl = MyAtom
+ ## HandleImpl = MyHandle
+ ## ```
+ ## 2. **Include** (**not** import) this file:
+ ## ```nim
+ ## include chame/htmlparseriface
+ ## ```
+ ## 3. Implement all `*Impl` functions until the compiler no longer complains.
+ ##
+ ## Then you can call `parseHTML` with your custom DOMBuilder.
+ ##
+ ## You can also just implement the required functions without including
+ ## this interface, but then you will have to do the casting from
+ ## `DOMBuilder[HandleImpl, AtomImpl]` -> `DOMBuilderImpl` manually and will
+ ## get uglier error messages when a function is missing.
+ ##
+ ## Note that when using this interface you can't use procs with different side
+ ## effects than declared, so e.g. `func getDocumentImpl(...` **will not work**.
+ ## You must use `proc getDocumentImpl(...` instead.
+ ##
+ ## Also, make sure that parameter names match the ones defined here,
+ ## otherwise you are likely to get strange compilation errors.
+ ##
+ ## ## Optional hooks
+ ## Following procedures are optional hooks; implementations of this interface
+ ## can choose to leave them out without getting compilation errors.
+ ##
+ ##
+ ## ```nim
+ ## proc setQuirksModeImpl(builder: DOMBuilderBase, quirksMode: QuirksMode)
+ ## ```
+ ##
+ ## Set quirks mode to either `QUIRKS` or `LIMITED_QUIRKS`. `NO_QUIRKS` is the
+ ## default and is therefore never passed here.
+ ##
+ ##
+ ## ```nim
+ ## proc setEncodingImpl(builder: DOMBuilderBase, encoding: string):
+ ## SetEncodingResult
+ ## ```
+ ##
+ ## Called whenever a <meta charset=... or a <meta http-equiv=... tag
+ ## containing a non-empty character set is encountered. A SetEncodingResult
+ ## return value is expected, which is either `SET_ENCODING_STOP`, stopping
+ ## the parser, or `SET_ENCODING_CONTINUE`, allowing the parser to continue.
+ ##
+ ## Note that htmlparser no longer contains any encoding-related logic, not
+ ## even UTF-8 validation. Implementing this is left to the caller. (For an
+ ## example, see minidom_cs which implements decoding of all character sets
+ ## in the WHATWG recommendation.)
+ ##
+ ##
+ ## ```nim
+ ## proc elementPoppedImpl(builder: DOMBuilderBase, handle: HandleImpl)
+ ## ```
+ ##
+ ## Called when an element is popped from the stack of open elements
+ ## (i.e. when it has been closed.)
+ ##
+ ##
+ ## ```nim
+ ## proc setScriptAlreadyStartedImpl(builder: DOMBuilderBase, handle: HandleImpl)
+ ## ```
+ ##
+ ## Set the "already started" flag for the script element.
+ ##
+ ## Note: this flag is not togglable, so implementations of this callback
+ ## should just set the flag to true.
+ ##
+ ##
+ ## ```nim
+ ## proc associateWithFormImpl(builder: DOMBuilderBase, element, form,
+ ## intendedParent: HandleImpl)
+ ## ```
+ ##
+ ## Called after createElement. Attempts to set form for form-associated
+ ## elements.
+ ##
+ ## Note: the DOM builder is responsible for checking whether the intended
+ ## parent and the form element are in the same tree.
+ # Dummy definitions
+ import std/tables
+ import htmlparser
+ type
+ HandleImpl = int
+ AtomImpl = int
+ DOMBuilderImpl = DOMBuilder[HandleImpl, AtomImpl]
+
+# DOMBuilder
+static:
+ # DOMBuilderImpl must be an instance of DOMBuilder with the handle type
+ # HandleImpl and atom type AtomImpl.
+ doAssert DOMBuilderImpl is DOMBuilder[HandleImpl, AtomImpl]
+
+converter toDOMBuilderImpl(dombuilder: DOMBuilder[HandleImpl, AtomImpl]):
+ DOMBuilderImpl =
+ return DOMBuilderImpl(dombuilder)
+
+when defined(nimdocdummy):
+ import std/macros
+
+ macro doc(f: untyped) =
+ f[0] = newNimNode(nnkPostfix).add(ident("*")).add(f[0])
+ f
+else:
+ macro doc(f: untyped) = f
+
+proc strToAtomImpl(builder: DOMBuilderImpl, s: string): AtomImpl {.doc.}
+ ## Turn a string `s` into an Atom.
+ ##
+ ## This must always convert *every* string with the same value into the
+ ## same Atom. We recommend using a hash table-based approach for this
+ ## (see e.g. MAtomFactory).
+
+proc tagTypeToAtomImpl(builder: DOMBuilderImpl, tagType: TagType): AtomImpl
+ {.doc.}
+ ## Turn a TagType `tagType` into an Atom.
+ ##
+ ## Every TagType `tagType` must always be converted into the same atom as
+ ## that represented by its stringifier. An implementation could be:
+ ## ```nim
+ ## proc tagTypeToAtomImpl(builder: DOMBuilderImpl, tt: TagType): AtomImpl =
+ ## assert tt != TAG_UNKNOWN # parser never calls this with TAG_UNKNOWN.
+ ## return builder.strToAtomImpl($tt)
+ ## ```
+
+proc atomToTagTypeImpl(builder: DOMBuilderImpl, atom: AtomImpl): TagType {.doc.}
+ ## Turn an Atom `atom` into a TagType. This is the inverse function of
+ ## `tagTypeToAtomImpl`.
+
+proc getDocumentImpl(builder: DOMBuilderImpl): HandleImpl {.doc.}
+ ## Get the root document node's handle.
+ ## This must not return nil, not even in the fragment parsing case.
+
+proc getParentNodeImpl(builder: DOMBuilderImpl, handle: HandleImpl):
+ Option[HandleImpl] {.doc.}
+ ## Retrieve a handle to the parent node.
+ ## May return none(Handle) if no parent node exists.
+
+proc createHTMLElementImpl(builder: DOMBuilderImpl): HandleImpl {.doc.}
+ ## Create a new <html> element node. The tag type of the created element must
+ ## be TAG_HTML, and its namespace must be Namespace.HTML.
+ ##
+ ## This should not be confused with the "create an element for a token"
+ ## step, which is not executed here.
+
+proc createElementForTokenImpl(builder: DOMBuilderImpl, localName: AtomImpl,
+ namespace: Namespace, intendedParent: HandleImpl,
+ htmlAttrs: Table[AtomImpl, string], xmlAttrs: seq[ParsedAttr[AtomImpl]]):
+ HandleImpl {.doc.}
+ ## Create a new element node.
+ ##
+ ## `localName` is an Atom representing the tag name of the start token.
+ ##
+ ## Note that the parser determines the TagType of an element by its namespace
+ ## and localName; for non-HTML elements it is always considered TAG_UNKNOWN.
+ ##
+ ## (However, tokens have no namespace, so TAG_SVG and TAG_MATHML can still
+ ## used on them.)
+ ##
+ ## `namespace` is the namespace of the new element. For HTML elements,
+ ## it's HTML; for embedded SVG/MathML elements, it is Namespace.SVG or
+ ## Namespace.MATHML. No other namespace is used currently.
+ ##
+ ## `htmlAttrs` is a seq of the new elements attributes. It only contains
+ ## attributes with prefix NO_PREFIX and namespace NO_NAMESPACE; adjusted
+ ## foreign of embedded SVG/MathML elements that *do* have namespaces are
+ ## *not* included, these can be found in `xmlAttrs`. All attribute names in
+ ## `htmlAttrs` are guaranteed to be unique, but the parser makes no guarantees
+ ## about the order of the attributes. (TODO maybe attrs should be a hash
+ ## table after all?)
+ ##
+ ## `xmlAttrs` is a list of (XML) adjusted attributes. They are only set
+ ## for elements in the MathML or SVG namespace, for which there are
+ ## pre-defined attributes in the standard with names whose casing, namespace,
+ ## and namespace prefixes must be adjusted by the parser.
+ ##
+ ## `intendedParent` is the intended parent of the element, as passed to the
+ ## "create an element for a token" step. This may be used for looking up
+ ## custom element definitions.
+ ##
+ ## Implementers of this function are encouraged to consult the
+ ## [create an element for a token](https://html.spec.whatwg.org/multipage/parsing.html#create-an-element-for-the-token)
+ ## section of the standard. In particular, steps 3 (Let document be intended
+ ## parent's node document.) to 13 (If element is a resettable element...)
+ ## should be implemented.
+ ##
+ ## Note that step 14. (If element is a form-associated element...) should
+ ## *not* be implemented here. In fact, it is impossible to do so without
+ ## access to the parser internals, so for this step, the parser will call
+ ## associateWithFormImpl if all conditions (except "the intended parent is
+ ## in the same tree as the element pointed to by the form element pointer")
+ ## are fulfilled.
+
+proc getLocalNameImpl(builder: DOMBuilderImpl, handle: HandleImpl): AtomImpl
+ {.doc.}
+ ## Retrieve the local name (also known as the tag name) of the element
+ ## represented by `handle`.
+
+proc getNamespaceImpl(builder: DOMBuilderImpl, handle: HandleImpl): Namespace
+ {.doc.}
+ ## Retrieve the namespace of element. For HTML elements, this should be
+ ## `Namespace.HTML`. For embedded SVG or MathML elements, it should be
+ ## `Namespace.SVG` or `Namespace.MathML`, respectively.
+ ##
+ ## (In general, you should just return the namespace that was passed to
+ ## `createElement`.)
+
+proc getTemplateContentImpl(builder: DOMBuilderImpl, handle: HandleImpl):
+ HandleImpl {.doc.}
+ ## Retrieve a handle to the template element's contents. Every element
+ ## where `builder.atomToTagTypeImpl(element.localName)` equals TAG_TEMPLATE
+ ## and `builder.getNamespaceImpl(element)` equals `Namespace.HTML` must have
+ ## an associated "template contents" node which this function must return.
+
+proc addAttrsIfMissingImpl(builder: DOMBuilderImpl, handle: HandleImpl,
+ attrs: Table[AtomImpl, string]) {.doc.}
+ ## Add the attributes in `attrs` to the element node `element`.
+ ## This is only called with the HTML and BODY tags, when more than one
+ ## exists in a document.
+ ##
+ ## Pseudocode implementation:
+ ## ```nim
+ ## for attr in attrs:
+ ## if attr.name notin element.attrs:
+ ## element.attrs.add(attr)
+ ## ```
+
+proc createCommentImpl(builder: DOMBuilderImpl, text: string): HandleImpl
+ {.doc.}
+ ## Create a new comment node. `text` is a string representing the new comment
+ ## node's character data.
+
+proc createDocumentTypeImpl(builder: DOMBuilderImpl, name, publicId,
+ systemId: string): HandleImpl {.doc.}
+ ## Create a new document type node.
+
+proc insertBeforeImpl(builder: DOMBuilderImpl, parent, child: HandleImpl,
+ before: Option[HandleImpl]) {.doc.}
+ ## Insert node `child` before the node called `before`.
+ ##
+ ## If `before` is `none(Handle)`, `child` is expected to be appended to
+ ## `parent`'s node list.
+ ##
+ ## If `child` is a text, and its previous sibling after insertion is a
+ ## text as well, then they should be merged. `before` is never a
+ ## text node (and thus never has to be merged).
+ ##
+ ## Note: parent may be either an Element or a Document node.
+
+proc insertTextImpl(builder: DOMBuilderImpl, parent: HandleImpl, text: string,
+ before: Option[HandleImpl]) {.doc.}
+ ## Insert a text node at the specified location with contents `text`. If
+ ## the specified location has a previous sibling that is a text node, no new
+ ## text node should be created, but instead `text` should be appended to the
+ ## previous sibling's character data (or if `before` is `none(Handle)`,
+ ## to the last element).
+
+proc removeImpl(builder: DOMBuilderImpl, child: HandleImpl) {.doc.}
+ ## If `child` does not have a parent node, do nothing. Otherwise, remove
+ ## `child` from its parent node.
+
+proc moveChildrenImpl(builder: DOMBuilderImpl, fromNode, toNode: HandleImpl)
+ {.doc.}
+ ## Remove all children from the node `fromHandle`, then append them to
+ ## `toHandle`.
+
+when defined(nimdocdummy):
+ # Dummy definitions
+ proc strToAtomImpl(builder: DOMBuilderImpl, s: string): AtomImpl =
+ discard
+
+ proc tagTypeToAtomImpl(builder: DOMBuilderImpl, tagType: TagType): AtomImpl =
+ discard
+
+ proc atomToTagTypeImpl(builder: DOMBuilderImpl, atom: AtomImpl): TagType =
+ discard
+
+ proc getDocumentImpl(builder: DOMBuilderImpl): HandleImpl =
+ discard
+
+ proc getParentNodeImpl(builder: DOMBuilderImpl, handle: HandleImpl):
+ Option[HandleImpl] =
+ discard
+
+ proc createHTMLElementImpl(builder: DOMBuilderImpl): HandleImpl = discard
+
+ proc createElementForTokenImpl(builder: DOMBuilderImpl, localName: AtomImpl,
+ namespace: Namespace, intendedParent: HandleImpl,
+ htmlAttrs: Table[AtomImpl, string], xmlAttrs: seq[ParsedAttr[AtomImpl]]):
+ HandleImpl = discard
+
+ proc getLocalNameImpl(builder: DOMBuilderImpl, handle: HandleImpl): AtomImpl =
+ discard
+
+ proc getNamespaceImpl(builder: DOMBuilderImpl, handle: HandleImpl):
+ Namespace =
+ discard
+
+ proc getTemplateContentImpl(builder: DOMBuilderImpl, handle: HandleImpl):
+ HandleImpl =
+ discard
+
+ proc addAttrsIfMissingImpl(builder: DOMBuilderImpl, handle: HandleImpl,
+ attrs: Table[AtomImpl, string]) =
+ discard
+
+ proc createCommentImpl(builder: DOMBuilderImpl, text: string): HandleImpl =
+ discard
+
+ proc createDocumentTypeImpl(builder: DOMBuilderImpl, name, publicId,
+ systemId: string): HandleImpl =
+ discard
+
+ proc insertBeforeImpl(builder: DOMBuilderImpl, parent, child: HandleImpl,
+ before: Option[HandleImpl]) =
+ discard
+
+ proc insertTextImpl(builder: DOMBuilderImpl, parent: HandleImpl, text: string,
+ before: Option[HandleImpl]) =
+ discard
+
+ proc removeImpl(builder: DOMBuilderImpl, child: HandleImpl) =
+ discard
+
+ proc moveChildrenImpl(builder: DOMBuilderImpl, fromNode, toNode: HandleImpl) =
+ discard
diff --git a/lib/chame0/chame/htmltokenizer.nim b/lib/chame0/chame/htmltokenizer.nim
new file mode 100644
index 00000000..e9180a4d
--- /dev/null
+++ b/lib/chame0/chame/htmltokenizer.nim
@@ -0,0 +1,1422 @@
+{.experimental: "overloadableEnums".}
+
+import std/options
+import std/strformat
+import std/strutils
+import std/tables
+
+import dombuilder
+import entity_gen
+import tokstate
+
+export tokstate
+
+type
+ Tokenizer*[Handle, Atom] = object
+ dombuilder: DOMBuilder[Handle, Atom]
+ state*: TokenizerState
+ rstate: TokenizerState # return state
+ # temporary buffer (mentioned by the standard, but also used for attribute
+ # names)
+ tmp: string
+ code: uint32 # codepoint of current numeric character reference
+ tok: Token[Atom] # current token to be emitted
+ laststart*: Token[Atom] # last start tag token
+ attrna: Atom # atom representing attrn after the attribute name is closed
+ attrv: string # buffer for attribute values
+ attr: bool # is there already an attr in the previous values?
+ hasnonhtml*: bool # does the stack of open elements have a non-HTML node?
+ tokqueue*: seq[Token[Atom]] # queue of tokens to be emitted in this iteration
+ charbuf: string # buffer for character tokens
+ tagNameBuf: string # buffer for storing the tag name
+ peekBuf: array[64, char] # a stack with the last element at peekBufLen - 1
+ peekBufLen: int
+ inputBufIdx*: int # last character consumed in input buf
+ ignoreLF: bool # ignore the next consumed line feed (for CRLF normalization)
+ isend: bool # if consume returns -1 and isend, we are at EOF
+ isws: bool # is the current character token whitespace-only?
+
+ TokenType* = enum
+ DOCTYPE, START_TAG, END_TAG, COMMENT, CHARACTER, CHARACTER_WHITESPACE,
+ CHARACTER_NULL, EOF
+
+ Token*[Atom] = ref object
+ case t*: TokenType
+ of DOCTYPE:
+ quirks*: bool
+ name*: Option[string]
+ pubid*: Option[string]
+ sysid*: Option[string]
+ of START_TAG, END_TAG:
+ selfclosing*: bool
+ tagname*: Atom
+ attrs*: Table[Atom, string]
+ of CHARACTER, CHARACTER_WHITESPACE:
+ s*: string
+ of COMMENT:
+ data*: string
+ of EOF, CHARACTER_NULL: discard
+
+const AsciiUpperAlpha = {'A'..'Z'}
+const AsciiLowerAlpha = {'a'..'z'}
+const AsciiAlpha = (AsciiUpperAlpha + AsciiLowerAlpha)
+const AsciiDigit = {'0'..'9'}
+const AsciiAlphaNumeric = AsciiAlpha + AsciiDigit
+const AsciiWhitespace = {' ', '\n', '\r', '\t', '\f'}
+
+func `$`*(tok: Token): string =
+ case tok.t
+ of DOCTYPE: fmt"{tok.t} {tok.name} {tok.pubid} {tok.sysid} {tok.quirks}"
+ of START_TAG, END_TAG: fmt"{tok.t} {tok.tagname} {tok.selfclosing} {tok.attrs}"
+ of CHARACTER, CHARACTER_WHITESPACE: $tok.t & " " & tok.s
+ of CHARACTER_NULL: $tok.t
+ of COMMENT: fmt"{tok.t} {tok.data}"
+ of EOF: fmt"{tok.t}"
+
+proc strToAtom[Handle, Atom](tokenizer: Tokenizer[Handle, Atom],
+ s: string): Atom =
+ mixin strToAtomImpl
+ return tokenizer.dombuilder.strToAtomImpl(s)
+
+proc newTokenizer*[Handle, Atom](dombuilder: DOMBuilder[Handle, Atom],
+ initialState = DATA): Tokenizer[Handle, Atom] =
+ return Tokenizer[Handle, Atom](state: initialState, dombuilder: dombuilder)
+
+proc reconsume(tokenizer: var Tokenizer, s: openArray[char]) =
+ for i in countdown(s.high, 0):
+ tokenizer.peekBuf[tokenizer.peekBufLen] = s[i]
+ inc tokenizer.peekBufLen
+
+proc reconsume(tokenizer: var Tokenizer, c: char) =
+ tokenizer.peekBuf[tokenizer.peekBufLen] = c
+ inc tokenizer.peekBufLen
+
+proc consume(tokenizer: var Tokenizer, ibuf: openArray[char]): int =
+ if tokenizer.peekBufLen > 0:
+ dec tokenizer.peekBufLen
+ return int(tokenizer.peekBuf[tokenizer.peekBufLen])
+ if tokenizer.inputBufIdx >= ibuf.len:
+ return -1
+ var c = ibuf[tokenizer.inputBufIdx]
+ inc tokenizer.inputBufIdx
+ if tokenizer.ignoreLF:
+ if c == '\n':
+ if tokenizer.inputBufIdx >= ibuf.len:
+ return -1
+ c = ibuf[tokenizer.inputBufIdx]
+ inc tokenizer.inputBufIdx
+ tokenizer.ignoreLF = false
+ if c == '\r':
+ tokenizer.ignoreLF = true
+ c = '\n'
+ return int(c)
+
+proc flushChars[Handle, Atom](tokenizer: var Tokenizer[Handle, Atom]) =
+ if tokenizer.charbuf.len > 0:
+ if tokenizer.isws:
+ tokenizer.tokqueue.add(Token[Atom](
+ t: CHARACTER_WHITESPACE,
+ s: tokenizer.charbuf
+ ))
+ else:
+ tokenizer.tokqueue.add(Token[Atom](t: CHARACTER, s: tokenizer.charbuf))
+ tokenizer.isws = false
+ tokenizer.charbuf.setLen(0)
+
+const AttributeStates = {
+ ATTRIBUTE_VALUE_DOUBLE_QUOTED, ATTRIBUTE_VALUE_SINGLE_QUOTED,
+ ATTRIBUTE_VALUE_UNQUOTED
+}
+
+func consumedAsAttribute(tokenizer: Tokenizer): bool =
+ return tokenizer.rstate in AttributeStates
+
+proc appendToAttrValue(tokenizer: var Tokenizer, s: openArray[char]) =
+ if tokenizer.attr:
+ for c in s:
+ tokenizer.attrv &= c
+
+proc emit(tokenizer: var Tokenizer, c: char) =
+ let isws = c in AsciiWhitespace
+ if tokenizer.isws != isws:
+ # Emit whitespace & non-whitespace separately.
+ tokenizer.flushChars()
+ tokenizer.isws = isws
+ tokenizer.charbuf &= c
+
+type CharRefResult = tuple[i, ci: int, entry: cstring]
+
+proc findCharRef(tokenizer: var Tokenizer, c: char, ibuf: openArray[char]):
+ CharRefResult =
+ var i = charMap[c]
+ if i == -1:
+ return (0, 0, nil)
+ tokenizer.tmp &= c
+ var entry = entityMap[i]
+ var ci = 1
+ let oc = c
+ while entry != nil and entry[ci] != ':':
+ let n = tokenizer.consume(ibuf)
+ if n == -1 and not tokenizer.isend:
+ # We must retry at the next iteration :/
+ #TODO it would be nice to save state in this case
+ return (-1, 0, nil)
+ if n != int(entry[ci]):
+ entry = nil
+ # i is not the right entry.
+ while entry == nil:
+ if i == 0:
+ # See below; we avoid flushing the last character consumed by
+ # decrementing `ci'.
+ dec ci
+ break
+ dec i
+ entry = entityMap[i]
+ if oc != entry[0]:
+ # Out of entries that start with the character `oc'; give up.
+ # We must not flush the last character consumed as a character
+ # reference, since it is not a prefix of any entry (and can indeed be
+ # markup; e.g. in the case of `&g<'), so decrement `ci' here.
+ dec ci
+ entry = nil
+ break
+ var j = 1
+ while j < tokenizer.tmp.len - 1:
+ if entry[j] == ':':
+ # Full match: entry is a prefix of the previous entry we inspected.
+ break
+ if tokenizer.tmp[j + 1] != entry[j]:
+ # Characters consumed until now are not a prefix of entry.
+ # Try the next one instead.
+ entry = nil
+ break
+ inc j
+ if entry != nil:
+ if entry[j] == ':':
+ # Full match: make sure the outer loop exits.
+ ci = j - 1
+ elif int(entry[j]) == n:
+ # Partial match, *including c*. (This is never reached with n == -1)
+ ci = j
+ else:
+ # Continue with the loop.
+ # If entry is set to non-nil after this iteration, then ci will
+ # also be set appropriately.
+ # Otherwise, if entry remains nil, ci will point to the first
+ # non-matching character in tmp; this will be reconsumed.
+ entry = nil
+ if n != -1:
+ tokenizer.tmp &= cast[char](n)
+ inc ci
+ return (i, ci, entry)
+
+proc appendAttrOrEmit(tokenizer: var Tokenizer, s: openArray[char]) =
+ if tokenizer.consumedAsAttribute():
+ tokenizer.appendToAttrValue(s)
+ else:
+ for c in s:
+ tokenizer.emit(c)
+
+proc numericCharacterReferenceEndState(tokenizer: var Tokenizer) =
+ const ControlMap = [
+ 0x20ACu16, 0, 0x201A, 0x192, 0x201E, 0x2026, 0x2020, 0x2021,
+ 0x2C6, 0x2030, 0x160, 0x2039, 0x152, 0, 0x17D, 0,
+ 0, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
+ 0x2DC, 0x2122, 0x161, 0x203A, 0x153, 0, 0x17E, 0x178
+ ]
+ var u = tokenizer.code
+ let cc = u - 0x80
+ if cc < ControlMap.len and ControlMap[cc] != 0:
+ u = ControlMap[cc]
+ elif u == 0x00 or u > 0x10FFFF or u in 0xD800u32..0xDFFFu32:
+ u = 0xFFFD
+ var s = ""
+ if u < 0x80:
+ s = $char(u)
+ elif u < 0x800:
+ s = char(u shr 6 or 0xC0) &
+ char(u and 0x3F or 0x80)
+ elif u < 0x10000:
+ s = char(u shr 12 or 0xE0) &
+ char(u shr 6 and 0x3F or 0x80) &
+ char(u and 0x3F or 0x80)
+ else:
+ s = char(u shr 18 or 0xF0) &
+ char(u shr 12 and 0x3F or 0x80) &
+ char(u shr 6 and 0x3F or 0x80) &
+ char(u and 0x3F or 0x80)
+ tokenizer.appendAttrOrEmit(s)
+
+proc flushAttr(tokenizer: var Tokenizer) =
+ tokenizer.tok.attrs[tokenizer.attrna] = tokenizer.attrv
+
+type EatStrResult = enum
+ esrFail, esrSuccess, esrRetry
+
+proc eatStr(tokenizer: var Tokenizer, c: char, s, ibuf: openArray[char]):
+ EatStrResult =
+ var cs = $c
+ for c in s:
+ let n = tokenizer.consume(ibuf)
+ if n != -1:
+ cs &= cast[char](n)
+ if n != int(c):
+ tokenizer.reconsume(cs)
+ if n == -1 and not tokenizer.isend:
+ return esrRetry
+ return esrFail
+ return esrSuccess
+
+proc eatStrNoCase0(tokenizer: var Tokenizer, c: char, s, ibuf: openArray[char]):
+ EatStrResult =
+ var cs = $c
+ for c in s:
+ let n = tokenizer.consume(ibuf)
+ if n != -1:
+ cs &= cast[char](n)
+ if n == -1 or cast[char](n).toLowerAscii() != c:
+ tokenizer.reconsume(cs)
+ if n == -1 and not tokenizer.isend:
+ return esrRetry
+ return esrFail
+ return esrSuccess
+
+# convenience template for eatStrNoCase0 (to make sure it's called correctly)
+template eatStrNoCase(tokenizer: var Tokenizer, c: char, s: static string,
+ ibuf: openArray[char]): EatStrResult =
+ const s0 = s.toLowerAscii()
+ tokenizer.eatStrNoCase0(c, s0, ibuf)
+
+proc flushTagName(tokenizer: var Tokenizer) =
+ tokenizer.tok.tagname = tokenizer.strToAtom(tokenizer.tagNameBuf)
+
+proc emitTmp(tokenizer: var Tokenizer) =
+ if tokenizer.isws:
+ tokenizer.flushChars()
+ tokenizer.charbuf &= "</"
+ tokenizer.charbuf &= tokenizer.tmp
+
+# if true, redo
+proc tokenizeEOF[Handle, Atom](tokenizer: var Tokenizer[Handle, Atom]): bool =
+ tokenizer.tokqueue.setLen(0)
+ if tokenizer.isws:
+ tokenizer.flushChars()
+ case tokenizer.state
+ of TAG_OPEN, RCDATA_LESS_THAN_SIGN, RAWTEXT_LESS_THAN_SIGN,
+ SCRIPT_DATA_LESS_THAN_SIGN, SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN:
+ tokenizer.charbuf &= '<'
+ of END_TAG_OPEN, RCDATA_END_TAG_OPEN, RAWTEXT_END_TAG_OPEN,
+ SCRIPT_DATA_END_TAG_OPEN, SCRIPT_DATA_ESCAPED_END_TAG_OPEN:
+ tokenizer.charbuf &= "</"
+ of RCDATA_END_TAG_NAME, RAWTEXT_END_TAG_NAME, SCRIPT_DATA_END_TAG_NAME,
+ SCRIPT_DATA_ESCAPED_END_TAG_NAME:
+ tokenizer.emitTmp()
+ of BOGUS_COMMENT, BOGUS_DOCTYPE, COMMENT_END_DASH,
+ COMMENT_END, COMMENT_END_BANG, COMMENT_LESS_THAN_SIGN_BANG_DASH,
+ COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH, COMMENT_START_DASH, COMMENT,
+ COMMENT_START, COMMENT_LESS_THAN_SIGN, COMMENT_LESS_THAN_SIGN_BANG:
+ tokenizer.flushChars()
+ tokenizer.tokqueue.add(tokenizer.tok)
+ of MARKUP_DECLARATION_OPEN:
+ tokenizer.flushChars()
+ tokenizer.tokqueue.add(Token[Atom](t: COMMENT))
+ of DOCTYPE, BEFORE_DOCTYPE_NAME:
+ tokenizer.flushChars()
+ tokenizer.tokqueue.add(Token[Atom](t: DOCTYPE, quirks: true))
+ of DOCTYPE_NAME, AFTER_DOCTYPE_NAME, AFTER_DOCTYPE_PUBLIC_KEYWORD,
+ BEFORE_DOCTYPE_PUBLIC_IDENTIFIER,
+ DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED,
+ DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED,
+ AFTER_DOCTYPE_PUBLIC_IDENTIFIER,
+ BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS,
+ AFTER_DOCTYPE_SYSTEM_KEYWORD, BEFORE_DOCTYPE_SYSTEM_IDENTIFIER,
+ DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED,
+ DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED,
+ AFTER_DOCTYPE_SYSTEM_IDENTIFIER:
+ tokenizer.tok.quirks = true
+ tokenizer.flushChars()
+ tokenizer.tokqueue.add(tokenizer.tok)
+ of CDATA_SECTION_BRACKET:
+ tokenizer.charbuf &= ']'
+ of CDATA_SECTION_END:
+ tokenizer.charbuf &= "]]"
+ of CHARACTER_REFERENCE:
+ tokenizer.appendAttrOrEmit("&")
+ tokenizer.state = tokenizer.rstate
+ return true
+ of AMBIGUOUS_AMPERSAND_STATE:
+ tokenizer.state = tokenizer.rstate
+ return true
+ of NAMED_CHARACTER_REFERENCE, HEXADECIMAL_CHARACTER_REFERENCE_START,
+ NUMERIC_CHARACTER_REFERENCE:
+ tokenizer.appendAttrOrEmit(tokenizer.tmp)
+ tokenizer.state = tokenizer.rstate
+ return true
+ of HEXADECIMAL_CHARACTER_REFERENCE, DECIMAL_CHARACTER_REFERENCE:
+ tokenizer.numericCharacterReferenceEndState()
+ # we unnecessarily consumed once so reconsume
+ tokenizer.state = tokenizer.rstate
+ return true
+ else: discard
+ tokenizer.flushChars()
+ false
+
+type TokenizeResult* = enum
+ trDone, trEmit
+
+proc tokenize*[Handle, Atom](tokenizer: var Tokenizer[Handle, Atom],
+ ibuf: openArray[char]): TokenizeResult =
+ template emit(s: static string) =
+ static:
+ doAssert AsciiWhitespace notin s
+ if tokenizer.isws:
+ tokenizer.flushChars()
+ tokenizer.charbuf &= s
+ template emit(ch: char) =
+ tokenizer.emit(ch)
+ template emit_null =
+ tokenizer.flushChars()
+ tokenizer.tokqueue.add(Token[Atom](t: CHARACTER_NULL))
+ template prepare_attrs_if_start =
+ if tokenizer.tok.t == START_TAG and tokenizer.attr:
+ tokenizer.flushAttr()
+ template emit_tok =
+ tokenizer.flushChars()
+ tokenizer.tokqueue.add(tokenizer.tok)
+ template emit_replacement = emit "\uFFFD"
+ template switch_state(s: TokenizerState) =
+ tokenizer.state = s
+ template switch_state_return(s: TokenizerState) =
+ tokenizer.rstate = tokenizer.state
+ tokenizer.state = s
+ template is_appropriate_end_tag_token(): bool =
+ tokenizer.laststart != nil and
+ tokenizer.laststart.tagname == tokenizer.tok.tagname
+ template start_new_attribute =
+ if tokenizer.tok.t == START_TAG and tokenizer.attr:
+ # This can also be called with tok.t == END_TAG, in that case we do
+ # not want to flush attributes.
+ tokenizer.flushAttr()
+ tokenizer.tmp = ""
+ tokenizer.attrv = ""
+ tokenizer.attr = true
+ template leave_attribute_name_state =
+ tokenizer.attrna = tokenizer.strToAtom(tokenizer.tmp)
+ if tokenizer.attrna in tokenizer.tok.attrs:
+ tokenizer.attr = false
+ template new_token(t: Token) =
+ tokenizer.attr = false
+ tokenizer.tok = t
+
+ tokenizer.tokqueue.setLen(0)
+
+ while true:
+ if tokenizer.tokqueue.len > 0:
+ return trEmit
+ let n = tokenizer.consume(ibuf)
+ if n == -1:
+ break # trDone
+ let c = cast[char](n)
+ template reconsume_in(s: TokenizerState) =
+ tokenizer.reconsume(c)
+ switch_state s
+
+ case tokenizer.state
+ of DATA:
+ case c
+ of '&': switch_state_return CHARACTER_REFERENCE
+ of '<': switch_state TAG_OPEN
+ of '\0': emit_null
+ else: emit c
+
+ of RCDATA:
+ case c
+ of '&': switch_state_return CHARACTER_REFERENCE
+ of '<': switch_state RCDATA_LESS_THAN_SIGN
+ of '\0': emit_replacement
+ else: emit c
+
+ of RAWTEXT:
+ case c
+ of '<': switch_state RAWTEXT_LESS_THAN_SIGN
+ of '\0': emit_replacement
+ else: emit c
+
+ of SCRIPT_DATA:
+ case c
+ of '<': switch_state SCRIPT_DATA_LESS_THAN_SIGN
+ of '\0': emit_replacement
+ else: emit c
+
+ of PLAINTEXT:
+ case c
+ of '\0': emit_replacement
+ else: emit c
+
+ of TAG_OPEN:
+ case c
+ of '!': switch_state MARKUP_DECLARATION_OPEN
+ of '/': switch_state END_TAG_OPEN
+ of AsciiAlpha:
+ new_token Token[Atom](t: START_TAG)
+ tokenizer.laststart = tokenizer.tok
+ tokenizer.tagNameBuf = $c.toLowerAscii()
+ # note: was reconsume
+ switch_state TAG_NAME
+ of '?':
+ new_token Token[Atom](t: COMMENT, data: "?")
+ # note: was reconsume
+ switch_state BOGUS_COMMENT
+ else:
+ emit '<'
+ reconsume_in DATA
+
+ of END_TAG_OPEN:
+ case c
+ of AsciiAlpha:
+ new_token Token[Atom](t: END_TAG)
+ tokenizer.tagNameBuf = $c.toLowerAscii()
+ # note: was reconsume
+ switch_state TAG_NAME
+ of '>': switch_state DATA
+ else:
+ new_token Token[Atom](t: COMMENT)
+ reconsume_in BOGUS_COMMENT
+
+ of TAG_NAME:
+ case c
+ of AsciiWhitespace:
+ tokenizer.flushTagName()
+ switch_state BEFORE_ATTRIBUTE_NAME
+ of '/':
+ tokenizer.flushTagName()
+ switch_state SELF_CLOSING_START_TAG
+ of '>':
+ switch_state DATA
+ tokenizer.flushTagName()
+ emit_tok
+ of '\0': tokenizer.tagNameBuf &= "\uFFFD"
+ else: tokenizer.tagNameBuf &= c.toLowerAscii()
+
+ of RCDATA_LESS_THAN_SIGN:
+ case c
+ of '/':
+ tokenizer.tmp = ""
+ switch_state RCDATA_END_TAG_OPEN
+ else:
+ emit '<'
+ reconsume_in RCDATA
+
+ of RCDATA_END_TAG_OPEN:
+ case c
+ of AsciiAlpha:
+ new_token Token[Atom](t: END_TAG)
+ tokenizer.tagNameBuf = $c.toLowerAscii()
+ tokenizer.tmp &= c
+ # note: was reconsume
+ switch_state RCDATA_END_TAG_NAME
+ else:
+ emit "</"
+ reconsume_in RCDATA
+
+ of RCDATA_END_TAG_NAME:
+ template anything_else =
+ tokenizer.emitTmp()
+ reconsume_in RCDATA
+ case c
+ of AsciiWhitespace:
+ tokenizer.flushTagName()
+ if is_appropriate_end_tag_token:
+ switch_state BEFORE_ATTRIBUTE_NAME
+ else:
+ anything_else
+ of '/':
+ tokenizer.flushTagName()
+ if is_appropriate_end_tag_token:
+ switch_state SELF_CLOSING_START_TAG
+ else:
+ anything_else
+ of '>':
+ tokenizer.flushTagName()
+ if is_appropriate_end_tag_token:
+ switch_state DATA
+ emit_tok
+ else:
+ anything_else
+ of AsciiAlpha: # note: merged upper & lower
+ tokenizer.tagNameBuf &= c.toLowerAscii()
+ tokenizer.tmp &= c
+ else:
+ anything_else
+
+ of RAWTEXT_LESS_THAN_SIGN:
+ case c
+ of '/':
+ tokenizer.tmp = ""
+ switch_state RAWTEXT_END_TAG_OPEN
+ else:
+ emit '<'
+ reconsume_in RAWTEXT
+
+ of RAWTEXT_END_TAG_OPEN:
+ case c
+ of AsciiAlpha:
+ new_token Token[Atom](t: END_TAG)
+ tokenizer.tagNameBuf = $c.toLowerAscii()
+ tokenizer.tmp &= c
+ # note: was reconsume
+ switch_state RAWTEXT_END_TAG_NAME
+ else:
+ emit "</"
+ reconsume_in RAWTEXT
+
+ of RAWTEXT_END_TAG_NAME:
+ template anything_else =
+ tokenizer.emitTmp()
+ reconsume_in RAWTEXT
+ case c
+ of AsciiWhitespace:
+ tokenizer.flushTagName()
+ if is_appropriate_end_tag_token:
+ switch_state BEFORE_ATTRIBUTE_NAME
+ else:
+ anything_else
+ of '/':
+ tokenizer.flushTagName()
+ if is_appropriate_end_tag_token:
+ switch_state SELF_CLOSING_START_TAG
+ else:
+ anything_else
+ of '>':
+ tokenizer.flushTagName()
+ if is_appropriate_end_tag_token:
+ switch_state DATA
+ emit_tok
+ else:
+ anything_else
+ of AsciiAlpha: # note: merged upper & lower
+ tokenizer.tagNameBuf &= c.toLowerAscii()
+ tokenizer.tmp &= c
+ else:
+ anything_else
+
+ of SCRIPT_DATA_LESS_THAN_SIGN:
+ case c
+ of '/':
+ tokenizer.tmp = ""
+ switch_state SCRIPT_DATA_END_TAG_OPEN
+ of '!':
+ switch_state SCRIPT_DATA_ESCAPE_START
+ emit "<!"
+ else:
+ emit '<'
+ reconsume_in SCRIPT_DATA
+
+ of SCRIPT_DATA_END_TAG_OPEN:
+ case c
+ of AsciiAlpha:
+ new_token Token[Atom](t: END_TAG)
+ tokenizer.tagNameBuf = $c.toLowerAscii()
+ tokenizer.tmp &= c
+ # note: was reconsume
+ switch_state SCRIPT_DATA_END_TAG_NAME
+ else:
+ emit "</"
+ reconsume_in SCRIPT_DATA
+
+ of SCRIPT_DATA_END_TAG_NAME:
+ template anything_else =
+ tokenizer.emitTmp()
+ reconsume_in SCRIPT_DATA
+ case c
+ of AsciiWhitespace:
+ tokenizer.flushTagName()
+ if is_appropriate_end_tag_token:
+ switch_state BEFORE_ATTRIBUTE_NAME
+ else:
+ anything_else
+ of '/':
+ tokenizer.flushTagName()
+ if is_appropriate_end_tag_token:
+ switch_state SELF_CLOSING_START_TAG
+ else:
+ anything_else
+ of '>':
+ tokenizer.flushTagName()
+ if is_appropriate_end_tag_token:
+ switch_state DATA
+ emit_tok
+ else:
+ anything_else
+ of AsciiAlpha: # note: merged upper & lower
+ tokenizer.tagNameBuf &= c.toLowerAscii()
+ tokenizer.tmp &= c
+ else:
+ anything_else
+
+ of SCRIPT_DATA_ESCAPE_START:
+ case c
+ of '-':
+ switch_state SCRIPT_DATA_ESCAPE_START_DASH
+ emit '-'
+ else:
+ reconsume_in SCRIPT_DATA
+
+ of SCRIPT_DATA_ESCAPE_START_DASH:
+ case c
+ of '-':
+ switch_state SCRIPT_DATA_ESCAPED_DASH_DASH
+ emit '-'
+ else:
+ reconsume_in SCRIPT_DATA
+
+ of SCRIPT_DATA_ESCAPED:
+ case c
+ of '-':
+ switch_state SCRIPT_DATA_ESCAPED_DASH
+ emit '-'
+ of '<': switch_state SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN
+ of '\0': emit_replacement
+ else: emit c
+
+ of SCRIPT_DATA_ESCAPED_DASH:
+ case c
+ of '-':
+ switch_state SCRIPT_DATA_ESCAPED_DASH_DASH
+ emit '-'
+ of '<':
+ switch_state SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN
+ of '\0':
+ switch_state SCRIPT_DATA_ESCAPED
+ emit_replacement
+ else:
+ switch_state SCRIPT_DATA_ESCAPED
+ emit c
+
+ of SCRIPT_DATA_ESCAPED_DASH_DASH:
+ case c
+ of '-':
+ emit '-'
+ of '<':
+ switch_state SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN
+ of '>':
+ switch_state SCRIPT_DATA
+ emit '>'
+ of '\0':
+ switch_state SCRIPT_DATA_ESCAPED
+ emit_replacement
+ else:
+ switch_state SCRIPT_DATA_ESCAPED
+ emit c
+
+ of SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN:
+ case c
+ of '/':
+ tokenizer.tmp = ""
+ switch_state SCRIPT_DATA_ESCAPED_END_TAG_OPEN
+ of AsciiAlpha:
+ tokenizer.tmp = $c.toLowerAscii()
+ emit '<'
+ emit c
+ # note: was reconsume
+ switch_state SCRIPT_DATA_DOUBLE_ESCAPE_START
+ else:
+ emit '<'
+ reconsume_in SCRIPT_DATA_ESCAPED
+
+ of SCRIPT_DATA_ESCAPED_END_TAG_OPEN:
+ if c in AsciiAlpha:
+ new_token Token[Atom](t: END_TAG)
+ tokenizer.tagNameBuf = $c.toLowerAscii()
+ tokenizer.tmp &= c
+ # note: was reconsume
+ switch_state SCRIPT_DATA_ESCAPED_END_TAG_NAME
+ else:
+ emit "</"
+ reconsume_in SCRIPT_DATA_ESCAPED
+
+ of SCRIPT_DATA_ESCAPED_END_TAG_NAME:
+ template anything_else =
+ tokenizer.emitTmp()
+ reconsume_in SCRIPT_DATA_ESCAPED
+ case c
+ of AsciiWhitespace:
+ tokenizer.flushTagName()
+ if is_appropriate_end_tag_token:
+ switch_state BEFORE_ATTRIBUTE_NAME
+ else:
+ anything_else
+ of '/':
+ tokenizer.flushTagName()
+ if is_appropriate_end_tag_token:
+ switch_state SELF_CLOSING_START_TAG
+ else:
+ anything_else
+ of '>':
+ tokenizer.flushTagName()
+ if is_appropriate_end_tag_token:
+ switch_state DATA
+ emit_tok
+ else:
+ anything_else
+ of AsciiAlpha:
+ tokenizer.tagNameBuf &= c.toLowerAscii()
+ tokenizer.tmp &= c
+ else:
+ anything_else
+
+ of SCRIPT_DATA_DOUBLE_ESCAPE_START:
+ case c
+ of AsciiWhitespace, '/', '>':
+ if tokenizer.tmp == "script":
+ switch_state SCRIPT_DATA_DOUBLE_ESCAPED
+ else:
+ switch_state SCRIPT_DATA_ESCAPED
+ emit c
+ of AsciiAlpha: # note: merged upper & lower
+ tokenizer.tmp &= c.toLowerAscii()
+ emit c
+ else: reconsume_in SCRIPT_DATA_ESCAPED
+
+ of SCRIPT_DATA_DOUBLE_ESCAPED:
+ case c
+ of '-':
+ switch_state SCRIPT_DATA_DOUBLE_ESCAPED_DASH
+ emit '-'
+ of '<':
+ switch_state SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN
+ emit '<'
+ of '\0': emit_replacement
+ else: emit c
+
+ of SCRIPT_DATA_DOUBLE_ESCAPED_DASH:
+ case c
+ of '-':
+ switch_state SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH
+ emit '-'
+ of '<':
+ switch_state SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN
+ emit '<'
+ of '\0':
+ switch_state SCRIPT_DATA_DOUBLE_ESCAPED
+ emit_replacement
+ else:
+ switch_state SCRIPT_DATA_DOUBLE_ESCAPED
+ emit c
+
+ of SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH:
+ case c
+ of '-': emit '-'
+ of '<':
+ switch_state SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN
+ emit '<'
+ of '>':
+ switch_state SCRIPT_DATA
+ emit '>'
+ of '\0':
+ switch_state SCRIPT_DATA_DOUBLE_ESCAPED
+ emit_replacement
+ else:
+ switch_state SCRIPT_DATA_DOUBLE_ESCAPED
+ emit c
+
+ of SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN:
+ case c
+ of '/':
+ tokenizer.tmp = ""
+ switch_state SCRIPT_DATA_DOUBLE_ESCAPE_END
+ emit '/'
+ else: reconsume_in SCRIPT_DATA_DOUBLE_ESCAPED
+
+ of SCRIPT_DATA_DOUBLE_ESCAPE_END:
+ case c
+ of AsciiWhitespace, '/', '>':
+ if tokenizer.tmp == "script":
+ switch_state SCRIPT_DATA_ESCAPED
+ else:
+ switch_state SCRIPT_DATA_DOUBLE_ESCAPED
+ emit c
+ of AsciiAlpha: # note: merged upper & lower
+ tokenizer.tmp &= c.toLowerAscii()
+ emit c
+ else:
+ reconsume_in SCRIPT_DATA_DOUBLE_ESCAPED
+
+ of BEFORE_ATTRIBUTE_NAME:
+ case c
+ of AsciiWhitespace: discard
+ of '/', '>': reconsume_in AFTER_ATTRIBUTE_NAME
+ of '=':
+ start_new_attribute
+ tokenizer.tmp &= c
+ switch_state ATTRIBUTE_NAME
+ else:
+ start_new_attribute
+ reconsume_in ATTRIBUTE_NAME
+
+ of ATTRIBUTE_NAME:
+ case c
+ of AsciiWhitespace, '/', '>':
+ leave_attribute_name_state
+ reconsume_in AFTER_ATTRIBUTE_NAME
+ of '=':
+ leave_attribute_name_state
+ switch_state BEFORE_ATTRIBUTE_VALUE
+ of '\0':
+ tokenizer.tmp &= "\uFFFD"
+ else:
+ tokenizer.tmp &= c.toLowerAscii()
+
+ of AFTER_ATTRIBUTE_NAME:
+ case c
+ of AsciiWhitespace: discard
+ of '/': switch_state SELF_CLOSING_START_TAG
+ of '=': switch_state BEFORE_ATTRIBUTE_VALUE
+ of '>':
+ switch_state DATA
+ prepare_attrs_if_start
+ emit_tok
+ else:
+ start_new_attribute
+ reconsume_in ATTRIBUTE_NAME
+
+ of BEFORE_ATTRIBUTE_VALUE:
+ case c
+ of AsciiWhitespace: discard
+ of '"': switch_state ATTRIBUTE_VALUE_DOUBLE_QUOTED
+ of '\'': switch_state ATTRIBUTE_VALUE_SINGLE_QUOTED
+ of '>':
+ switch_state DATA
+ prepare_attrs_if_start
+ emit_tok
+ else: reconsume_in ATTRIBUTE_VALUE_UNQUOTED
+
+ of ATTRIBUTE_VALUE_DOUBLE_QUOTED:
+ case c
+ of '"': switch_state AFTER_ATTRIBUTE_VALUE_QUOTED
+ of '&': switch_state_return CHARACTER_REFERENCE
+ of '\0': tokenizer.appendToAttrValue("\uFFFD")
+ else: tokenizer.appendToAttrValue([c])
+
+ of ATTRIBUTE_VALUE_SINGLE_QUOTED:
+ case c
+ of '\'': switch_state AFTER_ATTRIBUTE_VALUE_QUOTED
+ of '&': switch_state_return CHARACTER_REFERENCE
+ of '\0': tokenizer.appendToAttrValue("\uFFFD")
+ else: tokenizer.appendToAttrValue([c])
+
+ of ATTRIBUTE_VALUE_UNQUOTED:
+ case c
+ of AsciiWhitespace: switch_state BEFORE_ATTRIBUTE_NAME
+ of '&': switch_state_return CHARACTER_REFERENCE
+ of '>':
+ switch_state DATA
+ prepare_attrs_if_start
+ emit_tok
+ of '\0': tokenizer.appendToAttrValue("\uFFFD")
+ else: tokenizer.appendToAttrValue([c])
+
+ of AFTER_ATTRIBUTE_VALUE_QUOTED:
+ case c
+ of AsciiWhitespace:
+ switch_state BEFORE_ATTRIBUTE_NAME
+ of '/':
+ switch_state SELF_CLOSING_START_TAG
+ of '>':
+ switch_state DATA
+ prepare_attrs_if_start
+ emit_tok
+ else: reconsume_in BEFORE_ATTRIBUTE_NAME
+
+ of SELF_CLOSING_START_TAG:
+ case c
+ of '>':
+ tokenizer.tok.selfclosing = true
+ switch_state DATA
+ prepare_attrs_if_start
+ emit_tok
+ else: reconsume_in BEFORE_ATTRIBUTE_NAME
+
+ of BOGUS_COMMENT:
+ assert tokenizer.tok.t == COMMENT
+ case c
+ of '>':
+ switch_state DATA
+ emit_tok
+ of '\0': tokenizer.tok.data &= "\uFFFD"
+ else: tokenizer.tok.data &= c
+
+ of MARKUP_DECLARATION_OPEN: # note: rewritten to fit case model as we consume a char anyway
+ template anything_else =
+ new_token Token[Atom](t: COMMENT)
+ switch_state BOGUS_COMMENT
+ case c
+ of '-':
+ case tokenizer.eatStr(c, "-", ibuf)
+ of esrSuccess:
+ new_token Token[Atom](t: COMMENT)
+ tokenizer.state = COMMENT_START
+ of esrRetry: break
+ of esrFail: anything_else
+ of 'D', 'd':
+ case tokenizer.eatStrNoCase(c, "octype", ibuf)
+ of esrSuccess: switch_state DOCTYPE
+ of esrRetry: break
+ of esrFail: anything_else
+ of '[':
+ case tokenizer.eatStr(c, "CDATA[", ibuf)
+ of esrSuccess:
+ if tokenizer.hasnonhtml:
+ switch_state CDATA_SECTION
+ else:
+ new_token Token[Atom](t: COMMENT, data: "[CDATA[")
+ switch_state BOGUS_COMMENT
+ of esrRetry: break
+ of esrFail: anything_else
+ else:
+ # eat didn't reconsume, do it ourselves
+ tokenizer.reconsume(c)
+ anything_else
+
+ of COMMENT_START:
+ case c
+ of '-': switch_state COMMENT_START_DASH
+ of '>':
+ switch_state DATA
+ emit_tok
+ else: reconsume_in COMMENT
+
+ of COMMENT_START_DASH:
+ case c
+ of '-': switch_state COMMENT_END
+ of '>':
+ switch_state DATA
+ emit_tok
+ else:
+ tokenizer.tok.data &= '-'
+ reconsume_in COMMENT
+
+ of COMMENT:
+ case c
+ of '<':
+ tokenizer.tok.data &= c
+ switch_state COMMENT_LESS_THAN_SIGN
+ of '-': switch_state COMMENT_END_DASH
+ of '\0': tokenizer.tok.data &= "\uFFFD"
+ else: tokenizer.tok.data &= c
+
+ of COMMENT_LESS_THAN_SIGN:
+ case c
+ of '!':
+ tokenizer.tok.data &= c
+ switch_state COMMENT_LESS_THAN_SIGN_BANG
+ of '<': tokenizer.tok.data &= c
+ else: reconsume_in COMMENT
+
+ of COMMENT_LESS_THAN_SIGN_BANG:
+ case c
+ of '-': switch_state COMMENT_LESS_THAN_SIGN_BANG_DASH
+ else: reconsume_in COMMENT
+
+ of COMMENT_LESS_THAN_SIGN_BANG_DASH:
+ case c
+ of '-': switch_state COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH
+ else: reconsume_in COMMENT_END_DASH
+
+ of COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH:
+ case c
+ of '>':
+ # note: was reconsume (comment end)
+ switch_state DATA
+ emit_tok
+ else: reconsume_in COMMENT_END
+
+ of COMMENT_END_DASH:
+ case c
+ of '-': switch_state COMMENT_END
+ else:
+ tokenizer.tok.data &= '-'
+ reconsume_in COMMENT
+
+ of COMMENT_END:
+ case c
+ of '>':
+ switch_state DATA
+ emit_tok
+ of '!': switch_state COMMENT_END_BANG
+ of '-': tokenizer.tok.data &= '-'
+ else:
+ tokenizer.tok.data &= "--"
+ reconsume_in COMMENT
+
+ of COMMENT_END_BANG:
+ case c
+ of '-':
+ tokenizer.tok.data &= "--!"
+ switch_state COMMENT_END_DASH
+ of '>':
+ switch_state DATA
+ emit_tok
+ else:
+ tokenizer.tok.data &= "--!"
+ reconsume_in COMMENT
+
+ of DOCTYPE:
+ if c notin AsciiWhitespace:
+ tokenizer.reconsume(c)
+ switch_state BEFORE_DOCTYPE_NAME
+
+ of BEFORE_DOCTYPE_NAME:
+ case c
+ of AsciiWhitespace: discard
+ of '\0':
+ new_token Token[Atom](t: DOCTYPE, name: some("\uFFFD"))
+ switch_state DOCTYPE_NAME
+ of '>':
+ new_token Token[Atom](t: DOCTYPE, quirks: true)
+ switch_state DATA
+ emit_tok
+ else:
+ new_token Token[Atom](t: DOCTYPE, name: some($c.toLowerAscii()))
+ switch_state DOCTYPE_NAME
+
+ of DOCTYPE_NAME:
+ case c
+ of AsciiWhitespace: switch_state AFTER_DOCTYPE_NAME
+ of '>':
+ switch_state DATA
+ emit_tok
+ of '\0': tokenizer.tok.name.get &= "\uFFFD"
+ else: tokenizer.tok.name.get &= c.toLowerAscii()
+
+ of AFTER_DOCTYPE_NAME: # note: rewritten to fit case model as we consume a char anyway
+ template anything_else =
+ tokenizer.tok.quirks = true
+ switch_state BOGUS_DOCTYPE
+ case c
+ of AsciiWhitespace: discard
+ of '>':
+ switch_state DATA
+ emit_tok
+ of 'p', 'P':
+ case tokenizer.eatStrNoCase(c, "ublic", ibuf)
+ of esrSuccess: switch_state AFTER_DOCTYPE_PUBLIC_KEYWORD
+ of esrRetry: break
+ of esrFail: anything_else
+ of 's', 'S':
+ case tokenizer.eatStrNoCase(c, "ystem", ibuf)
+ of esrSuccess: switch_state AFTER_DOCTYPE_SYSTEM_KEYWORD
+ of esrRetry: break
+ of esrFail: anything_else
+ else:
+ # eat didn't reconsume, do it ourselves
+ tokenizer.reconsume(c)
+ anything_else
+
+ of AFTER_DOCTYPE_PUBLIC_KEYWORD:
+ case c
+ of AsciiWhitespace: switch_state BEFORE_DOCTYPE_PUBLIC_IDENTIFIER
+ of '"':
+ tokenizer.tok.pubid = some("")
+ switch_state DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED
+ of '\'':
+ tokenizer.tok.pubid = some("")
+ switch_state DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED
+ of '>':
+ tokenizer.tok.quirks = true
+ switch_state DATA
+ emit_tok
+ else:
+ tokenizer.tok.quirks = true
+ reconsume_in BOGUS_DOCTYPE
+
+ of BEFORE_DOCTYPE_PUBLIC_IDENTIFIER:
+ case c
+ of AsciiWhitespace: discard
+ of '"':
+ tokenizer.tok.pubid = some("")
+ switch_state DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED
+ of '\'':
+ tokenizer.tok.pubid = some("")
+ switch_state DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED
+ of '>':
+ tokenizer.tok.quirks = true
+ switch_state DATA
+ emit_tok
+ else:
+ tokenizer.tok.quirks = true
+ reconsume_in BOGUS_DOCTYPE
+
+ of DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED:
+ case c
+ of '"': switch_state AFTER_DOCTYPE_PUBLIC_IDENTIFIER
+ of '\0': tokenizer.tok.pubid.get &= "\uFFFD"
+ of '>':
+ tokenizer.tok.quirks = true
+ switch_state DATA
+ emit_tok
+ else: tokenizer.tok.pubid.get &= c
+
+ of DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED:
+ case c
+ of '\'': switch_state AFTER_DOCTYPE_PUBLIC_IDENTIFIER
+ of '\0': tokenizer.tok.pubid.get &= "\uFFFD"
+ of '>':
+ tokenizer.tok.quirks = true
+ switch_state DATA
+ emit_tok
+ else: tokenizer.tok.pubid.get &= c
+
+ of AFTER_DOCTYPE_PUBLIC_IDENTIFIER:
+ case c
+ of AsciiWhitespace:
+ switch_state BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS
+ of '>':
+ switch_state DATA
+ emit_tok
+ of '"':
+ tokenizer.tok.sysid = some("")
+ switch_state DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED
+ of '\'':
+ tokenizer.tok.sysid = some("")
+ switch_state DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED
+ else:
+ tokenizer.tok.quirks = true
+ reconsume_in BOGUS_DOCTYPE
+
+ of BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS:
+ case c
+ of AsciiWhitespace: discard
+ of '>':
+ switch_state DATA
+ emit_tok
+ of '"':
+ tokenizer.tok.sysid = some("")
+ switch_state DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED
+ of '\'':
+ tokenizer.tok.sysid = some("")
+ switch_state DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED
+ else:
+ tokenizer.tok.quirks = true
+ reconsume_in BOGUS_DOCTYPE
+
+ of AFTER_DOCTYPE_SYSTEM_KEYWORD:
+ case c
+ of AsciiWhitespace: switch_state BEFORE_DOCTYPE_SYSTEM_IDENTIFIER
+ of '"':
+ tokenizer.tok.sysid = some("")
+ switch_state DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED
+ of '\'':
+ tokenizer.tok.sysid = some("")
+ switch_state DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED
+ of '>':
+ tokenizer.tok.quirks = true
+ switch_state DATA
+ emit_tok
+ else:
+ tokenizer.tok.quirks = true
+ reconsume_in BOGUS_DOCTYPE
+
+ of BEFORE_DOCTYPE_SYSTEM_IDENTIFIER:
+ case c
+ of AsciiWhitespace: discard
+ of '"':
+ tokenizer.tok.sysid = some("")
+ switch_state DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED
+ of '\'':
+ tokenizer.tok.sysid = some("")
+ switch_state DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED
+ of '>':
+ tokenizer.tok.quirks = true
+ switch_state DATA
+ emit_tok
+ else:
+ tokenizer.tok.quirks = true
+ reconsume_in BOGUS_DOCTYPE
+
+ of DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED:
+ case c
+ of '"': switch_state AFTER_DOCTYPE_SYSTEM_IDENTIFIER
+ of '\0': tokenizer.tok.sysid.get &= "\uFFFD"
+ of '>':
+ tokenizer.tok.quirks = true
+ switch_state DATA
+ emit_tok
+ else: tokenizer.tok.sysid.get &= c
+
+ of DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED:
+ case c
+ of '\'': switch_state AFTER_DOCTYPE_SYSTEM_IDENTIFIER
+ of '\0': tokenizer.tok.sysid.get &= "\uFFFD"
+ of '>':
+ tokenizer.tok.quirks = true
+ switch_state DATA
+ emit_tok
+ else:
+ tokenizer.tok.sysid.get &= c
+
+ of AFTER_DOCTYPE_SYSTEM_IDENTIFIER:
+ case c
+ of AsciiWhitespace: discard
+ of '>':
+ switch_state DATA
+ emit_tok
+ else:
+ switch_state BOGUS_DOCTYPE
+
+ of BOGUS_DOCTYPE:
+ if c == '>':
+ emit_tok
+ switch_state DATA
+
+ of CDATA_SECTION:
+ case c
+ of ']': switch_state CDATA_SECTION_BRACKET
+ of '\0':
+ # "U+0000 NULL characters are handled in the tree construction stage,
+ # as part of the in foreign content insertion mode, which is the only
+ # place where CDATA sections can appear."
+ emit_null
+ else:
+ emit c
+
+ of CDATA_SECTION_BRACKET:
+ if c == ']':
+ switch_state CDATA_SECTION_END
+ else:
+ emit ']'
+ reconsume_in CDATA_SECTION
+
+ of CDATA_SECTION_END:
+ case c
+ of ']': emit ']'
+ of '>': switch_state DATA
+ else:
+ emit "]]"
+ reconsume_in CDATA_SECTION
+
+ of CHARACTER_REFERENCE:
+ case c
+ of AsciiAlpha:
+ tokenizer.tmp = "&"
+ reconsume_in NAMED_CHARACTER_REFERENCE
+ of '#':
+ tokenizer.tmp = "&#"
+ switch_state NUMERIC_CHARACTER_REFERENCE
+ else:
+ tokenizer.appendAttrOrEmit("&")
+ reconsume_in tokenizer.rstate
+
+ of NAMED_CHARACTER_REFERENCE:
+ let (i, ci, entry) = tokenizer.findCharRef(c, ibuf)
+ if entry == nil and i == -1:
+ # -1 encountered without isend
+ tokenizer.reconsume(tokenizer.tmp.toOpenArray(1, tokenizer.tmp.high))
+ tokenizer.tmp = "&"
+ break
+ # Move back the pointer & shorten the buffer to the last match.
+ # (Add 1, because we do not store the starting & char in entityMap,
+ # but tmp starts with an &.)
+ tokenizer.reconsume(tokenizer.tmp.toOpenArray(ci + 1, tokenizer.tmp.high))
+ tokenizer.tmp.setLen(ci + 1)
+ if entry != nil and entry[ci] == ':':
+ let n = tokenizer.consume(ibuf)
+ let sc = tokenizer.consumedAsAttribute() and tokenizer.tmp[^1] != ';'
+ if sc and n != -1 and cast[char](n) in {'='} + AsciiAlphaNumeric:
+ tokenizer.reconsume(cast[char](n))
+ tokenizer.appendAttrOrEmit(tokenizer.tmp)
+ switch_state tokenizer.rstate
+ elif sc and n == -1 and not tokenizer.isend:
+ # We have to redo the above check.
+ tokenizer.reconsume(tokenizer.tmp.toOpenArray(1, tokenizer.tmp.high))
+ tokenizer.tmp = "&"
+ break
+ else:
+ if n != -1:
+ tokenizer.reconsume(cast[char](n))
+ tokenizer.tmp = ""
+ var ci = ci + 1
+ while (let c = entry[ci]; c != '\0'):
+ tokenizer.tmp &= c
+ inc ci
+ tokenizer.appendAttrOrEmit(tokenizer.tmp)
+ switch_state tokenizer.rstate
+ else:
+ tokenizer.appendAttrOrEmit(tokenizer.tmp)
+ switch_state AMBIGUOUS_AMPERSAND_STATE
+
+ of AMBIGUOUS_AMPERSAND_STATE:
+ if c in AsciiAlpha:
+ tokenizer.appendAttrOrEmit([c])
+ else:
+ reconsume_in tokenizer.rstate
+
+ of NUMERIC_CHARACTER_REFERENCE:
+ tokenizer.code = 0
+ case c
+ of 'x', 'X':
+ tokenizer.tmp &= c
+ switch_state HEXADECIMAL_CHARACTER_REFERENCE_START
+ of AsciiDigit:
+ tokenizer.code = uint32(c) - uint32('0')
+ # note: was reconsume
+ switch_state DECIMAL_CHARACTER_REFERENCE
+ else:
+ tokenizer.appendAttrOrEmit(tokenizer.tmp)
+ reconsume_in tokenizer.rstate
+
+ of HEXADECIMAL_CHARACTER_REFERENCE_START:
+ let c2 = c.toLowerAscii()
+ case c2
+ of AsciiDigit:
+ tokenizer.code = uint32(c2) - uint32('0')
+ # note: was reconsume
+ switch_state HEXADECIMAL_CHARACTER_REFERENCE
+ of 'a'..'f':
+ tokenizer.code = uint32(c2) - uint32('a') + 10
+ # note: was reconsume
+ switch_state HEXADECIMAL_CHARACTER_REFERENCE
+ else:
+ tokenizer.appendAttrOrEmit(tokenizer.tmp)
+ reconsume_in tokenizer.rstate
+
+ of HEXADECIMAL_CHARACTER_REFERENCE:
+ let c2 = c.toLowerAscii()
+ case c2
+ of AsciiDigit:
+ if tokenizer.code < 0x10FFFF:
+ tokenizer.code *= 0x10
+ tokenizer.code += uint32(c2) - uint32('0')
+ of 'a'..'f':
+ if tokenizer.code < 0x10FFFF:
+ tokenizer.code *= 0x10
+ tokenizer.code += uint32(c2) - uint32('a') + 10
+ else:
+ if c != ';':
+ tokenizer.reconsume(c)
+ tokenizer.numericCharacterReferenceEndState()
+ switch_state tokenizer.rstate
+
+ of DECIMAL_CHARACTER_REFERENCE:
+ if c in AsciiDigit:
+ if tokenizer.code < 0x10FFFF:
+ tokenizer.code *= 10
+ tokenizer.code += uint32(c) - uint32('0')
+ else:
+ if c != ';':
+ tokenizer.reconsume(c)
+ tokenizer.numericCharacterReferenceEndState()
+ switch_state tokenizer.rstate
+
+ return trDone
+
+proc finish*[Handle, Atom](tokenizer: var Tokenizer[Handle, Atom]):
+ TokenizeResult =
+ if tokenizer.peekBufLen > 0:
+ tokenizer.isend = true
+ if tokenizer.tokenize([]) != trDone:
+ return trEmit
+ if tokenizer.tokenizeEOF():
+ let r = tokenizer.tokenizeEOF()
+ assert not r
+ return trDone
diff --git a/lib/chame0/chame/minidom.nim b/lib/chame0/chame/minidom.nim
new file mode 100644
index 00000000..0fe10e46
--- /dev/null
+++ b/lib/chame0/chame/minidom.nim
@@ -0,0 +1,497 @@
+## Minimal DOMBuilder example. Implements the absolute minimum required
+## for htmlparser to work correctly.
+##
+## For an example of a complete implementation (with JS support and
+## document.write), see Chawan's chadombuilder.
+##
+## Note: this only works with UTF-8 inputs. For a variant that can
+## switch encodings when meta tags are encountered etc. see
+## [chame/minidom_cs](minidom_cs.html).
+
+import std/algorithm
+import std/hashes
+import std/options
+import std/sets
+import std/streams
+import std/tables
+
+import htmlparser
+import tags
+
+export tags
+
+# Atom implementation
+#TODO maybe we should use a better hash map.
+const MAtomFactoryStrMapLength = 1024 # must be a power of 2
+static:
+ doAssert (MAtomFactoryStrMapLength and (MAtomFactoryStrMapLength - 1)) == 0
+
+type
+ MAtom* = distinct int
+
+ MAtomFactory* = ref object of RootObj
+ strMap: array[MAtomFactoryStrMapLength, seq[MAtom]]
+ atomMap: seq[string]
+
+# Mandatory Atom functions
+func `==`*(a, b: MAtom): bool {.borrow.}
+func hash*(atom: MAtom): Hash {.borrow.}
+
+func strToAtom*(factory: MAtomFactory, s: string): MAtom
+
+proc newMAtomFactory*(): MAtomFactory =
+ const minCap = int(TagType.high) + 1
+ let factory = MAtomFactory(
+ atomMap: newSeqOfCap[string](minCap),
+ )
+ factory.atomMap.add("") # skip TAG_UNKNOWN
+ for tagType in TagType(int(TAG_UNKNOWN) + 1) .. TagType.high:
+ discard factory.strToAtom($tagType)
+ return factory
+
+func strToAtom*(factory: MAtomFactory, s: string): MAtom =
+ let h = s.hash()
+ let i = h and (factory.strMap.len - 1)
+ for atom in factory.strMap[i]:
+ if factory.atomMap[int(atom)] == s:
+ # Found
+ return atom
+ # Not found
+ let atom = MAtom(factory.atomMap.len)
+ factory.atomMap.add(s)
+ factory.strMap[i].add(atom)
+ return atom
+
+func tagTypeToAtom*(factory: MAtomFactory, tagType: TagType): MAtom =
+ assert tagType != TAG_UNKNOWN
+ return MAtom(tagType)
+
+func atomToStr*(factory: MAtomFactory, atom: MAtom): string =
+ return factory.atomMap[int(atom)]
+
+# Node types
+type
+ Attribute* = ParsedAttr[MAtom]
+
+ Node* = ref object of RootObj
+ childList*: seq[Node]
+ parentNode* {.cursor.}: Node
+
+ CharacterData* = ref object of Node
+ data*: string
+
+ Comment* = ref object of CharacterData
+
+ Document* = ref object of Node
+ factory*: MAtomFactory
+
+ Text* = ref object of CharacterData
+
+ DocumentType* = ref object of Node
+ name*: string
+ publicId*: string
+ systemId*: string
+
+ Element* = ref object of Node
+ localName*: MAtom
+ namespace*: Namespace
+ attrs*: seq[Attribute]
+ document*: Document
+
+ DocumentFragment* = ref object of Node
+
+ HTMLTemplateElement* = ref object of Element
+ content*: DocumentFragment
+
+type
+ MiniDOMBuilder* = ref object of DOMBuilder[Node, MAtom]
+ document*: Document
+ factory*: MAtomFactory
+
+type
+ DOMBuilderImpl = MiniDOMBuilder
+ AtomImpl = MAtom
+ HandleImpl = Node
+
+include htmlparseriface
+
+func toTagType*(atom: MAtom): TagType {.inline.} =
+ if int(atom) <= int(high(TagType)):
+ return TagType(atom)
+ return TAG_UNKNOWN
+
+func tagType*(element: Element): TagType =
+ return element.localName.toTagType()
+
+func cmp*(a, b: MAtom): int {.inline.} =
+ return cmp(int(a), int(b))
+
+# We use this to validate input strings, since htmltokenizer/htmlparser does no
+# input validation.
+proc toValidUTF8(s: string): string =
+ result = ""
+ var i = 0
+ while i < s.len:
+ if int(s[i]) < 0x80:
+ result &= s[i]
+ inc i
+ elif int(s[i]) shr 5 == 0x6:
+ if i + 1 < s.len and int(s[i + 1]) shr 6 == 2:
+ result &= s[i]
+ result &= s[i + 1]
+ else:
+ result &= "\uFFFD"
+ i += 2
+ elif int(s[i]) shr 4 == 0xE:
+ if i + 2 < s.len and int(s[i + 1]) shr 6 == 2 and
+ int(s[i + 2]) shr 6 == 2:
+ result &= s[i]
+ result &= s[i + 1]
+ result &= s[i + 2]
+ else:
+ result &= "\uFFFD"
+ i += 3
+ elif int(s[i]) shr 3 == 0x1E:
+ if i + 3 < s.len and int(s[i + 1]) shr 6 == 2 and
+ int(s[i + 2]) shr 6 == 2 and int(s[i + 3]) shr 6 == 2:
+ result &= s[i]
+ result &= s[i + 1]
+ result &= s[i + 2]
+ result &= s[i + 3]
+ else:
+ result &= "\uFFFD"
+ i += 4
+ else:
+ result &= "\uFFFD"
+ inc i
+
+proc localNameStr*(element: Element): string =
+ return element.document.factory.atomToStr(element.localName)
+
+iterator attrsStr*(element: Element): tuple[name, value: string] =
+ let factory = element.document.factory
+ for attr in element.attrs:
+ var name = ""
+ if attr.prefix != NO_PREFIX:
+ name &= $attr.prefix & ':'
+ name &= factory.atomToStr(attr.name)
+ yield (name, attr.value)
+
+# htmlparseriface implementation
+proc strToAtomImpl(builder: MiniDOMBuilder, s: string): MAtom =
+ return builder.factory.strToAtom(s)
+
+proc tagTypeToAtomImpl(builder: MiniDOMBuilder, tagType: TagType): MAtom =
+ return builder.factory.tagTypeToAtom(tagType)
+
+proc atomToTagTypeImpl(builder: MiniDOMBuilder, atom: MAtom): TagType =
+ return atom.toTagType()
+
+proc getDocumentImpl(builder: MiniDOMBuilder): Node =
+ return builder.document
+
+proc getParentNodeImpl(builder: MiniDOMBuilder, handle: Node): Option[Node] =
+ return option(handle.parentNode)
+
+proc createElement(document: Document, localName: MAtom, namespace: Namespace):
+ Element =
+ let element = if localName.toTagType() == TAG_TEMPLATE and
+ namespace == Namespace.HTML:
+ HTMLTemplateElement(
+ content: DocumentFragment()
+ )
+ else:
+ Element()
+ element.localName = localName
+ element.namespace = namespace
+ element.document = document
+ return element
+
+proc createHTMLElementImpl(builder: MiniDOMBuilder): Node =
+ let localName = builder.factory.tagTypeToAtom(TAG_HTML)
+ return builder.document.createElement(localName, Namespace.HTML)
+
+proc createElementForTokenImpl(builder: MiniDOMBuilder, localName: MAtom,
+ namespace: Namespace, intendedParent: Node, htmlAttrs: Table[MAtom, string],
+ xmlAttrs: seq[Attribute]): Node =
+ let element = builder.document.createElement(localName, namespace)
+ element.attrs = xmlAttrs
+ for k, v in htmlAttrs:
+ element.attrs.add((NO_PREFIX, NO_NAMESPACE, k, v.toValidUTF8()))
+ element.attrs.sort(func(a, b: Attribute): int = cmp(a.name, b.name))
+ return element
+
+proc getLocalNameImpl(builder: MiniDOMBuilder, handle: Node): MAtom =
+ return Element(handle).localName
+
+proc getNamespaceImpl(builder: MiniDOMBuilder, handle: Node): Namespace =
+ return Element(handle).namespace
+
+proc getTemplateContentImpl(builder: MiniDOMBuilder, handle: Node): Node =
+ return HTMLTemplateElement(handle).content
+
+proc createCommentImpl(builder: MiniDOMBuilder, text: string): Node =
+ return Comment(data: text.toValidUTF8())
+
+proc createDocumentTypeImpl(builder: MiniDOMBuilder, name, publicId,
+ systemId: string): Node =
+ return DocumentType(
+ name: name.toValidUTF8(),
+ publicId: publicId.toValidUTF8(),
+ systemId: systemId.toValidUTF8()
+ )
+
+func countElementChildren(node: Node): int =
+ result = 0
+ for child in node.childList:
+ if child of Element:
+ inc result
+
+func hasTextChild(node: Node): bool =
+ for child in node.childList:
+ if child of Text:
+ return true
+ return false
+
+func hasElementChild(node: Node): bool =
+ for child in node.childList:
+ if child of Element:
+ return true
+ return false
+
+func hasDocumentTypeChild(node: Node): bool =
+ for child in node.childList:
+ if child of DocumentType:
+ return true
+ return false
+
+func isHostIncludingInclusiveAncestor(a, b: Node): bool =
+ var b = b
+ while b != nil:
+ if b == a:
+ return true
+ b = b.parentNode
+ return false
+
+func hasPreviousElementSibling(node: Node): bool =
+ for n in node.parentNode.childList:
+ if n == node:
+ break
+ if n of Element:
+ return true
+ return false
+
+func hasNextDocumentTypeSibling(node: Node): bool =
+ for i in countdown(node.parentNode.childList.len, 0):
+ let n = node.parentNode.childList[i]
+ if n == node:
+ break
+ if n of DocumentType:
+ return true
+ return false
+
+func isValidParent(node: Node): bool =
+ return node of Element or node of Document or node of DocumentFragment
+
+func isValidChild(node: Node): bool =
+ return node.isValidParent or node of DocumentType or node of CharacterData
+
+# WARNING the ordering of the arguments in the standard is whack so this
+# doesn't match that
+func preInsertionValidity*(parent, node: Node, before: Node): bool =
+ if not parent.isValidParent:
+ return false
+ if node.isHostIncludingInclusiveAncestor(parent):
+ return false
+ if before != nil and before.parentNode != parent:
+ return false
+ if not node.isValidChild:
+ return false
+ if node of Text and parent of Document:
+ return false
+ if node of DocumentType and not (parent of Document):
+ return false
+ if parent of Document:
+ if node of DocumentFragment:
+ let elems = node.countElementChildren()
+ if elems > 1 or node.hasTextChild():
+ return false
+ elif elems == 1 and (parent.hasElementChild() or
+ before != nil and
+ (before of DocumentType or before.hasNextDocumentTypeSibling())):
+ return false
+ elif node of Element:
+ if parent.hasElementChild():
+ return false
+ elif before != nil and (before of DocumentType or
+ before.hasNextDocumentTypeSibling()):
+ return false
+ elif node of DocumentType:
+ if parent.hasDocumentTypeChild() or
+ before != nil and before.hasPreviousElementSibling() or
+ before == nil and parent.hasElementChild():
+ return false
+ return true # no exception reached
+
+proc insertBefore(parent, child: Node, before: Option[Node]) =
+ let before = before.get(nil)
+ if parent.preInsertionValidity(child, before):
+ assert child.parentNode == nil
+ if before == nil:
+ parent.childList.add(child)
+ else:
+ let i = parent.childList.find(before)
+ parent.childList.insert(child, i)
+ child.parentNode = parent
+
+proc insertBeforeImpl(builder: MiniDOMBuilder, parent, child: Node,
+ before: Option[Node]) =
+ parent.insertBefore(child, before)
+
+proc insertTextImpl(builder: MiniDOMBuilder, parent: Node, text: string,
+ before: Option[Node]) =
+ let text = text.toValidUTF8()
+ let before = before.get(nil)
+ let prevSibling = if before != nil:
+ let i = parent.childList.find(before)
+ if i == 0:
+ nil
+ else:
+ parent.childList[i - 1]
+ elif parent.childList.len > 0:
+ parent.childList[^1]
+ else:
+ nil
+ if prevSibling != nil and prevSibling of Text:
+ Text(prevSibling).data &= text
+ else:
+ let text = Text(data: text)
+ parent.insertBefore(text, option(before))
+
+proc removeImpl(builder: MiniDOMBuilder, child: Node) =
+ if child.parentNode != nil:
+ let i = child.parentNode.childList.find(child)
+ child.parentNode.childList.delete(i)
+ child.parentNode = nil
+
+proc moveChildrenImpl(builder: MiniDOMBuilder, fromNode, toNode: Node) =
+ let tomove = @(fromNode.childList)
+ fromNode.childList.setLen(0)
+ for child in tomove:
+ child.parentNode = nil
+ toNode.insertBefore(child, none(Node))
+
+proc addAttrsIfMissingImpl(builder: MiniDOMBuilder, handle: Node,
+ attrs: Table[MAtom, string]) =
+ let element = Element(handle)
+ var oldNames = initHashSet[MAtom]()
+ for attr in element.attrs:
+ oldNames.incl(attr.name)
+ for name, value in attrs:
+ if name notin oldNames:
+ element.attrs.add((NO_PREFIX, NO_NAMESPACE, name, value.toValidUTF8()))
+ element.attrs.sort(func(a, b: Attribute): int = cmp(a.name, b.name))
+
+method setEncodingImpl(builder: MiniDOMBuilder, encoding: string):
+ SetEncodingResult {.base.} =
+ # Provided as a method for minidom_cs to override.
+ return SET_ENCODING_CONTINUE
+
+proc newMiniDOMBuilder*(factory: MAtomFactory): MiniDOMBuilder =
+ let document = Document(factory: factory)
+ let builder = MiniDOMBuilder(
+ document: document,
+ factory: factory
+ )
+ return builder
+
+proc parseFromStream(parser: var HTML5Parser[Node, MAtom],
+ inputStream: Stream) =
+ var buffer {.noinit.}: array[4096, char]
+ while true:
+ let n = inputStream.readData(addr buffer[0], buffer.len)
+ if n == 0: break
+ # res can be PRES_CONTINUE or PRES_SCRIPTING. PRES_STOP is only returned
+ # on charset switching, and minidom does not support that.
+ var res = parser.parseChunk(buffer.toOpenArray(0, n - 1))
+ # Important: we must repeat parseChunk with the same contents for the script
+ # end tag result, with reprocess = true.
+ #
+ # (This is only relevant for calls where scripting = true; with scripting =
+ # false, PRES_SCRIPT would never be returned.)
+ var ip = 0
+ while res == PRES_SCRIPT and (ip += parser.getInsertionPoint(); ip != n):
+ res = parser.parseChunk(buffer.toOpenArray(ip, n - 1))
+ parser.finish()
+
+proc parseHTML*(inputStream: Stream, opts = HTML5ParserOpts[Node, MAtom](),
+ factory = newMAtomFactory()): Document =
+ ## Read, parse and return an HTML document from `inputStream`, using
+ ## parser options `opts` and MAtom factory `factory`.
+ ##
+ ## `inputStream` is not required to be seekable.
+ ##
+ ## For a description of `HTML5ParserOpts`, see the `htmlparser` module's
+ ## documentation.
+ let builder = newMiniDOMBuilder(factory)
+ var parser = initHTML5Parser(builder, opts)
+ parser.parseFromStream(inputStream)
+ return builder.document
+
+proc parseHTMLFragment*(inputStream: Stream, element: Element,
+ opts: HTML5ParserOpts[Node, MAtom], factory = newMAtomFactory()):
+ seq[Node] =
+ ## Read, parse and return the children of an HTML fragment from `inputStream`,
+ ## using context element `element` and parser options `opts`.
+ ##
+ ## For information on `opts` (an `HTML5ParserOpts` object), please consult
+ ## the documentation of chame/htmlparser.nim.
+ ##
+ ## For details on the HTML fragment parsing algorithm, see
+ ## https://html.spec.whatwg.org/multipage/parsing.html#parsing-html-fragments
+ ##
+ ## Note: the members `ctx`, `initialTokenizerState`, `openElementsInit` and
+ ## `pushInTemplate` of `opts` are overridden (in accordance with the standard).
+ let builder = newMiniDOMBuilder(factory)
+ let document = builder.document
+ let state = if element.namespace != Namespace.HTML:
+ DATA
+ else:
+ case element.tagType
+ of TAG_TITLE, TAG_TEXTAREA: RCDATA
+ of TAG_STYLE, TAG_XMP, TAG_IFRAME, TAG_NOEMBED, TAG_NOFRAMES: RAWTEXT
+ of TAG_SCRIPT: SCRIPT_DATA
+ of TAG_NOSCRIPT: DATA # no scripting
+ of TAG_PLAINTEXT: PLAINTEXT
+ else: DATA
+ let htmlAtom = builder.factory.tagTypeToAtom(TAG_HTML)
+ let root = Element(
+ localName: htmlAtom,
+ namespace: HTML,
+ document: document
+ )
+ document.childList = @[Node(root)]
+ var opts = opts
+ opts.ctx = some((Node(element), element.localName))
+ opts.initialTokenizerState = state
+ opts.openElementsInit = @[(Node(root), htmlAtom)]
+ opts.pushInTemplate = element.tagType == TAG_TEMPLATE
+ var parser = initHTML5Parser(builder, opts)
+ parser.parseFromStream(inputStream)
+ return root.childList
+
+proc parseHTMLFragment*(s: string, element: Element): seq[Node] =
+ ## Convenience wrapper around parseHTMLFragment with opts.
+ ##
+ ## Read, parse and return the children of an HTML fragment from the string `s`,
+ ## using context element `element`.
+ ##
+ ## For details on the HTML fragment parsing algorithm, see
+ ## https://html.spec.whatwg.org/multipage/parsing.html#parsing-html-fragments
+ let inputStream = newStringStream(s)
+ let opts = HTML5ParserOpts[Node, MAtom](
+ isIframeSrcdoc: false,
+ scripting: false,
+ pushInTemplate: element.tagType == TAG_TEMPLATE
+ )
+ return parseHTMLFragment(inputStream, element, opts)
diff --git a/lib/chame0/chame/minidom_cs.nim b/lib/chame0/chame/minidom_cs.nim
new file mode 100644
index 00000000..6b183785
--- /dev/null
+++ b/lib/chame0/chame/minidom_cs.nim
@@ -0,0 +1,165 @@
+## A demonstration of using the Chagashi encoding library in combination
+## with the Chame HTML parser.
+##
+## For the most part, this is the same as minidom, except it supports
+## decoding documents with arbitrary character sets.
+##
+## Note: this is not implemented for the fragment parsing algorithm,
+## because that is only defined for UTF-8 in the standard.
+##
+## For a version without the encoding library dependency, see
+## [minidom](minidom.html).
+
+import std/streams
+
+import minidom
+import htmlparser
+import tags
+
+import chagashi/charset
+import chagashi/decoder
+
+export minidom
+export tags
+
+type CharsetConfidence = enum
+ ccTentative, ccCertain
+
+type CharsetMiniDOMBuilder = ref object of MiniDOMBuilder
+ charset: Charset
+ confidence: CharsetConfidence
+
+method setEncodingImpl(builder: CharsetMiniDOMBuilder, encoding: string):
+ SetEncodingResult =
+ let charset = getCharset(encoding)
+ if charset == CHARSET_UNKNOWN:
+ return SET_ENCODING_CONTINUE
+ if builder.charset in {CHARSET_UTF_16_LE, CHARSET_UTF_16_BE}:
+ builder.confidence = ccCertain
+ return SET_ENCODING_CONTINUE
+ builder.confidence = ccCertain
+ if charset == builder.charset:
+ return SET_ENCODING_CONTINUE
+ if charset == CHARSET_X_USER_DEFINED:
+ builder.charset = CHARSET_WINDOWS_1252
+ else:
+ builder.charset = charset
+ return SET_ENCODING_STOP
+
+proc newCharsetMiniDOMBuilder(factory: MAtomFactory): CharsetMiniDOMBuilder =
+ let document = Document(factory: factory)
+ let builder = CharsetMiniDOMBuilder(document: document, factory: factory)
+ return builder
+
+#TODO this should be handled by decoderstream
+proc bomSniff(inputStream: Stream): Charset =
+ let bom = inputStream.readStr(2)
+ if bom == "\xFE\xFF":
+ return CHARSET_UTF_16_BE
+ if bom == "\xFF\xFE":
+ return CHARSET_UTF_16_LE
+ if bom == "\xEF\xBB":
+ if inputStream.readChar() == '\xBF':
+ return CHARSET_UTF_8
+ inputStream.setPosition(0)
+ return CHARSET_UNKNOWN
+
+proc parseHTML*(inputStream: Stream, opts: HTML5ParserOpts[Node, MAtom],
+ charsets: seq[Charset], seekable = true,
+ factory = newMAtomFactory()): Document =
+ ## Read, parse and return an HTML document from `inputStream`.
+ ##
+ ## `charsets` is a list of input character sets to try. If empty, it will be
+ ## initialized to `@[CHARSET_UTF_8]`.
+ ##
+ ## The list of fallback charsets is used as follows:
+ ##
+ ## * A charset stack is initialized to `charsets`, reversed. This
+ ## means that the first charset specified in `charsets` is on top of
+ ## the stack. (e.g. say `charsets = @[CHARSET_UTF_16_LE, CHARSET_UTF_8]`,
+ ## then utf-16-le is tried before utf-8.)
+ ## * BOM sniffing is attempted. If successful, confidence is set to
+ ## certain and the resulting charset is used (i.e. other character
+ ## sets will not be tried for decoding this document.)
+ ## * If the charset stack is empty, UTF-8 is pushed on top.
+ ## * Attempt to parse the document with the first charset on top of
+ ## the stack.
+ ## * If BOM sniffing was unsuccessful, and a <meta charset=...> tag
+ ## is encountered, parsing is restarted with the specified charset.
+ ## No further attempts are made to detect the encoding, and decoder
+ ## errors are signaled by U+FFFD replacement characters.
+ ## * Otherwise, each charset on the charset stack is tried until either no
+ ## decoding errors are encountered, or only one charset is left. For
+ ## the last charset, decoder errors are signaled by U+FFFD replacement
+ ## characters.
+ ##
+ ## `seekable` must be true only if `inputStream` is seekable; if set to true,
+ ## `inputStream.setPosition(0)` must work.
+ ##
+ ## Note that `seekable = false` disables automatic character set detection;
+ ## even `<meta charset=...` tags will be disregarded.
+ ## (TODO: this should be improved in the future; theoretically we could still
+ ## switch between ASCII-compatible charsets before non-ASCII is encountered.)
+ let builder = newCharsetMiniDOMBuilder(factory)
+ var charsetStack: seq[Charset] = @[]
+ for i in countdown(charsets.high, 0):
+ charsetStack.add(charsets[i])
+ var seekable = seekable
+ var inputStream = inputStream
+ if seekable:
+ let scs = inputStream.bomSniff()
+ if scs != CHARSET_UNKNOWN:
+ charsetStack.add(scs)
+ builder.confidence = ccCertain
+ seekable = false
+ if charsetStack.len == 0:
+ charsetStack.add(DefaultCharset) # UTF-8
+ while true:
+ builder.charset = charsetStack.pop()
+ if seekable and charsetStack.len > 0:
+ builder.confidence = ccTentative # used in the next iteration
+ else:
+ builder.confidence = ccCertain
+ var parser = initHTML5Parser(builder, opts)
+ var iq {.noinit.}: array[4096, char]
+ let decoder = newTextDecoder(builder.charset)
+ let errorMode = [
+ ccTentative: demFatal,
+ ccCertain: demReplacement
+ ][builder.confidence]
+ var ctx = initTextDecoderContext(decoder, errorMode)
+ while true:
+ let n = inputStream.readData(addr iq[0], iq.len)
+ var finish = n < iq.len
+ for chunk in ctx.decode(iq.toOpenArrayByte(0, n - 1), finish = finish):
+ # res can be PRES_SCRIPT, PRES_STOP or PRES_CONTINUE.
+ var res = parser.parseChunk(chunk.toOpenArray())
+ # For PRES_SCRIPT, we must re-feed the same chunk as in minidom, but
+ # starting from the current insertion point.
+ var ip = 0
+ while res == PRES_SCRIPT and
+ (ip += parser.getInsertionPoint(); ip != chunk.len):
+ res = parser.parseChunk(chunk.toOpenArray(ip, chunk.high))
+ # PRES_STOP is returned when we return SET_ENCODING_STOP from
+ # setEncodingImpl. We immediately stop parsing in this case.
+ if res == PRES_STOP:
+ finish = true
+ break
+ if finish:
+ break
+ parser.finish()
+ if builder.confidence == ccCertain and seekable:
+ # A meta tag describing the charset has been found; force use of this
+ # charset.
+ inputStream.setPosition(0)
+ builder.document = Document(factory: factory)
+ charsetStack.add(builder.charset)
+ seekable = false
+ continue
+ if ctx.failed and seekable:
+ # Retry with another charset.
+ inputStream.setPosition(0)
+ builder.document = Document(factory: factory)
+ continue
+ break
+ return builder.document
diff --git a/lib/chame0/chame/res/entity.json b/lib/chame0/chame/res/entity.json
new file mode 100644
index 00000000..557170b4
--- /dev/null
+++ b/lib/chame0/chame/res/entity.json
@@ -0,0 +1,2233 @@
+{
+ "&AElig": { "codepoints": [198], "characters": "\u00C6" },
+ "&AElig;": { "codepoints": [198], "characters": "\u00C6" },
+ "&AMP": { "codepoints": [38], "characters": "\u0026" },
+ "&AMP;": { "codepoints": [38], "characters": "\u0026" },
+ "&Aacute": { "codepoints": [193], "characters": "\u00C1" },
+ "&Aacute;": { "codepoints": [193], "characters": "\u00C1" },
+ "&Abreve;": { "codepoints": [258], "characters": "\u0102" },
+ "&Acirc": { "codepoints": [194], "characters": "\u00C2" },
+ "&Acirc;": { "codepoints": [194], "characters": "\u00C2" },
+ "&Acy;": { "codepoints": [1040], "characters": "\u0410" },
+ "&Afr;": { "codepoints": [120068], "characters": "\uD835\uDD04" },
+ "&Agrave": { "codepoints": [192], "characters": "\u00C0" },
+ "&Agrave;": { "codepoints": [192], "characters": "\u00C0" },
+ "&Alpha;": { "codepoints": [913], "characters": "\u0391" },
+ "&Amacr;": { "codepoints": [256], "characters": "\u0100" },
+ "&And;": { "codepoints": [10835], "characters": "\u2A53" },
+ "&Aogon;": { "codepoints": [260], "characters": "\u0104" },
+ "&Aopf;": { "codepoints": [120120], "characters": "\uD835\uDD38" },
+ "&ApplyFunction;": { "codepoints": [8289], "characters": "\u2061" },
+ "&Aring": { "codepoints": [197], "characters": "\u00C5" },
+ "&Aring;": { "codepoints": [197], "characters": "\u00C5" },
+ "&Ascr;": { "codepoints": [119964], "characters": "\uD835\uDC9C" },
+ "&Assign;": { "codepoints": [8788], "characters": "\u2254" },
+ "&Atilde": { "codepoints": [195], "characters": "\u00C3" },
+ "&Atilde;": { "codepoints": [195], "characters": "\u00C3" },
+ "&Auml": { "codepoints": [196], "characters": "\u00C4" },
+ "&Auml;": { "codepoints": [196], "characters": "\u00C4" },
+ "&Backslash;": { "codepoints": [8726], "characters": "\u2216" },
+ "&Barv;": { "codepoints": [10983], "characters": "\u2AE7" },
+ "&Barwed;": { "codepoints": [8966], "characters": "\u2306" },
+ "&Bcy;": { "codepoints": [1041], "characters": "\u0411" },
+ "&Because;": { "codepoints": [8757], "characters": "\u2235" },
+ "&Bernoullis;": { "codepoints": [8492], "characters": "\u212C" },
+ "&Beta;": { "codepoints": [914], "characters": "\u0392" },
+ "&Bfr;": { "codepoints": [120069], "characters": "\uD835\uDD05" },
+ "&Bopf;": { "codepoints": [120121], "characters": "\uD835\uDD39" },
+ "&Breve;": { "codepoints": [728], "characters": "\u02D8" },
+ "&Bscr;": { "codepoints": [8492], "characters": "\u212C" },
+ "&Bumpeq;": { "codepoints": [8782], "characters": "\u224E" },
+ "&CHcy;": { "codepoints": [1063], "characters": "\u0427" },
+ "&COPY": { "codepoints": [169], "characters": "\u00A9" },
+ "&COPY;": { "codepoints": [169], "characters": "\u00A9" },
+ "&Cacute;": { "codepoints": [262], "characters": "\u0106" },
+ "&Cap;": { "codepoints": [8914], "characters": "\u22D2" },
+ "&CapitalDifferentialD;": { "codepoints": [8517], "characters": "\u2145" },
+ "&Cayleys;": { "codepoints": [8493], "characters": "\u212D" },
+ "&Ccaron;": { "codepoints": [268], "characters": "\u010C" },
+ "&Ccedil": { "codepoints": [199], "characters": "\u00C7" },
+ "&Ccedil;": { "codepoints": [199], "characters": "\u00C7" },
+ "&Ccirc;": { "codepoints": [264], "characters": "\u0108" },
+ "&Cconint;": { "codepoints": [8752], "characters": "\u2230" },
+ "&Cdot;": { "codepoints": [266], "characters": "\u010A" },
+ "&Cedilla;": { "codepoints": [184], "characters": "\u00B8" },
+ "&CenterDot;": { "codepoints": [183], "characters": "\u00B7" },
+ "&Cfr;": { "codepoints": [8493], "characters": "\u212D" },
+ "&Chi;": { "codepoints": [935], "characters": "\u03A7" },
+ "&CircleDot;": { "codepoints": [8857], "characters": "\u2299" },
+ "&CircleMinus;": { "codepoints": [8854], "characters": "\u2296" },
+ "&CirclePlus;": { "codepoints": [8853], "characters": "\u2295" },
+ "&CircleTimes;": { "codepoints": [8855], "characters": "\u2297" },
+ "&ClockwiseContourIntegral;": { "codepoints": [8754], "characters": "\u2232" },
+ "&CloseCurlyDoubleQuote;": { "codepoints": [8221], "characters": "\u201D" },
+ "&CloseCurlyQuote;": { "codepoints": [8217], "characters": "\u2019" },
+ "&Colon;": { "codepoints": [8759], "characters": "\u2237" },
+ "&Colone;": { "codepoints": [10868], "characters": "\u2A74" },
+ "&Congruent;": { "codepoints": [8801], "characters": "\u2261" },
+ "&Conint;": { "codepoints": [8751], "characters": "\u222F" },
+ "&ContourIntegral;": { "codepoints": [8750], "characters": "\u222E" },
+ "&Copf;": { "codepoints": [8450], "characters": "\u2102" },
+ "&Coproduct;": { "codepoints": [8720], "characters": "\u2210" },
+ "&CounterClockwiseContourIntegral;": { "codepoints": [8755], "characters": "\u2233" },
+ "&Cross;": { "codepoints": [10799], "characters": "\u2A2F" },
+ "&Cscr;": { "codepoints": [119966], "characters": "\uD835\uDC9E" },
+ "&Cup;": { "codepoints": [8915], "characters": "\u22D3" },
+ "&CupCap;": { "codepoints": [8781], "characters": "\u224D" },
+ "&DD;": { "codepoints": [8517], "characters": "\u2145" },
+ "&DDotrahd;": { "codepoints": [10513], "characters": "\u2911" },
+ "&DJcy;": { "codepoints": [1026], "characters": "\u0402" },
+ "&DScy;": { "codepoints": [1029], "characters": "\u0405" },
+ "&DZcy;": { "codepoints": [1039], "characters": "\u040F" },
+ "&Dagger;": { "codepoints": [8225], "characters": "\u2021" },
+ "&Darr;": { "codepoints": [8609], "characters": "\u21A1" },
+ "&Dashv;": { "codepoints": [10980], "characters": "\u2AE4" },
+ "&Dcaron;": { "codepoints": [270], "characters": "\u010E" },
+ "&Dcy;": { "codepoints": [1044], "characters": "\u0414" },
+ "&Del;": { "codepoints": [8711], "characters": "\u2207" },
+ "&Delta;": { "codepoints": [916], "characters": "\u0394" },
+ "&Dfr;": { "codepoints": [120071], "characters": "\uD835\uDD07" },
+ "&DiacriticalAcute;": { "codepoints": [180], "characters": "\u00B4" },
+ "&DiacriticalDot;": { "codepoints": [729], "characters": "\u02D9" },
+ "&DiacriticalDoubleAcute;": { "codepoints": [733], "characters": "\u02DD" },
+ "&DiacriticalGrave;": { "codepoints": [96], "characters": "\u0060" },
+ "&DiacriticalTilde;": { "codepoints": [732], "characters": "\u02DC" },
+ "&Diamond;": { "codepoints": [8900], "characters": "\u22C4" },
+ "&DifferentialD;": { "codepoints": [8518], "characters": "\u2146" },
+ "&Dopf;": { "codepoints": [120123], "characters": "\uD835\uDD3B" },
+ "&Dot;": { "codepoints": [168], "characters": "\u00A8" },
+ "&DotDot;": { "codepoints": [8412], "characters": "\u20DC" },
+ "&DotEqual;": { "codepoints": [8784], "characters": "\u2250" },
+ "&DoubleContourIntegral;": { "codepoints": [8751], "characters": "\u222F" },
+ "&DoubleDot;": { "codepoints": [168], "characters": "\u00A8" },
+ "&DoubleDownArrow;": { "codepoints": [8659], "characters": "\u21D3" },
+ "&DoubleLeftArrow;": { "codepoints": [8656], "characters": "\u21D0" },
+ "&DoubleLeftRightArrow;": { "codepoints": [8660], "characters": "\u21D4" },
+ "&DoubleLeftTee;": { "codepoints": [10980], "characters": "\u2AE4" },
+ "&DoubleLongLeftArrow;": { "codepoints": [10232], "characters": "\u27F8" },
+ "&DoubleLongLeftRightArrow;": { "codepoints": [10234], "characters": "\u27FA" },
+ "&DoubleLongRightArrow;": { "codepoints": [10233], "characters": "\u27F9" },
+ "&DoubleRightArrow;": { "codepoints": [8658], "characters": "\u21D2" },
+ "&DoubleRightTee;": { "codepoints": [8872], "characters": "\u22A8" },
+ "&DoubleUpArrow;": { "codepoints": [8657], "characters": "\u21D1" },
+ "&DoubleUpDownArrow;": { "codepoints": [8661], "characters": "\u21D5" },
+ "&DoubleVerticalBar;": { "codepoints": [8741], "characters": "\u2225" },
+ "&DownArrow;": { "codepoints": [8595], "characters": "\u2193" },
+ "&DownArrowBar;": { "codepoints": [10515], "characters": "\u2913" },
+ "&DownArrowUpArrow;": { "codepoints": [8693], "characters": "\u21F5" },
+ "&DownBreve;": { "codepoints": [785], "characters": "\u0311" },
+ "&DownLeftRightVector;": { "codepoints": [10576], "characters": "\u2950" },
+ "&DownLeftTeeVector;": { "codepoints": [10590], "characters": "\u295E" },
+ "&DownLeftVector;": { "codepoints": [8637], "characters": "\u21BD" },
+ "&DownLeftVectorBar;": { "codepoints": [10582], "characters": "\u2956" },
+ "&DownRightTeeVector;": { "codepoints": [10591], "characters": "\u295F" },
+ "&DownRightVector;": { "codepoints": [8641], "characters": "\u21C1" },
+ "&DownRightVectorBar;": { "codepoints": [10583], "characters": "\u2957" },
+ "&DownTee;": { "codepoints": [8868], "characters": "\u22A4" },
+ "&DownTeeArrow;": { "codepoints": [8615], "characters": "\u21A7" },
+ "&Downarrow;": { "codepoints": [8659], "characters": "\u21D3" },
+ "&Dscr;": { "codepoints": [119967], "characters": "\uD835\uDC9F" },
+ "&Dstrok;": { "codepoints": [272], "characters": "\u0110" },
+ "&ENG;": { "codepoints": [330], "characters": "\u014A" },
+ "&ETH": { "codepoints": [208], "characters": "\u00D0" },
+ "&ETH;": { "codepoints": [208], "characters": "\u00D0" },
+ "&Eacute": { "codepoints": [201], "characters": "\u00C9" },
+ "&Eacute;": { "codepoints": [201], "characters": "\u00C9" },
+ "&Ecaron;": { "codepoints": [282], "characters": "\u011A" },
+ "&Ecirc": { "codepoints": [202], "characters": "\u00CA" },
+ "&Ecirc;": { "codepoints": [202], "characters": "\u00CA" },
+ "&Ecy;": { "codepoints": [1069], "characters": "\u042D" },
+ "&Edot;": { "codepoints": [278], "characters": "\u0116" },
+ "&Efr;": { "codepoints": [120072], "characters": "\uD835\uDD08" },
+ "&Egrave": { "codepoints": [200], "characters": "\u00C8" },
+ "&Egrave;": { "codepoints": [200], "characters": "\u00C8" },
+ "&Element;": { "codepoints": [8712], "characters": "\u2208" },
+ "&Emacr;": { "codepoints": [274], "characters": "\u0112" },
+ "&EmptySmallSquare;": { "codepoints": [9723], "characters": "\u25FB" },
+ "&EmptyVerySmallSquare;": { "codepoints": [9643], "characters": "\u25AB" },
+ "&Eogon;": { "codepoints": [280], "characters": "\u0118" },
+ "&Eopf;": { "codepoints": [120124], "characters": "\uD835\uDD3C" },
+ "&Epsilon;": { "codepoints": [917], "characters": "\u0395" },
+ "&Equal;": { "codepoints": [10869], "characters": "\u2A75" },
+ "&EqualTilde;": { "codepoints": [8770], "characters": "\u2242" },
+ "&Equilibrium;": { "codepoints": [8652], "characters": "\u21CC" },
+ "&Escr;": { "codepoints": [8496], "characters": "\u2130" },
+ "&Esim;": { "codepoints": [10867], "characters": "\u2A73" },
+ "&Eta;": { "codepoints": [919], "characters": "\u0397" },
+ "&Euml": { "codepoints": [203], "characters": "\u00CB" },
+ "&Euml;": { "codepoints": [203], "characters": "\u00CB" },
+ "&Exists;": { "codepoints": [8707], "characters": "\u2203" },
+ "&ExponentialE;": { "codepoints": [8519], "characters": "\u2147" },
+ "&Fcy;": { "codepoints": [1060], "characters": "\u0424" },
+ "&Ffr;": { "codepoints": [120073], "characters": "\uD835\uDD09" },
+ "&FilledSmallSquare;": { "codepoints": [9724], "characters": "\u25FC" },
+ "&FilledVerySmallSquare;": { "codepoints": [9642], "characters": "\u25AA" },
+ "&Fopf;": { "codepoints": [120125], "characters": "\uD835\uDD3D" },
+ "&ForAll;": { "codepoints": [8704], "characters": "\u2200" },
+ "&Fouriertrf;": { "codepoints": [8497], "characters": "\u2131" },
+ "&Fscr;": { "codepoints": [8497], "characters": "\u2131" },
+ "&GJcy;": { "codepoints": [1027], "characters": "\u0403" },
+ "&GT": { "codepoints": [62], "characters": "\u003E" },
+ "&GT;": { "codepoints": [62], "characters": "\u003E" },
+ "&Gamma;": { "codepoints": [915], "characters": "\u0393" },
+ "&Gammad;": { "codepoints": [988], "characters": "\u03DC" },
+ "&Gbreve;": { "codepoints": [286], "characters": "\u011E" },
+ "&Gcedil;": { "codepoints": [290], "characters": "\u0122" },
+ "&Gcirc;": { "codepoints": [284], "characters": "\u011C" },
+ "&Gcy;": { "codepoints": [1043], "characters": "\u0413" },
+ "&Gdot;": { "codepoints": [288], "characters": "\u0120" },
+ "&Gfr;": { "codepoints": [120074], "characters": "\uD835\uDD0A" },
+ "&Gg;": { "codepoints": [8921], "characters": "\u22D9" },
+ "&Gopf;": { "codepoints": [120126], "characters": "\uD835\uDD3E" },
+ "&GreaterEqual;": { "codepoints": [8805], "characters": "\u2265" },
+ "&GreaterEqualLess;": { "codepoints": [8923], "characters": "\u22DB" },
+ "&GreaterFullEqual;": { "codepoints": [8807], "characters": "\u2267" },
+ "&GreaterGreater;": { "codepoints": [10914], "characters": "\u2AA2" },
+ "&GreaterLess;": { "codepoints": [8823], "characters": "\u2277" },
+ "&GreaterSlantEqual;": { "codepoints": [10878], "characters": "\u2A7E" },
+ "&GreaterTilde;": { "codepoints": [8819], "characters": "\u2273" },
+ "&Gscr;": { "codepoints": [119970], "characters": "\uD835\uDCA2" },
+ "&Gt;": { "codepoints": [8811], "characters": "\u226B" },
+ "&HARDcy;": { "codepoints": [1066], "characters": "\u042A" },
+ "&Hacek;": { "codepoints": [711], "characters": "\u02C7" },
+ "&Hat;": { "codepoints": [94], "characters": "\u005E" },
+ "&Hcirc;": { "codepoints": [292], "characters": "\u0124" },
+ "&Hfr;": { "codepoints": [8460], "characters": "\u210C" },
+ "&HilbertSpace;": { "codepoints": [8459], "characters": "\u210B" },
+ "&Hopf;": { "codepoints": [8461], "characters": "\u210D" },
+ "&HorizontalLine;": { "codepoints": [9472], "characters": "\u2500" },
+ "&Hscr;": { "codepoints": [8459], "characters": "\u210B" },
+ "&Hstrok;": { "codepoints": [294], "characters": "\u0126" },
+ "&HumpDownHump;": { "codepoints": [8782], "characters": "\u224E" },
+ "&HumpEqual;": { "codepoints": [8783], "characters": "\u224F" },
+ "&IEcy;": { "codepoints": [1045], "characters": "\u0415" },
+ "&IJlig;": { "codepoints": [306], "characters": "\u0132" },
+ "&IOcy;": { "codepoints": [1025], "characters": "\u0401" },
+ "&Iacute": { "codepoints": [205], "characters": "\u00CD" },
+ "&Iacute;": { "codepoints": [205], "characters": "\u00CD" },
+ "&Icirc": { "codepoints": [206], "characters": "\u00CE" },
+ "&Icirc;": { "codepoints": [206], "characters": "\u00CE" },
+ "&Icy;": { "codepoints": [1048], "characters": "\u0418" },
+ "&Idot;": { "codepoints": [304], "characters": "\u0130" },
+ "&Ifr;": { "codepoints": [8465], "characters": "\u2111" },
+ "&Igrave": { "codepoints": [204], "characters": "\u00CC" },
+ "&Igrave;": { "codepoints": [204], "characters": "\u00CC" },
+ "&Im;": { "codepoints": [8465], "characters": "\u2111" },
+ "&Imacr;": { "codepoints": [298], "characters": "\u012A" },
+ "&ImaginaryI;": { "codepoints": [8520], "characters": "\u2148" },
+ "&Implies;": { "codepoints": [8658], "characters": "\u21D2" },
+ "&Int;": { "codepoints": [8748], "characters": "\u222C" },
+ "&Integral;": { "codepoints": [8747], "characters": "\u222B" },
+ "&Intersection;": { "codepoints": [8898], "characters": "\u22C2" },
+ "&InvisibleComma;": { "codepoints": [8291], "characters": "\u2063" },
+ "&InvisibleTimes;": { "codepoints": [8290], "characters": "\u2062" },
+ "&Iogon;": { "codepoints": [302], "characters": "\u012E" },
+ "&Iopf;": { "codepoints": [120128], "characters": "\uD835\uDD40" },
+ "&Iota;": { "codepoints": [921], "characters": "\u0399" },
+ "&Iscr;": { "codepoints": [8464], "characters": "\u2110" },
+ "&Itilde;": { "codepoints": [296], "characters": "\u0128" },
+ "&Iukcy;": { "codepoints": [1030], "characters": "\u0406" },
+ "&Iuml": { "codepoints": [207], "characters": "\u00CF" },
+ "&Iuml;": { "codepoints": [207], "characters": "\u00CF" },
+ "&Jcirc;": { "codepoints": [308], "characters": "\u0134" },
+ "&Jcy;": { "codepoints": [1049], "characters": "\u0419" },
+ "&Jfr;": { "codepoints": [120077], "characters": "\uD835\uDD0D" },
+ "&Jopf;": { "codepoints": [120129], "characters": "\uD835\uDD41" },
+ "&Jscr;": { "codepoints": [119973], "characters": "\uD835\uDCA5" },
+ "&Jsercy;": { "codepoints": [1032], "characters": "\u0408" },
+ "&Jukcy;": { "codepoints": [1028], "characters": "\u0404" },
+ "&KHcy;": { "codepoints": [1061], "characters": "\u0425" },
+ "&KJcy;": { "codepoints": [1036], "characters": "\u040C" },
+ "&Kappa;": { "codepoints": [922], "characters": "\u039A" },
+ "&Kcedil;": { "codepoints": [310], "characters": "\u0136" },
+ "&Kcy;": { "codepoints": [1050], "characters": "\u041A" },
+ "&Kfr;": { "codepoints": [120078], "characters": "\uD835\uDD0E" },
+ "&Kopf;": { "codepoints": [120130], "characters": "\uD835\uDD42" },
+ "&Kscr;": { "codepoints": [119974], "characters": "\uD835\uDCA6" },
+ "&LJcy;": { "codepoints": [1033], "characters": "\u0409" },
+ "&LT": { "codepoints": [60], "characters": "\u003C" },
+ "&LT;": { "codepoints": [60], "characters": "\u003C" },
+ "&Lacute;": { "codepoints": [313], "characters": "\u0139" },
+ "&Lambda;": { "codepoints": [923], "characters": "\u039B" },
+ "&Lang;": { "codepoints": [10218], "characters": "\u27EA" },
+ "&Laplacetrf;": { "codepoints": [8466], "characters": "\u2112" },
+ "&Larr;": { "codepoints": [8606], "characters": "\u219E" },
+ "&Lcaron;": { "codepoints": [317], "characters": "\u013D" },
+ "&Lcedil;": { "codepoints": [315], "characters": "\u013B" },
+ "&Lcy;": { "codepoints": [1051], "characters": "\u041B" },
+ "&LeftAngleBracket;": { "codepoints": [10216], "characters": "\u27E8" },
+ "&LeftArrow;": { "codepoints": [8592], "characters": "\u2190" },
+ "&LeftArrowBar;": { "codepoints": [8676], "characters": "\u21E4" },
+ "&LeftArrowRightArrow;": { "codepoints": [8646], "characters": "\u21C6" },
+ "&LeftCeiling;": { "codepoints": [8968], "characters": "\u2308" },
+ "&LeftDoubleBracket;": { "codepoints": [10214], "characters": "\u27E6" },
+ "&LeftDownTeeVector;": { "codepoints": [10593], "characters": "\u2961" },
+ "&LeftDownVector;": { "codepoints": [8643], "characters": "\u21C3" },
+ "&LeftDownVectorBar;": { "codepoints": [10585], "characters": "\u2959" },
+ "&LeftFloor;": { "codepoints": [8970], "characters": "\u230A" },
+ "&LeftRightArrow;": { "codepoints": [8596], "characters": "\u2194" },
+ "&LeftRightVector;": { "codepoints": [10574], "characters": "\u294E" },
+ "&LeftTee;": { "codepoints": [8867], "characters": "\u22A3" },
+ "&LeftTeeArrow;": { "codepoints": [8612], "characters": "\u21A4" },
+ "&LeftTeeVector;": { "codepoints": [10586], "characters": "\u295A" },
+ "&LeftTriangle;": { "codepoints": [8882], "characters": "\u22B2" },
+ "&LeftTriangleBar;": { "codepoints": [10703], "characters": "\u29CF" },
+ "&LeftTriangleEqual;": { "codepoints": [8884], "characters": "\u22B4" },
+ "&LeftUpDownVector;": { "codepoints": [10577], "characters": "\u2951" },
+ "&LeftUpTeeVector;": { "codepoints": [10592], "characters": "\u2960" },
+ "&LeftUpVector;": { "codepoints": [8639], "characters": "\u21BF" },
+ "&LeftUpVectorBar;": { "codepoints": [10584], "characters": "\u2958" },
+ "&LeftVector;": { "codepoints": [8636], "characters": "\u21BC" },
+ "&LeftVectorBar;": { "codepoints": [10578], "characters": "\u2952" },
+ "&Leftarrow;": { "codepoints": [8656], "characters": "\u21D0" },
+ "&Leftrightarrow;": { "codepoints": [8660], "characters": "\u21D4" },
+ "&LessEqualGreater;": { "codepoints": [8922], "characters": "\u22DA" },
+ "&LessFullEqual;": { "codepoints": [8806], "characters": "\u2266" },
+ "&LessGreater;": { "codepoints": [8822], "characters": "\u2276" },
+ "&LessLess;": { "codepoints": [10913], "characters": "\u2AA1" },
+ "&LessSlantEqual;": { "codepoints": [10877], "characters": "\u2A7D" },
+ "&LessTilde;": { "codepoints": [8818], "characters": "\u2272" },
+ "&Lfr;": { "codepoints": [120079], "characters": "\uD835\uDD0F" },
+ "&Ll;": { "codepoints": [8920], "characters": "\u22D8" },
+ "&Lleftarrow;": { "codepoints": [8666], "characters": "\u21DA" },
+ "&Lmidot;": { "codepoints": [319], "characters": "\u013F" },
+ "&LongLeftArrow;": { "codepoints": [10229], "characters": "\u27F5" },
+ "&LongLeftRightArrow;": { "codepoints": [10231], "characters": "\u27F7" },
+ "&LongRightArrow;": { "codepoints": [10230], "characters": "\u27F6" },
+ "&Longleftarrow;": { "codepoints": [10232], "characters": "\u27F8" },
+ "&Longleftrightarrow;": { "codepoints": [10234], "characters": "\u27FA" },
+ "&Longrightarrow;": { "codepoints": [10233], "characters": "\u27F9" },
+ "&Lopf;": { "codepoints": [120131], "characters": "\uD835\uDD43" },
+ "&LowerLeftArrow;": { "codepoints": [8601], "characters": "\u2199" },
+ "&LowerRightArrow;": { "codepoints": [8600], "characters": "\u2198" },
+ "&Lscr;": { "codepoints": [8466], "characters": "\u2112" },
+ "&Lsh;": { "codepoints": [8624], "characters": "\u21B0" },
+ "&Lstrok;": { "codepoints": [321], "characters": "\u0141" },
+ "&Lt;": { "codepoints": [8810], "characters": "\u226A" },
+ "&Map;": { "codepoints": [10501], "characters": "\u2905" },
+ "&Mcy;": { "codepoints": [1052], "characters": "\u041C" },
+ "&MediumSpace;": { "codepoints": [8287], "characters": "\u205F" },
+ "&Mellintrf;": { "codepoints": [8499], "characters": "\u2133" },
+ "&Mfr;": { "codepoints": [120080], "characters": "\uD835\uDD10" },
+ "&MinusPlus;": { "codepoints": [8723], "characters": "\u2213" },
+ "&Mopf;": { "codepoints": [120132], "characters": "\uD835\uDD44" },
+ "&Mscr;": { "codepoints": [8499], "characters": "\u2133" },
+ "&Mu;": { "codepoints": [924], "characters": "\u039C" },
+ "&NJcy;": { "codepoints": [1034], "characters": "\u040A" },
+ "&Nacute;": { "codepoints": [323], "characters": "\u0143" },
+ "&Ncaron;": { "codepoints": [327], "characters": "\u0147" },
+ "&Ncedil;": { "codepoints": [325], "characters": "\u0145" },
+ "&Ncy;": { "codepoints": [1053], "characters": "\u041D" },
+ "&NegativeMediumSpace;": { "codepoints": [8203], "characters": "\u200B" },
+ "&NegativeThickSpace;": { "codepoints": [8203], "characters": "\u200B" },
+ "&NegativeThinSpace;": { "codepoints": [8203], "characters": "\u200B" },
+ "&NegativeVeryThinSpace;": { "codepoints": [8203], "characters": "\u200B" },
+ "&NestedGreaterGreater;": { "codepoints": [8811], "characters": "\u226B" },
+ "&NestedLessLess;": { "codepoints": [8810], "characters": "\u226A" },
+ "&NewLine;": { "codepoints": [10], "characters": "\u000A" },
+ "&Nfr;": { "codepoints": [120081], "characters": "\uD835\uDD11" },
+ "&NoBreak;": { "codepoints": [8288], "characters": "\u2060" },
+ "&NonBreakingSpace;": { "codepoints": [160], "characters": "\u00A0" },
+ "&Nopf;": { "codepoints": [8469], "characters": "\u2115" },
+ "&Not;": { "codepoints": [10988], "characters": "\u2AEC" },
+ "&NotCongruent;": { "codepoints": [8802], "characters": "\u2262" },
+ "&NotCupCap;": { "codepoints": [8813], "characters": "\u226D" },
+ "&NotDoubleVerticalBar;": { "codepoints": [8742], "characters": "\u2226" },
+ "&NotElement;": { "codepoints": [8713], "characters": "\u2209" },
+ "&NotEqual;": { "codepoints": [8800], "characters": "\u2260" },
+ "&NotEqualTilde;": { "codepoints": [8770, 824], "characters": "\u2242\u0338" },
+ "&NotExists;": { "codepoints": [8708], "characters": "\u2204" },
+ "&NotGreater;": { "codepoints": [8815], "characters": "\u226F" },
+ "&NotGreaterEqual;": { "codepoints": [8817], "characters": "\u2271" },
+ "&NotGreaterFullEqual;": { "codepoints": [8807, 824], "characters": "\u2267\u0338" },
+ "&NotGreaterGreater;": { "codepoints": [8811, 824], "characters": "\u226B\u0338" },
+ "&NotGreaterLess;": { "codepoints": [8825], "characters": "\u2279" },
+ "&NotGreaterSlantEqual;": { "codepoints": [10878, 824], "characters": "\u2A7E\u0338" },
+ "&NotGreaterTilde;": { "codepoints": [8821], "characters": "\u2275" },
+ "&NotHumpDownHump;": { "codepoints": [8782, 824], "characters": "\u224E\u0338" },
+ "&NotHumpEqual;": { "codepoints": [8783, 824], "characters": "\u224F\u0338" },
+ "&NotLeftTriangle;": { "codepoints": [8938], "characters": "\u22EA" },
+ "&NotLeftTriangleBar;": { "codepoints": [10703, 824], "characters": "\u29CF\u0338" },
+ "&NotLeftTriangleEqual;": { "codepoints": [8940], "characters": "\u22EC" },
+ "&NotLess;": { "codepoints": [8814], "characters": "\u226E" },
+ "&NotLessEqual;": { "codepoints": [8816], "characters": "\u2270" },
+ "&NotLessGreater;": { "codepoints": [8824], "characters": "\u2278" },
+ "&NotLessLess;": { "codepoints": [8810, 824], "characters": "\u226A\u0338" },
+ "&NotLessSlantEqual;": { "codepoints": [10877, 824], "characters": "\u2A7D\u0338" },
+ "&NotLessTilde;": { "codepoints": [8820], "characters": "\u2274" },
+ "&NotNestedGreaterGreater;": { "codepoints": [10914, 824], "characters": "\u2AA2\u0338" },
+ "&NotNestedLessLess;": { "codepoints": [10913, 824], "characters": "\u2AA1\u0338" },
+ "&NotPrecedes;": { "codepoints": [8832], "characters": "\u2280" },
+ "&NotPrecedesEqual;": { "codepoints": [10927, 824], "characters": "\u2AAF\u0338" },
+ "&NotPrecedesSlantEqual;": { "codepoints": [8928], "characters": "\u22E0" },
+ "&NotReverseElement;": { "codepoints": [8716], "characters": "\u220C" },
+ "&NotRightTriangle;": { "codepoints": [8939], "characters": "\u22EB" },
+ "&NotRightTriangleBar;": { "codepoints": [10704, 824], "characters": "\u29D0\u0338" },
+ "&NotRightTriangleEqual;": { "codepoints": [8941], "characters": "\u22ED" },
+ "&NotSquareSubset;": { "codepoints": [8847, 824], "characters": "\u228F\u0338" },
+ "&NotSquareSubsetEqual;": { "codepoints": [8930], "characters": "\u22E2" },
+ "&NotSquareSuperset;": { "codepoints": [8848, 824], "characters": "\u2290\u0338" },
+ "&NotSquareSupersetEqual;": { "codepoints": [8931], "characters": "\u22E3" },
+ "&NotSubset;": { "codepoints": [8834, 8402], "characters": "\u2282\u20D2" },
+ "&NotSubsetEqual;": { "codepoints": [8840], "characters": "\u2288" },
+ "&NotSucceeds;": { "codepoints": [8833], "characters": "\u2281" },
+ "&NotSucceedsEqual;": { "codepoints": [10928, 824], "characters": "\u2AB0\u0338" },
+ "&NotSucceedsSlantEqual;": { "codepoints": [8929], "characters": "\u22E1" },
+ "&NotSucceedsTilde;": { "codepoints": [8831, 824], "characters": "\u227F\u0338" },
+ "&NotSuperset;": { "codepoints": [8835, 8402], "characters": "\u2283\u20D2" },
+ "&NotSupersetEqual;": { "codepoints": [8841], "characters": "\u2289" },
+ "&NotTilde;": { "codepoints": [8769], "characters": "\u2241" },
+ "&NotTildeEqual;": { "codepoints": [8772], "characters": "\u2244" },
+ "&NotTildeFullEqual;": { "codepoints": [8775], "characters": "\u2247" },
+ "&NotTildeTilde;": { "codepoints": [8777], "characters": "\u2249" },
+ "&NotVerticalBar;": { "codepoints": [8740], "characters": "\u2224" },
+ "&Nscr;": { "codepoints": [119977], "characters": "\uD835\uDCA9" },
+ "&Ntilde": { "codepoints": [209], "characters": "\u00D1" },
+ "&Ntilde;": { "codepoints": [209], "characters": "\u00D1" },
+ "&Nu;": { "codepoints": [925], "characters": "\u039D" },
+ "&OElig;": { "codepoints": [338], "characters": "\u0152" },
+ "&Oacute": { "codepoints": [211], "characters": "\u00D3" },
+ "&Oacute;": { "codepoints": [211], "characters": "\u00D3" },
+ "&Ocirc": { "codepoints": [212], "characters": "\u00D4" },
+ "&Ocirc;": { "codepoints": [212], "characters": "\u00D4" },
+ "&Ocy;": { "codepoints": [1054], "characters": "\u041E" },
+ "&Odblac;": { "codepoints": [336], "characters": "\u0150" },
+ "&Ofr;": { "codepoints": [120082], "characters": "\uD835\uDD12" },
+ "&Ograve": { "codepoints": [210], "characters": "\u00D2" },
+ "&Ograve;": { "codepoints": [210], "characters": "\u00D2" },
+ "&Omacr;": { "codepoints": [332], "characters": "\u014C" },
+ "&Omega;": { "codepoints": [937], "characters": "\u03A9" },
+ "&Omicron;": { "codepoints": [927], "characters": "\u039F" },
+ "&Oopf;": { "codepoints": [120134], "characters": "\uD835\uDD46" },
+ "&OpenCurlyDoubleQuote;": { "codepoints": [8220], "characters": "\u201C" },
+ "&OpenCurlyQuote;": { "codepoints": [8216], "characters": "\u2018" },
+ "&Or;": { "codepoints": [10836], "characters": "\u2A54" },
+ "&Oscr;": { "codepoints": [119978], "characters": "\uD835\uDCAA" },
+ "&Oslash": { "codepoints": [216], "characters": "\u00D8" },
+ "&Oslash;": { "codepoints": [216], "characters": "\u00D8" },
+ "&Otilde": { "codepoints": [213], "characters": "\u00D5" },
+ "&Otilde;": { "codepoints": [213], "characters": "\u00D5" },
+ "&Otimes;": { "codepoints": [10807], "characters": "\u2A37" },
+ "&Ouml": { "codepoints": [214], "characters": "\u00D6" },
+ "&Ouml;": { "codepoints": [214], "characters": "\u00D6" },
+ "&OverBar;": { "codepoints": [8254], "characters": "\u203E" },
+ "&OverBrace;": { "codepoints": [9182], "characters": "\u23DE" },
+ "&OverBracket;": { "codepoints": [9140], "characters": "\u23B4" },
+ "&OverParenthesis;": { "codepoints": [9180], "characters": "\u23DC" },
+ "&PartialD;": { "codepoints": [8706], "characters": "\u2202" },
+ "&Pcy;": { "codepoints": [1055], "characters": "\u041F" },
+ "&Pfr;": { "codepoints": [120083], "characters": "\uD835\uDD13" },
+ "&Phi;": { "codepoints": [934], "characters": "\u03A6" },
+ "&Pi;": { "codepoints": [928], "characters": "\u03A0" },
+ "&PlusMinus;": { "codepoints": [177], "characters": "\u00B1" },
+ "&Poincareplane;": { "codepoints": [8460], "characters": "\u210C" },
+ "&Popf;": { "codepoints": [8473], "characters": "\u2119" },
+ "&Pr;": { "codepoints": [10939], "characters": "\u2ABB" },
+ "&Precedes;": { "codepoints": [8826], "characters": "\u227A" },
+ "&PrecedesEqual;": { "codepoints": [10927], "characters": "\u2AAF" },
+ "&PrecedesSlantEqual;": { "codepoints": [8828], "characters": "\u227C" },
+ "&PrecedesTilde;": { "codepoints": [8830], "characters": "\u227E" },
+ "&Prime;": { "codepoints": [8243], "characters": "\u2033" },
+ "&Product;": { "codepoints": [8719], "characters": "\u220F" },
+ "&Proportion;": { "codepoints": [8759], "characters": "\u2237" },
+ "&Proportional;": { "codepoints": [8733], "characters": "\u221D" },
+ "&Pscr;": { "codepoints": [119979], "characters": "\uD835\uDCAB" },
+ "&Psi;": { "codepoints": [936], "characters": "\u03A8" },
+ "&QUOT": { "codepoints": [34], "characters": "\u0022" },
+ "&QUOT;": { "codepoints": [34], "characters": "\u0022" },
+ "&Qfr;": { "codepoints": [120084], "characters": "\uD835\uDD14" },
+ "&Qopf;": { "codepoints": [8474], "characters": "\u211A" },
+ "&Qscr;": { "codepoints": [119980], "characters": "\uD835\uDCAC" },
+ "&RBarr;": { "codepoints": [10512], "characters": "\u2910" },
+ "&REG": { "codepoints": [174], "characters": "\u00AE" },
+ "&REG;": { "codepoints": [174], "characters": "\u00AE" },
+ "&Racute;": { "codepoints": [340], "characters": "\u0154" },
+ "&Rang;": { "codepoints": [10219], "characters": "\u27EB" },
+ "&Rarr;": { "codepoints": [8608], "characters": "\u21A0" },
+ "&Rarrtl;": { "codepoints": [10518], "characters": "\u2916" },
+ "&Rcaron;": { "codepoints": [344], "characters": "\u0158" },
+ "&Rcedil;": { "codepoints": [342], "characters": "\u0156" },
+ "&Rcy;": { "codepoints": [1056], "characters": "\u0420" },
+ "&Re;": { "codepoints": [8476], "characters": "\u211C" },
+ "&ReverseElement;": { "codepoints": [8715], "characters": "\u220B" },
+ "&ReverseEquilibrium;": { "codepoints": [8651], "characters": "\u21CB" },
+ "&ReverseUpEquilibrium;": { "codepoints": [10607], "characters": "\u296F" },
+ "&Rfr;": { "codepoints": [8476], "characters": "\u211C" },
+ "&Rho;": { "codepoints": [929], "characters": "\u03A1" },
+ "&RightAngleBracket;": { "codepoints": [10217], "characters": "\u27E9" },
+ "&RightArrow;": { "codepoints": [8594], "characters": "\u2192" },
+ "&RightArrowBar;": { "codepoints": [8677], "characters": "\u21E5" },
+ "&RightArrowLeftArrow;": { "codepoints": [8644], "characters": "\u21C4" },
+ "&RightCeiling;": { "codepoints": [8969], "characters": "\u2309" },
+ "&RightDoubleBracket;": { "codepoints": [10215], "characters": "\u27E7" },
+ "&RightDownTeeVector;": { "codepoints": [10589], "characters": "\u295D" },
+ "&RightDownVector;": { "codepoints": [8642], "characters": "\u21C2" },
+ "&RightDownVectorBar;": { "codepoints": [10581], "characters": "\u2955" },
+ "&RightFloor;": { "codepoints": [8971], "characters": "\u230B" },
+ "&RightTee;": { "codepoints": [8866], "characters": "\u22A2" },
+ "&RightTeeArrow;": { "codepoints": [8614], "characters": "\u21A6" },
+ "&RightTeeVector;": { "codepoints": [10587], "characters": "\u295B" },
+ "&RightTriangle;": { "codepoints": [8883], "characters": "\u22B3" },
+ "&RightTriangleBar;": { "codepoints": [10704], "characters": "\u29D0" },
+ "&RightTriangleEqual;": { "codepoints": [8885], "characters": "\u22B5" },
+ "&RightUpDownVector;": { "codepoints": [10575], "characters": "\u294F" },
+ "&RightUpTeeVector;": { "codepoints": [10588], "characters": "\u295C" },
+ "&RightUpVector;": { "codepoints": [8638], "characters": "\u21BE" },
+ "&RightUpVectorBar;": { "codepoints": [10580], "characters": "\u2954" },
+ "&RightVector;": { "codepoints": [8640], "characters": "\u21C0" },
+ "&RightVectorBar;": { "codepoints": [10579], "characters": "\u2953" },
+ "&Rightarrow;": { "codepoints": [8658], "characters": "\u21D2" },
+ "&Ropf;": { "codepoints": [8477], "characters": "\u211D" },
+ "&RoundImplies;": { "codepoints": [10608], "characters": "\u2970" },
+ "&Rrightarrow;": { "codepoints": [8667], "characters": "\u21DB" },
+ "&Rscr;": { "codepoints": [8475], "characters": "\u211B" },
+ "&Rsh;": { "codepoints": [8625], "characters": "\u21B1" },
+ "&RuleDelayed;": { "codepoints": [10740], "characters": "\u29F4" },
+ "&SHCHcy;": { "codepoints": [1065], "characters": "\u0429" },
+ "&SHcy;": { "codepoints": [1064], "characters": "\u0428" },
+ "&SOFTcy;": { "codepoints": [1068], "characters": "\u042C" },
+ "&Sacute;": { "codepoints": [346], "characters": "\u015A" },
+ "&Sc;": { "codepoints": [10940], "characters": "\u2ABC" },
+ "&Scaron;": { "codepoints": [352], "characters": "\u0160" },
+ "&Scedil;": { "codepoints": [350], "characters": "\u015E" },
+ "&Scirc;": { "codepoints": [348], "characters": "\u015C" },
+ "&Scy;": { "codepoints": [1057], "characters": "\u0421" },
+ "&Sfr;": { "codepoints": [120086], "characters": "\uD835\uDD16" },
+ "&ShortDownArrow;": { "codepoints": [8595], "characters": "\u2193" },
+ "&ShortLeftArrow;": { "codepoints": [8592], "characters": "\u2190" },
+ "&ShortRightArrow;": { "codepoints": [8594], "characters": "\u2192" },
+ "&ShortUpArrow;": { "codepoints": [8593], "characters": "\u2191" },
+ "&Sigma;": { "codepoints": [931], "characters": "\u03A3" },
+ "&SmallCircle;": { "codepoints": [8728], "characters": "\u2218" },
+ "&Sopf;": { "codepoints": [120138], "characters": "\uD835\uDD4A" },
+ "&Sqrt;": { "codepoints": [8730], "characters": "\u221A" },
+ "&Square;": { "codepoints": [9633], "characters": "\u25A1" },
+ "&SquareIntersection;": { "codepoints": [8851], "characters": "\u2293" },
+ "&SquareSubset;": { "codepoints": [8847], "characters": "\u228F" },
+ "&SquareSubsetEqual;": { "codepoints": [8849], "characters": "\u2291" },
+ "&SquareSuperset;": { "codepoints": [8848], "characters": "\u2290" },
+ "&SquareSupersetEqual;": { "codepoints": [8850], "characters": "\u2292" },
+ "&SquareUnion;": { "codepoints": [8852], "characters": "\u2294" },
+ "&Sscr;": { "codepoints": [119982], "characters": "\uD835\uDCAE" },
+ "&Star;": { "codepoints": [8902], "characters": "\u22C6" },
+ "&Sub;": { "codepoints": [8912], "characters": "\u22D0" },
+ "&Subset;": { "codepoints": [8912], "characters": "\u22D0" },
+ "&SubsetEqual;": { "codepoints": [8838], "characters": "\u2286" },
+ "&Succeeds;": { "codepoints": [8827], "characters": "\u227B" },
+ "&SucceedsEqual;": { "codepoints": [10928], "characters": "\u2AB0" },
+ "&SucceedsSlantEqual;": { "codepoints": [8829], "characters": "\u227D" },
+ "&SucceedsTilde;": { "codepoints": [8831], "characters": "\u227F" },
+ "&SuchThat;": { "codepoints": [8715], "characters": "\u220B" },
+ "&Sum;": { "codepoints": [8721], "characters": "\u2211" },
+ "&Sup;": { "codepoints": [8913], "characters": "\u22D1" },
+ "&Superset;": { "codepoints": [8835], "characters": "\u2283" },
+ "&SupersetEqual;": { "codepoints": [8839], "characters": "\u2287" },
+ "&Supset;": { "codepoints": [8913], "characters": "\u22D1" },
+ "&THORN": { "codepoints": [222], "characters": "\u00DE" },
+ "&THORN;": { "codepoints": [222], "characters": "\u00DE" },
+ "&TRADE;": { "codepoints": [8482], "characters": "\u2122" },
+ "&TSHcy;": { "codepoints": [1035], "characters": "\u040B" },
+ "&TScy;": { "codepoints": [1062], "characters": "\u0426" },
+ "&Tab;": { "codepoints": [9], "characters": "\u0009" },
+ "&Tau;": { "codepoints": [932], "characters": "\u03A4" },
+ "&Tcaron;": { "codepoints": [356], "characters": "\u0164" },
+ "&Tcedil;": { "codepoints": [354], "characters": "\u0162" },
+ "&Tcy;": { "codepoints": [1058], "characters": "\u0422" },
+ "&Tfr;": { "codepoints": [120087], "characters": "\uD835\uDD17" },
+ "&Therefore;": { "codepoints": [8756], "characters": "\u2234" },
+ "&Theta;": { "codepoints": [920], "characters": "\u0398" },
+ "&ThickSpace;": { "codepoints": [8287, 8202], "characters": "\u205F\u200A" },
+ "&ThinSpace;": { "codepoints": [8201], "characters": "\u2009" },
+ "&Tilde;": { "codepoints": [8764], "characters": "\u223C" },
+ "&TildeEqual;": { "codepoints": [8771], "characters": "\u2243" },
+ "&TildeFullEqual;": { "codepoints": [8773], "characters": "\u2245" },
+ "&TildeTilde;": { "codepoints": [8776], "characters": "\u2248" },
+ "&Topf;": { "codepoints": [120139], "characters": "\uD835\uDD4B" },
+ "&TripleDot;": { "codepoints": [8411], "characters": "\u20DB" },
+ "&Tscr;": { "codepoints": [119983], "characters": "\uD835\uDCAF" },
+ "&Tstrok;": { "codepoints": [358], "characters": "\u0166" },
+ "&Uacute": { "codepoints": [218], "characters": "\u00DA" },
+ "&Uacute;": { "codepoints": [218], "characters": "\u00DA" },
+ "&Uarr;": { "codepoints": [8607], "characters": "\u219F" },
+ "&Uarrocir;": { "codepoints": [10569], "characters": "\u2949" },
+ "&Ubrcy;": { "codepoints": [1038], "characters": "\u040E" },
+ "&Ubreve;": { "codepoints": [364], "characters": "\u016C" },
+ "&Ucirc": { "codepoints": [219], "characters": "\u00DB" },
+ "&Ucirc;": { "codepoints": [219], "characters": "\u00DB" },
+ "&Ucy;": { "codepoints": [1059], "characters": "\u0423" },
+ "&Udblac;": { "codepoints": [368], "characters": "\u0170" },
+ "&Ufr;": { "codepoints": [120088], "characters": "\uD835\uDD18" },
+ "&Ugrave": { "codepoints": [217], "characters": "\u00D9" },
+ "&Ugrave;": { "codepoints": [217], "characters": "\u00D9" },
+ "&Umacr;": { "codepoints": [362], "characters": "\u016A" },
+ "&UnderBar;": { "codepoints": [95], "characters": "\u005F" },
+ "&UnderBrace;": { "codepoints": [9183], "characters": "\u23DF" },
+ "&UnderBracket;": { "codepoints": [9141], "characters": "\u23B5" },
+ "&UnderParenthesis;": { "codepoints": [9181], "characters": "\u23DD" },
+ "&Union;": { "codepoints": [8899], "characters": "\u22C3" },
+ "&UnionPlus;": { "codepoints": [8846], "characters": "\u228E" },
+ "&Uogon;": { "codepoints": [370], "characters": "\u0172" },
+ "&Uopf;": { "codepoints": [120140], "characters": "\uD835\uDD4C" },
+ "&UpArrow;": { "codepoints": [8593], "characters": "\u2191" },
+ "&UpArrowBar;": { "codepoints": [10514], "characters": "\u2912" },
+ "&UpArrowDownArrow;": { "codepoints": [8645], "characters": "\u21C5" },
+ "&UpDownArrow;": { "codepoints": [8597], "characters": "\u2195" },
+ "&UpEquilibrium;": { "codepoints": [10606], "characters": "\u296E" },
+ "&UpTee;": { "codepoints": [8869], "characters": "\u22A5" },
+ "&UpTeeArrow;": { "codepoints": [8613], "characters": "\u21A5" },
+ "&Uparrow;": { "codepoints": [8657], "characters": "\u21D1" },
+ "&Updownarrow;": { "codepoints": [8661], "characters": "\u21D5" },
+ "&UpperLeftArrow;": { "codepoints": [8598], "characters": "\u2196" },
+ "&UpperRightArrow;": { "codepoints": [8599], "characters": "\u2197" },
+ "&Upsi;": { "codepoints": [978], "characters": "\u03D2" },
+ "&Upsilon;": { "codepoints": [933], "characters": "\u03A5" },
+ "&Uring;": { "codepoints": [366], "characters": "\u016E" },
+ "&Uscr;": { "codepoints": [119984], "characters": "\uD835\uDCB0" },
+ "&Utilde;": { "codepoints": [360], "characters": "\u0168" },
+ "&Uuml": { "codepoints": [220], "characters": "\u00DC" },
+ "&Uuml;": { "codepoints": [220], "characters": "\u00DC" },
+ "&VDash;": { "codepoints": [8875], "characters": "\u22AB" },
+ "&Vbar;": { "codepoints": [10987], "characters": "\u2AEB" },
+ "&Vcy;": { "codepoints": [1042], "characters": "\u0412" },
+ "&Vdash;": { "codepoints": [8873], "characters": "\u22A9" },
+ "&Vdashl;": { "codepoints": [10982], "characters": "\u2AE6" },
+ "&Vee;": { "codepoints": [8897], "characters": "\u22C1" },
+ "&Verbar;": { "codepoints": [8214], "characters": "\u2016" },
+ "&Vert;": { "codepoints": [8214], "characters": "\u2016" },
+ "&VerticalBar;": { "codepoints": [8739], "characters": "\u2223" },
+ "&VerticalLine;": { "codepoints": [124], "characters": "\u007C" },
+ "&VerticalSeparator;": { "codepoints": [10072], "characters": "\u2758" },
+ "&VerticalTilde;": { "codepoints": [8768], "characters": "\u2240" },
+ "&VeryThinSpace;": { "codepoints": [8202], "characters": "\u200A" },
+ "&Vfr;": { "codepoints": [120089], "characters": "\uD835\uDD19" },
+ "&Vopf;": { "codepoints": [120141], "characters": "\uD835\uDD4D" },
+ "&Vscr;": { "codepoints": [119985], "characters": "\uD835\uDCB1" },
+ "&Vvdash;": { "codepoints": [8874], "characters": "\u22AA" },
+ "&Wcirc;": { "codepoints": [372], "characters": "\u0174" },
+ "&Wedge;": { "codepoints": [8896], "characters": "\u22C0" },
+ "&Wfr;": { "codepoints": [120090], "characters": "\uD835\uDD1A" },
+ "&Wopf;": { "codepoints": [120142], "characters": "\uD835\uDD4E" },
+ "&Wscr;": { "codepoints": [119986], "characters": "\uD835\uDCB2" },
+ "&Xfr;": { "codepoints": [120091], "characters": "\uD835\uDD1B" },
+ "&Xi;": { "codepoints": [926], "characters": "\u039E" },
+ "&Xopf;": { "codepoints": [120143], "characters": "\uD835\uDD4F" },
+ "&Xscr;": { "codepoints": [119987], "characters": "\uD835\uDCB3" },
+ "&YAcy;": { "codepoints": [1071], "characters": "\u042F" },
+ "&YIcy;": { "codepoints": [1031], "characters": "\u0407" },
+ "&YUcy;": { "codepoints": [1070], "characters": "\u042E" },
+ "&Yacute": { "codepoints": [221], "characters": "\u00DD" },
+ "&Yacute;": { "codepoints": [221], "characters": "\u00DD" },
+ "&Ycirc;": { "codepoints": [374], "characters": "\u0176" },
+ "&Ycy;": { "codepoints": [1067], "characters": "\u042B" },
+ "&Yfr;": { "codepoints": [120092], "characters": "\uD835\uDD1C" },
+ "&Yopf;": { "codepoints": [120144], "characters": "\uD835\uDD50" },
+ "&Yscr;": { "codepoints": [119988], "characters": "\uD835\uDCB4" },
+ "&Yuml;": { "codepoints": [376], "characters": "\u0178" },
+ "&ZHcy;": { "codepoints": [1046], "characters": "\u0416" },
+ "&Zacute;": { "codepoints": [377], "characters": "\u0179" },
+ "&Zcaron;": { "codepoints": [381], "characters": "\u017D" },
+ "&Zcy;": { "codepoints": [1047], "characters": "\u0417" },
+ "&Zdot;": { "codepoints": [379], "characters": "\u017B" },
+ "&ZeroWidthSpace;": { "codepoints": [8203], "characters": "\u200B" },
+ "&Zeta;": { "codepoints": [918], "characters": "\u0396" },
+ "&Zfr;": { "codepoints": [8488], "characters": "\u2128" },
+ "&Zopf;": { "codepoints": [8484], "characters": "\u2124" },
+ "&Zscr;": { "codepoints": [119989], "characters": "\uD835\uDCB5" },
+ "&aacute": { "codepoints": [225], "characters": "\u00E1" },
+ "&aacute;": { "codepoints": [225], "characters": "\u00E1" },
+ "&abreve;": { "codepoints": [259], "characters": "\u0103" },
+ "&ac;": { "codepoints": [8766], "characters": "\u223E" },
+ "&acE;": { "codepoints": [8766, 819], "characters": "\u223E\u0333" },
+ "&acd;": { "codepoints": [8767], "characters": "\u223F" },
+ "&acirc": { "codepoints": [226], "characters": "\u00E2" },
+ "&acirc;": { "codepoints": [226], "characters": "\u00E2" },
+ "&acute": { "codepoints": [180], "characters": "\u00B4" },
+ "&acute;": { "codepoints": [180], "characters": "\u00B4" },
+ "&acy;": { "codepoints": [1072], "characters": "\u0430" },
+ "&aelig": { "codepoints": [230], "characters": "\u00E6" },
+ "&aelig;": { "codepoints": [230], "characters": "\u00E6" },
+ "&af;": { "codepoints": [8289], "characters": "\u2061" },
+ "&afr;": { "codepoints": [120094], "characters": "\uD835\uDD1E" },
+ "&agrave": { "codepoints": [224], "characters": "\u00E0" },
+ "&agrave;": { "codepoints": [224], "characters": "\u00E0" },
+ "&alefsym;": { "codepoints": [8501], "characters": "\u2135" },
+ "&aleph;": { "codepoints": [8501], "characters": "\u2135" },
+ "&alpha;": { "codepoints": [945], "characters": "\u03B1" },
+ "&amacr;": { "codepoints": [257], "characters": "\u0101" },
+ "&amalg;": { "codepoints": [10815], "characters": "\u2A3F" },
+ "&amp": { "codepoints": [38], "characters": "\u0026" },
+ "&amp;": { "codepoints": [38], "characters": "\u0026" },
+ "&and;": { "codepoints": [8743], "characters": "\u2227" },
+ "&andand;": { "codepoints": [10837], "characters": "\u2A55" },
+ "&andd;": { "codepoints": [10844], "characters": "\u2A5C" },
+ "&andslope;": { "codepoints": [10840], "characters": "\u2A58" },
+ "&andv;": { "codepoints": [10842], "characters": "\u2A5A" },
+ "&ang;": { "codepoints": [8736], "characters": "\u2220" },
+ "&ange;": { "codepoints": [10660], "characters": "\u29A4" },
+ "&angle;": { "codepoints": [8736], "characters": "\u2220" },
+ "&angmsd;": { "codepoints": [8737], "characters": "\u2221" },
+ "&angmsdaa;": { "codepoints": [10664], "characters": "\u29A8" },
+ "&angmsdab;": { "codepoints": [10665], "characters": "\u29A9" },
+ "&angmsdac;": { "codepoints": [10666], "characters": "\u29AA" },
+ "&angmsdad;": { "codepoints": [10667], "characters": "\u29AB" },
+ "&angmsdae;": { "codepoints": [10668], "characters": "\u29AC" },
+ "&angmsdaf;": { "codepoints": [10669], "characters": "\u29AD" },
+ "&angmsdag;": { "codepoints": [10670], "characters": "\u29AE" },
+ "&angmsdah;": { "codepoints": [10671], "characters": "\u29AF" },
+ "&angrt;": { "codepoints": [8735], "characters": "\u221F" },
+ "&angrtvb;": { "codepoints": [8894], "characters": "\u22BE" },
+ "&angrtvbd;": { "codepoints": [10653], "characters": "\u299D" },
+ "&angsph;": { "codepoints": [8738], "characters": "\u2222" },
+ "&angst;": { "codepoints": [197], "characters": "\u00C5" },
+ "&angzarr;": { "codepoints": [9084], "characters": "\u237C" },
+ "&aogon;": { "codepoints": [261], "characters": "\u0105" },
+ "&aopf;": { "codepoints": [120146], "characters": "\uD835\uDD52" },
+ "&ap;": { "codepoints": [8776], "characters": "\u2248" },
+ "&apE;": { "codepoints": [10864], "characters": "\u2A70" },
+ "&apacir;": { "codepoints": [10863], "characters": "\u2A6F" },
+ "&ape;": { "codepoints": [8778], "characters": "\u224A" },
+ "&apid;": { "codepoints": [8779], "characters": "\u224B" },
+ "&apos;": { "codepoints": [39], "characters": "\u0027" },
+ "&approx;": { "codepoints": [8776], "characters": "\u2248" },
+ "&approxeq;": { "codepoints": [8778], "characters": "\u224A" },
+ "&aring": { "codepoints": [229], "characters": "\u00E5" },
+ "&aring;": { "codepoints": [229], "characters": "\u00E5" },
+ "&ascr;": { "codepoints": [119990], "characters": "\uD835\uDCB6" },
+ "&ast;": { "codepoints": [42], "characters": "\u002A" },
+ "&asymp;": { "codepoints": [8776], "characters": "\u2248" },
+ "&asympeq;": { "codepoints": [8781], "characters": "\u224D" },
+ "&atilde": { "codepoints": [227], "characters": "\u00E3" },
+ "&atilde;": { "codepoints": [227], "characters": "\u00E3" },
+ "&auml": { "codepoints": [228], "characters": "\u00E4" },
+ "&auml;": { "codepoints": [228], "characters": "\u00E4" },
+ "&awconint;": { "codepoints": [8755], "characters": "\u2233" },
+ "&awint;": { "codepoints": [10769], "characters": "\u2A11" },
+ "&bNot;": { "codepoints": [10989], "characters": "\u2AED" },
+ "&backcong;": { "codepoints": [8780], "characters": "\u224C" },
+ "&backepsilon;": { "codepoints": [1014], "characters": "\u03F6" },
+ "&backprime;": { "codepoints": [8245], "characters": "\u2035" },
+ "&backsim;": { "codepoints": [8765], "characters": "\u223D" },
+ "&backsimeq;": { "codepoints": [8909], "characters": "\u22CD" },
+ "&barvee;": { "codepoints": [8893], "characters": "\u22BD" },
+ "&barwed;": { "codepoints": [8965], "characters": "\u2305" },
+ "&barwedge;": { "codepoints": [8965], "characters": "\u2305" },
+ "&bbrk;": { "codepoints": [9141], "characters": "\u23B5" },
+ "&bbrktbrk;": { "codepoints": [9142], "characters": "\u23B6" },
+ "&bcong;": { "codepoints": [8780], "characters": "\u224C" },
+ "&bcy;": { "codepoints": [1073], "characters": "\u0431" },
+ "&bdquo;": { "codepoints": [8222], "characters": "\u201E" },
+ "&becaus;": { "codepoints": [8757], "characters": "\u2235" },
+ "&because;": { "codepoints": [8757], "characters": "\u2235" },
+ "&bemptyv;": { "codepoints": [10672], "characters": "\u29B0" },
+ "&bepsi;": { "codepoints": [1014], "characters": "\u03F6" },
+ "&bernou;": { "codepoints": [8492], "characters": "\u212C" },
+ "&beta;": { "codepoints": [946], "characters": "\u03B2" },
+ "&beth;": { "codepoints": [8502], "characters": "\u2136" },
+ "&between;": { "codepoints": [8812], "characters": "\u226C" },
+ "&bfr;": { "codepoints": [120095], "characters": "\uD835\uDD1F" },
+ "&bigcap;": { "codepoints": [8898], "characters": "\u22C2" },
+ "&bigcirc;": { "codepoints": [9711], "characters": "\u25EF" },
+ "&bigcup;": { "codepoints": [8899], "characters": "\u22C3" },
+ "&bigodot;": { "codepoints": [10752], "characters": "\u2A00" },
+ "&bigoplus;": { "codepoints": [10753], "characters": "\u2A01" },
+ "&bigotimes;": { "codepoints": [10754], "characters": "\u2A02" },
+ "&bigsqcup;": { "codepoints": [10758], "characters": "\u2A06" },
+ "&bigstar;": { "codepoints": [9733], "characters": "\u2605" },
+ "&bigtriangledown;": { "codepoints": [9661], "characters": "\u25BD" },
+ "&bigtriangleup;": { "codepoints": [9651], "characters": "\u25B3" },
+ "&biguplus;": { "codepoints": [10756], "characters": "\u2A04" },
+ "&bigvee;": { "codepoints": [8897], "characters": "\u22C1" },
+ "&bigwedge;": { "codepoints": [8896], "characters": "\u22C0" },
+ "&bkarow;": { "codepoints": [10509], "characters": "\u290D" },
+ "&blacklozenge;": { "codepoints": [10731], "characters": "\u29EB" },
+ "&blacksquare;": { "codepoints": [9642], "characters": "\u25AA" },
+ "&blacktriangle;": { "codepoints": [9652], "characters": "\u25B4" },
+ "&blacktriangledown;": { "codepoints": [9662], "characters": "\u25BE" },
+ "&blacktriangleleft;": { "codepoints": [9666], "characters": "\u25C2" },
+ "&blacktriangleright;": { "codepoints": [9656], "characters": "\u25B8" },
+ "&blank;": { "codepoints": [9251], "characters": "\u2423" },
+ "&blk12;": { "codepoints": [9618], "characters": "\u2592" },
+ "&blk14;": { "codepoints": [9617], "characters": "\u2591" },
+ "&blk34;": { "codepoints": [9619], "characters": "\u2593" },
+ "&block;": { "codepoints": [9608], "characters": "\u2588" },
+ "&bne;": { "codepoints": [61, 8421], "characters": "\u003D\u20E5" },
+ "&bnequiv;": { "codepoints": [8801, 8421], "characters": "\u2261\u20E5" },
+ "&bnot;": { "codepoints": [8976], "characters": "\u2310" },
+ "&bopf;": { "codepoints": [120147], "characters": "\uD835\uDD53" },
+ "&bot;": { "codepoints": [8869], "characters": "\u22A5" },
+ "&bottom;": { "codepoints": [8869], "characters": "\u22A5" },
+ "&bowtie;": { "codepoints": [8904], "characters": "\u22C8" },
+ "&boxDL;": { "codepoints": [9559], "characters": "\u2557" },
+ "&boxDR;": { "codepoints": [9556], "characters": "\u2554" },
+ "&boxDl;": { "codepoints": [9558], "characters": "\u2556" },
+ "&boxDr;": { "codepoints": [9555], "characters": "\u2553" },
+ "&boxH;": { "codepoints": [9552], "characters": "\u2550" },
+ "&boxHD;": { "codepoints": [9574], "characters": "\u2566" },
+ "&boxHU;": { "codepoints": [9577], "characters": "\u2569" },
+ "&boxHd;": { "codepoints": [9572], "characters": "\u2564" },
+ "&boxHu;": { "codepoints": [9575], "characters": "\u2567" },
+ "&boxUL;": { "codepoints": [9565], "characters": "\u255D" },
+ "&boxUR;": { "codepoints": [9562], "characters": "\u255A" },
+ "&boxUl;": { "codepoints": [9564], "characters": "\u255C" },
+ "&boxUr;": { "codepoints": [9561], "characters": "\u2559" },
+ "&boxV;": { "codepoints": [9553], "characters": "\u2551" },
+ "&boxVH;": { "codepoints": [9580], "characters": "\u256C" },
+ "&boxVL;": { "codepoints": [9571], "characters": "\u2563" },
+ "&boxVR;": { "codepoints": [9568], "characters": "\u2560" },
+ "&boxVh;": { "codepoints": [9579], "characters": "\u256B" },
+ "&boxVl;": { "codepoints": [9570], "characters": "\u2562" },
+ "&boxVr;": { "codepoints": [9567], "characters": "\u255F" },
+ "&boxbox;": { "codepoints": [10697], "characters": "\u29C9" },
+ "&boxdL;": { "codepoints": [9557], "characters": "\u2555" },
+ "&boxdR;": { "codepoints": [9554], "characters": "\u2552" },
+ "&boxdl;": { "codepoints": [9488], "characters": "\u2510" },
+ "&boxdr;": { "codepoints": [9484], "characters": "\u250C" },
+ "&boxh;": { "codepoints": [9472], "characters": "\u2500" },
+ "&boxhD;": { "codepoints": [9573], "characters": "\u2565" },
+ "&boxhU;": { "codepoints": [9576], "characters": "\u2568" },
+ "&boxhd;": { "codepoints": [9516], "characters": "\u252C" },
+ "&boxhu;": { "codepoints": [9524], "characters": "\u2534" },
+ "&boxminus;": { "codepoints": [8863], "characters": "\u229F" },
+ "&boxplus;": { "codepoints": [8862], "characters": "\u229E" },
+ "&boxtimes;": { "codepoints": [8864], "characters": "\u22A0" },
+ "&boxuL;": { "codepoints": [9563], "characters": "\u255B" },
+ "&boxuR;": { "codepoints": [9560], "characters": "\u2558" },
+ "&boxul;": { "codepoints": [9496], "characters": "\u2518" },
+ "&boxur;": { "codepoints": [9492], "characters": "\u2514" },
+ "&boxv;": { "codepoints": [9474], "characters": "\u2502" },
+ "&boxvH;": { "codepoints": [9578], "characters": "\u256A" },
+ "&boxvL;": { "codepoints": [9569], "characters": "\u2561" },
+ "&boxvR;": { "codepoints": [9566], "characters": "\u255E" },
+ "&boxvh;": { "codepoints": [9532], "characters": "\u253C" },
+ "&boxvl;": { "codepoints": [9508], "characters": "\u2524" },
+ "&boxvr;": { "codepoints": [9500], "characters": "\u251C" },
+ "&bprime;": { "codepoints": [8245], "characters": "\u2035" },
+ "&breve;": { "codepoints": [728], "characters": "\u02D8" },
+ "&brvbar": { "codepoints": [166], "characters": "\u00A6" },
+ "&brvbar;": { "codepoints": [166], "characters": "\u00A6" },
+ "&bscr;": { "codepoints": [119991], "characters": "\uD835\uDCB7" },
+ "&bsemi;": { "codepoints": [8271], "characters": "\u204F" },
+ "&bsim;": { "codepoints": [8765], "characters": "\u223D" },
+ "&bsime;": { "codepoints": [8909], "characters": "\u22CD" },
+ "&bsol;": { "codepoints": [92], "characters": "\u005C" },
+ "&bsolb;": { "codepoints": [10693], "characters": "\u29C5" },
+ "&bsolhsub;": { "codepoints": [10184], "characters": "\u27C8" },
+ "&bull;": { "codepoints": [8226], "characters": "\u2022" },
+ "&bullet;": { "codepoints": [8226], "characters": "\u2022" },
+ "&bump;": { "codepoints": [8782], "characters": "\u224E" },
+ "&bumpE;": { "codepoints": [10926], "characters": "\u2AAE" },
+ "&bumpe;": { "codepoints": [8783], "characters": "\u224F" },
+ "&bumpeq;": { "codepoints": [8783], "characters": "\u224F" },
+ "&cacute;": { "codepoints": [263], "characters": "\u0107" },
+ "&cap;": { "codepoints": [8745], "characters": "\u2229" },
+ "&capand;": { "codepoints": [10820], "characters": "\u2A44" },
+ "&capbrcup;": { "codepoints": [10825], "characters": "\u2A49" },
+ "&capcap;": { "codepoints": [10827], "characters": "\u2A4B" },
+ "&capcup;": { "codepoints": [10823], "characters": "\u2A47" },
+ "&capdot;": { "codepoints": [10816], "characters": "\u2A40" },
+ "&caps;": { "codepoints": [8745, 65024], "characters": "\u2229\uFE00" },
+ "&caret;": { "codepoints": [8257], "characters": "\u2041" },
+ "&caron;": { "codepoints": [711], "characters": "\u02C7" },
+ "&ccaps;": { "codepoints": [10829], "characters": "\u2A4D" },
+ "&ccaron;": { "codepoints": [269], "characters": "\u010D" },
+ "&ccedil": { "codepoints": [231], "characters": "\u00E7" },
+ "&ccedil;": { "codepoints": [231], "characters": "\u00E7" },
+ "&ccirc;": { "codepoints": [265], "characters": "\u0109" },
+ "&ccups;": { "codepoints": [10828], "characters": "\u2A4C" },
+ "&ccupssm;": { "codepoints": [10832], "characters": "\u2A50" },
+ "&cdot;": { "codepoints": [267], "characters": "\u010B" },
+ "&cedil": { "codepoints": [184], "characters": "\u00B8" },
+ "&cedil;": { "codepoints": [184], "characters": "\u00B8" },
+ "&cemptyv;": { "codepoints": [10674], "characters": "\u29B2" },
+ "&cent": { "codepoints": [162], "characters": "\u00A2" },
+ "&cent;": { "codepoints": [162], "characters": "\u00A2" },
+ "&centerdot;": { "codepoints": [183], "characters": "\u00B7" },
+ "&cfr;": { "codepoints": [120096], "characters": "\uD835\uDD20" },
+ "&chcy;": { "codepoints": [1095], "characters": "\u0447" },
+ "&check;": { "codepoints": [10003], "characters": "\u2713" },
+ "&checkmark;": { "codepoints": [10003], "characters": "\u2713" },
+ "&chi;": { "codepoints": [967], "characters": "\u03C7" },
+ "&cir;": { "codepoints": [9675], "characters": "\u25CB" },
+ "&cirE;": { "codepoints": [10691], "characters": "\u29C3" },
+ "&circ;": { "codepoints": [710], "characters": "\u02C6" },
+ "&circeq;": { "codepoints": [8791], "characters": "\u2257" },
+ "&circlearrowleft;": { "codepoints": [8634], "characters": "\u21BA" },
+ "&circlearrowright;": { "codepoints": [8635], "characters": "\u21BB" },
+ "&circledR;": { "codepoints": [174], "characters": "\u00AE" },
+ "&circledS;": { "codepoints": [9416], "characters": "\u24C8" },
+ "&circledast;": { "codepoints": [8859], "characters": "\u229B" },
+ "&circledcirc;": { "codepoints": [8858], "characters": "\u229A" },
+ "&circleddash;": { "codepoints": [8861], "characters": "\u229D" },
+ "&cire;": { "codepoints": [8791], "characters": "\u2257" },
+ "&cirfnint;": { "codepoints": [10768], "characters": "\u2A10" },
+ "&cirmid;": { "codepoints": [10991], "characters": "\u2AEF" },
+ "&cirscir;": { "codepoints": [10690], "characters": "\u29C2" },
+ "&clubs;": { "codepoints": [9827], "characters": "\u2663" },
+ "&clubsuit;": { "codepoints": [9827], "characters": "\u2663" },
+ "&colon;": { "codepoints": [58], "characters": "\u003A" },
+ "&colone;": { "codepoints": [8788], "characters": "\u2254" },
+ "&coloneq;": { "codepoints": [8788], "characters": "\u2254" },
+ "&comma;": { "codepoints": [44], "characters": "\u002C" },
+ "&commat;": { "codepoints": [64], "characters": "\u0040" },
+ "&comp;": { "codepoints": [8705], "characters": "\u2201" },
+ "&compfn;": { "codepoints": [8728], "characters": "\u2218" },
+ "&complement;": { "codepoints": [8705], "characters": "\u2201" },
+ "&complexes;": { "codepoints": [8450], "characters": "\u2102" },
+ "&cong;": { "codepoints": [8773], "characters": "\u2245" },
+ "&congdot;": { "codepoints": [10861], "characters": "\u2A6D" },
+ "&conint;": { "codepoints": [8750], "characters": "\u222E" },
+ "&copf;": { "codepoints": [120148], "characters": "\uD835\uDD54" },
+ "&coprod;": { "codepoints": [8720], "characters": "\u2210" },
+ "&copy": { "codepoints": [169], "characters": "\u00A9" },
+ "&copy;": { "codepoints": [169], "characters": "\u00A9" },
+ "&copysr;": { "codepoints": [8471], "characters": "\u2117" },
+ "&crarr;": { "codepoints": [8629], "characters": "\u21B5" },
+ "&cross;": { "codepoints": [10007], "characters": "\u2717" },
+ "&cscr;": { "codepoints": [119992], "characters": "\uD835\uDCB8" },
+ "&csub;": { "codepoints": [10959], "characters": "\u2ACF" },
+ "&csube;": { "codepoints": [10961], "characters": "\u2AD1" },
+ "&csup;": { "codepoints": [10960], "characters": "\u2AD0" },
+ "&csupe;": { "codepoints": [10962], "characters": "\u2AD2" },
+ "&ctdot;": { "codepoints": [8943], "characters": "\u22EF" },
+ "&cudarrl;": { "codepoints": [10552], "characters": "\u2938" },
+ "&cudarrr;": { "codepoints": [10549], "characters": "\u2935" },
+ "&cuepr;": { "codepoints": [8926], "characters": "\u22DE" },
+ "&cuesc;": { "codepoints": [8927], "characters": "\u22DF" },
+ "&cularr;": { "codepoints": [8630], "characters": "\u21B6" },
+ "&cularrp;": { "codepoints": [10557], "characters": "\u293D" },
+ "&cup;": { "codepoints": [8746], "characters": "\u222A" },
+ "&cupbrcap;": { "codepoints": [10824], "characters": "\u2A48" },
+ "&cupcap;": { "codepoints": [10822], "characters": "\u2A46" },
+ "&cupcup;": { "codepoints": [10826], "characters": "\u2A4A" },
+ "&cupdot;": { "codepoints": [8845], "characters": "\u228D" },
+ "&cupor;": { "codepoints": [10821], "characters": "\u2A45" },
+ "&cups;": { "codepoints": [8746, 65024], "characters": "\u222A\uFE00" },
+ "&curarr;": { "codepoints": [8631], "characters": "\u21B7" },
+ "&curarrm;": { "codepoints": [10556], "characters": "\u293C" },
+ "&curlyeqprec;": { "codepoints": [8926], "characters": "\u22DE" },
+ "&curlyeqsucc;": { "codepoints": [8927], "characters": "\u22DF" },
+ "&curlyvee;": { "codepoints": [8910], "characters": "\u22CE" },
+ "&curlywedge;": { "codepoints": [8911], "characters": "\u22CF" },
+ "&curren": { "codepoints": [164], "characters": "\u00A4" },
+ "&curren;": { "codepoints": [164], "characters": "\u00A4" },
+ "&curvearrowleft;": { "codepoints": [8630], "characters": "\u21B6" },
+ "&curvearrowright;": { "codepoints": [8631], "characters": "\u21B7" },
+ "&cuvee;": { "codepoints": [8910], "characters": "\u22CE" },
+ "&cuwed;": { "codepoints": [8911], "characters": "\u22CF" },
+ "&cwconint;": { "codepoints": [8754], "characters": "\u2232" },
+ "&cwint;": { "codepoints": [8753], "characters": "\u2231" },
+ "&cylcty;": { "codepoints": [9005], "characters": "\u232D" },
+ "&dArr;": { "codepoints": [8659], "characters": "\u21D3" },
+ "&dHar;": { "codepoints": [10597], "characters": "\u2965" },
+ "&dagger;": { "codepoints": [8224], "characters": "\u2020" },
+ "&daleth;": { "codepoints": [8504], "characters": "\u2138" },
+ "&darr;": { "codepoints": [8595], "characters": "\u2193" },
+ "&dash;": { "codepoints": [8208], "characters": "\u2010" },
+ "&dashv;": { "codepoints": [8867], "characters": "\u22A3" },
+ "&dbkarow;": { "codepoints": [10511], "characters": "\u290F" },
+ "&dblac;": { "codepoints": [733], "characters": "\u02DD" },
+ "&dcaron;": { "codepoints": [271], "characters": "\u010F" },
+ "&dcy;": { "codepoints": [1076], "characters": "\u0434" },
+ "&dd;": { "codepoints": [8518], "characters": "\u2146" },
+ "&ddagger;": { "codepoints": [8225], "characters": "\u2021" },
+ "&ddarr;": { "codepoints": [8650], "characters": "\u21CA" },
+ "&ddotseq;": { "codepoints": [10871], "characters": "\u2A77" },
+ "&deg": { "codepoints": [176], "characters": "\u00B0" },
+ "&deg;": { "codepoints": [176], "characters": "\u00B0" },
+ "&delta;": { "codepoints": [948], "characters": "\u03B4" },
+ "&demptyv;": { "codepoints": [10673], "characters": "\u29B1" },
+ "&dfisht;": { "codepoints": [10623], "characters": "\u297F" },
+ "&dfr;": { "codepoints": [120097], "characters": "\uD835\uDD21" },
+ "&dharl;": { "codepoints": [8643], "characters": "\u21C3" },
+ "&dharr;": { "codepoints": [8642], "characters": "\u21C2" },
+ "&diam;": { "codepoints": [8900], "characters": "\u22C4" },
+ "&diamond;": { "codepoints": [8900], "characters": "\u22C4" },
+ "&diamondsuit;": { "codepoints": [9830], "characters": "\u2666" },
+ "&diams;": { "codepoints": [9830], "characters": "\u2666" },
+ "&die;": { "codepoints": [168], "characters": "\u00A8" },
+ "&digamma;": { "codepoints": [989], "characters": "\u03DD" },
+ "&disin;": { "codepoints": [8946], "characters": "\u22F2" },
+ "&div;": { "codepoints": [247], "characters": "\u00F7" },
+ "&divide": { "codepoints": [247], "characters": "\u00F7" },
+ "&divide;": { "codepoints": [247], "characters": "\u00F7" },
+ "&divideontimes;": { "codepoints": [8903], "characters": "\u22C7" },
+ "&divonx;": { "codepoints": [8903], "characters": "\u22C7" },
+ "&djcy;": { "codepoints": [1106], "characters": "\u0452" },
+ "&dlcorn;": { "codepoints": [8990], "characters": "\u231E" },
+ "&dlcrop;": { "codepoints": [8973], "characters": "\u230D" },
+ "&dollar;": { "codepoints": [36], "characters": "\u0024" },
+ "&dopf;": { "codepoints": [120149], "characters": "\uD835\uDD55" },
+ "&dot;": { "codepoints": [729], "characters": "\u02D9" },
+ "&doteq;": { "codepoints": [8784], "characters": "\u2250" },
+ "&doteqdot;": { "codepoints": [8785], "characters": "\u2251" },
+ "&dotminus;": { "codepoints": [8760], "characters": "\u2238" },
+ "&dotplus;": { "codepoints": [8724], "characters": "\u2214" },
+ "&dotsquare;": { "codepoints": [8865], "characters": "\u22A1" },
+ "&doublebarwedge;": { "codepoints": [8966], "characters": "\u2306" },
+ "&downarrow;": { "codepoints": [8595], "characters": "\u2193" },
+ "&downdownarrows;": { "codepoints": [8650], "characters": "\u21CA" },
+ "&downharpoonleft;": { "codepoints": [8643], "characters": "\u21C3" },
+ "&downharpoonright;": { "codepoints": [8642], "characters": "\u21C2" },
+ "&drbkarow;": { "codepoints": [10512], "characters": "\u2910" },
+ "&drcorn;": { "codepoints": [8991], "characters": "\u231F" },
+ "&drcrop;": { "codepoints": [8972], "characters": "\u230C" },
+ "&dscr;": { "codepoints": [119993], "characters": "\uD835\uDCB9" },
+ "&dscy;": { "codepoints": [1109], "characters": "\u0455" },
+ "&dsol;": { "codepoints": [10742], "characters": "\u29F6" },
+ "&dstrok;": { "codepoints": [273], "characters": "\u0111" },
+ "&dtdot;": { "codepoints": [8945], "characters": "\u22F1" },
+ "&dtri;": { "codepoints": [9663], "characters": "\u25BF" },
+ "&dtrif;": { "codepoints": [9662], "characters": "\u25BE" },
+ "&duarr;": { "codepoints": [8693], "characters": "\u21F5" },
+ "&duhar;": { "codepoints": [10607], "characters": "\u296F" },
+ "&dwangle;": { "codepoints": [10662], "characters": "\u29A6" },
+ "&dzcy;": { "codepoints": [1119], "characters": "\u045F" },
+ "&dzigrarr;": { "codepoints": [10239], "characters": "\u27FF" },
+ "&eDDot;": { "codepoints": [10871], "characters": "\u2A77" },
+ "&eDot;": { "codepoints": [8785], "characters": "\u2251" },
+ "&eacute": { "codepoints": [233], "characters": "\u00E9" },
+ "&eacute;": { "codepoints": [233], "characters": "\u00E9" },
+ "&easter;": { "codepoints": [10862], "characters": "\u2A6E" },
+ "&ecaron;": { "codepoints": [283], "characters": "\u011B" },
+ "&ecir;": { "codepoints": [8790], "characters": "\u2256" },
+ "&ecirc": { "codepoints": [234], "characters": "\u00EA" },
+ "&ecirc;": { "codepoints": [234], "characters": "\u00EA" },
+ "&ecolon;": { "codepoints": [8789], "characters": "\u2255" },
+ "&ecy;": { "codepoints": [1101], "characters": "\u044D" },
+ "&edot;": { "codepoints": [279], "characters": "\u0117" },
+ "&ee;": { "codepoints": [8519], "characters": "\u2147" },
+ "&efDot;": { "codepoints": [8786], "characters": "\u2252" },
+ "&efr;": { "codepoints": [120098], "characters": "\uD835\uDD22" },
+ "&eg;": { "codepoints": [10906], "characters": "\u2A9A" },
+ "&egrave": { "codepoints": [232], "characters": "\u00E8" },
+ "&egrave;": { "codepoints": [232], "characters": "\u00E8" },
+ "&egs;": { "codepoints": [10902], "characters": "\u2A96" },
+ "&egsdot;": { "codepoints": [10904], "characters": "\u2A98" },
+ "&el;": { "codepoints": [10905], "characters": "\u2A99" },
+ "&elinters;": { "codepoints": [9191], "characters": "\u23E7" },
+ "&ell;": { "codepoints": [8467], "characters": "\u2113" },
+ "&els;": { "codepoints": [10901], "characters": "\u2A95" },
+ "&elsdot;": { "codepoints": [10903], "characters": "\u2A97" },
+ "&emacr;": { "codepoints": [275], "characters": "\u0113" },
+ "&empty;": { "codepoints": [8709], "characters": "\u2205" },
+ "&emptyset;": { "codepoints": [8709], "characters": "\u2205" },
+ "&emptyv;": { "codepoints": [8709], "characters": "\u2205" },
+ "&emsp13;": { "codepoints": [8196], "characters": "\u2004" },
+ "&emsp14;": { "codepoints": [8197], "characters": "\u2005" },
+ "&emsp;": { "codepoints": [8195], "characters": "\u2003" },
+ "&eng;": { "codepoints": [331], "characters": "\u014B" },
+ "&ensp;": { "codepoints": [8194], "characters": "\u2002" },
+ "&eogon;": { "codepoints": [281], "characters": "\u0119" },
+ "&eopf;": { "codepoints": [120150], "characters": "\uD835\uDD56" },
+ "&epar;": { "codepoints": [8917], "characters": "\u22D5" },
+ "&eparsl;": { "codepoints": [10723], "characters": "\u29E3" },
+ "&eplus;": { "codepoints": [10865], "characters": "\u2A71" },
+ "&epsi;": { "codepoints": [949], "characters": "\u03B5" },
+ "&epsilon;": { "codepoints": [949], "characters": "\u03B5" },
+ "&epsiv;": { "codepoints": [1013], "characters": "\u03F5" },
+ "&eqcirc;": { "codepoints": [8790], "characters": "\u2256" },
+ "&eqcolon;": { "codepoints": [8789], "characters": "\u2255" },
+ "&eqsim;": { "codepoints": [8770], "characters": "\u2242" },
+ "&eqslantgtr;": { "codepoints": [10902], "characters": "\u2A96" },
+ "&eqslantless;": { "codepoints": [10901], "characters": "\u2A95" },
+ "&equals;": { "codepoints": [61], "characters": "\u003D" },
+ "&equest;": { "codepoints": [8799], "characters": "\u225F" },
+ "&equiv;": { "codepoints": [8801], "characters": "\u2261" },
+ "&equivDD;": { "codepoints": [10872], "characters": "\u2A78" },
+ "&eqvparsl;": { "codepoints": [10725], "characters": "\u29E5" },
+ "&erDot;": { "codepoints": [8787], "characters": "\u2253" },
+ "&erarr;": { "codepoints": [10609], "characters": "\u2971" },
+ "&escr;": { "codepoints": [8495], "characters": "\u212F" },
+ "&esdot;": { "codepoints": [8784], "characters": "\u2250" },
+ "&esim;": { "codepoints": [8770], "characters": "\u2242" },
+ "&eta;": { "codepoints": [951], "characters": "\u03B7" },
+ "&eth": { "codepoints": [240], "characters": "\u00F0" },
+ "&eth;": { "codepoints": [240], "characters": "\u00F0" },
+ "&euml": { "codepoints": [235], "characters": "\u00EB" },
+ "&euml;": { "codepoints": [235], "characters": "\u00EB" },
+ "&euro;": { "codepoints": [8364], "characters": "\u20AC" },
+ "&excl;": { "codepoints": [33], "characters": "\u0021" },
+ "&exist;": { "codepoints": [8707], "characters": "\u2203" },
+ "&expectation;": { "codepoints": [8496], "characters": "\u2130" },
+ "&exponentiale;": { "codepoints": [8519], "characters": "\u2147" },
+ "&fallingdotseq;": { "codepoints": [8786], "characters": "\u2252" },
+ "&fcy;": { "codepoints": [1092], "characters": "\u0444" },
+ "&female;": { "codepoints": [9792], "characters": "\u2640" },
+ "&ffilig;": { "codepoints": [64259], "characters": "\uFB03" },
+ "&fflig;": { "codepoints": [64256], "characters": "\uFB00" },
+ "&ffllig;": { "codepoints": [64260], "characters": "\uFB04" },
+ "&ffr;": { "codepoints": [120099], "characters": "\uD835\uDD23" },
+ "&filig;": { "codepoints": [64257], "characters": "\uFB01" },
+ "&fjlig;": { "codepoints": [102, 106], "characters": "\u0066\u006A" },
+ "&flat;": { "codepoints": [9837], "characters": "\u266D" },
+ "&fllig;": { "codepoints": [64258], "characters": "\uFB02" },
+ "&fltns;": { "codepoints": [9649], "characters": "\u25B1" },
+ "&fnof;": { "codepoints": [402], "characters": "\u0192" },
+ "&fopf;": { "codepoints": [120151], "characters": "\uD835\uDD57" },
+ "&forall;": { "codepoints": [8704], "characters": "\u2200" },
+ "&fork;": { "codepoints": [8916], "characters": "\u22D4" },
+ "&forkv;": { "codepoints": [10969], "characters": "\u2AD9" },
+ "&fpartint;": { "codepoints": [10765], "characters": "\u2A0D" },
+ "&frac12": { "codepoints": [189], "characters": "\u00BD" },
+ "&frac12;": { "codepoints": [189], "characters": "\u00BD" },
+ "&frac13;": { "codepoints": [8531], "characters": "\u2153" },
+ "&frac14": { "codepoints": [188], "characters": "\u00BC" },
+ "&frac14;": { "codepoints": [188], "characters": "\u00BC" },
+ "&frac15;": { "codepoints": [8533], "characters": "\u2155" },
+ "&frac16;": { "codepoints": [8537], "characters": "\u2159" },
+ "&frac18;": { "codepoints": [8539], "characters": "\u215B" },
+ "&frac23;": { "codepoints": [8532], "characters": "\u2154" },
+ "&frac25;": { "codepoints": [8534], "characters": "\u2156" },
+ "&frac34": { "codepoints": [190], "characters": "\u00BE" },
+ "&frac34;": { "codepoints": [190], "characters": "\u00BE" },
+ "&frac35;": { "codepoints": [8535], "characters": "\u2157" },
+ "&frac38;": { "codepoints": [8540], "characters": "\u215C" },
+ "&frac45;": { "codepoints": [8536], "characters": "\u2158" },
+ "&frac56;": { "codepoints": [8538], "characters": "\u215A" },
+ "&frac58;": { "codepoints": [8541], "characters": "\u215D" },
+ "&frac78;": { "codepoints": [8542], "characters": "\u215E" },
+ "&frasl;": { "codepoints": [8260], "characters": "\u2044" },
+ "&frown;": { "codepoints": [8994], "characters": "\u2322" },
+ "&fscr;": { "codepoints": [119995], "characters": "\uD835\uDCBB" },
+ "&gE;": { "codepoints": [8807], "characters": "\u2267" },
+ "&gEl;": { "codepoints": [10892], "characters": "\u2A8C" },
+ "&gacute;": { "codepoints": [501], "characters": "\u01F5" },
+ "&gamma;": { "codepoints": [947], "characters": "\u03B3" },
+ "&gammad;": { "codepoints": [989], "characters": "\u03DD" },
+ "&gap;": { "codepoints": [10886], "characters": "\u2A86" },
+ "&gbreve;": { "codepoints": [287], "characters": "\u011F" },
+ "&gcirc;": { "codepoints": [285], "characters": "\u011D" },
+ "&gcy;": { "codepoints": [1075], "characters": "\u0433" },
+ "&gdot;": { "codepoints": [289], "characters": "\u0121" },
+ "&ge;": { "codepoints": [8805], "characters": "\u2265" },
+ "&gel;": { "codepoints": [8923], "characters": "\u22DB" },
+ "&geq;": { "codepoints": [8805], "characters": "\u2265" },
+ "&geqq;": { "codepoints": [8807], "characters": "\u2267" },
+ "&geqslant;": { "codepoints": [10878], "characters": "\u2A7E" },
+ "&ges;": { "codepoints": [10878], "characters": "\u2A7E" },
+ "&gescc;": { "codepoints": [10921], "characters": "\u2AA9" },
+ "&gesdot;": { "codepoints": [10880], "characters": "\u2A80" },
+ "&gesdoto;": { "codepoints": [10882], "characters": "\u2A82" },
+ "&gesdotol;": { "codepoints": [10884], "characters": "\u2A84" },
+ "&gesl;": { "codepoints": [8923, 65024], "characters": "\u22DB\uFE00" },
+ "&gesles;": { "codepoints": [10900], "characters": "\u2A94" },
+ "&gfr;": { "codepoints": [120100], "characters": "\uD835\uDD24" },
+ "&gg;": { "codepoints": [8811], "characters": "\u226B" },
+ "&ggg;": { "codepoints": [8921], "characters": "\u22D9" },
+ "&gimel;": { "codepoints": [8503], "characters": "\u2137" },
+ "&gjcy;": { "codepoints": [1107], "characters": "\u0453" },
+ "&gl;": { "codepoints": [8823], "characters": "\u2277" },
+ "&glE;": { "codepoints": [10898], "characters": "\u2A92" },
+ "&gla;": { "codepoints": [10917], "characters": "\u2AA5" },
+ "&glj;": { "codepoints": [10916], "characters": "\u2AA4" },
+ "&gnE;": { "codepoints": [8809], "characters": "\u2269" },
+ "&gnap;": { "codepoints": [10890], "characters": "\u2A8A" },
+ "&gnapprox;": { "codepoints": [10890], "characters": "\u2A8A" },
+ "&gne;": { "codepoints": [10888], "characters": "\u2A88" },
+ "&gneq;": { "codepoints": [10888], "characters": "\u2A88" },
+ "&gneqq;": { "codepoints": [8809], "characters": "\u2269" },
+ "&gnsim;": { "codepoints": [8935], "characters": "\u22E7" },
+ "&gopf;": { "codepoints": [120152], "characters": "\uD835\uDD58" },
+ "&grave;": { "codepoints": [96], "characters": "\u0060" },
+ "&gscr;": { "codepoints": [8458], "characters": "\u210A" },
+ "&gsim;": { "codepoints": [8819], "characters": "\u2273" },
+ "&gsime;": { "codepoints": [10894], "characters": "\u2A8E" },
+ "&gsiml;": { "codepoints": [10896], "characters": "\u2A90" },
+ "&gt": { "codepoints": [62], "characters": "\u003E" },
+ "&gt;": { "codepoints": [62], "characters": "\u003E" },
+ "&gtcc;": { "codepoints": [10919], "characters": "\u2AA7" },
+ "&gtcir;": { "codepoints": [10874], "characters": "\u2A7A" },
+ "&gtdot;": { "codepoints": [8919], "characters": "\u22D7" },
+ "&gtlPar;": { "codepoints": [10645], "characters": "\u2995" },
+ "&gtquest;": { "codepoints": [10876], "characters": "\u2A7C" },
+ "&gtrapprox;": { "codepoints": [10886], "characters": "\u2A86" },
+ "&gtrarr;": { "codepoints": [10616], "characters": "\u2978" },
+ "&gtrdot;": { "codepoints": [8919], "characters": "\u22D7" },
+ "&gtreqless;": { "codepoints": [8923], "characters": "\u22DB" },
+ "&gtreqqless;": { "codepoints": [10892], "characters": "\u2A8C" },
+ "&gtrless;": { "codepoints": [8823], "characters": "\u2277" },
+ "&gtrsim;": { "codepoints": [8819], "characters": "\u2273" },
+ "&gvertneqq;": { "codepoints": [8809, 65024], "characters": "\u2269\uFE00" },
+ "&gvnE;": { "codepoints": [8809, 65024], "characters": "\u2269\uFE00" },
+ "&hArr;": { "codepoints": [8660], "characters": "\u21D4" },
+ "&hairsp;": { "codepoints": [8202], "characters": "\u200A" },
+ "&half;": { "codepoints": [189], "characters": "\u00BD" },
+ "&hamilt;": { "codepoints": [8459], "characters": "\u210B" },
+ "&hardcy;": { "codepoints": [1098], "characters": "\u044A" },
+ "&harr;": { "codepoints": [8596], "characters": "\u2194" },
+ "&harrcir;": { "codepoints": [10568], "characters": "\u2948" },
+ "&harrw;": { "codepoints": [8621], "characters": "\u21AD" },
+ "&hbar;": { "codepoints": [8463], "characters": "\u210F" },
+ "&hcirc;": { "codepoints": [293], "characters": "\u0125" },
+ "&hearts;": { "codepoints": [9829], "characters": "\u2665" },
+ "&heartsuit;": { "codepoints": [9829], "characters": "\u2665" },
+ "&hellip;": { "codepoints": [8230], "characters": "\u2026" },
+ "&hercon;": { "codepoints": [8889], "characters": "\u22B9" },
+ "&hfr;": { "codepoints": [120101], "characters": "\uD835\uDD25" },
+ "&hksearow;": { "codepoints": [10533], "characters": "\u2925" },
+ "&hkswarow;": { "codepoints": [10534], "characters": "\u2926" },
+ "&hoarr;": { "codepoints": [8703], "characters": "\u21FF" },
+ "&homtht;": { "codepoints": [8763], "characters": "\u223B" },
+ "&hookleftarrow;": { "codepoints": [8617], "characters": "\u21A9" },
+ "&hookrightarrow;": { "codepoints": [8618], "characters": "\u21AA" },
+ "&hopf;": { "codepoints": [120153], "characters": "\uD835\uDD59" },
+ "&horbar;": { "codepoints": [8213], "characters": "\u2015" },
+ "&hscr;": { "codepoints": [119997], "characters": "\uD835\uDCBD" },
+ "&hslash;": { "codepoints": [8463], "characters": "\u210F" },
+ "&hstrok;": { "codepoints": [295], "characters": "\u0127" },
+ "&hybull;": { "codepoints": [8259], "characters": "\u2043" },
+ "&hyphen;": { "codepoints": [8208], "characters": "\u2010" },
+ "&iacute": { "codepoints": [237], "characters": "\u00ED" },
+ "&iacute;": { "codepoints": [237], "characters": "\u00ED" },
+ "&ic;": { "codepoints": [8291], "characters": "\u2063" },
+ "&icirc": { "codepoints": [238], "characters": "\u00EE" },
+ "&icirc;": { "codepoints": [238], "characters": "\u00EE" },
+ "&icy;": { "codepoints": [1080], "characters": "\u0438" },
+ "&iecy;": { "codepoints": [1077], "characters": "\u0435" },
+ "&iexcl": { "codepoints": [161], "characters": "\u00A1" },
+ "&iexcl;": { "codepoints": [161], "characters": "\u00A1" },
+ "&iff;": { "codepoints": [8660], "characters": "\u21D4" },
+ "&ifr;": { "codepoints": [120102], "characters": "\uD835\uDD26" },
+ "&igrave": { "codepoints": [236], "characters": "\u00EC" },
+ "&igrave;": { "codepoints": [236], "characters": "\u00EC" },
+ "&ii;": { "codepoints": [8520], "characters": "\u2148" },
+ "&iiiint;": { "codepoints": [10764], "characters": "\u2A0C" },
+ "&iiint;": { "codepoints": [8749], "characters": "\u222D" },
+ "&iinfin;": { "codepoints": [10716], "characters": "\u29DC" },
+ "&iiota;": { "codepoints": [8489], "characters": "\u2129" },
+ "&ijlig;": { "codepoints": [307], "characters": "\u0133" },
+ "&imacr;": { "codepoints": [299], "characters": "\u012B" },
+ "&image;": { "codepoints": [8465], "characters": "\u2111" },
+ "&imagline;": { "codepoints": [8464], "characters": "\u2110" },
+ "&imagpart;": { "codepoints": [8465], "characters": "\u2111" },
+ "&imath;": { "codepoints": [305], "characters": "\u0131" },
+ "&imof;": { "codepoints": [8887], "characters": "\u22B7" },
+ "&imped;": { "codepoints": [437], "characters": "\u01B5" },
+ "&in;": { "codepoints": [8712], "characters": "\u2208" },
+ "&incare;": { "codepoints": [8453], "characters": "\u2105" },
+ "&infin;": { "codepoints": [8734], "characters": "\u221E" },
+ "&infintie;": { "codepoints": [10717], "characters": "\u29DD" },
+ "&inodot;": { "codepoints": [305], "characters": "\u0131" },
+ "&int;": { "codepoints": [8747], "characters": "\u222B" },
+ "&intcal;": { "codepoints": [8890], "characters": "\u22BA" },
+ "&integers;": { "codepoints": [8484], "characters": "\u2124" },
+ "&intercal;": { "codepoints": [8890], "characters": "\u22BA" },
+ "&intlarhk;": { "codepoints": [10775], "characters": "\u2A17" },
+ "&intprod;": { "codepoints": [10812], "characters": "\u2A3C" },
+ "&iocy;": { "codepoints": [1105], "characters": "\u0451" },
+ "&iogon;": { "codepoints": [303], "characters": "\u012F" },
+ "&iopf;": { "codepoints": [120154], "characters": "\uD835\uDD5A" },
+ "&iota;": { "codepoints": [953], "characters": "\u03B9" },
+ "&iprod;": { "codepoints": [10812], "characters": "\u2A3C" },
+ "&iquest": { "codepoints": [191], "characters": "\u00BF" },
+ "&iquest;": { "codepoints": [191], "characters": "\u00BF" },
+ "&iscr;": { "codepoints": [119998], "characters": "\uD835\uDCBE" },
+ "&isin;": { "codepoints": [8712], "characters": "\u2208" },
+ "&isinE;": { "codepoints": [8953], "characters": "\u22F9" },
+ "&isindot;": { "codepoints": [8949], "characters": "\u22F5" },
+ "&isins;": { "codepoints": [8948], "characters": "\u22F4" },
+ "&isinsv;": { "codepoints": [8947], "characters": "\u22F3" },
+ "&isinv;": { "codepoints": [8712], "characters": "\u2208" },
+ "&it;": { "codepoints": [8290], "characters": "\u2062" },
+ "&itilde;": { "codepoints": [297], "characters": "\u0129" },
+ "&iukcy;": { "codepoints": [1110], "characters": "\u0456" },
+ "&iuml": { "codepoints": [239], "characters": "\u00EF" },
+ "&iuml;": { "codepoints": [239], "characters": "\u00EF" },
+ "&jcirc;": { "codepoints": [309], "characters": "\u0135" },
+ "&jcy;": { "codepoints": [1081], "characters": "\u0439" },
+ "&jfr;": { "codepoints": [120103], "characters": "\uD835\uDD27" },
+ "&jmath;": { "codepoints": [567], "characters": "\u0237" },
+ "&jopf;": { "codepoints": [120155], "characters": "\uD835\uDD5B" },
+ "&jscr;": { "codepoints": [119999], "characters": "\uD835\uDCBF" },
+ "&jsercy;": { "codepoints": [1112], "characters": "\u0458" },
+ "&jukcy;": { "codepoints": [1108], "characters": "\u0454" },
+ "&kappa;": { "codepoints": [954], "characters": "\u03BA" },
+ "&kappav;": { "codepoints": [1008], "characters": "\u03F0" },
+ "&kcedil;": { "codepoints": [311], "characters": "\u0137" },
+ "&kcy;": { "codepoints": [1082], "characters": "\u043A" },
+ "&kfr;": { "codepoints": [120104], "characters": "\uD835\uDD28" },
+ "&kgreen;": { "codepoints": [312], "characters": "\u0138" },
+ "&khcy;": { "codepoints": [1093], "characters": "\u0445" },
+ "&kjcy;": { "codepoints": [1116], "characters": "\u045C" },
+ "&kopf;": { "codepoints": [120156], "characters": "\uD835\uDD5C" },
+ "&kscr;": { "codepoints": [120000], "characters": "\uD835\uDCC0" },
+ "&lAarr;": { "codepoints": [8666], "characters": "\u21DA" },
+ "&lArr;": { "codepoints": [8656], "characters": "\u21D0" },
+ "&lAtail;": { "codepoints": [10523], "characters": "\u291B" },
+ "&lBarr;": { "codepoints": [10510], "characters": "\u290E" },
+ "&lE;": { "codepoints": [8806], "characters": "\u2266" },
+ "&lEg;": { "codepoints": [10891], "characters": "\u2A8B" },
+ "&lHar;": { "codepoints": [10594], "characters": "\u2962" },
+ "&lacute;": { "codepoints": [314], "characters": "\u013A" },
+ "&laemptyv;": { "codepoints": [10676], "characters": "\u29B4" },
+ "&lagran;": { "codepoints": [8466], "characters": "\u2112" },
+ "&lambda;": { "codepoints": [955], "characters": "\u03BB" },
+ "&lang;": { "codepoints": [10216], "characters": "\u27E8" },
+ "&langd;": { "codepoints": [10641], "characters": "\u2991" },
+ "&langle;": { "codepoints": [10216], "characters": "\u27E8" },
+ "&lap;": { "codepoints": [10885], "characters": "\u2A85" },
+ "&laquo": { "codepoints": [171], "characters": "\u00AB" },
+ "&laquo;": { "codepoints": [171], "characters": "\u00AB" },
+ "&larr;": { "codepoints": [8592], "characters": "\u2190" },
+ "&larrb;": { "codepoints": [8676], "characters": "\u21E4" },
+ "&larrbfs;": { "codepoints": [10527], "characters": "\u291F" },
+ "&larrfs;": { "codepoints": [10525], "characters": "\u291D" },
+ "&larrhk;": { "codepoints": [8617], "characters": "\u21A9" },
+ "&larrlp;": { "codepoints": [8619], "characters": "\u21AB" },
+ "&larrpl;": { "codepoints": [10553], "characters": "\u2939" },
+ "&larrsim;": { "codepoints": [10611], "characters": "\u2973" },
+ "&larrtl;": { "codepoints": [8610], "characters": "\u21A2" },
+ "&lat;": { "codepoints": [10923], "characters": "\u2AAB" },
+ "&latail;": { "codepoints": [10521], "characters": "\u2919" },
+ "&late;": { "codepoints": [10925], "characters": "\u2AAD" },
+ "&lates;": { "codepoints": [10925, 65024], "characters": "\u2AAD\uFE00" },
+ "&lbarr;": { "codepoints": [10508], "characters": "\u290C" },
+ "&lbbrk;": { "codepoints": [10098], "characters": "\u2772" },
+ "&lbrace;": { "codepoints": [123], "characters": "\u007B" },
+ "&lbrack;": { "codepoints": [91], "characters": "\u005B" },
+ "&lbrke;": { "codepoints": [10635], "characters": "\u298B" },
+ "&lbrksld;": { "codepoints": [10639], "characters": "\u298F" },
+ "&lbrkslu;": { "codepoints": [10637], "characters": "\u298D" },
+ "&lcaron;": { "codepoints": [318], "characters": "\u013E" },
+ "&lcedil;": { "codepoints": [316], "characters": "\u013C" },
+ "&lceil;": { "codepoints": [8968], "characters": "\u2308" },
+ "&lcub;": { "codepoints": [123], "characters": "\u007B" },
+ "&lcy;": { "codepoints": [1083], "characters": "\u043B" },
+ "&ldca;": { "codepoints": [10550], "characters": "\u2936" },
+ "&ldquo;": { "codepoints": [8220], "characters": "\u201C" },
+ "&ldquor;": { "codepoints": [8222], "characters": "\u201E" },
+ "&ldrdhar;": { "codepoints": [10599], "characters": "\u2967" },
+ "&ldrushar;": { "codepoints": [10571], "characters": "\u294B" },
+ "&ldsh;": { "codepoints": [8626], "characters": "\u21B2" },
+ "&le;": { "codepoints": [8804], "characters": "\u2264" },
+ "&leftarrow;": { "codepoints": [8592], "characters": "\u2190" },
+ "&leftarrowtail;": { "codepoints": [8610], "characters": "\u21A2" },
+ "&leftharpoondown;": { "codepoints": [8637], "characters": "\u21BD" },
+ "&leftharpoonup;": { "codepoints": [8636], "characters": "\u21BC" },
+ "&leftleftarrows;": { "codepoints": [8647], "characters": "\u21C7" },
+ "&leftrightarrow;": { "codepoints": [8596], "characters": "\u2194" },
+ "&leftrightarrows;": { "codepoints": [8646], "characters": "\u21C6" },
+ "&leftrightharpoons;": { "codepoints": [8651], "characters": "\u21CB" },
+ "&leftrightsquigarrow;": { "codepoints": [8621], "characters": "\u21AD" },
+ "&leftthreetimes;": { "codepoints": [8907], "characters": "\u22CB" },
+ "&leg;": { "codepoints": [8922], "characters": "\u22DA" },
+ "&leq;": { "codepoints": [8804], "characters": "\u2264" },
+ "&leqq;": { "codepoints": [8806], "characters": "\u2266" },
+ "&leqslant;": { "codepoints": [10877], "characters": "\u2A7D" },
+ "&les;": { "codepoints": [10877], "characters": "\u2A7D" },
+ "&lescc;": { "codepoints": [10920], "characters": "\u2AA8" },
+ "&lesdot;": { "codepoints": [10879], "characters": "\u2A7F" },
+ "&lesdoto;": { "codepoints": [10881], "characters": "\u2A81" },
+ "&lesdotor;": { "codepoints": [10883], "characters": "\u2A83" },
+ "&lesg;": { "codepoints": [8922, 65024], "characters": "\u22DA\uFE00" },
+ "&lesges;": { "codepoints": [10899], "characters": "\u2A93" },
+ "&lessapprox;": { "codepoints": [10885], "characters": "\u2A85" },
+ "&lessdot;": { "codepoints": [8918], "characters": "\u22D6" },
+ "&lesseqgtr;": { "codepoints": [8922], "characters": "\u22DA" },
+ "&lesseqqgtr;": { "codepoints": [10891], "characters": "\u2A8B" },
+ "&lessgtr;": { "codepoints": [8822], "characters": "\u2276" },
+ "&lesssim;": { "codepoints": [8818], "characters": "\u2272" },
+ "&lfisht;": { "codepoints": [10620], "characters": "\u297C" },
+ "&lfloor;": { "codepoints": [8970], "characters": "\u230A" },
+ "&lfr;": { "codepoints": [120105], "characters": "\uD835\uDD29" },
+ "&lg;": { "codepoints": [8822], "characters": "\u2276" },
+ "&lgE;": { "codepoints": [10897], "characters": "\u2A91" },
+ "&lhard;": { "codepoints": [8637], "characters": "\u21BD" },
+ "&lharu;": { "codepoints": [8636], "characters": "\u21BC" },
+ "&lharul;": { "codepoints": [10602], "characters": "\u296A" },
+ "&lhblk;": { "codepoints": [9604], "characters": "\u2584" },
+ "&ljcy;": { "codepoints": [1113], "characters": "\u0459" },
+ "&ll;": { "codepoints": [8810], "characters": "\u226A" },
+ "&llarr;": { "codepoints": [8647], "characters": "\u21C7" },
+ "&llcorner;": { "codepoints": [8990], "characters": "\u231E" },
+ "&llhard;": { "codepoints": [10603], "characters": "\u296B" },
+ "&lltri;": { "codepoints": [9722], "characters": "\u25FA" },
+ "&lmidot;": { "codepoints": [320], "characters": "\u0140" },
+ "&lmoust;": { "codepoints": [9136], "characters": "\u23B0" },
+ "&lmoustache;": { "codepoints": [9136], "characters": "\u23B0" },
+ "&lnE;": { "codepoints": [8808], "characters": "\u2268" },
+ "&lnap;": { "codepoints": [10889], "characters": "\u2A89" },
+ "&lnapprox;": { "codepoints": [10889], "characters": "\u2A89" },
+ "&lne;": { "codepoints": [10887], "characters": "\u2A87" },
+ "&lneq;": { "codepoints": [10887], "characters": "\u2A87" },
+ "&lneqq;": { "codepoints": [8808], "characters": "\u2268" },
+ "&lnsim;": { "codepoints": [8934], "characters": "\u22E6" },
+ "&loang;": { "codepoints": [10220], "characters": "\u27EC" },
+ "&loarr;": { "codepoints": [8701], "characters": "\u21FD" },
+ "&lobrk;": { "codepoints": [10214], "characters": "\u27E6" },
+ "&longleftarrow;": { "codepoints": [10229], "characters": "\u27F5" },
+ "&longleftrightarrow;": { "codepoints": [10231], "characters": "\u27F7" },
+ "&longmapsto;": { "codepoints": [10236], "characters": "\u27FC" },
+ "&longrightarrow;": { "codepoints": [10230], "characters": "\u27F6" },
+ "&looparrowleft;": { "codepoints": [8619], "characters": "\u21AB" },
+ "&looparrowright;": { "codepoints": [8620], "characters": "\u21AC" },
+ "&lopar;": { "codepoints": [10629], "characters": "\u2985" },
+ "&lopf;": { "codepoints": [120157], "characters": "\uD835\uDD5D" },
+ "&loplus;": { "codepoints": [10797], "characters": "\u2A2D" },
+ "&lotimes;": { "codepoints": [10804], "characters": "\u2A34" },
+ "&lowast;": { "codepoints": [8727], "characters": "\u2217" },
+ "&lowbar;": { "codepoints": [95], "characters": "\u005F" },
+ "&loz;": { "codepoints": [9674], "characters": "\u25CA" },
+ "&lozenge;": { "codepoints": [9674], "characters": "\u25CA" },
+ "&lozf;": { "codepoints": [10731], "characters": "\u29EB" },
+ "&lpar;": { "codepoints": [40], "characters": "\u0028" },
+ "&lparlt;": { "codepoints": [10643], "characters": "\u2993" },
+ "&lrarr;": { "codepoints": [8646], "characters": "\u21C6" },
+ "&lrcorner;": { "codepoints": [8991], "characters": "\u231F" },
+ "&lrhar;": { "codepoints": [8651], "characters": "\u21CB" },
+ "&lrhard;": { "codepoints": [10605], "characters": "\u296D" },
+ "&lrm;": { "codepoints": [8206], "characters": "\u200E" },
+ "&lrtri;": { "codepoints": [8895], "characters": "\u22BF" },
+ "&lsaquo;": { "codepoints": [8249], "characters": "\u2039" },
+ "&lscr;": { "codepoints": [120001], "characters": "\uD835\uDCC1" },
+ "&lsh;": { "codepoints": [8624], "characters": "\u21B0" },
+ "&lsim;": { "codepoints": [8818], "characters": "\u2272" },
+ "&lsime;": { "codepoints": [10893], "characters": "\u2A8D" },
+ "&lsimg;": { "codepoints": [10895], "characters": "\u2A8F" },
+ "&lsqb;": { "codepoints": [91], "characters": "\u005B" },
+ "&lsquo;": { "codepoints": [8216], "characters": "\u2018" },
+ "&lsquor;": { "codepoints": [8218], "characters": "\u201A" },
+ "&lstrok;": { "codepoints": [322], "characters": "\u0142" },
+ "&lt": { "codepoints": [60], "characters": "\u003C" },
+ "&lt;": { "codepoints": [60], "characters": "\u003C" },
+ "&ltcc;": { "codepoints": [10918], "characters": "\u2AA6" },
+ "&ltcir;": { "codepoints": [10873], "characters": "\u2A79" },
+ "&ltdot;": { "codepoints": [8918], "characters": "\u22D6" },
+ "&lthree;": { "codepoints": [8907], "characters": "\u22CB" },
+ "&ltimes;": { "codepoints": [8905], "characters": "\u22C9" },
+ "&ltlarr;": { "codepoints": [10614], "characters": "\u2976" },
+ "&ltquest;": { "codepoints": [10875], "characters": "\u2A7B" },
+ "&ltrPar;": { "codepoints": [10646], "characters": "\u2996" },
+ "&ltri;": { "codepoints": [9667], "characters": "\u25C3" },
+ "&ltrie;": { "codepoints": [8884], "characters": "\u22B4" },
+ "&ltrif;": { "codepoints": [9666], "characters": "\u25C2" },
+ "&lurdshar;": { "codepoints": [10570], "characters": "\u294A" },
+ "&luruhar;": { "codepoints": [10598], "characters": "\u2966" },
+ "&lvertneqq;": { "codepoints": [8808, 65024], "characters": "\u2268\uFE00" },
+ "&lvnE;": { "codepoints": [8808, 65024], "characters": "\u2268\uFE00" },
+ "&mDDot;": { "codepoints": [8762], "characters": "\u223A" },
+ "&macr": { "codepoints": [175], "characters": "\u00AF" },
+ "&macr;": { "codepoints": [175], "characters": "\u00AF" },
+ "&male;": { "codepoints": [9794], "characters": "\u2642" },
+ "&malt;": { "codepoints": [10016], "characters": "\u2720" },
+ "&maltese;": { "codepoints": [10016], "characters": "\u2720" },
+ "&map;": { "codepoints": [8614], "characters": "\u21A6" },
+ "&mapsto;": { "codepoints": [8614], "characters": "\u21A6" },
+ "&mapstodown;": { "codepoints": [8615], "characters": "\u21A7" },
+ "&mapstoleft;": { "codepoints": [8612], "characters": "\u21A4" },
+ "&mapstoup;": { "codepoints": [8613], "characters": "\u21A5" },
+ "&marker;": { "codepoints": [9646], "characters": "\u25AE" },
+ "&mcomma;": { "codepoints": [10793], "characters": "\u2A29" },
+ "&mcy;": { "codepoints": [1084], "characters": "\u043C" },
+ "&mdash;": { "codepoints": [8212], "characters": "\u2014" },
+ "&measuredangle;": { "codepoints": [8737], "characters": "\u2221" },
+ "&mfr;": { "codepoints": [120106], "characters": "\uD835\uDD2A" },
+ "&mho;": { "codepoints": [8487], "characters": "\u2127" },
+ "&micro": { "codepoints": [181], "characters": "\u00B5" },
+ "&micro;": { "codepoints": [181], "characters": "\u00B5" },
+ "&mid;": { "codepoints": [8739], "characters": "\u2223" },
+ "&midast;": { "codepoints": [42], "characters": "\u002A" },
+ "&midcir;": { "codepoints": [10992], "characters": "\u2AF0" },
+ "&middot": { "codepoints": [183], "characters": "\u00B7" },
+ "&middot;": { "codepoints": [183], "characters": "\u00B7" },
+ "&minus;": { "codepoints": [8722], "characters": "\u2212" },
+ "&minusb;": { "codepoints": [8863], "characters": "\u229F" },
+ "&minusd;": { "codepoints": [8760], "characters": "\u2238" },
+ "&minusdu;": { "codepoints": [10794], "characters": "\u2A2A" },
+ "&mlcp;": { "codepoints": [10971], "characters": "\u2ADB" },
+ "&mldr;": { "codepoints": [8230], "characters": "\u2026" },
+ "&mnplus;": { "codepoints": [8723], "characters": "\u2213" },
+ "&models;": { "codepoints": [8871], "characters": "\u22A7" },
+ "&mopf;": { "codepoints": [120158], "characters": "\uD835\uDD5E" },
+ "&mp;": { "codepoints": [8723], "characters": "\u2213" },
+ "&mscr;": { "codepoints": [120002], "characters": "\uD835\uDCC2" },
+ "&mstpos;": { "codepoints": [8766], "characters": "\u223E" },
+ "&mu;": { "codepoints": [956], "characters": "\u03BC" },
+ "&multimap;": { "codepoints": [8888], "characters": "\u22B8" },
+ "&mumap;": { "codepoints": [8888], "characters": "\u22B8" },
+ "&nGg;": { "codepoints": [8921, 824], "characters": "\u22D9\u0338" },
+ "&nGt;": { "codepoints": [8811, 8402], "characters": "\u226B\u20D2" },
+ "&nGtv;": { "codepoints": [8811, 824], "characters": "\u226B\u0338" },
+ "&nLeftarrow;": { "codepoints": [8653], "characters": "\u21CD" },
+ "&nLeftrightarrow;": { "codepoints": [8654], "characters": "\u21CE" },
+ "&nLl;": { "codepoints": [8920, 824], "characters": "\u22D8\u0338" },
+ "&nLt;": { "codepoints": [8810, 8402], "characters": "\u226A\u20D2" },
+ "&nLtv;": { "codepoints": [8810, 824], "characters": "\u226A\u0338" },
+ "&nRightarrow;": { "codepoints": [8655], "characters": "\u21CF" },
+ "&nVDash;": { "codepoints": [8879], "characters": "\u22AF" },
+ "&nVdash;": { "codepoints": [8878], "characters": "\u22AE" },
+ "&nabla;": { "codepoints": [8711], "characters": "\u2207" },
+ "&nacute;": { "codepoints": [324], "characters": "\u0144" },
+ "&nang;": { "codepoints": [8736, 8402], "characters": "\u2220\u20D2" },
+ "&nap;": { "codepoints": [8777], "characters": "\u2249" },
+ "&napE;": { "codepoints": [10864, 824], "characters": "\u2A70\u0338" },
+ "&napid;": { "codepoints": [8779, 824], "characters": "\u224B\u0338" },
+ "&napos;": { "codepoints": [329], "characters": "\u0149" },
+ "&napprox;": { "codepoints": [8777], "characters": "\u2249" },
+ "&natur;": { "codepoints": [9838], "characters": "\u266E" },
+ "&natural;": { "codepoints": [9838], "characters": "\u266E" },
+ "&naturals;": { "codepoints": [8469], "characters": "\u2115" },
+ "&nbsp": { "codepoints": [160], "characters": "\u00A0" },
+ "&nbsp;": { "codepoints": [160], "characters": "\u00A0" },
+ "&nbump;": { "codepoints": [8782, 824], "characters": "\u224E\u0338" },
+ "&nbumpe;": { "codepoints": [8783, 824], "characters": "\u224F\u0338" },
+ "&ncap;": { "codepoints": [10819], "characters": "\u2A43" },
+ "&ncaron;": { "codepoints": [328], "characters": "\u0148" },
+ "&ncedil;": { "codepoints": [326], "characters": "\u0146" },
+ "&ncong;": { "codepoints": [8775], "characters": "\u2247" },
+ "&ncongdot;": { "codepoints": [10861, 824], "characters": "\u2A6D\u0338" },
+ "&ncup;": { "codepoints": [10818], "characters": "\u2A42" },
+ "&ncy;": { "codepoints": [1085], "characters": "\u043D" },
+ "&ndash;": { "codepoints": [8211], "characters": "\u2013" },
+ "&ne;": { "codepoints": [8800], "characters": "\u2260" },
+ "&neArr;": { "codepoints": [8663], "characters": "\u21D7" },
+ "&nearhk;": { "codepoints": [10532], "characters": "\u2924" },
+ "&nearr;": { "codepoints": [8599], "characters": "\u2197" },
+ "&nearrow;": { "codepoints": [8599], "characters": "\u2197" },
+ "&nedot;": { "codepoints": [8784, 824], "characters": "\u2250\u0338" },
+ "&nequiv;": { "codepoints": [8802], "characters": "\u2262" },
+ "&nesear;": { "codepoints": [10536], "characters": "\u2928" },
+ "&nesim;": { "codepoints": [8770, 824], "characters": "\u2242\u0338" },
+ "&nexist;": { "codepoints": [8708], "characters": "\u2204" },
+ "&nexists;": { "codepoints": [8708], "characters": "\u2204" },
+ "&nfr;": { "codepoints": [120107], "characters": "\uD835\uDD2B" },
+ "&ngE;": { "codepoints": [8807, 824], "characters": "\u2267\u0338" },
+ "&nge;": { "codepoints": [8817], "characters": "\u2271" },
+ "&ngeq;": { "codepoints": [8817], "characters": "\u2271" },
+ "&ngeqq;": { "codepoints": [8807, 824], "characters": "\u2267\u0338" },
+ "&ngeqslant;": { "codepoints": [10878, 824], "characters": "\u2A7E\u0338" },
+ "&nges;": { "codepoints": [10878, 824], "characters": "\u2A7E\u0338" },
+ "&ngsim;": { "codepoints": [8821], "characters": "\u2275" },
+ "&ngt;": { "codepoints": [8815], "characters": "\u226F" },
+ "&ngtr;": { "codepoints": [8815], "characters": "\u226F" },
+ "&nhArr;": { "codepoints": [8654], "characters": "\u21CE" },
+ "&nharr;": { "codepoints": [8622], "characters": "\u21AE" },
+ "&nhpar;": { "codepoints": [10994], "characters": "\u2AF2" },
+ "&ni;": { "codepoints": [8715], "characters": "\u220B" },
+ "&nis;": { "codepoints": [8956], "characters": "\u22FC" },
+ "&nisd;": { "codepoints": [8954], "characters": "\u22FA" },
+ "&niv;": { "codepoints": [8715], "characters": "\u220B" },
+ "&njcy;": { "codepoints": [1114], "characters": "\u045A" },
+ "&nlArr;": { "codepoints": [8653], "characters": "\u21CD" },
+ "&nlE;": { "codepoints": [8806, 824], "characters": "\u2266\u0338" },
+ "&nlarr;": { "codepoints": [8602], "characters": "\u219A" },
+ "&nldr;": { "codepoints": [8229], "characters": "\u2025" },
+ "&nle;": { "codepoints": [8816], "characters": "\u2270" },
+ "&nleftarrow;": { "codepoints": [8602], "characters": "\u219A" },
+ "&nleftrightarrow;": { "codepoints": [8622], "characters": "\u21AE" },
+ "&nleq;": { "codepoints": [8816], "characters": "\u2270" },
+ "&nleqq;": { "codepoints": [8806, 824], "characters": "\u2266\u0338" },
+ "&nleqslant;": { "codepoints": [10877, 824], "characters": "\u2A7D\u0338" },
+ "&nles;": { "codepoints": [10877, 824], "characters": "\u2A7D\u0338" },
+ "&nless;": { "codepoints": [8814], "characters": "\u226E" },
+ "&nlsim;": { "codepoints": [8820], "characters": "\u2274" },
+ "&nlt;": { "codepoints": [8814], "characters": "\u226E" },
+ "&nltri;": { "codepoints": [8938], "characters": "\u22EA" },
+ "&nltrie;": { "codepoints": [8940], "characters": "\u22EC" },
+ "&nmid;": { "codepoints": [8740], "characters": "\u2224" },
+ "&nopf;": { "codepoints": [120159], "characters": "\uD835\uDD5F" },
+ "&not": { "codepoints": [172], "characters": "\u00AC" },
+ "&not;": { "codepoints": [172], "characters": "\u00AC" },
+ "&notin;": { "codepoints": [8713], "characters": "\u2209" },
+ "&notinE;": { "codepoints": [8953, 824], "characters": "\u22F9\u0338" },
+ "&notindot;": { "codepoints": [8949, 824], "characters": "\u22F5\u0338" },
+ "&notinva;": { "codepoints": [8713], "characters": "\u2209" },
+ "&notinvb;": { "codepoints": [8951], "characters": "\u22F7" },
+ "&notinvc;": { "codepoints": [8950], "characters": "\u22F6" },
+ "&notni;": { "codepoints": [8716], "characters": "\u220C" },
+ "&notniva;": { "codepoints": [8716], "characters": "\u220C" },
+ "&notnivb;": { "codepoints": [8958], "characters": "\u22FE" },
+ "&notnivc;": { "codepoints": [8957], "characters": "\u22FD" },
+ "&npar;": { "codepoints": [8742], "characters": "\u2226" },
+ "&nparallel;": { "codepoints": [8742], "characters": "\u2226" },
+ "&nparsl;": { "codepoints": [11005, 8421], "characters": "\u2AFD\u20E5" },
+ "&npart;": { "codepoints": [8706, 824], "characters": "\u2202\u0338" },
+ "&npolint;": { "codepoints": [10772], "characters": "\u2A14" },
+ "&npr;": { "codepoints": [8832], "characters": "\u2280" },
+ "&nprcue;": { "codepoints": [8928], "characters": "\u22E0" },
+ "&npre;": { "codepoints": [10927, 824], "characters": "\u2AAF\u0338" },
+ "&nprec;": { "codepoints": [8832], "characters": "\u2280" },
+ "&npreceq;": { "codepoints": [10927, 824], "characters": "\u2AAF\u0338" },
+ "&nrArr;": { "codepoints": [8655], "characters": "\u21CF" },
+ "&nrarr;": { "codepoints": [8603], "characters": "\u219B" },
+ "&nrarrc;": { "codepoints": [10547, 824], "characters": "\u2933\u0338" },
+ "&nrarrw;": { "codepoints": [8605, 824], "characters": "\u219D\u0338" },
+ "&nrightarrow;": { "codepoints": [8603], "characters": "\u219B" },
+ "&nrtri;": { "codepoints": [8939], "characters": "\u22EB" },
+ "&nrtrie;": { "codepoints": [8941], "characters": "\u22ED" },
+ "&nsc;": { "codepoints": [8833], "characters": "\u2281" },
+ "&nsccue;": { "codepoints": [8929], "characters": "\u22E1" },
+ "&nsce;": { "codepoints": [10928, 824], "characters": "\u2AB0\u0338" },
+ "&nscr;": { "codepoints": [120003], "characters": "\uD835\uDCC3" },
+ "&nshortmid;": { "codepoints": [8740], "characters": "\u2224" },
+ "&nshortparallel;": { "codepoints": [8742], "characters": "\u2226" },
+ "&nsim;": { "codepoints": [8769], "characters": "\u2241" },
+ "&nsime;": { "codepoints": [8772], "characters": "\u2244" },
+ "&nsimeq;": { "codepoints": [8772], "characters": "\u2244" },
+ "&nsmid;": { "codepoints": [8740], "characters": "\u2224" },
+ "&nspar;": { "codepoints": [8742], "characters": "\u2226" },
+ "&nsqsube;": { "codepoints": [8930], "characters": "\u22E2" },
+ "&nsqsupe;": { "codepoints": [8931], "characters": "\u22E3" },
+ "&nsub;": { "codepoints": [8836], "characters": "\u2284" },
+ "&nsubE;": { "codepoints": [10949, 824], "characters": "\u2AC5\u0338" },
+ "&nsube;": { "codepoints": [8840], "characters": "\u2288" },
+ "&nsubset;": { "codepoints": [8834, 8402], "characters": "\u2282\u20D2" },
+ "&nsubseteq;": { "codepoints": [8840], "characters": "\u2288" },
+ "&nsubseteqq;": { "codepoints": [10949, 824], "characters": "\u2AC5\u0338" },
+ "&nsucc;": { "codepoints": [8833], "characters": "\u2281" },
+ "&nsucceq;": { "codepoints": [10928, 824], "characters": "\u2AB0\u0338" },
+ "&nsup;": { "codepoints": [8837], "characters": "\u2285" },
+ "&nsupE;": { "codepoints": [10950, 824], "characters": "\u2AC6\u0338" },
+ "&nsupe;": { "codepoints": [8841], "characters": "\u2289" },
+ "&nsupset;": { "codepoints": [8835, 8402], "characters": "\u2283\u20D2" },
+ "&nsupseteq;": { "codepoints": [8841], "characters": "\u2289" },
+ "&nsupseteqq;": { "codepoints": [10950, 824], "characters": "\u2AC6\u0338" },
+ "&ntgl;": { "codepoints": [8825], "characters": "\u2279" },
+ "&ntilde": { "codepoints": [241], "characters": "\u00F1" },
+ "&ntilde;": { "codepoints": [241], "characters": "\u00F1" },
+ "&ntlg;": { "codepoints": [8824], "characters": "\u2278" },
+ "&ntriangleleft;": { "codepoints": [8938], "characters": "\u22EA" },
+ "&ntrianglelefteq;": { "codepoints": [8940], "characters": "\u22EC" },
+ "&ntriangleright;": { "codepoints": [8939], "characters": "\u22EB" },
+ "&ntrianglerighteq;": { "codepoints": [8941], "characters": "\u22ED" },
+ "&nu;": { "codepoints": [957], "characters": "\u03BD" },
+ "&num;": { "codepoints": [35], "characters": "\u0023" },
+ "&numero;": { "codepoints": [8470], "characters": "\u2116" },
+ "&numsp;": { "codepoints": [8199], "characters": "\u2007" },
+ "&nvDash;": { "codepoints": [8877], "characters": "\u22AD" },
+ "&nvHarr;": { "codepoints": [10500], "characters": "\u2904" },
+ "&nvap;": { "codepoints": [8781, 8402], "characters": "\u224D\u20D2" },
+ "&nvdash;": { "codepoints": [8876], "characters": "\u22AC" },
+ "&nvge;": { "codepoints": [8805, 8402], "characters": "\u2265\u20D2" },
+ "&nvgt;": { "codepoints": [62, 8402], "characters": "\u003E\u20D2" },
+ "&nvinfin;": { "codepoints": [10718], "characters": "\u29DE" },
+ "&nvlArr;": { "codepoints": [10498], "characters": "\u2902" },
+ "&nvle;": { "codepoints": [8804, 8402], "characters": "\u2264\u20D2" },
+ "&nvlt;": { "codepoints": [60, 8402], "characters": "\u003C\u20D2" },
+ "&nvltrie;": { "codepoints": [8884, 8402], "characters": "\u22B4\u20D2" },
+ "&nvrArr;": { "codepoints": [10499], "characters": "\u2903" },
+ "&nvrtrie;": { "codepoints": [8885, 8402], "characters": "\u22B5\u20D2" },
+ "&nvsim;": { "codepoints": [8764, 8402], "characters": "\u223C\u20D2" },
+ "&nwArr;": { "codepoints": [8662], "characters": "\u21D6" },
+ "&nwarhk;": { "codepoints": [10531], "characters": "\u2923" },
+ "&nwarr;": { "codepoints": [8598], "characters": "\u2196" },
+ "&nwarrow;": { "codepoints": [8598], "characters": "\u2196" },
+ "&nwnear;": { "codepoints": [10535], "characters": "\u2927" },
+ "&oS;": { "codepoints": [9416], "characters": "\u24C8" },
+ "&oacute": { "codepoints": [243], "characters": "\u00F3" },
+ "&oacute;": { "codepoints": [243], "characters": "\u00F3" },
+ "&oast;": { "codepoints": [8859], "characters": "\u229B" },
+ "&ocir;": { "codepoints": [8858], "characters": "\u229A" },
+ "&ocirc": { "codepoints": [244], "characters": "\u00F4" },
+ "&ocirc;": { "codepoints": [244], "characters": "\u00F4" },
+ "&ocy;": { "codepoints": [1086], "characters": "\u043E" },
+ "&odash;": { "codepoints": [8861], "characters": "\u229D" },
+ "&odblac;": { "codepoints": [337], "characters": "\u0151" },
+ "&odiv;": { "codepoints": [10808], "characters": "\u2A38" },
+ "&odot;": { "codepoints": [8857], "characters": "\u2299" },
+ "&odsold;": { "codepoints": [10684], "characters": "\u29BC" },
+ "&oelig;": { "codepoints": [339], "characters": "\u0153" },
+ "&ofcir;": { "codepoints": [10687], "characters": "\u29BF" },
+ "&ofr;": { "codepoints": [120108], "characters": "\uD835\uDD2C" },
+ "&ogon;": { "codepoints": [731], "characters": "\u02DB" },
+ "&ograve": { "codepoints": [242], "characters": "\u00F2" },
+ "&ograve;": { "codepoints": [242], "characters": "\u00F2" },
+ "&ogt;": { "codepoints": [10689], "characters": "\u29C1" },
+ "&ohbar;": { "codepoints": [10677], "characters": "\u29B5" },
+ "&ohm;": { "codepoints": [937], "characters": "\u03A9" },
+ "&oint;": { "codepoints": [8750], "characters": "\u222E" },
+ "&olarr;": { "codepoints": [8634], "characters": "\u21BA" },
+ "&olcir;": { "codepoints": [10686], "characters": "\u29BE" },
+ "&olcross;": { "codepoints": [10683], "characters": "\u29BB" },
+ "&oline;": { "codepoints": [8254], "characters": "\u203E" },
+ "&olt;": { "codepoints": [10688], "characters": "\u29C0" },
+ "&omacr;": { "codepoints": [333], "characters": "\u014D" },
+ "&omega;": { "codepoints": [969], "characters": "\u03C9" },
+ "&omicron;": { "codepoints": [959], "characters": "\u03BF" },
+ "&omid;": { "codepoints": [10678], "characters": "\u29B6" },
+ "&ominus;": { "codepoints": [8854], "characters": "\u2296" },
+ "&oopf;": { "codepoints": [120160], "characters": "\uD835\uDD60" },
+ "&opar;": { "codepoints": [10679], "characters": "\u29B7" },
+ "&operp;": { "codepoints": [10681], "characters": "\u29B9" },
+ "&oplus;": { "codepoints": [8853], "characters": "\u2295" },
+ "&or;": { "codepoints": [8744], "characters": "\u2228" },
+ "&orarr;": { "codepoints": [8635], "characters": "\u21BB" },
+ "&ord;": { "codepoints": [10845], "characters": "\u2A5D" },
+ "&order;": { "codepoints": [8500], "characters": "\u2134" },
+ "&orderof;": { "codepoints": [8500], "characters": "\u2134" },
+ "&ordf": { "codepoints": [170], "characters": "\u00AA" },
+ "&ordf;": { "codepoints": [170], "characters": "\u00AA" },
+ "&ordm": { "codepoints": [186], "characters": "\u00BA" },
+ "&ordm;": { "codepoints": [186], "characters": "\u00BA" },
+ "&origof;": { "codepoints": [8886], "characters": "\u22B6" },
+ "&oror;": { "codepoints": [10838], "characters": "\u2A56" },
+ "&orslope;": { "codepoints": [10839], "characters": "\u2A57" },
+ "&orv;": { "codepoints": [10843], "characters": "\u2A5B" },
+ "&oscr;": { "codepoints": [8500], "characters": "\u2134" },
+ "&oslash": { "codepoints": [248], "characters": "\u00F8" },
+ "&oslash;": { "codepoints": [248], "characters": "\u00F8" },
+ "&osol;": { "codepoints": [8856], "characters": "\u2298" },
+ "&otilde": { "codepoints": [245], "characters": "\u00F5" },
+ "&otilde;": { "codepoints": [245], "characters": "\u00F5" },
+ "&otimes;": { "codepoints": [8855], "characters": "\u2297" },
+ "&otimesas;": { "codepoints": [10806], "characters": "\u2A36" },
+ "&ouml": { "codepoints": [246], "characters": "\u00F6" },
+ "&ouml;": { "codepoints": [246], "characters": "\u00F6" },
+ "&ovbar;": { "codepoints": [9021], "characters": "\u233D" },
+ "&par;": { "codepoints": [8741], "characters": "\u2225" },
+ "&para": { "codepoints": [182], "characters": "\u00B6" },
+ "&para;": { "codepoints": [182], "characters": "\u00B6" },
+ "&parallel;": { "codepoints": [8741], "characters": "\u2225" },
+ "&parsim;": { "codepoints": [10995], "characters": "\u2AF3" },
+ "&parsl;": { "codepoints": [11005], "characters": "\u2AFD" },
+ "&part;": { "codepoints": [8706], "characters": "\u2202" },
+ "&pcy;": { "codepoints": [1087], "characters": "\u043F" },
+ "&percnt;": { "codepoints": [37], "characters": "\u0025" },
+ "&period;": { "codepoints": [46], "characters": "\u002E" },
+ "&permil;": { "codepoints": [8240], "characters": "\u2030" },
+ "&perp;": { "codepoints": [8869], "characters": "\u22A5" },
+ "&pertenk;": { "codepoints": [8241], "characters": "\u2031" },
+ "&pfr;": { "codepoints": [120109], "characters": "\uD835\uDD2D" },
+ "&phi;": { "codepoints": [966], "characters": "\u03C6" },
+ "&phiv;": { "codepoints": [981], "characters": "\u03D5" },
+ "&phmmat;": { "codepoints": [8499], "characters": "\u2133" },
+ "&phone;": { "codepoints": [9742], "characters": "\u260E" },
+ "&pi;": { "codepoints": [960], "characters": "\u03C0" },
+ "&pitchfork;": { "codepoints": [8916], "characters": "\u22D4" },
+ "&piv;": { "codepoints": [982], "characters": "\u03D6" },
+ "&planck;": { "codepoints": [8463], "characters": "\u210F" },
+ "&planckh;": { "codepoints": [8462], "characters": "\u210E" },
+ "&plankv;": { "codepoints": [8463], "characters": "\u210F" },
+ "&plus;": { "codepoints": [43], "characters": "\u002B" },
+ "&plusacir;": { "codepoints": [10787], "characters": "\u2A23" },
+ "&plusb;": { "codepoints": [8862], "characters": "\u229E" },
+ "&pluscir;": { "codepoints": [10786], "characters": "\u2A22" },
+ "&plusdo;": { "codepoints": [8724], "characters": "\u2214" },
+ "&plusdu;": { "codepoints": [10789], "characters": "\u2A25" },
+ "&pluse;": { "codepoints": [10866], "characters": "\u2A72" },
+ "&plusmn": { "codepoints": [177], "characters": "\u00B1" },
+ "&plusmn;": { "codepoints": [177], "characters": "\u00B1" },
+ "&plussim;": { "codepoints": [10790], "characters": "\u2A26" },
+ "&plustwo;": { "codepoints": [10791], "characters": "\u2A27" },
+ "&pm;": { "codepoints": [177], "characters": "\u00B1" },
+ "&pointint;": { "codepoints": [10773], "characters": "\u2A15" },
+ "&popf;": { "codepoints": [120161], "characters": "\uD835\uDD61" },
+ "&pound": { "codepoints": [163], "characters": "\u00A3" },
+ "&pound;": { "codepoints": [163], "characters": "\u00A3" },
+ "&pr;": { "codepoints": [8826], "characters": "\u227A" },
+ "&prE;": { "codepoints": [10931], "characters": "\u2AB3" },
+ "&prap;": { "codepoints": [10935], "characters": "\u2AB7" },
+ "&prcue;": { "codepoints": [8828], "characters": "\u227C" },
+ "&pre;": { "codepoints": [10927], "characters": "\u2AAF" },
+ "&prec;": { "codepoints": [8826], "characters": "\u227A" },
+ "&precapprox;": { "codepoints": [10935], "characters": "\u2AB7" },
+ "&preccurlyeq;": { "codepoints": [8828], "characters": "\u227C" },
+ "&preceq;": { "codepoints": [10927], "characters": "\u2AAF" },
+ "&precnapprox;": { "codepoints": [10937], "characters": "\u2AB9" },
+ "&precneqq;": { "codepoints": [10933], "characters": "\u2AB5" },
+ "&precnsim;": { "codepoints": [8936], "characters": "\u22E8" },
+ "&precsim;": { "codepoints": [8830], "characters": "\u227E" },
+ "&prime;": { "codepoints": [8242], "characters": "\u2032" },
+ "&primes;": { "codepoints": [8473], "characters": "\u2119" },
+ "&prnE;": { "codepoints": [10933], "characters": "\u2AB5" },
+ "&prnap;": { "codepoints": [10937], "characters": "\u2AB9" },
+ "&prnsim;": { "codepoints": [8936], "characters": "\u22E8" },
+ "&prod;": { "codepoints": [8719], "characters": "\u220F" },
+ "&profalar;": { "codepoints": [9006], "characters": "\u232E" },
+ "&profline;": { "codepoints": [8978], "characters": "\u2312" },
+ "&profsurf;": { "codepoints": [8979], "characters": "\u2313" },
+ "&prop;": { "codepoints": [8733], "characters": "\u221D" },
+ "&propto;": { "codepoints": [8733], "characters": "\u221D" },
+ "&prsim;": { "codepoints": [8830], "characters": "\u227E" },
+ "&prurel;": { "codepoints": [8880], "characters": "\u22B0" },
+ "&pscr;": { "codepoints": [120005], "characters": "\uD835\uDCC5" },
+ "&psi;": { "codepoints": [968], "characters": "\u03C8" },
+ "&puncsp;": { "codepoints": [8200], "characters": "\u2008" },
+ "&qfr;": { "codepoints": [120110], "characters": "\uD835\uDD2E" },
+ "&qint;": { "codepoints": [10764], "characters": "\u2A0C" },
+ "&qopf;": { "codepoints": [120162], "characters": "\uD835\uDD62" },
+ "&qprime;": { "codepoints": [8279], "characters": "\u2057" },
+ "&qscr;": { "codepoints": [120006], "characters": "\uD835\uDCC6" },
+ "&quaternions;": { "codepoints": [8461], "characters": "\u210D" },
+ "&quatint;": { "codepoints": [10774], "characters": "\u2A16" },
+ "&quest;": { "codepoints": [63], "characters": "\u003F" },
+ "&questeq;": { "codepoints": [8799], "characters": "\u225F" },
+ "&quot": { "codepoints": [34], "characters": "\u0022" },
+ "&quot;": { "codepoints": [34], "characters": "\u0022" },
+ "&rAarr;": { "codepoints": [8667], "characters": "\u21DB" },
+ "&rArr;": { "codepoints": [8658], "characters": "\u21D2" },
+ "&rAtail;": { "codepoints": [10524], "characters": "\u291C" },
+ "&rBarr;": { "codepoints": [10511], "characters": "\u290F" },
+ "&rHar;": { "codepoints": [10596], "characters": "\u2964" },
+ "&race;": { "codepoints": [8765, 817], "characters": "\u223D\u0331" },
+ "&racute;": { "codepoints": [341], "characters": "\u0155" },
+ "&radic;": { "codepoints": [8730], "characters": "\u221A" },
+ "&raemptyv;": { "codepoints": [10675], "characters": "\u29B3" },
+ "&rang;": { "codepoints": [10217], "characters": "\u27E9" },
+ "&rangd;": { "codepoints": [10642], "characters": "\u2992" },
+ "&range;": { "codepoints": [10661], "characters": "\u29A5" },
+ "&rangle;": { "codepoints": [10217], "characters": "\u27E9" },
+ "&raquo": { "codepoints": [187], "characters": "\u00BB" },
+ "&raquo;": { "codepoints": [187], "characters": "\u00BB" },
+ "&rarr;": { "codepoints": [8594], "characters": "\u2192" },
+ "&rarrap;": { "codepoints": [10613], "characters": "\u2975" },
+ "&rarrb;": { "codepoints": [8677], "characters": "\u21E5" },
+ "&rarrbfs;": { "codepoints": [10528], "characters": "\u2920" },
+ "&rarrc;": { "codepoints": [10547], "characters": "\u2933" },
+ "&rarrfs;": { "codepoints": [10526], "characters": "\u291E" },
+ "&rarrhk;": { "codepoints": [8618], "characters": "\u21AA" },
+ "&rarrlp;": { "codepoints": [8620], "characters": "\u21AC" },
+ "&rarrpl;": { "codepoints": [10565], "characters": "\u2945" },
+ "&rarrsim;": { "codepoints": [10612], "characters": "\u2974" },
+ "&rarrtl;": { "codepoints": [8611], "characters": "\u21A3" },
+ "&rarrw;": { "codepoints": [8605], "characters": "\u219D" },
+ "&ratail;": { "codepoints": [10522], "characters": "\u291A" },
+ "&ratio;": { "codepoints": [8758], "characters": "\u2236" },
+ "&rationals;": { "codepoints": [8474], "characters": "\u211A" },
+ "&rbarr;": { "codepoints": [10509], "characters": "\u290D" },
+ "&rbbrk;": { "codepoints": [10099], "characters": "\u2773" },
+ "&rbrace;": { "codepoints": [125], "characters": "\u007D" },
+ "&rbrack;": { "codepoints": [93], "characters": "\u005D" },
+ "&rbrke;": { "codepoints": [10636], "characters": "\u298C" },
+ "&rbrksld;": { "codepoints": [10638], "characters": "\u298E" },
+ "&rbrkslu;": { "codepoints": [10640], "characters": "\u2990" },
+ "&rcaron;": { "codepoints": [345], "characters": "\u0159" },
+ "&rcedil;": { "codepoints": [343], "characters": "\u0157" },
+ "&rceil;": { "codepoints": [8969], "characters": "\u2309" },
+ "&rcub;": { "codepoints": [125], "characters": "\u007D" },
+ "&rcy;": { "codepoints": [1088], "characters": "\u0440" },
+ "&rdca;": { "codepoints": [10551], "characters": "\u2937" },
+ "&rdldhar;": { "codepoints": [10601], "characters": "\u2969" },
+ "&rdquo;": { "codepoints": [8221], "characters": "\u201D" },
+ "&rdquor;": { "codepoints": [8221], "characters": "\u201D" },
+ "&rdsh;": { "codepoints": [8627], "characters": "\u21B3" },
+ "&real;": { "codepoints": [8476], "characters": "\u211C" },
+ "&realine;": { "codepoints": [8475], "characters": "\u211B" },
+ "&realpart;": { "codepoints": [8476], "characters": "\u211C" },
+ "&reals;": { "codepoints": [8477], "characters": "\u211D" },
+ "&rect;": { "codepoints": [9645], "characters": "\u25AD" },
+ "&reg": { "codepoints": [174], "characters": "\u00AE" },
+ "&reg;": { "codepoints": [174], "characters": "\u00AE" },
+ "&rfisht;": { "codepoints": [10621], "characters": "\u297D" },
+ "&rfloor;": { "codepoints": [8971], "characters": "\u230B" },
+ "&rfr;": { "codepoints": [120111], "characters": "\uD835\uDD2F" },
+ "&rhard;": { "codepoints": [8641], "characters": "\u21C1" },
+ "&rharu;": { "codepoints": [8640], "characters": "\u21C0" },
+ "&rharul;": { "codepoints": [10604], "characters": "\u296C" },
+ "&rho;": { "codepoints": [961], "characters": "\u03C1" },
+ "&rhov;": { "codepoints": [1009], "characters": "\u03F1" },
+ "&rightarrow;": { "codepoints": [8594], "characters": "\u2192" },
+ "&rightarrowtail;": { "codepoints": [8611], "characters": "\u21A3" },
+ "&rightharpoondown;": { "codepoints": [8641], "characters": "\u21C1" },
+ "&rightharpoonup;": { "codepoints": [8640], "characters": "\u21C0" },
+ "&rightleftarrows;": { "codepoints": [8644], "characters": "\u21C4" },
+ "&rightleftharpoons;": { "codepoints": [8652], "characters": "\u21CC" },
+ "&rightrightarrows;": { "codepoints": [8649], "characters": "\u21C9" },
+ "&rightsquigarrow;": { "codepoints": [8605], "characters": "\u219D" },
+ "&rightthreetimes;": { "codepoints": [8908], "characters": "\u22CC" },
+ "&ring;": { "codepoints": [730], "characters": "\u02DA" },
+ "&risingdotseq;": { "codepoints": [8787], "characters": "\u2253" },
+ "&rlarr;": { "codepoints": [8644], "characters": "\u21C4" },
+ "&rlhar;": { "codepoints": [8652], "characters": "\u21CC" },
+ "&rlm;": { "codepoints": [8207], "characters": "\u200F" },
+ "&rmoust;": { "codepoints": [9137], "characters": "\u23B1" },
+ "&rmoustache;": { "codepoints": [9137], "characters": "\u23B1" },
+ "&rnmid;": { "codepoints": [10990], "characters": "\u2AEE" },
+ "&roang;": { "codepoints": [10221], "characters": "\u27ED" },
+ "&roarr;": { "codepoints": [8702], "characters": "\u21FE" },
+ "&robrk;": { "codepoints": [10215], "characters": "\u27E7" },
+ "&ropar;": { "codepoints": [10630], "characters": "\u2986" },
+ "&ropf;": { "codepoints": [120163], "characters": "\uD835\uDD63" },
+ "&roplus;": { "codepoints": [10798], "characters": "\u2A2E" },
+ "&rotimes;": { "codepoints": [10805], "characters": "\u2A35" },
+ "&rpar;": { "codepoints": [41], "characters": "\u0029" },
+ "&rpargt;": { "codepoints": [10644], "characters": "\u2994" },
+ "&rppolint;": { "codepoints": [10770], "characters": "\u2A12" },
+ "&rrarr;": { "codepoints": [8649], "characters": "\u21C9" },
+ "&rsaquo;": { "codepoints": [8250], "characters": "\u203A" },
+ "&rscr;": { "codepoints": [120007], "characters": "\uD835\uDCC7" },
+ "&rsh;": { "codepoints": [8625], "characters": "\u21B1" },
+ "&rsqb;": { "codepoints": [93], "characters": "\u005D" },
+ "&rsquo;": { "codepoints": [8217], "characters": "\u2019" },
+ "&rsquor;": { "codepoints": [8217], "characters": "\u2019" },
+ "&rthree;": { "codepoints": [8908], "characters": "\u22CC" },
+ "&rtimes;": { "codepoints": [8906], "characters": "\u22CA" },
+ "&rtri;": { "codepoints": [9657], "characters": "\u25B9" },
+ "&rtrie;": { "codepoints": [8885], "characters": "\u22B5" },
+ "&rtrif;": { "codepoints": [9656], "characters": "\u25B8" },
+ "&rtriltri;": { "codepoints": [10702], "characters": "\u29CE" },
+ "&ruluhar;": { "codepoints": [10600], "characters": "\u2968" },
+ "&rx;": { "codepoints": [8478], "characters": "\u211E" },
+ "&sacute;": { "codepoints": [347], "characters": "\u015B" },
+ "&sbquo;": { "codepoints": [8218], "characters": "\u201A" },
+ "&sc;": { "codepoints": [8827], "characters": "\u227B" },
+ "&scE;": { "codepoints": [10932], "characters": "\u2AB4" },
+ "&scap;": { "codepoints": [10936], "characters": "\u2AB8" },
+ "&scaron;": { "codepoints": [353], "characters": "\u0161" },
+ "&sccue;": { "codepoints": [8829], "characters": "\u227D" },
+ "&sce;": { "codepoints": [10928], "characters": "\u2AB0" },
+ "&scedil;": { "codepoints": [351], "characters": "\u015F" },
+ "&scirc;": { "codepoints": [349], "characters": "\u015D" },
+ "&scnE;": { "codepoints": [10934], "characters": "\u2AB6" },
+ "&scnap;": { "codepoints": [10938], "characters": "\u2ABA" },
+ "&scnsim;": { "codepoints": [8937], "characters": "\u22E9" },
+ "&scpolint;": { "codepoints": [10771], "characters": "\u2A13" },
+ "&scsim;": { "codepoints": [8831], "characters": "\u227F" },
+ "&scy;": { "codepoints": [1089], "characters": "\u0441" },
+ "&sdot;": { "codepoints": [8901], "characters": "\u22C5" },
+ "&sdotb;": { "codepoints": [8865], "characters": "\u22A1" },
+ "&sdote;": { "codepoints": [10854], "characters": "\u2A66" },
+ "&seArr;": { "codepoints": [8664], "characters": "\u21D8" },
+ "&searhk;": { "codepoints": [10533], "characters": "\u2925" },
+ "&searr;": { "codepoints": [8600], "characters": "\u2198" },
+ "&searrow;": { "codepoints": [8600], "characters": "\u2198" },
+ "&sect": { "codepoints": [167], "characters": "\u00A7" },
+ "&sect;": { "codepoints": [167], "characters": "\u00A7" },
+ "&semi;": { "codepoints": [59], "characters": "\u003B" },
+ "&seswar;": { "codepoints": [10537], "characters": "\u2929" },
+ "&setminus;": { "codepoints": [8726], "characters": "\u2216" },
+ "&setmn;": { "codepoints": [8726], "characters": "\u2216" },
+ "&sext;": { "codepoints": [10038], "characters": "\u2736" },
+ "&sfr;": { "codepoints": [120112], "characters": "\uD835\uDD30" },
+ "&sfrown;": { "codepoints": [8994], "characters": "\u2322" },
+ "&sharp;": { "codepoints": [9839], "characters": "\u266F" },
+ "&shchcy;": { "codepoints": [1097], "characters": "\u0449" },
+ "&shcy;": { "codepoints": [1096], "characters": "\u0448" },
+ "&shortmid;": { "codepoints": [8739], "characters": "\u2223" },
+ "&shortparallel;": { "codepoints": [8741], "characters": "\u2225" },
+ "&shy": { "codepoints": [173], "characters": "\u00AD" },
+ "&shy;": { "codepoints": [173], "characters": "\u00AD" },
+ "&sigma;": { "codepoints": [963], "characters": "\u03C3" },
+ "&sigmaf;": { "codepoints": [962], "characters": "\u03C2" },
+ "&sigmav;": { "codepoints": [962], "characters": "\u03C2" },
+ "&sim;": { "codepoints": [8764], "characters": "\u223C" },
+ "&simdot;": { "codepoints": [10858], "characters": "\u2A6A" },
+ "&sime;": { "codepoints": [8771], "characters": "\u2243" },
+ "&simeq;": { "codepoints": [8771], "characters": "\u2243" },
+ "&simg;": { "codepoints": [10910], "characters": "\u2A9E" },
+ "&simgE;": { "codepoints": [10912], "characters": "\u2AA0" },
+ "&siml;": { "codepoints": [10909], "characters": "\u2A9D" },
+ "&simlE;": { "codepoints": [10911], "characters": "\u2A9F" },
+ "&simne;": { "codepoints": [8774], "characters": "\u2246" },
+ "&simplus;": { "codepoints": [10788], "characters": "\u2A24" },
+ "&simrarr;": { "codepoints": [10610], "characters": "\u2972" },
+ "&slarr;": { "codepoints": [8592], "characters": "\u2190" },
+ "&smallsetminus;": { "codepoints": [8726], "characters": "\u2216" },
+ "&smashp;": { "codepoints": [10803], "characters": "\u2A33" },
+ "&smeparsl;": { "codepoints": [10724], "characters": "\u29E4" },
+ "&smid;": { "codepoints": [8739], "characters": "\u2223" },
+ "&smile;": { "codepoints": [8995], "characters": "\u2323" },
+ "&smt;": { "codepoints": [10922], "characters": "\u2AAA" },
+ "&smte;": { "codepoints": [10924], "characters": "\u2AAC" },
+ "&smtes;": { "codepoints": [10924, 65024], "characters": "\u2AAC\uFE00" },
+ "&softcy;": { "codepoints": [1100], "characters": "\u044C" },
+ "&sol;": { "codepoints": [47], "characters": "\u002F" },
+ "&solb;": { "codepoints": [10692], "characters": "\u29C4" },
+ "&solbar;": { "codepoints": [9023], "characters": "\u233F" },
+ "&sopf;": { "codepoints": [120164], "characters": "\uD835\uDD64" },
+ "&spades;": { "codepoints": [9824], "characters": "\u2660" },
+ "&spadesuit;": { "codepoints": [9824], "characters": "\u2660" },
+ "&spar;": { "codepoints": [8741], "characters": "\u2225" },
+ "&sqcap;": { "codepoints": [8851], "characters": "\u2293" },
+ "&sqcaps;": { "codepoints": [8851, 65024], "characters": "\u2293\uFE00" },
+ "&sqcup;": { "codepoints": [8852], "characters": "\u2294" },
+ "&sqcups;": { "codepoints": [8852, 65024], "characters": "\u2294\uFE00" },
+ "&sqsub;": { "codepoints": [8847], "characters": "\u228F" },
+ "&sqsube;": { "codepoints": [8849], "characters": "\u2291" },
+ "&sqsubset;": { "codepoints": [8847], "characters": "\u228F" },
+ "&sqsubseteq;": { "codepoints": [8849], "characters": "\u2291" },
+ "&sqsup;": { "codepoints": [8848], "characters": "\u2290" },
+ "&sqsupe;": { "codepoints": [8850], "characters": "\u2292" },
+ "&sqsupset;": { "codepoints": [8848], "characters": "\u2290" },
+ "&sqsupseteq;": { "codepoints": [8850], "characters": "\u2292" },
+ "&squ;": { "codepoints": [9633], "characters": "\u25A1" },
+ "&square;": { "codepoints": [9633], "characters": "\u25A1" },
+ "&squarf;": { "codepoints": [9642], "characters": "\u25AA" },
+ "&squf;": { "codepoints": [9642], "characters": "\u25AA" },
+ "&srarr;": { "codepoints": [8594], "characters": "\u2192" },
+ "&sscr;": { "codepoints": [120008], "characters": "\uD835\uDCC8" },
+ "&ssetmn;": { "codepoints": [8726], "characters": "\u2216" },
+ "&ssmile;": { "codepoints": [8995], "characters": "\u2323" },
+ "&sstarf;": { "codepoints": [8902], "characters": "\u22C6" },
+ "&star;": { "codepoints": [9734], "characters": "\u2606" },
+ "&starf;": { "codepoints": [9733], "characters": "\u2605" },
+ "&straightepsilon;": { "codepoints": [1013], "characters": "\u03F5" },
+ "&straightphi;": { "codepoints": [981], "characters": "\u03D5" },
+ "&strns;": { "codepoints": [175], "characters": "\u00AF" },
+ "&sub;": { "codepoints": [8834], "characters": "\u2282" },
+ "&subE;": { "codepoints": [10949], "characters": "\u2AC5" },
+ "&subdot;": { "codepoints": [10941], "characters": "\u2ABD" },
+ "&sube;": { "codepoints": [8838], "characters": "\u2286" },
+ "&subedot;": { "codepoints": [10947], "characters": "\u2AC3" },
+ "&submult;": { "codepoints": [10945], "characters": "\u2AC1" },
+ "&subnE;": { "codepoints": [10955], "characters": "\u2ACB" },
+ "&subne;": { "codepoints": [8842], "characters": "\u228A" },
+ "&subplus;": { "codepoints": [10943], "characters": "\u2ABF" },
+ "&subrarr;": { "codepoints": [10617], "characters": "\u2979" },
+ "&subset;": { "codepoints": [8834], "characters": "\u2282" },
+ "&subseteq;": { "codepoints": [8838], "characters": "\u2286" },
+ "&subseteqq;": { "codepoints": [10949], "characters": "\u2AC5" },
+ "&subsetneq;": { "codepoints": [8842], "characters": "\u228A" },
+ "&subsetneqq;": { "codepoints": [10955], "characters": "\u2ACB" },
+ "&subsim;": { "codepoints": [10951], "characters": "\u2AC7" },
+ "&subsub;": { "codepoints": [10965], "characters": "\u2AD5" },
+ "&subsup;": { "codepoints": [10963], "characters": "\u2AD3" },
+ "&succ;": { "codepoints": [8827], "characters": "\u227B" },
+ "&succapprox;": { "codepoints": [10936], "characters": "\u2AB8" },
+ "&succcurlyeq;": { "codepoints": [8829], "characters": "\u227D" },
+ "&succeq;": { "codepoints": [10928], "characters": "\u2AB0" },
+ "&succnapprox;": { "codepoints": [10938], "characters": "\u2ABA" },
+ "&succneqq;": { "codepoints": [10934], "characters": "\u2AB6" },
+ "&succnsim;": { "codepoints": [8937], "characters": "\u22E9" },
+ "&succsim;": { "codepoints": [8831], "characters": "\u227F" },
+ "&sum;": { "codepoints": [8721], "characters": "\u2211" },
+ "&sung;": { "codepoints": [9834], "characters": "\u266A" },
+ "&sup1": { "codepoints": [185], "characters": "\u00B9" },
+ "&sup1;": { "codepoints": [185], "characters": "\u00B9" },
+ "&sup2": { "codepoints": [178], "characters": "\u00B2" },
+ "&sup2;": { "codepoints": [178], "characters": "\u00B2" },
+ "&sup3": { "codepoints": [179], "characters": "\u00B3" },
+ "&sup3;": { "codepoints": [179], "characters": "\u00B3" },
+ "&sup;": { "codepoints": [8835], "characters": "\u2283" },
+ "&supE;": { "codepoints": [10950], "characters": "\u2AC6" },
+ "&supdot;": { "codepoints": [10942], "characters": "\u2ABE" },
+ "&supdsub;": { "codepoints": [10968], "characters": "\u2AD8" },
+ "&supe;": { "codepoints": [8839], "characters": "\u2287" },
+ "&supedot;": { "codepoints": [10948], "characters": "\u2AC4" },
+ "&suphsol;": { "codepoints": [10185], "characters": "\u27C9" },
+ "&suphsub;": { "codepoints": [10967], "characters": "\u2AD7" },
+ "&suplarr;": { "codepoints": [10619], "characters": "\u297B" },
+ "&supmult;": { "codepoints": [10946], "characters": "\u2AC2" },
+ "&supnE;": { "codepoints": [10956], "characters": "\u2ACC" },
+ "&supne;": { "codepoints": [8843], "characters": "\u228B" },
+ "&supplus;": { "codepoints": [10944], "characters": "\u2AC0" },
+ "&supset;": { "codepoints": [8835], "characters": "\u2283" },
+ "&supseteq;": { "codepoints": [8839], "characters": "\u2287" },
+ "&supseteqq;": { "codepoints": [10950], "characters": "\u2AC6" },
+ "&supsetneq;": { "codepoints": [8843], "characters": "\u228B" },
+ "&supsetneqq;": { "codepoints": [10956], "characters": "\u2ACC" },
+ "&supsim;": { "codepoints": [10952], "characters": "\u2AC8" },
+ "&supsub;": { "codepoints": [10964], "characters": "\u2AD4" },
+ "&supsup;": { "codepoints": [10966], "characters": "\u2AD6" },
+ "&swArr;": { "codepoints": [8665], "characters": "\u21D9" },
+ "&swarhk;": { "codepoints": [10534], "characters": "\u2926" },
+ "&swarr;": { "codepoints": [8601], "characters": "\u2199" },
+ "&swarrow;": { "codepoints": [8601], "characters": "\u2199" },
+ "&swnwar;": { "codepoints": [10538], "characters": "\u292A" },
+ "&szlig": { "codepoints": [223], "characters": "\u00DF" },
+ "&szlig;": { "codepoints": [223], "characters": "\u00DF" },
+ "&target;": { "codepoints": [8982], "characters": "\u2316" },
+ "&tau;": { "codepoints": [964], "characters": "\u03C4" },
+ "&tbrk;": { "codepoints": [9140], "characters": "\u23B4" },
+ "&tcaron;": { "codepoints": [357], "characters": "\u0165" },
+ "&tcedil;": { "codepoints": [355], "characters": "\u0163" },
+ "&tcy;": { "codepoints": [1090], "characters": "\u0442" },
+ "&tdot;": { "codepoints": [8411], "characters": "\u20DB" },
+ "&telrec;": { "codepoints": [8981], "characters": "\u2315" },
+ "&tfr;": { "codepoints": [120113], "characters": "\uD835\uDD31" },
+ "&there4;": { "codepoints": [8756], "characters": "\u2234" },
+ "&therefore;": { "codepoints": [8756], "characters": "\u2234" },
+ "&theta;": { "codepoints": [952], "characters": "\u03B8" },
+ "&thetasym;": { "codepoints": [977], "characters": "\u03D1" },
+ "&thetav;": { "codepoints": [977], "characters": "\u03D1" },
+ "&thickapprox;": { "codepoints": [8776], "characters": "\u2248" },
+ "&thicksim;": { "codepoints": [8764], "characters": "\u223C" },
+ "&thinsp;": { "codepoints": [8201], "characters": "\u2009" },
+ "&thkap;": { "codepoints": [8776], "characters": "\u2248" },
+ "&thksim;": { "codepoints": [8764], "characters": "\u223C" },
+ "&thorn": { "codepoints": [254], "characters": "\u00FE" },
+ "&thorn;": { "codepoints": [254], "characters": "\u00FE" },
+ "&tilde;": { "codepoints": [732], "characters": "\u02DC" },
+ "&times": { "codepoints": [215], "characters": "\u00D7" },
+ "&times;": { "codepoints": [215], "characters": "\u00D7" },
+ "&timesb;": { "codepoints": [8864], "characters": "\u22A0" },
+ "&timesbar;": { "codepoints": [10801], "characters": "\u2A31" },
+ "&timesd;": { "codepoints": [10800], "characters": "\u2A30" },
+ "&tint;": { "codepoints": [8749], "characters": "\u222D" },
+ "&toea;": { "codepoints": [10536], "characters": "\u2928" },
+ "&top;": { "codepoints": [8868], "characters": "\u22A4" },
+ "&topbot;": { "codepoints": [9014], "characters": "\u2336" },
+ "&topcir;": { "codepoints": [10993], "characters": "\u2AF1" },
+ "&topf;": { "codepoints": [120165], "characters": "\uD835\uDD65" },
+ "&topfork;": { "codepoints": [10970], "characters": "\u2ADA" },
+ "&tosa;": { "codepoints": [10537], "characters": "\u2929" },
+ "&tprime;": { "codepoints": [8244], "characters": "\u2034" },
+ "&trade;": { "codepoints": [8482], "characters": "\u2122" },
+ "&triangle;": { "codepoints": [9653], "characters": "\u25B5" },
+ "&triangledown;": { "codepoints": [9663], "characters": "\u25BF" },
+ "&triangleleft;": { "codepoints": [9667], "characters": "\u25C3" },
+ "&trianglelefteq;": { "codepoints": [8884], "characters": "\u22B4" },
+ "&triangleq;": { "codepoints": [8796], "characters": "\u225C" },
+ "&triangleright;": { "codepoints": [9657], "characters": "\u25B9" },
+ "&trianglerighteq;": { "codepoints": [8885], "characters": "\u22B5" },
+ "&tridot;": { "codepoints": [9708], "characters": "\u25EC" },
+ "&trie;": { "codepoints": [8796], "characters": "\u225C" },
+ "&triminus;": { "codepoints": [10810], "characters": "\u2A3A" },
+ "&triplus;": { "codepoints": [10809], "characters": "\u2A39" },
+ "&trisb;": { "codepoints": [10701], "characters": "\u29CD" },
+ "&tritime;": { "codepoints": [10811], "characters": "\u2A3B" },
+ "&trpezium;": { "codepoints": [9186], "characters": "\u23E2" },
+ "&tscr;": { "codepoints": [120009], "characters": "\uD835\uDCC9" },
+ "&tscy;": { "codepoints": [1094], "characters": "\u0446" },
+ "&tshcy;": { "codepoints": [1115], "characters": "\u045B" },
+ "&tstrok;": { "codepoints": [359], "characters": "\u0167" },
+ "&twixt;": { "codepoints": [8812], "characters": "\u226C" },
+ "&twoheadleftarrow;": { "codepoints": [8606], "characters": "\u219E" },
+ "&twoheadrightarrow;": { "codepoints": [8608], "characters": "\u21A0" },
+ "&uArr;": { "codepoints": [8657], "characters": "\u21D1" },
+ "&uHar;": { "codepoints": [10595], "characters": "\u2963" },
+ "&uacute": { "codepoints": [250], "characters": "\u00FA" },
+ "&uacute;": { "codepoints": [250], "characters": "\u00FA" },
+ "&uarr;": { "codepoints": [8593], "characters": "\u2191" },
+ "&ubrcy;": { "codepoints": [1118], "characters": "\u045E" },
+ "&ubreve;": { "codepoints": [365], "characters": "\u016D" },
+ "&ucirc": { "codepoints": [251], "characters": "\u00FB" },
+ "&ucirc;": { "codepoints": [251], "characters": "\u00FB" },
+ "&ucy;": { "codepoints": [1091], "characters": "\u0443" },
+ "&udarr;": { "codepoints": [8645], "characters": "\u21C5" },
+ "&udblac;": { "codepoints": [369], "characters": "\u0171" },
+ "&udhar;": { "codepoints": [10606], "characters": "\u296E" },
+ "&ufisht;": { "codepoints": [10622], "characters": "\u297E" },
+ "&ufr;": { "codepoints": [120114], "characters": "\uD835\uDD32" },
+ "&ugrave": { "codepoints": [249], "characters": "\u00F9" },
+ "&ugrave;": { "codepoints": [249], "characters": "\u00F9" },
+ "&uharl;": { "codepoints": [8639], "characters": "\u21BF" },
+ "&uharr;": { "codepoints": [8638], "characters": "\u21BE" },
+ "&uhblk;": { "codepoints": [9600], "characters": "\u2580" },
+ "&ulcorn;": { "codepoints": [8988], "characters": "\u231C" },
+ "&ulcorner;": { "codepoints": [8988], "characters": "\u231C" },
+ "&ulcrop;": { "codepoints": [8975], "characters": "\u230F" },
+ "&ultri;": { "codepoints": [9720], "characters": "\u25F8" },
+ "&umacr;": { "codepoints": [363], "characters": "\u016B" },
+ "&uml": { "codepoints": [168], "characters": "\u00A8" },
+ "&uml;": { "codepoints": [168], "characters": "\u00A8" },
+ "&uogon;": { "codepoints": [371], "characters": "\u0173" },
+ "&uopf;": { "codepoints": [120166], "characters": "\uD835\uDD66" },
+ "&uparrow;": { "codepoints": [8593], "characters": "\u2191" },
+ "&updownarrow;": { "codepoints": [8597], "characters": "\u2195" },
+ "&upharpoonleft;": { "codepoints": [8639], "characters": "\u21BF" },
+ "&upharpoonright;": { "codepoints": [8638], "characters": "\u21BE" },
+ "&uplus;": { "codepoints": [8846], "characters": "\u228E" },
+ "&upsi;": { "codepoints": [965], "characters": "\u03C5" },
+ "&upsih;": { "codepoints": [978], "characters": "\u03D2" },
+ "&upsilon;": { "codepoints": [965], "characters": "\u03C5" },
+ "&upuparrows;": { "codepoints": [8648], "characters": "\u21C8" },
+ "&urcorn;": { "codepoints": [8989], "characters": "\u231D" },
+ "&urcorner;": { "codepoints": [8989], "characters": "\u231D" },
+ "&urcrop;": { "codepoints": [8974], "characters": "\u230E" },
+ "&uring;": { "codepoints": [367], "characters": "\u016F" },
+ "&urtri;": { "codepoints": [9721], "characters": "\u25F9" },
+ "&uscr;": { "codepoints": [120010], "characters": "\uD835\uDCCA" },
+ "&utdot;": { "codepoints": [8944], "characters": "\u22F0" },
+ "&utilde;": { "codepoints": [361], "characters": "\u0169" },
+ "&utri;": { "codepoints": [9653], "characters": "\u25B5" },
+ "&utrif;": { "codepoints": [9652], "characters": "\u25B4" },
+ "&uuarr;": { "codepoints": [8648], "characters": "\u21C8" },
+ "&uuml": { "codepoints": [252], "characters": "\u00FC" },
+ "&uuml;": { "codepoints": [252], "characters": "\u00FC" },
+ "&uwangle;": { "codepoints": [10663], "characters": "\u29A7" },
+ "&vArr;": { "codepoints": [8661], "characters": "\u21D5" },
+ "&vBar;": { "codepoints": [10984], "characters": "\u2AE8" },
+ "&vBarv;": { "codepoints": [10985], "characters": "\u2AE9" },
+ "&vDash;": { "codepoints": [8872], "characters": "\u22A8" },
+ "&vangrt;": { "codepoints": [10652], "characters": "\u299C" },
+ "&varepsilon;": { "codepoints": [1013], "characters": "\u03F5" },
+ "&varkappa;": { "codepoints": [1008], "characters": "\u03F0" },
+ "&varnothing;": { "codepoints": [8709], "characters": "\u2205" },
+ "&varphi;": { "codepoints": [981], "characters": "\u03D5" },
+ "&varpi;": { "codepoints": [982], "characters": "\u03D6" },
+ "&varpropto;": { "codepoints": [8733], "characters": "\u221D" },
+ "&varr;": { "codepoints": [8597], "characters": "\u2195" },
+ "&varrho;": { "codepoints": [1009], "characters": "\u03F1" },
+ "&varsigma;": { "codepoints": [962], "characters": "\u03C2" },
+ "&varsubsetneq;": { "codepoints": [8842, 65024], "characters": "\u228A\uFE00" },
+ "&varsubsetneqq;": { "codepoints": [10955, 65024], "characters": "\u2ACB\uFE00" },
+ "&varsupsetneq;": { "codepoints": [8843, 65024], "characters": "\u228B\uFE00" },
+ "&varsupsetneqq;": { "codepoints": [10956, 65024], "characters": "\u2ACC\uFE00" },
+ "&vartheta;": { "codepoints": [977], "characters": "\u03D1" },
+ "&vartriangleleft;": { "codepoints": [8882], "characters": "\u22B2" },
+ "&vartriangleright;": { "codepoints": [8883], "characters": "\u22B3" },
+ "&vcy;": { "codepoints": [1074], "characters": "\u0432" },
+ "&vdash;": { "codepoints": [8866], "characters": "\u22A2" },
+ "&vee;": { "codepoints": [8744], "characters": "\u2228" },
+ "&veebar;": { "codepoints": [8891], "characters": "\u22BB" },
+ "&veeeq;": { "codepoints": [8794], "characters": "\u225A" },
+ "&vellip;": { "codepoints": [8942], "characters": "\u22EE" },
+ "&verbar;": { "codepoints": [124], "characters": "\u007C" },
+ "&vert;": { "codepoints": [124], "characters": "\u007C" },
+ "&vfr;": { "codepoints": [120115], "characters": "\uD835\uDD33" },
+ "&vltri;": { "codepoints": [8882], "characters": "\u22B2" },
+ "&vnsub;": { "codepoints": [8834, 8402], "characters": "\u2282\u20D2" },
+ "&vnsup;": { "codepoints": [8835, 8402], "characters": "\u2283\u20D2" },
+ "&vopf;": { "codepoints": [120167], "characters": "\uD835\uDD67" },
+ "&vprop;": { "codepoints": [8733], "characters": "\u221D" },
+ "&vrtri;": { "codepoints": [8883], "characters": "\u22B3" },
+ "&vscr;": { "codepoints": [120011], "characters": "\uD835\uDCCB" },
+ "&vsubnE;": { "codepoints": [10955, 65024], "characters": "\u2ACB\uFE00" },
+ "&vsubne;": { "codepoints": [8842, 65024], "characters": "\u228A\uFE00" },
+ "&vsupnE;": { "codepoints": [10956, 65024], "characters": "\u2ACC\uFE00" },
+ "&vsupne;": { "codepoints": [8843, 65024], "characters": "\u228B\uFE00" },
+ "&vzigzag;": { "codepoints": [10650], "characters": "\u299A" },
+ "&wcirc;": { "codepoints": [373], "characters": "\u0175" },
+ "&wedbar;": { "codepoints": [10847], "characters": "\u2A5F" },
+ "&wedge;": { "codepoints": [8743], "characters": "\u2227" },
+ "&wedgeq;": { "codepoints": [8793], "characters": "\u2259" },
+ "&weierp;": { "codepoints": [8472], "characters": "\u2118" },
+ "&wfr;": { "codepoints": [120116], "characters": "\uD835\uDD34" },
+ "&wopf;": { "codepoints": [120168], "characters": "\uD835\uDD68" },
+ "&wp;": { "codepoints": [8472], "characters": "\u2118" },
+ "&wr;": { "codepoints": [8768], "characters": "\u2240" },
+ "&wreath;": { "codepoints": [8768], "characters": "\u2240" },
+ "&wscr;": { "codepoints": [120012], "characters": "\uD835\uDCCC" },
+ "&xcap;": { "codepoints": [8898], "characters": "\u22C2" },
+ "&xcirc;": { "codepoints": [9711], "characters": "\u25EF" },
+ "&xcup;": { "codepoints": [8899], "characters": "\u22C3" },
+ "&xdtri;": { "codepoints": [9661], "characters": "\u25BD" },
+ "&xfr;": { "codepoints": [120117], "characters": "\uD835\uDD35" },
+ "&xhArr;": { "codepoints": [10234], "characters": "\u27FA" },
+ "&xharr;": { "codepoints": [10231], "characters": "\u27F7" },
+ "&xi;": { "codepoints": [958], "characters": "\u03BE" },
+ "&xlArr;": { "codepoints": [10232], "characters": "\u27F8" },
+ "&xlarr;": { "codepoints": [10229], "characters": "\u27F5" },
+ "&xmap;": { "codepoints": [10236], "characters": "\u27FC" },
+ "&xnis;": { "codepoints": [8955], "characters": "\u22FB" },
+ "&xodot;": { "codepoints": [10752], "characters": "\u2A00" },
+ "&xopf;": { "codepoints": [120169], "characters": "\uD835\uDD69" },
+ "&xoplus;": { "codepoints": [10753], "characters": "\u2A01" },
+ "&xotime;": { "codepoints": [10754], "characters": "\u2A02" },
+ "&xrArr;": { "codepoints": [10233], "characters": "\u27F9" },
+ "&xrarr;": { "codepoints": [10230], "characters": "\u27F6" },
+ "&xscr;": { "codepoints": [120013], "characters": "\uD835\uDCCD" },
+ "&xsqcup;": { "codepoints": [10758], "characters": "\u2A06" },
+ "&xuplus;": { "codepoints": [10756], "characters": "\u2A04" },
+ "&xutri;": { "codepoints": [9651], "characters": "\u25B3" },
+ "&xvee;": { "codepoints": [8897], "characters": "\u22C1" },
+ "&xwedge;": { "codepoints": [8896], "characters": "\u22C0" },
+ "&yacute": { "codepoints": [253], "characters": "\u00FD" },
+ "&yacute;": { "codepoints": [253], "characters": "\u00FD" },
+ "&yacy;": { "codepoints": [1103], "characters": "\u044F" },
+ "&ycirc;": { "codepoints": [375], "characters": "\u0177" },
+ "&ycy;": { "codepoints": [1099], "characters": "\u044B" },
+ "&yen": { "codepoints": [165], "characters": "\u00A5" },
+ "&yen;": { "codepoints": [165], "characters": "\u00A5" },
+ "&yfr;": { "codepoints": [120118], "characters": "\uD835\uDD36" },
+ "&yicy;": { "codepoints": [1111], "characters": "\u0457" },
+ "&yopf;": { "codepoints": [120170], "characters": "\uD835\uDD6A" },
+ "&yscr;": { "codepoints": [120014], "characters": "\uD835\uDCCE" },
+ "&yucy;": { "codepoints": [1102], "characters": "\u044E" },
+ "&yuml": { "codepoints": [255], "characters": "\u00FF" },
+ "&yuml;": { "codepoints": [255], "characters": "\u00FF" },
+ "&zacute;": { "codepoints": [378], "characters": "\u017A" },
+ "&zcaron;": { "codepoints": [382], "characters": "\u017E" },
+ "&zcy;": { "codepoints": [1079], "characters": "\u0437" },
+ "&zdot;": { "codepoints": [380], "characters": "\u017C" },
+ "&zeetrf;": { "codepoints": [8488], "characters": "\u2128" },
+ "&zeta;": { "codepoints": [950], "characters": "\u03B6" },
+ "&zfr;": { "codepoints": [120119], "characters": "\uD835\uDD37" },
+ "&zhcy;": { "codepoints": [1078], "characters": "\u0436" },
+ "&zigrarr;": { "codepoints": [8669], "characters": "\u21DD" },
+ "&zopf;": { "codepoints": [120171], "characters": "\uD835\uDD6B" },
+ "&zscr;": { "codepoints": [120015], "characters": "\uD835\uDCCF" },
+ "&zwj;": { "codepoints": [8205], "characters": "\u200D" },
+ "&zwnj;": { "codepoints": [8204], "characters": "\u200C" }
+}
diff --git a/lib/chame0/chame/res/genentity.nim b/lib/chame0/chame/res/genentity.nim
new file mode 100644
index 00000000..b25a8993
--- /dev/null
+++ b/lib/chame0/chame/res/genentity.nim
@@ -0,0 +1,49 @@
+import std/json
+import std/streams
+import std/strutils
+
+type LineWriter = object
+ s: Stream
+ line: string
+
+proc write(writer: var LineWriter, s: string) =
+ if s.len + writer.line.len > 80:
+ writer.s.writeLine(writer.line)
+ writer.line = ""
+ writer.line &= s
+
+proc flush(writer: var LineWriter) =
+ writer.s.writeLine(writer.line)
+ writer.line = ""
+
+proc main() =
+ let entityJson = parseJson(readFile("entity.json"))
+ echo "type Z = cstring"
+ var writer = LineWriter(s: newFileStream(stdout))
+ var cc: char
+ var charMap: array[char, int]
+ for i in charMap.mitems:
+ i = -1
+ var entityMap: seq[tuple[name, value: string]]
+ for k, v in entityJson:
+ entityMap.add((k.substr(1), v{"characters"}.getStr()))
+ let n = entityMap.len
+ echo "const entityMap*: array[" & $n & ", Z] = ["
+ var i = 0
+ for (k, v) in entityMap:
+ if k[0] != cc:
+ charMap[cc] = i - 1
+ cc = k[0]
+ writer.write((k & ":" & v).escape() & ",")
+ inc i
+ assert cc == 'z'
+ charMap[cc] = i - 1
+ writer.flush()
+ echo "]"
+ echo ""
+ echo "const charMap*: array[char, int] = ["
+ for c in char.low..char.high:
+ writer.write($charMap[c] & ",")
+ writer.flush()
+ echo "]"
+main()
diff --git a/lib/chame0/chame/tags.nim b/lib/chame0/chame/tags.nim
new file mode 100644
index 00000000..09df69f0
--- /dev/null
+++ b/lib/chame0/chame/tags.nim
@@ -0,0 +1,197 @@
+type
+ TagType* = enum
+ TAG_UNKNOWN = ""
+ TAG_APPLET = "applet"
+ TAG_BIG = "big"
+ TAG_HTML = "html"
+ TAG_BASE = "base"
+ TAG_BASEFONT = "basefont"
+ TAG_BGSOUND = "bgsound"
+ TAG_HEAD = "head"
+ TAG_LINK = "link"
+ TAG_LISTING = "listing"
+ TAG_META = "meta"
+ TAG_STYLE = "style"
+ TAG_TITLE = "title"
+ TAG_BODY = "body"
+ TAG_ADDRESS = "address"
+ TAG_ARTICLE = "article"
+ TAG_ASIDE = "aside"
+ TAG_FOOTER = "footer"
+ TAG_HEADER = "header"
+ TAG_H1 = "h1"
+ TAG_H2 = "h2"
+ TAG_H3 = "h3"
+ TAG_H4 = "h4"
+ TAG_H5 = "h5"
+ TAG_H6 = "h6"
+ TAG_HGROUP = "hgroup"
+ TAG_MAIN = "main"
+ TAG_NAV = "nav"
+ TAG_SEARCH = "search"
+ TAG_SECTION = "section"
+ TAG_BLOCKQUOTE = "blockquote"
+ TAG_DD = "dd"
+ TAG_DIV = "div"
+ TAG_DL = "dl"
+ TAG_DT = "dt"
+ TAG_FIGCAPTION = "figcaption"
+ TAG_FIGURE = "figure"
+ TAG_HR = "hr"
+ TAG_LI = "li"
+ TAG_OL = "ol"
+ TAG_P = "p"
+ TAG_PRE = "pre"
+ TAG_UL = "ul"
+ TAG_A = "a"
+ TAG_ABBR = "abbr"
+ TAG_B = "b"
+ TAG_BDI = "bdi"
+ TAG_BDO = "bdo"
+ TAG_BR = "br"
+ TAG_NOBR = "nobr"
+ TAG_CITE = "cite"
+ TAG_CODE = "code"
+ TAG_DATA = "data"
+ TAG_DFN = "dfn"
+ TAG_EM = "em"
+ TAG_EMBED = "embed"
+ TAG_I = "i"
+ TAG_KBD = "kbd"
+ TAG_MARK = "mark"
+ TAG_MARQUEE = "marquee"
+ TAG_Q = "q"
+ TAG_RB = "rb"
+ TAG_RP = "rp"
+ TAG_RT = "rt"
+ TAG_RTC = "rtc"
+ TAG_RUBY = "ruby"
+ TAG_S = "s"
+ TAG_SAMP = "samp"
+ TAG_SMALL = "small"
+ TAG_SPAN = "span"
+ TAG_STRONG = "strong"
+ TAG_SUB = "sub"
+ TAG_SUP = "sup"
+ TAG_TIME = "time"
+ TAG_U = "u"
+ TAG_VAR = "var"
+ TAG_WBR = "wbr"
+ TAG_AREA = "area"
+ TAG_AUDIO = "audio"
+ TAG_IMG = "img"
+ TAG_IMAGE = "image"
+ TAG_MAP = "map"
+ TAG_TRACK = "track"
+ TAG_VIDEO = "video"
+ TAG_IFRAME = "iframe"
+ TAG_OBJECT = "object"
+ TAG_PARAM = "param"
+ TAG_PICTURE = "picture"
+ TAG_PORTAL = "portal"
+ TAG_SOURCE = "source"
+ TAG_CANVAS = "canvas"
+ TAG_NOSCRIPT = "noscript"
+ TAG_NOEMBED = "noembed"
+ TAG_PLAINTEXT = "plaintext"
+ TAG_XMP = "xmp"
+ TAG_SCRIPT = "script"
+ TAG_DEL = "del"
+ TAG_INS = "ins"
+ TAG_CAPTION = "caption"
+ TAG_COL = "col"
+ TAG_COLGROUP = "colgroup"
+ TAG_TABLE = "table"
+ TAG_TBODY = "tbody"
+ TAG_TD = "td"
+ TAG_TFOOT = "tfoot"
+ TAG_TH = "th"
+ TAG_THEAD = "thead"
+ TAG_TR = "tr"
+ TAG_BUTTON = "button"
+ TAG_DATALIST = "datalist"
+ TAG_FIELDSET = "fieldset"
+ TAG_FORM = "form"
+ TAG_INPUT = "input"
+ TAG_KEYGEN = "keygen"
+ TAG_LABEL = "label"
+ TAG_LEGEND = "legend"
+ TAG_METER = "meter"
+ TAG_OPTGROUP = "optgroup"
+ TAG_OPTION = "option"
+ TAG_OUTPUT = "output"
+ TAG_PROGRESS = "progress"
+ TAG_SELECT = "select"
+ TAG_TEXTAREA = "textarea"
+ TAG_DETAILS = "details"
+ TAG_DIALOG = "dialog"
+ TAG_MENU = "menu"
+ TAG_SUMMARY = "summary"
+ TAG_BLINK = "blink"
+ TAG_CENTER = "center"
+ TAG_CONTENT = "content"
+ TAG_DIR = "dir"
+ TAG_FONT = "font"
+ TAG_FRAME = "frame"
+ TAG_NOFRAMES = "noframes"
+ TAG_FRAMESET = "frameset"
+ TAG_STRIKE = "strike"
+ TAG_TT = "tt"
+ TAG_TEMPLATE = "template"
+ TAG_SARCASM = "sarcasm"
+ TAG_MATH = "math"
+ TAG_SVG = "svg"
+ TAG_CHARSET = "charset"
+ TAG_HTTP_EQUIV = "http-equiv"
+ TAG_TYP = "type"
+ TAG_DEFINITION_URL = "definitionurl"
+ TAG_ANNOTATION_XML = "annotation-xml"
+ TAG_FOREIGN_OBJECT = "foreignObject"
+ TAG_DESC = "desc"
+ TAG_ENCODING = "encoding"
+ TAG_MI = "mi"
+ TAG_MO = "mo"
+ TAG_MN = "mn"
+ TAG_MS = "ms"
+ TAG_MTEXT = "mtext"
+ TAG_MGLYPH = "mglyph"
+ TAG_MALIGNMARK = "malignmark"
+ TAG_COLOR = "color"
+ TAG_FACE = "face"
+ TAG_SIZE = "size"
+
+ QuirksMode* = enum
+ NO_QUIRKS, QUIRKS, LIMITED_QUIRKS
+
+ Namespace* = enum
+ NO_NAMESPACE = "",
+ HTML = "http://www.w3.org/1999/xhtml",
+ MATHML = "http://www.w3.org/1998/Math/MathML",
+ SVG = "http://www.w3.org/2000/svg",
+ XLINK = "http://www.w3.org/1999/xlink",
+ XML = "http://www.w3.org/XML/1998/namespace",
+ XMLNS = "http://www.w3.org/2000/xmlns/"
+ NAMESPACE_UNKNOWN = ""
+
+ NamespacePrefix* = enum
+ NO_PREFIX = ""
+ PREFIX_XLINK = "xlink"
+ PREFIX_XML = "xml"
+ PREFIX_XMLNS = "xmlns"
+ PREFIX_UNKNOWN = ""
+
+const AllTagTypes* = {TagType.low..TagType.high}
+
+const HTagTypes* = {
+ TAG_H1, TAG_H2, TAG_H3, TAG_H4, TAG_H5, TAG_H6
+}
+
+# 4.10.2 Categories
+const FormAssociatedElements* = {
+ TAG_BUTTON, TAG_FIELDSET, TAG_INPUT, TAG_OBJECT, TAG_OUTPUT, TAG_SELECT,
+ TAG_TEXTAREA, TAG_IMG
+}
+
+const ListedElements* = {
+ TAG_FIELDSET, TAG_INPUT, TAG_OBJECT, TAG_OUTPUT, TAG_SELECT, TAG_TEXTAREA
+}
diff --git a/lib/chame0/chame/tokstate.nim b/lib/chame0/chame/tokstate.nim
new file mode 100644
index 00000000..0d794ea0
--- /dev/null
+++ b/lib/chame0/chame/tokstate.nim
@@ -0,0 +1,32 @@
+type TokenizerState* = enum
+ DATA, CHARACTER_REFERENCE, TAG_OPEN, RCDATA, RCDATA_LESS_THAN_SIGN,
+ RAWTEXT, RAWTEXT_LESS_THAN_SIGN, SCRIPT_DATA, SCRIPT_DATA_LESS_THAN_SIGN,
+ PLAINTEXT, MARKUP_DECLARATION_OPEN, END_TAG_OPEN, BOGUS_COMMENT, TAG_NAME,
+ BEFORE_ATTRIBUTE_NAME, RCDATA_END_TAG_OPEN, RCDATA_END_TAG_NAME,
+ RAWTEXT_END_TAG_OPEN, RAWTEXT_END_TAG_NAME, SELF_CLOSING_START_TAG,
+ SCRIPT_DATA_END_TAG_OPEN, SCRIPT_DATA_ESCAPE_START,
+ SCRIPT_DATA_END_TAG_NAME, SCRIPT_DATA_ESCAPE_START_DASH,
+ SCRIPT_DATA_ESCAPED_DASH_DASH, SCRIPT_DATA_ESCAPED,
+ SCRIPT_DATA_ESCAPED_DASH, SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN,
+ SCRIPT_DATA_ESCAPED_END_TAG_OPEN, SCRIPT_DATA_DOUBLE_ESCAPE_START,
+ SCRIPT_DATA_ESCAPED_END_TAG_NAME, SCRIPT_DATA_DOUBLE_ESCAPED,
+ SCRIPT_DATA_DOUBLE_ESCAPED_DASH, SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,
+ SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH, SCRIPT_DATA_DOUBLE_ESCAPE_END,
+ AFTER_ATTRIBUTE_NAME, ATTRIBUTE_NAME, BEFORE_ATTRIBUTE_VALUE,
+ ATTRIBUTE_VALUE_DOUBLE_QUOTED, ATTRIBUTE_VALUE_SINGLE_QUOTED,
+ ATTRIBUTE_VALUE_UNQUOTED, AFTER_ATTRIBUTE_VALUE_QUOTED, COMMENT_START,
+ CDATA_SECTION, COMMENT_START_DASH, COMMENT, COMMENT_END,
+ COMMENT_LESS_THAN_SIGN, COMMENT_END_DASH, COMMENT_LESS_THAN_SIGN_BANG,
+ COMMENT_LESS_THAN_SIGN_BANG_DASH, COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH,
+ COMMENT_END_BANG, DOCTYPE, BEFORE_DOCTYPE_NAME, DOCTYPE_NAME,
+ AFTER_DOCTYPE_NAME, AFTER_DOCTYPE_PUBLIC_KEYWORD,
+ AFTER_DOCTYPE_SYSTEM_KEYWORD, BOGUS_DOCTYPE,
+ BEFORE_DOCTYPE_PUBLIC_IDENTIFIER, DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED,
+ DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED, AFTER_DOCTYPE_PUBLIC_IDENTIFIER,
+ BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS,
+ DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED,
+ DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED, BEFORE_DOCTYPE_SYSTEM_IDENTIFIER,
+ AFTER_DOCTYPE_SYSTEM_IDENTIFIER, CDATA_SECTION_BRACKET, CDATA_SECTION_END,
+ NAMED_CHARACTER_REFERENCE, NUMERIC_CHARACTER_REFERENCE,
+ AMBIGUOUS_AMPERSAND_STATE, HEXADECIMAL_CHARACTER_REFERENCE_START,
+ HEXADECIMAL_CHARACTER_REFERENCE, DECIMAL_CHARACTER_REFERENCE
diff --git a/lib/chame0/chame/version.nim b/lib/chame0/chame/version.nim
new file mode 100644
index 00000000..6c29dff8
--- /dev/null
+++ b/lib/chame0/chame/version.nim
@@ -0,0 +1,3 @@
+const Major* = 1
+const Minor* = 0
+const Patch* = 3
diff --git a/lib/chame0/doc/.index.md b/lib/chame0/doc/.index.md
new file mode 100644
index 00000000..a38863e6
--- /dev/null
+++ b/lib/chame0/doc/.index.md
@@ -0,0 +1,18 @@
+# Documentation of Chame, an HTML5 parsing library written in Nim.
+
+To get started, please read the [readme](https://git.sr.ht/~bptato/chame).
+
+Index of the (stable) public API:
+
+* [minidom](minidom.html): minimal DOM module and a high-level interface to the
+ HTML parser.
+* [minidom_cs](minidom_cs.html): minidom with support for non-UTF-8 character
+ sets.
+* [htmlparser](htmlparser.html): low-level interface to the HTML parser.
+* [htmlparseriface](htmlparseriface.html): forward declarations for the HTML
+ parser
+* [tags](tags.html): enum definitions for Chame (tags, namespaces, etc.)
+* [tokstate](tokstate.html): tokenizer states for the fragment parsing
+ algorithm
+
+Also of interest: the Chame [manual](manual.html).
diff --git a/lib/chame0/doc/manual.md b/lib/chame0/doc/manual.md
new file mode 100644
index 00000000..afa50b56
--- /dev/null
+++ b/lib/chame0/doc/manual.md
@@ -0,0 +1,273 @@
+# Using Chame
+
+Chame is divided into two parts: a low-level API ([htmlparser](htmlparser.html))
+and a high-level API ([minidom](minidom.html), [minidom_cs](minidom_cs.html)).
+The high-level APIs build on top of htmlparser, and are easier to use. However,
+they give consumers less control than htmlparser.
+
+Here we describe both APIs.
+
+## Table of Contents
+
+* [Basic concepts](#basic-concepts)
+ - [Standards](#standards)
+ - [String interning](#string-interning)
+ - [String validation](#string-validation)
+* [High-level API (minidom, minidom_cs)](#high-level-api-minidom-minidom_cs)
+* [Low-level API (htmlparser)](#low-level-api-htmlparser)
+ - [Functions and procedures](#functions-and-procedures)
+ * [initHTML5Parser](#inithtml5parser)
+ * [parseChunk](#parsechunk)
+ * [finish](#finish)
+ - [Generic parameters](#generic-parameters)
+* [Example](#example)
+
+## Basic concepts
+
+### Standards
+
+Chame implements HTML5 parsing as described in the
+[Parsing HTML documents](https://html.spec.whatwg.org/multipage/parsing.html)
+section of WHATWG's living standard. Note that this document may change at
+any time, and newer additions might take some time to implement in Chame.
+
+Users of the low-level API are encouraged to consult the appropriate sections
+of the standard while implementing hooks provided by htmlparser.
+
+### String interning
+
+To achieve O(1) comparisons of tag and attribute names and a lower
+memory footprint, Chame uses
+[string interning](https://en.wikipedia.org/wiki/String_interning).
+While minidom users can simply call the appropriate conversion functions
+on Document.factory, consumers of htmlparser must implement string
+interning themselves, be that through MAtomFactory or a custom solution.
+
+### String validation
+
+Note that (as per standard) the tokenization stage strips out all NUL
+characters, so strings from the parser can be safely converted to cstrings.
+
+htmlparser itself does no UTF-8 validation; it is up to the DOM builder to
+validate the input. Non-ASCII characters are treated as opaque characters,
+so parsing of ASCII-compatible character sets should just work with the caveat
+that the strings from htmlparser will not necessarily be valid UTF-8. This is
+not a problem in minidom, since it abstracts over this difficulty.
+
+## High-level API (minidom, minidom_cs)
+
+minidom has two main entry points: `parseHTML` and `parseHTMLFragment`. For
+parsing documents, `parseHTML` should be used; `parseHTMLFragment` is for parsing
+incomplete document fragments.
+
+e.g. in a browser, the `innerHTML` setter would use `parseHTMLFragment`, while
+`DOMParser.parseFromString` would use `parseHTML`.
+
+The input stream must be passed as a `Stream` object from `std/streams`. Both
+`parseHTML` and `parseHTMLFragment` return only when the input stream has been
+completely consumed from the stream. For chunked parsing, you must use the
+low-level htmlparser API instead.
+
+minidom (and minidom_cs) implements string interning using `MAtomFactory`, and
+interned strings in minidom are represented using `MAtom`s. Every `MAtom` is
+guaranteed to point to a valid UTF-8 string. To convert a Nim string into an
+`MAtom`, use the `MAtomFactory.strToAtom` function. To convert an `MAtom` into a
+Nim string, use the `MAtomFactory.atomToStr` function.
+
+Note: it is always more efficient to convert strings to atoms (i.e. to use
+`strToAtom`) than to do it the other way. `MAtom`s are just integers, so
+storing, copying, and comparing them is a lot cheaper than the same operations
+with strings.
+
+The output is a DOM tree, with the root node being a `Document`. The root
+Document node also contains a `MAtomFactory` instance, which can be used to
+convert `MAtom`s back to strings (through `atomToStr`).
+
+Strings returned from minidom are guaranteed to be valid UTF-8. Note however
+that minidom only understands UTF-8 documents. For parsing documents with
+character sets other than UTF-8, minidom_cs must be used. The `parseHTML`
+function of minidom_cs is also able to BOM sniff, interpret meta charset
+tags, and optionally retry parsing with a predefined list of character
+sets (using the companion character decoding library Chagashi).
+
+## Low-level API (htmlparser)
+
+### Functions and procedures
+
+htmlparser has three defined procedures: `initHTML5Parser`, `parseChunk`, and
+`finish`. A `getInsertionPoint` function is available as well.
+
+#### initHTML5Parser
+
+```nim
+# Signature
+proc initHTML5Parser[Handle, Atom](dombuilder: DOMBuilder[Handle, Atom],
+ opts: HTML5ParserOpts[Handle, Atom]): HTML5Parser[Handle, Atom]
+```
+
+The `initHTML5Parser` procedure requires a user-defined DOMBuilder object
+derived from the `DOMBuilder[Handle, Atom]` generic object reference.
+
+To implement all interfaces necessary for htmlparser, please include
+[htmlparseriface](htmlparseriface.html) in your DOM builder module; it contains
+forward-declarations for all procedures that `HTML5Parser` depends on. Feel
+free to study/copy [minidom](minidom.html)'s implementations.
+
+The return value is an `HTML5Parser[Handle, Atom]` object. Note that this is
+a rather large object that is passed by value; if possible, avoid copying it
+at all.
+
+#### parseChunk
+
+```nim
+# Signature
+proc parseChunk[Handle, Atom](parser: var HTML5Parser[Handle, Atom],
+ inputBuf: openArray[char], reprocess = false): ParseResult
+```
+
+`parseChunk` consumes all data passed in `inputBuf`. During this, the
+appropriate functions (`createElementImpl`, etc.) will be called by the parser.
+
+`parseChunk` returns a `ParseResult`, which is one of the following values:
+
+* `PRES_CONTINUE`: the caller should continue with parsing the next chunk of
+ data when it is available. (It's also fine to do delay processing the next
+ call by processing something different first.)
+* `PRES_STOP`: parsing was stopped by your setEncodingImpl implementation. The
+ caller is expected to restart parsing from the beginning using a **new**
+ `HTML5Parser` object. WARNING: do *not* re-use the current HTML5Parser for
+ this.
+* `PRES_SCRIPT`: a `</script>` end tag has been encountered, which immediately
+ suspended parsing. In the next `parseChunk` call, the caller is expected to
+ pass the **same** buffer (`inputBuf`) as in the current one. For details,
+ see below.
+
+Special care is required when implementing programs with scripting support. The
+HTML5 standard requires the parser to be re-entrant for supporting the
+`document.write` JavaScript function; therefore the parser suspends itself upon
+encountering a `</script>` end tag, returning a `PRES_SCRIPT` `ParseResult`.
+
+At this point, implementations have two options.
+
+##### Option 1: Continue parsing the current buffer
+
+If either:
+
+* your implementation does not support `document.write`, or
+* no `document.write` call has been issued by the script, or
+* parsing of all buffers passed by `document.write` calls has finished,
+
+then you can simply resume parsing the current buffer by calling `parseChunk`
+again with an openArray that uses the same backing buffer, except starting
+from `parser.getInsertionPoint()`. `minidom`, which pretends to support
+scripting in test cases, but does not actually execute scripts, has an example
+of this:
+
+```nim
+var buffer: array[4096, char]
+while true:
+ let n = inputStream.readData(addr buffer[0], buffer.len)
+ if n == 0: break
+ # res can be PRES_CONTINUE or PRES_SCRIPTING. PRES_STOP is only returned
+ # on charset switching, and minidom does not support that.
+ var res = parser.parseChunk(buffer.toOpenArray(0, n - 1))
+ # Important: we must repeat parseChunk with the same contents for the script
+ # end tag result, with reprocess = true.
+ #
+ # (This is only relevant for calls where scripting = true; with scripting =
+ # false, PRES_SCRIPT would never be returned.)
+ var ip = 0
+ while res == PRES_SCRIPT and (ip += parser.getInsertionPoint(); ip != n):
+ res = parser.parseChunk(buffer.toOpenArray(ip, n - 1))
+parser.finish()
+```
+
+Note the while loop; `parseChunk` will return `PRES_SCRIPT` multiple times
+for a single chunk if it contains several scripts.
+
+Also note that `minidom` does not handle `PRES_STOP`, since it does not support
+legacy encodings. For an implementation that *does* handle `PRES_STOP`, see
+`minidom_cs`.
+
+##### Option 2: Parse buffers passed by `document.write`
+
+Per standard, it is possible to insert buffers into the stream from scripts
+using the `document.write` function.
+
+It is possible to implement this, but it is somewhat too involved to give a
+detailed explanation of it here. Please refer to Chawan's implementation in
+html/chadombuilder and html/dom. (Good luck.)
+
+#### finish
+
+After having parsed all chunks of your document with `parseChunk`, you **must**
+call the `finish` function. This is necessary because the parser may still have
+some non-flushed characters in an internal buffer. e.g. when the parser receives
+the string `&gt`, it is not clear whether the character reference refers to a
+"greater than" sign, or a longer character reference like `&gtrsim;`; `finish`
+confirms that the reference is indeed a `&gt` sign. Also, the parser has to
+execute certain actions on encountering the `EOF` token, which only `finish` can
+produce.
+
+`finish` must never be called twice, and any `parseChunk` call after `finish`
+is invalid.
+
+### Generic parameters
+
+`initHTML5Parser` takes two generic parameters: `Handle` and `Atom`.
+
+`Handle` is conceptually a unique pointer to a node in the document. A naive
+single-threaded implementation (like minidom) may simply implement this as
+a Nim `ref` to an object. However, this is not mandatory; since `Handle` is
+a generic parameter, any type is accepted. For example, multi-processing
+implementations that use message passing might instead prefer to use an
+integer ID that refers to an object owned by a different thread.
+
+Similarly, `Atom` is a unique pointer to a string. This means that
+`DOMBuilder.strToAtom` must always return the same Atom for every string whose
+contents are equivalent. Additionally, `atomToTagType` and `tagTypeToAtom` must
+operate as if `TagType` values were equivalent to the contents of its
+stringifier. (i.e. `tagTypeToAtom(tagType) == strToAtom($tagType)` for all tag
+types except `TAG_UNKNOWN`, which is never passed to `tagTypeToAtom`.)
+
+Note that htmlparser does not *require* an `atomToStr` procedure, so it is not
+even necessary to store interned strings in a format compatible with the Nim
+string type. (Obviously, some way to stringify atoms is required for most use
+cases, but it need not be exposed to Chame.)
+
+## Example
+
+A simple example with minidom: dumps all text on a page.
+
+```Nim
+# Compile with nim c -d:ssl
+# List text found between HTML tags on the target website.
+import std/httpclient
+import std/os
+import std/strutils
+import chame/minidom
+
+if paramCount() != 1:
+ echo "Usage: " & paramStr(0) & " [URL]"
+ quit(1)
+let client = newHttpClient()
+let res = client.get(paramStr(1))
+let document = parseHTML(res.bodyStream)
+var stack = @[Node(document)]
+while stack.len > 0:
+ let node = stack.pop()
+ if node of Text:
+ let s = Text(node).data.strip()
+ if s != "":
+ echo s
+ for i in countdown(node.childList.high, 0):
+ stack.add(node.childList[i])
+```
+
+For more advanced usage of minidom, please study tests/tree.nim and
+tests/shared/tree_common.nim which together constitute a test runner of
+html5lib-tests.
+
+For an example implementation of [htmlparseriface](htmlparseriface.html), please
+check the source code of [minidom](minidom.html) (and if you need legacy charset
+support, [minidom_cs](minidom_cs.html)).
diff --git a/lib/chame0/gendoc.sh b/lib/chame0/gendoc.sh
new file mode 100755
index 00000000..4e7f5578
--- /dev/null
+++ b/lib/chame0/gendoc.sh
@@ -0,0 +1,25 @@
+#!/bin/sh
+mkdir -p .obj/doc
+for f in chame/*.nim
+do if test "$f" = "chame/htmlparseriface.nim"
+ then nim doc -d:nimdocdummy --outdir:.obj/doc "$f"
+ else nim doc -p:test/chagashi/ --outdir:.obj/doc "$f"
+ fi
+ sed -i \
+ -e '/<\!-- Google fonts -->/,+2d' \
+ -e 's/theindex.html/index.html/g' \
+ ".obj/doc/$(basename "$f" .nim).html"
+done
+makehtml() {
+ printf '<!DOCTYPE html>
+<head>
+<meta name=viewport content="width=device-width, initial-scale=1">
+<title>%s</title>
+</head>
+<body>
+' "$2"
+ cat "$1" | pandoc
+ printf '</body>\n'
+}
+makehtml doc/manual.md "Chame manual" > .obj/doc/manual.html
+makehtml doc/.index.md "Chame documentation" > .obj/doc/index.html
diff --git a/lib/chame0/test/chagashi b/lib/chame0/test/chagashi
new file mode 160000
+Subproject f77bd4183aad90aca00f387844de2ef8f75ce84
diff --git a/lib/chame0/test/config.nims b/lib/chame0/test/config.nims
new file mode 100644
index 00000000..80091ff6
--- /dev/null
+++ b/lib/chame0/test/config.nims
@@ -0,0 +1 @@
+switch("path", "$projectDir/../src")
diff --git a/lib/chame0/test/custom.dat b/lib/chame0/test/custom.dat
new file mode 100644
index 00000000..f3463935
--- /dev/null
+++ b/lib/chame0/test/custom.dat
@@ -0,0 +1,23 @@
+#data
+<!DOCTYPE html>
+<plaintext>
+いろはにほへと
+ちりぬるをわか
+よたれそつねな
+らむうゐのおく
+やまけふこえて
+あさくゆめみし
+ゑひもせす
+#document
+| <html>
+| <head>
+| <body>
+| <plaintext>
+| "
+縺�繧阪�ッ縺ォ縺サ縺ク縺ィ
+縺。繧翫〓繧九r繧上°
+繧医◆繧後◎縺、縺ュ縺ェ
+繧峨��縺�繧舌�ョ縺翫¥
+繧�縺セ縺代�オ縺薙∴縺ヲ
+縺ゅ&縺阪f繧√∩縺�
+繧代�イ繧ゅ○縺�"
diff --git a/lib/chame0/test/eprint.nim b/lib/chame0/test/eprint.nim
new file mode 100644
index 00000000..ef86818d
--- /dev/null
+++ b/lib/chame0/test/eprint.nim
@@ -0,0 +1,22 @@
+{.used.}
+
+template eprint0(s: varargs[string]) =
+ {.cast(noSideEffect), cast(tags: []), cast(raises: []).}:
+ var o = ""
+ for i in 0 ..< s.len:
+ if i != 0:
+ o &= ' '
+ o &= s[i]
+ when not declared(stderr):
+ echo o
+ else:
+ o &= '\n'
+ stderr.write(o)
+
+when defined(release):
+ func eprint*(s: varargs[string, `$`])
+ {.deprecated: "eprint is for debugging only".} =
+ eprint0(s)
+else:
+ func eprint*(s: varargs[string, `$`]) =
+ eprint0(s)
diff --git a/lib/chame0/test/gtrsim.dat b/lib/chame0/test/gtrsim.dat
new file mode 100644
index 00000000..1049dbd2
--- /dev/null
+++ b/lib/chame0/test/gtrsim.dat
@@ -0,0 +1,46 @@
+#data
+&gtrsim
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| ">rsim"
+
+#data
+&gt
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| ">"
+
+#data
+<h2>&g</h2>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <h2>
+| "&g"
+
+#data
+<H2>Q&A</H2>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <h2>
+| "Q&A"
+
+#data
+&zacute;
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| "ナコ"
diff --git a/lib/chame0/test/html5lib-tests b/lib/chame0/test/html5lib-tests
new file mode 160000
+Subproject a9f44960a9fedf265093d22b2aa3c7ca123727b
diff --git a/lib/chame0/test/latin1.dat b/lib/chame0/test/latin1.dat
new file mode 100644
index 00000000..bbca37da
--- /dev/null
+++ b/lib/chame0/test/latin1.dat
@@ -0,0 +1,13 @@
+#data
+<meta charset=latin1>
+゚
+#errors
+#document
+| <html>
+| <head>
+| <meta>
+| charset="latin1"
+| "
+"
+| <body>
+| "テ�"
diff --git a/lib/chame0/test/shared/tree_common.nim b/lib/chame0/test/shared/tree_common.nim
new file mode 100644
index 00000000..cac15100
--- /dev/null
+++ b/lib/chame0/test/shared/tree_common.nim
@@ -0,0 +1,334 @@
+import std/algorithm
+import std/options
+import std/strutils
+import std/tables
+import std/unittest
+
+import test1
+import chame/htmlparser
+import chame/minidom
+
+type
+ TCError = object
+ s: string
+
+ FragmentType = enum
+ FT_HTML, FT_SVG, FT_MATHML
+
+ TCFragment = object
+ fragmentType: FragmentType
+ ctx: Element
+
+ ScriptMode = enum
+ SCRIPT_BOTH, SCRIPT_OFF, SCRIPT_ON
+
+ TCTest = object
+ data: string
+ errors: seq[TCError]
+ newerrors: seq[TCError]
+ fragment: Option[TCFragment]
+ script: ScriptMode
+ document: Document
+
+ TCTestParser = object
+ s: string
+ i: int
+ pi: int
+ factory: MAtomFactory
+ linei: int
+
+func has(ctx: TCTestParser): bool =
+ return ctx.i < ctx.s.len
+
+proc reconsumeLine(ctx: var TCTestParser) =
+ ctx.i = ctx.pi
+ dec ctx.linei
+
+proc consumeLine(ctx: var TCTestParser): string =
+ result = ""
+ ctx.pi = ctx.i
+ inc ctx.linei
+ while ctx.has:
+ if ctx.s[ctx.i] == '\n':
+ inc ctx.i
+ break
+ result &= ctx.s[ctx.i]
+ inc ctx.i
+
+proc parseTestData(ctx: var TCTestParser): string =
+ result = ""
+ while ctx.has:
+ let line = ctx.consumeLine()
+ if line == "#errors":
+ return
+ if result.len > 0:
+ result &= '\n'
+ result &= line
+ doAssert false, "errors expected"
+
+proc parseTestNewErrors(ctx: var TCTestParser): seq[TCError] =
+ result = @[]
+ while ctx.has:
+ let line = ctx.consumeLine()
+ case line
+ of "#document-fragment", "#script-off", "#script-on", "#document":
+ ctx.reconsumeLine()
+ return
+ result.add(TCError(s: line))
+
+proc parseTestErrors(ctx: var TCTestParser): seq[TCError] =
+ result = @[]
+ while ctx.has:
+ let line = ctx.consumeLine()
+ case line
+ of "#new-errors":
+ ctx.reconsumeLine()
+ result.add(ctx.parseTestNewErrors())
+ return
+ of "#document-fragment", "#script-off", "#script-on", "#document":
+ ctx.reconsumeLine()
+ return
+ result.add(TCError(s: line))
+
+proc parseTestFragment(ctx: var TCTestParser): TCFragment =
+ var line = ctx.consumeLine()
+ var fragmentType = FT_HTML
+ if line.startsWith("svg "):
+ fragmentType = FT_SVG
+ line = line.substr("svg ".len)
+ elif line.startsWith("math "):
+ fragmentType = FT_MATHML
+ line = line.substr("math ".len)
+ let namespace = case fragmentType
+ of FT_SVG: Namespace.SVG
+ of FT_MATHML: Namespace.MATHML
+ of FT_HTML: Namespace.HTML
+ let element = Element(
+ namespace: namespace,
+ localName: ctx.factory.strToAtom(line)
+ )
+ return TCFragment(
+ fragmentType: fragmentType,
+ ctx: element
+ )
+
+proc parseDoctype(ctx: TCTestParser, s: string): DocumentType =
+ let doctype = DocumentType()
+ var i = "<!DOCTYPE ".len
+ while i < s.len and s[i] != ' ' and s[i] != '>':
+ doctype.name &= s[i]
+ inc i
+ while s[i] == ' ':
+ inc i
+ if s[i] == '>':
+ return doctype
+ assert s[i] == '"'
+ inc i
+ while i < s.len and s[i] != '"':
+ doctype.publicId &= s[i]
+ inc i
+ assert s[i] == '"'
+ inc i
+ assert s[i] == ' '
+ inc i
+ assert s[i] == '"'
+ inc i
+ while i < s.len and s[i] != '"':
+ doctype.systemId &= s[i]
+ inc i
+ while i + 1 < s.len and s[i + 1] == '"':
+ doctype.systemId &= s[i]
+ inc i
+ assert s[i] == '"'
+ inc i
+ assert s[i] == '>'
+ return doctype
+
+func until(s: string, c: set[char]): string =
+ result = ""
+ var i = 0
+ while i < s.len:
+ if s[i] in c:
+ break
+ result.add(s[i])
+ inc i
+
+func until(s: string, c: char): string = s.until({c})
+
+func after(s: string, c: set[char]): string =
+ var i = 0
+ while i < s.len:
+ if s[i] in c:
+ return s.substr(i + 1)
+ inc i
+ return ""
+
+func after(s: string, c: char): string = s.after({c})
+
+proc parseTestDocument(ctx: var TCTestParser): Document =
+ result = Document(factory: ctx.factory)
+ var stack = @[Node(result)]
+ template top: auto = stack[^1]
+ var thistext: Text = nil
+ var thiscomment: Comment = nil
+ var indent = 1
+ template pop_node =
+ let node = stack.pop()
+ if node of Element:
+ Element(node).attrs.sort(proc(a, b: Attribute): int = cmp(a.name, b.name))
+ indent -= 2
+ while ctx.has:
+ let line = ctx.consumeLine()
+ if thistext != nil:
+ if line.endsWith("\""):
+ thistext.data &= line.substr(0, line.high - 1)
+ thistext = nil
+ else:
+ thistext.data &= line & "\n"
+ continue
+ if thiscomment != nil:
+ if line.endsWith(" -->"):
+ thiscomment.data &= line.substr(0, line.high - " -->".len)
+ thiscomment = nil
+ else:
+ thiscomment.data &= line & "\n"
+ continue
+ if line == "":
+ break
+ assert line[0] == '|' and line[1] == ' '
+ while indent >= line.len or not line.startsWith('|' & ' '.repeat(indent)):
+ let node = stack.pop()
+ if node of Element:
+ Element(node).attrs.sort(proc(a, b: Attribute): int = cmp(a.name, b.name))
+ indent -= 2
+ let str = line.substr(indent + 1)
+ if str.startsWith("<!DOCTYPE "):
+ let doctype = ctx.parseDoctype(str)
+ top.childList.add(doctype)
+ elif str.startsWith("<!-- "):
+ let comment = minidom.Comment()
+ top.childList.add(comment)
+ if not str.endsWith(" -->"):
+ comment.data = str.substr("<!-- ".len) & "\n"
+ thiscomment = comment
+ else:
+ comment.data = str.substr("<!-- ".len, str.high - " -->".len)
+ elif str.startsWith("<?"):
+ assert false, "todo"
+ elif str.startsWith("<") and str.endsWith(">"):
+ var nameStr = str.substr(1, str.high - 1)
+ var namespace = Namespace.HTML
+ if nameStr.startsWith("svg "):
+ nameStr = nameStr.substr("svg ".len)
+ namespace = Namespace.SVG
+ elif nameStr.startsWith("math "):
+ nameStr = nameStr.substr("math ".len)
+ namespace = Namespace.MATHML
+ let element = if nameStr == "template":
+ HTMLTemplateElement()
+ else:
+ Element()
+ element.localName = ctx.factory.strToAtom(nameStr)
+ element.namespace = namespace
+ element.document = result
+ top.childList.add(element)
+ stack.add(element)
+ indent += 2
+ elif str == "content":
+ let fragment = DocumentFragment()
+ HTMLTemplateElement(top).content = fragment
+ stack.add(fragment)
+ indent += 2
+ elif str[0] == '"':
+ let text = Text()
+ top.childList.add(text)
+ if str[^1] != '"' or str.len == 1:
+ text.data = str.substr(1) & "\n"
+ thistext = text
+ else:
+ text.data = str.substr(1, str.high - 1)
+ else:
+ assert '=' in str
+ var name = str.until('=')
+ var prefix = NO_PREFIX
+ var ns = NO_NAMESPACE
+ if name.startsWith("xml "):
+ ns = Namespace.XML
+ prefix = PREFIX_XML
+ name = name.substr("xml ".len)
+ elif name.startsWith("xmlns "):
+ ns = Namespace.XMLNS
+ prefix = PREFIX_XMLNS
+ name = name.substr("xmlns ".len)
+ elif name.startsWith("xlink "):
+ ns = Namespace.XLINK
+ prefix = PREFIX_XLINK
+ name = name.substr("xlink ".len)
+ let na = ctx.factory.strToAtom(name)
+ let value = str.after('=')[1..^2]
+ Element(top).attrs.add((prefix, ns, na, value))
+ while indent > 1:
+ pop_node
+
+proc parseTest(ctx: var TCTestParser): TCTest =
+ doAssert ctx.consumeLine() == "#data"
+ var t = TCTest()
+ t.data = ctx.parseTestData()
+ t.errors = ctx.parseTestErrors()
+ while ctx.has:
+ let line = ctx.consumeLine()
+ case line
+ of "#document-fragment":
+ t.fragment = some(ctx.parseTestFragment())
+ of "#script-off":
+ t.script = SCRIPT_OFF
+ of "#script-on":
+ t.script = SCRIPT_ON
+ of "#document":
+ assert t.document == nil
+ t.document = ctx.parseTestDocument()
+ break
+ of "":
+ break
+ return t
+
+proc parseTests*(s: string, factory: MAtomFactory): seq[TCTest] =
+ result = @[]
+ var parser = TCTestParser(s: s, factory: factory)
+ while parser.i < s.len:
+ let test = parser.parseTest()
+ result.add(test)
+ var s = ""
+ for x in test.document.childList:
+ s &= $x & '\n'
+
+proc checkTest(nodein, nodep: Node) =
+ check nodein.childList.len == nodep.childList.len
+ if nodein.childList.len != nodep.childList.len:
+ echo nodein
+ echo nodep
+ if nodein of Element:
+ check nodep of Element
+ let nodein = Element(nodein)
+ let nodep = Element(nodep)
+ check nodein.localName == nodep.localName
+ check nodein.namespace == nodep.namespace
+ if nodein.attrs != nodep.attrs:
+ echo "NODEIN", $nodein
+ echo "NODEP", $nodep
+ check nodein.attrs == nodep.attrs
+ elif nodein of DocumentFragment:
+ assert false
+ elif nodein of CharacterData:
+ check nodep of CharacterData
+ check CharacterData(nodein).data == CharacterData(nodep).data
+ elif nodein of DocumentType:
+ check nodep of DocumentType
+ let nodein = DocumentType(nodein)
+ let nodep = DocumentType(nodep)
+ check nodein.name == nodep.name
+ check nodein.publicId == nodep.publicId
+ check nodein.systemId == nodep.systemId
+ for i in 0 ..< nodein.childList.len:
+ checkTest(nodein.childList[i], nodep.childList[i])
+
diff --git a/lib/chame0/test/sjis.dat b/lib/chame0/test/sjis.dat
new file mode 100644
index 00000000..6c2ac6bc
--- /dev/null
+++ b/lib/chame0/test/sjis.dat
@@ -0,0 +1,23 @@
+#data
+<plaintext>
+いろはにほへと
+ちりぬるをわか
+よたれそつねな
+らむうゐのおく
+やまけふこえて
+あさくゆめみし
+ゑひもせす
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <plaintext>
+| "
+縺�繧阪�ッ縺ォ縺サ縺ク縺ィ
+縺。繧翫〓繧九r繧上°
+繧医◆繧後◎縺、縺ュ縺ェ
+繧峨��縺�繧舌�ョ縺翫¥
+繧�縺セ縺代�オ縺薙∴縺ヲ
+縺ゅ&縺上f繧√∩縺�
+繧代�イ繧ゅ○縺�"
diff --git a/lib/chame0/test/test1.nim b/lib/chame0/test/test1.nim
new file mode 100644
index 00000000..b00cb4ac
--- /dev/null
+++ b/lib/chame0/test/test1.nim
@@ -0,0 +1,92 @@
+# "simple" test to check if it compiles
+# (actually, I just copy-pasted a throwaway test project here)
+
+import std/unittest
+import std/streams
+
+import chame/tags
+import chame/minidom
+
+func escapeText(s: string, attribute_mode = false): string =
+ result = ""
+ var nbsp_mode = false
+ var nbsp_prev = '\0'
+ for c in s:
+ if nbsp_mode:
+ if c == char(0xA0):
+ result &= "&nbsp;"
+ else:
+ result &= nbsp_prev & c
+ nbsp_mode = false
+ elif c == '&':
+ result &= "&amp;"
+ elif c == char(0xC2):
+ nbsp_mode = true
+ nbsp_prev = c
+ elif attribute_mode and c == '"':
+ result &= "&quot;"
+ elif not attribute_mode and c == '<':
+ result &= "&lt;"
+ elif not attribute_mode and c == '>':
+ result &= "&gt;"
+ else:
+ result &= c
+
+func `$`*(node: Node): string =
+ result = ""
+ if node of Element:
+ let element = Element(node)
+ var x = ""
+ if element.namespace == Namespace.SVG:
+ x = "svg "
+ elif element.namespace == Namespace.MATHML:
+ x = "math "
+ result = "<" & x & element.localNameStr
+ for k, v in element.attrsStr:
+ result &= ' ' & k & "=\"" & v.escapeText(true) & "\""
+ result &= ">"
+ for node in element.childList:
+ result &= $node
+ result &= "</" & x & element.localNameStr & ">"
+ elif node of Text:
+ let text = Text(node)
+ result = text.data.escapeText()
+ elif node of Comment:
+ result = "<!-- " & Comment(node).data & "-->"
+ elif node of DocumentType:
+ result = "<!DOCTYPE" & ' ' & DocumentType(node).name & ">"
+ elif node of Document:
+ result = "Node of Document"
+ else:
+ assert false
+
+# This is, in fact, standards-compliant behavior.
+# Don't ask.
+test "simple html serialization test":
+ const inhtml = """
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+<body>
+<main>
+Hello, world!
+</main>
+</body>
+</html>"""
+ const outhtml = """
+<!DOCTYPE html>
+<html><head>
+</head>
+<body>
+<main>
+Hello, world!
+</main>
+
+</body></html>
+"""
+ let document = parseHTML(newStringStream(inhtml))
+ var s = ""
+ for x in document.childList:
+ s &= $x & '\n'
+ check s == outhtml
diff --git a/lib/chame0/test/tokenizer.nim b/lib/chame0/test/tokenizer.nim
new file mode 100644
index 00000000..1d6ae41e
--- /dev/null
+++ b/lib/chame0/test/tokenizer.nim
@@ -0,0 +1,275 @@
+import std/json
+import std/options
+import std/tables
+import std/unicode
+import std/unittest
+
+import chame/htmltokenizer
+import chame/minidom
+
+const hexCharMap = (func(): array[char, int] =
+ for i in 0..255:
+ case chr(i)
+ of '0'..'9': result[char(i)] = i - ord('0')
+ of 'a'..'f': result[char(i)] = i - ord('a') + 10
+ of 'A'..'F': result[char(i)] = i - ord('A') + 10
+ else: result[char(i)] = -1
+)()
+
+func hexValue(c: char): int =
+ return hexCharMap[c]
+
+func doubleEscape(input: string): string =
+ var s = ""
+ var esc = 0
+ var u: uint32 = 0
+ for c in input:
+ if esc == 0:
+ if c == '\\':
+ inc esc
+ else:
+ s &= c
+ elif esc == 1:
+ if c == 'u':
+ inc esc
+ else:
+ s &= '\\'
+ dec esc
+ s &= c
+ elif esc < 6: # 2 + 4
+ inc esc
+ if esc == 3:
+ u = 0x00
+ let n = hexValue(c)
+ doAssert n != -1
+ u *= 0x10
+ u += uint32(n)
+ if esc == 6:
+ s &= $cast[Rune](u)
+ esc = 0
+ return s
+
+proc getAttrs(factory: MAtomFactory, o: JsonNode, esc: bool):
+ Table[MAtom, string] =
+ result = Table[MAtom, string]()
+ for k, v in o:
+ let k = factory.strToAtom(k)
+ if esc:
+ result[k] = v.getStr().doubleEscape()
+ else:
+ result[k] = v.getStr()
+
+proc getToken(factory: MAtomFactory, a: seq[JsonNode], esc: bool):
+ Token[MAtom] =
+ case a[0].getStr()
+ of "StartTag":
+ return Token[MAtom](
+ t: START_TAG,
+ tagname: factory.strToAtom(a[1].getStr()),
+ attrs: getAttrs(factory, a[2], esc),
+ selfclosing: a.len > 3 and a[3].getBool()
+ )
+ of "EndTag":
+ return Token[MAtom](
+ t: END_TAG,
+ tagname: factory.strToAtom(a[1].getStr())
+ )
+ of "Character":
+ let s = if esc:
+ doubleEscape(a[1].getStr())
+ else:
+ a[1].getStr()
+ return Token[MAtom](
+ t: CHARACTER,
+ s: s
+ )
+ of "DOCTYPE":
+ return Token[MAtom](
+ t: TokenType.DOCTYPE,
+ quirks: not a[4].getBool(), # yes, this is reversed. don't ask
+ name: if a[1].kind == JNull: none(string) else: some(a[1].getStr()),
+ pubid: if a[2].kind == JNull: none(string) else: some(a[2].getStr()),
+ sysid: if a[3].kind == JNull: none(string) else: some(a[3].getStr())
+ )
+ of "Comment":
+ let s = if esc:
+ doubleEscape(a[1].getStr())
+ else:
+ a[1].getStr()
+ return Token[MAtom](
+ t: TokenType.COMMENT,
+ data: s
+ )
+ else: discard
+
+proc checkEquals(factory: MAtomFactory, tok, otok: Token, desc: string) =
+ doAssert otok.t == tok.t, desc & " (tok t: " & $tok.t & " otok t: " &
+ $otok.t & ")"
+ case tok.t
+ of TokenType.DOCTYPE:
+ doAssert tok.name == otok.name, desc & " (" & "tok name: " & $tok.name &
+ " otok name: " & $otok.name & ")"
+ doAssert tok.pubid == otok.pubid, desc & " (" & "tok pubid: " &
+ $tok.pubid & " otok pubid: " & $otok.pubid & ")"
+ doAssert tok.sysid == otok.sysid, desc
+ doAssert tok.quirks == otok.quirks, desc
+ of TokenType.START_TAG, TokenType.END_TAG:
+ doAssert tok.tagname == otok.tagname, desc & " (tok tagname: " &
+ factory.atomToStr(tok.tagname) & " otok tagname " &
+ factory.atomToStr(otok.tagname) & ")"
+ if tok.t == TokenType.START_TAG:
+ #TODO not sure if this is the best solution. but end tags can't really
+ # be self-closing...
+ # Maybe use a separate "self-closing tag" token type?
+ doAssert tok.selfclosing == otok.selfclosing, desc
+ var attrs = ""
+ var i = 0
+ for name, value in tok.attrs:
+ if i > 0:
+ attrs &= " "
+ attrs &= factory.atomToStr(name)
+ attrs &= "="
+ attrs &= "'" & value & "'"
+ inc i
+ var oattrs = ""
+ i = 0
+ for name, value in otok.attrs:
+ if i > 0:
+ oattrs &= " "
+ oattrs &= factory.atomToStr(name)
+ oattrs &= "="
+ oattrs &= "'" & value & "'"
+ inc i
+ doAssert tok.attrs == otok.attrs, desc & " (tok attrs: " & attrs &
+ " otok attrs (" & oattrs & ")"
+ of TokenType.CHARACTER, TokenType.CHARACTER_WHITESPACE:
+ doAssert tok.s == otok.s, desc & " (tok s: " & tok.s & " otok s: " &
+ otok.s & ")"
+ of TokenType.COMMENT:
+ doAssert tok.data == otok.data, desc & " (tok data: " & tok.data &
+ " otok data: " & otok.data & ")"
+ of EOF, CHARACTER_NULL: discard
+
+proc runTest(builder: MiniDOMBuilder, desc: string,
+ output: seq[JsonNode], laststart: MAtom, esc: bool,
+ input: string, state = TokenizerState.DATA) =
+ let factory = builder.factory
+ var tokenizer = newTokenizer(builder, state)
+ tokenizer.laststart = Token[MAtom](t: START_TAG, tagname: laststart)
+ var i = 0
+ var chartok: Token[MAtom] = nil
+ var toks = newSeq[Token[MAtom]]()
+ while true:
+ let res = tokenizer.tokenize(input.toOpenArray(0, input.high))
+ toks.add(tokenizer.tokqueue)
+ if res == trDone:
+ break
+ while true:
+ let res = tokenizer.finish()
+ toks.add(tokenizer.tokqueue)
+ if res == trDone:
+ break
+ for tok in toks:
+ check tok != nil
+ if chartok != nil and tok.t notin {CHARACTER, CHARACTER_WHITESPACE,
+ CHARACTER_NULL}:
+ let otok = getToken(factory, output[i].getElems(), esc)
+ checkEquals(factory, chartok, otok, desc)
+ inc i
+ chartok = nil
+ if tok.t in {CHARACTER, CHARACTER_WHITESPACE}:
+ if chartok == nil:
+ chartok = Token[MAtom](t: CHARACTER)
+ chartok.s &= tok.s
+ elif tok.t == CHARACTER_NULL:
+ if chartok == nil:
+ chartok = Token[MAtom](t: CHARACTER)
+ chartok.s &= char(0)
+ else:
+ let otok = getToken(factory, output[i].getElems(), esc)
+ checkEquals(factory, tok, otok, desc)
+ inc i
+
+func getState(s: string): TokenizerState =
+ case s
+ of "Data state":
+ return DATA
+ of "PLAINTEXT state":
+ return PLAINTEXT
+ of "RCDATA state":
+ return RCDATA
+ of "RAWTEXT state":
+ return RAWTEXT
+ of "Script data state":
+ return SCRIPT_DATA
+ of "CDATA section state":
+ return CDATA_SECTION
+ else:
+ doAssert false, "Unknown state: " & s
+
+const rootpath = "test/html5lib-tests/tokenizer/"
+
+proc runTests(filename: string) =
+ let tests = parseFile(rootpath & filename){"tests"}
+ for t in tests:
+ let desc = t{"description"}.getStr()
+ var input = t{"input"}.getStr()
+ let esc = "doubleEscaped" in t and t{"doubleEscaped"}.getBool()
+ if esc:
+ input = doubleEscape(input)
+ let output = t{"output"}.getElems()
+ let laststart0 = if "lastStartTag" in t:
+ t{"lastStartTag"}.getStr()
+ else:
+ ""
+ let factory = newMAtomFactory()
+ let builder = newMiniDOMBuilder(factory)
+ let laststart = builder.factory.strToAtom(laststart0)
+ if "initialStates" notin t:
+ runTest(builder, desc, output, laststart, esc, input)
+ else:
+ for state in t{"initialStates"}:
+ let state = getState(state.getStr())
+ runTest(builder, desc, output, laststart, esc, input, state)
+
+test "contentModelFlags":
+ runTests("contentModelFlags.test")
+
+test "domjs":
+ runTests("domjs.test")
+
+test "entities":
+ runTests("entities.test")
+
+test "escapeFlag":
+ runTests("escapeFlag.test")
+
+test "namedEntities":
+ runTests("namedEntities.test")
+
+test "numericEntities":
+ runTests("numericEntities.test")
+
+#test "pendingSpecChanges":
+# runTests("pendingSpecChanges.test")
+
+test "test1":
+ runTests("test1.test")
+
+test "test2":
+ runTests("test2.test")
+
+test "test3":
+ runTests("test3.test")
+
+test "test4":
+ runTests("test4.test")
+
+test "unicodeChars":
+ runTests("unicodeChars.test")
+
+test "unicodeCharsProblematic":
+ runTests("unicodeCharsProblematic.test")
+
+#test "xmlViolation":
+# runTests("xmlViolation.test")
diff --git a/lib/chame0/test/tree.nim b/lib/chame0/test/tree.nim
new file mode 100644
index 00000000..87731f62
--- /dev/null
+++ b/lib/chame0/test/tree.nim
@@ -0,0 +1,215 @@
+include shared/tree_common
+
+import std/streams
+
+proc runTest(test: TCTest, factory: MAtomFactory, scripting, print: bool) =
+ let ss = newStringStream(test.data)
+ let opts = HTML5ParserOpts[Node, MAtom](
+ scripting: scripting
+ )
+ let pdoc = if test.fragment.isNone:
+ parseHTML(ss, opts, factory)
+ else:
+ let ctx = Element()
+ ctx[] = test.fragment.get.ctx[]
+ let childList = parseHTMLFragment(ss, ctx, opts, factory)
+ for child in childList:
+ if ctx.preInsertionValidity(child, nil):
+ ctx.childList.add(child)
+ Document(childList: ctx.childList)
+ if print:
+ var ins = ""
+ for x in test.document.childList:
+ ins &= $x & '\n'
+ var ps = ""
+ for x in pdoc.childList:
+ ps &= $x & '\n'
+ echo "data ", test.data
+ echo "indoc ", $ins
+ echo "psdoc ", $ps
+ checkTest(test.document, pdoc)
+
+const rootpath = "test/html5lib-tests/tree-construction/"
+
+proc runTests(filename: string, print = false) =
+ let factory = newMAtomFactory()
+ let tests = parseTests(readFile(rootpath & filename), factory)
+ for test in tests:
+ case test.script
+ of SCRIPT_OFF:
+ test.runTest(factory, scripting = false, print = print)
+ of SCRIPT_ON:
+ test.runTest(factory, scripting = true, print = print)
+ of SCRIPT_BOTH:
+ test.runTest(factory, scripting = false, print = print)
+ test.runTest(factory, scripting = true, print = print)
+
+test "tests1.dat":
+ runTests("tests1.dat")
+
+test "tests2.dat":
+ runTests("tests2.dat")
+
+test "tests3.dat":
+ runTests("tests3.dat")
+
+test "tests4.dat":
+ runTests("tests4.dat")
+
+test "tests5.dat":
+ runTests("tests5.dat")
+
+test "tests6.dat":
+ runTests("tests6.dat")
+
+test "tests7.dat":
+ runTests("tests7.dat")
+
+test "tests8.dat":
+ runTests("tests8.dat")
+
+test "tests9.dat":
+ runTests("tests9.dat")
+
+test "tests10.dat":
+ runTests("tests10.dat")
+
+test "tests11.dat":
+ runTests("tests11.dat")
+
+test "tests12.dat":
+ runTests("tests12.dat")
+
+# no tests13 in html5lib-tests :)
+
+test "tests14.dat":
+ runTests("tests14.dat")
+
+test "tests15.dat":
+ runTests("tests15.dat")
+
+test "tests16.dat":
+ runTests("tests16.dat")
+
+test "tests17.dat":
+ runTests("tests17.dat")
+
+test "tests18.dat":
+ runTests("tests18.dat")
+
+test "tests19.dat":
+ runTests("tests19.dat")
+
+test "tests20.dat":
+ runTests("tests20.dat")
+
+test "tests21.dat":
+ runTests("tests21.dat")
+
+test "tests22.dat":
+ runTests("tests22.dat")
+
+test "tests23.dat":
+ runTests("tests23.dat")
+
+test "tests24.dat":
+ runTests("tests24.dat")
+
+test "tests25.dat":
+ runTests("tests25.dat")
+
+test "tests26.dat":
+ runTests("tests26.dat")
+
+test "adoption01.dat":
+ runTests("adoption01.dat")
+
+test "adoption02.dat":
+ runTests("adoption02.dat")
+
+test "blocks.dat":
+ runTests("blocks.dat")
+
+test "comments01.dat":
+ runTests("comments01.dat")
+
+test "doctype01.dat":
+ runTests("doctype01.dat")
+
+test "domjs-unsafe.dat":
+ runTests("domjs-unsafe.dat")
+
+test "entities01.dat":
+ runTests("entities01.dat")
+
+test "entities02.dat":
+ runTests("entities02.dat")
+
+test "foreign-fragment.dat":
+ runTests("foreign-fragment.dat")
+
+test "html5test-com.dat":
+ runTests("html5test-com.dat")
+
+test "inbody01.dat":
+ runTests("inbody01.dat")
+
+test "isindex.dat":
+ runTests("isindex.dat")
+
+test "main-element.dat":
+ runTests("main-element.dat")
+
+test "math.dat":
+ runTests("math.dat")
+
+test "menuitem-element.dat":
+ runTests("menuitem-element.dat")
+
+test "namespace-sensitivity.dat":
+ runTests("namespace-sensitivity.dat")
+
+test "noscript01.dat":
+ runTests("noscript01.dat")
+
+test "pending-spec-changes.dat":
+ runTests("pending-spec-changes.dat")
+
+test "pending-spec-changes-plain-text-unsafe.dat":
+ runTests("pending-spec-changes-plain-text-unsafe.dat")
+
+test "plain-text-unsafe.dat":
+ runTests("plain-text-unsafe.dat")
+
+test "quirks01.dat":
+ runTests("quirks01.dat")
+
+test "ruby.dat":
+ runTests("ruby.dat")
+
+test "scriptdata01.dat":
+ runTests("scriptdata01.dat")
+
+test "search-element.dat":
+ runTests("search-element.dat")
+
+test "svg.dat":
+ runTests("svg.dat")
+
+test "tables01.dat":
+ runTests("tables01.dat")
+
+test "template.dat":
+ runTests("template.dat")
+
+test "tests_innerHTML_1.dat":
+ runTests("tests_innerHTML_1.dat")
+
+test "tricky01.dat":
+ runTests("tricky01.dat")
+
+test "webkit01.dat":
+ runTests("webkit01.dat")
+
+test "webkit02.dat":
+ runTests("webkit02.dat")
diff --git a/lib/chame0/test/tree_charset.nim b/lib/chame0/test/tree_charset.nim
new file mode 100644
index 00000000..d9069c94
--- /dev/null
+++ b/lib/chame0/test/tree_charset.nim
@@ -0,0 +1,50 @@
+include shared/tree_common
+
+import std/streams
+import chame/minidom_cs
+import chagashi/charset
+
+proc runTest(test: TCTest, factory: MAtomFactory, scripting: bool,
+ labels: openArray[string]) =
+ let ss = newStringStream(test.data)
+ let opts = HTML5ParserOpts[Node, MAtom](scripting: scripting)
+ assert test.fragment.isNone
+ var charsets: seq[Charset] = @[]
+ for s in labels:
+ let cs = getCharset(s)
+ assert cs != CHARSET_UNKNOWN
+ charsets.add(cs)
+ let pdoc = parseHTML(ss, opts, charsets, factory = factory)
+ #[
+ var ins = ""
+ for x in test.document.childList:
+ ins &= $x & '\n'
+ var ps = ""
+ for x in pdoc.childList:
+ ps &= $x & '\n'
+ echo "data ", test.data
+ echo "indoc ", $ins
+ echo "psdoc ", $ps
+ ]#
+ checkTest(test.document, pdoc)
+
+const rootpath = "test/"
+
+proc runTests(filename: string, labels: openArray[string]) =
+ let factory = newMAtomFactory()
+ let tests = parseTests(readFile(rootpath & filename), factory)
+ for test in tests:
+ case test.script
+ of SCRIPT_OFF:
+ test.runTest(factory, scripting = false, labels)
+ of SCRIPT_ON:
+ test.runTest(factory, scripting = true, labels)
+ of SCRIPT_BOTH:
+ test.runTest(factory, scripting = false, labels)
+ test.runTest(factory, scripting = true, labels)
+
+test "sjis.dat":
+ runTests("sjis.dat", ["utf8", "sjis", "latin1"])
+
+test "latin1.dat":
+ runTests("latin1.dat", ["utf8"])
diff --git a/lib/chame0/test/tree_misc.nim b/lib/chame0/test/tree_misc.nim
new file mode 100644
index 00000000..b26270cd
--- /dev/null
+++ b/lib/chame0/test/tree_misc.nim
@@ -0,0 +1,39 @@
+include shared/tree_common
+
+import std/streams
+
+proc runTest(test: TCTest, factory: MAtomFactory, scripting: bool) =
+ let ss = newStringStream(test.data)
+ let opts = HTML5ParserOpts[Node, MAtom](scripting: scripting)
+ assert test.fragment.isNone
+ let pdoc = parseHTML(ss, opts, factory = factory)
+ #[
+ var ins = ""
+ for x in test.document.childList:
+ ins &= $x & '\n'
+ var ps = ""
+ for x in pdoc.childList:
+ ps &= $x & '\n'
+ echo "data ", test.data
+ echo "indoc ", $ins
+ echo "psdoc ", $ps
+ ]#
+ checkTest(test.document, pdoc)
+
+const rootpath = "test/"
+
+proc runTests(filename: string) =
+ let factory = newMAtomFactory()
+ let tests = parseTests(readFile(rootpath & filename), factory)
+ for test in tests:
+ case test.script
+ of SCRIPT_OFF:
+ test.runTest(factory, scripting = false)
+ of SCRIPT_ON:
+ test.runTest(factory, scripting = true)
+ of SCRIPT_BOTH:
+ test.runTest(factory, scripting = false)
+ test.runTest(factory, scripting = true)
+
+test "gtrsim.dat":
+ runTests("gtrsim.dat")
diff --git a/lib/chame0/todo b/lib/chame0/todo
new file mode 100644
index 00000000..80ad5420
--- /dev/null
+++ b/lib/chame0/todo
@@ -0,0 +1,4 @@
+interface:
+* reduce use of getNamespace (maybe store ns on the stack of open elements?)
+etc:
+* add getElementById and some more basic stuff to minidom
diff --git a/lib/chame0/updver b/lib/chame0/updver
new file mode 100755
index 00000000..eb02af93
--- /dev/null
+++ b/lib/chame0/updver
@@ -0,0 +1,59 @@
+#!/bin/sh
+
+die()
+{
+ echo "$*" 2>&1
+ exit 1
+}
+
+test "$1" || die "Usage: updver [version]"
+
+vv=$(printf '%s\n' "$1" | sed 's/v//')
+
+major=$(printf '%s\n' "$vv" | sed 's/\..*//')
+minor=$(printf '%s\n' "$vv" | sed 's/[^.]*\.\([^.]*\)\..*/\1/')
+patch=$(printf '%s\n' "$vv" | sed 's/.*\.//')
+
+vs="$major.$minor.$patch"
+
+oldhdr=$(head -1 NEWS)
+
+msgfile=$(mktemp)
+
+printf '%s (%s)\n\n' "$vs" "$(date +'%Y.%m.%d')" > "$msgfile"
+cat NEWS >> "$msgfile"
+
+test -n "$EDITOR" || die 'missing $EDITOR env var'
+$EDITOR "$msgfile"
+
+printf 'Ok? (y/n) '
+read -r ok
+case "$ok" in
+y|Y) ;;
+*) die "Aborted. (File is $msgfile.)" ;;
+esac
+
+cp "$msgfile" NEWS
+echo "/version/c
+version = \"$vs\"
+.
+p
+wq" | ed -s chame.nimble
+
+echo "/Major/s/[0-9]*$/$major/
+/Minor/s/[0-9]*$/$minor/
+/Patch/s/[0-9]*$/$patch/
+g/.*/p
+wq" | ed -s chame/version.nim
+
+git add .
+git commit -m "Version $vs"
+
+tmp2=$(mktemp)
+
+while read line
+do if test "$line" = "$oldhdr"; then break; fi
+ printf '%s\n' "$line"
+done <NEWS >"$tmp2"
+
+git tag -faeF "$tmp2" "v$vs"