about summary refs log tree commit diff stats
Commit message (Collapse)AuthorAgeFilesLines
...
| * de-iteratorize tokenizerbptato2024-01-213-257/+287
| |
| * Fix copy-paste error attempt 2bptato2024-01-211-1/+1
| |
| * Fix copy-paste errorbptato2024-01-211-1/+1
| | | | | | | | whoops
| * htmlparser: set script already started on <script>bptato2024-01-211-1/+2
| | | | | | | | | | We already have the callback, so this is less confusing than having to special-case it in consumer code.
| * Get rid of radixtreebptato2024-01-187-230/+154
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | entityMap was a global variable initialized at runtime; plus it wasn't even efficient because radixtree used a heap-allocated tree, Nim strings as keys, a closure for searching, etc. We could have just brute forced the problem using a hash table, but a) we would need to store hashes + dummy entries for prefixes; that's a waste of bytes, and b) with std tables at least, we would need to re-hash for every char consumed. Instead, we just use what used to be called entityTable (renamed to entityMap), and pseudo-linear search it: * Use a jump table to find the starting entry's index * Go back in entityMap until either there are no more entries with the desired character or a matching entry found.
| * tags: remove NodeType and various setsbptato2024-01-157-123/+95
| | | | | | | | | | | | | | | | | | | | | | * NodeType is somewhat convenient, but adds a 1-word overhead to each node and makes object construction more error-prone. If needed, library users can still add it without us defining the enum. * Now that we have atoms, the tagType function is useless. * SpecialElements is only used in the specification's parser section, and is not even complete because it should also contain non-HTML tags. Moved to htmlparser. * AllTagTypes can be expressed in a simpler way.
| * Avoid having to import htmltokenizerbptato2024-01-154-45/+61
| | | | | | | | | | | | | | Just export the types needed for htmlparser to work. Also, create the initial Tokens inside htmlparser, so it does not become part of the interface.
| * tags: add NAMESPACE_UNKNOWN, PREFIX_UNKNOWNbptato2024-01-141-0/+2
| | | | | | | | | | | | Null values for when consumer code needs it. (NAMESPACE_UNKNOWN in particular could be returned from getNamespaceImpl for user-defined namespaces.)
| * htmlparseriface: split out <html> element creationbptato2024-01-143-37/+51
| | | | | | | | | | | | | | Simplifies createElementForToken; this way, we no longer have to pass an Option[Handle] just for a single special case. While we're at it, also remove some dead generic functions.
| * htmlparser: make it possible to implement custom elementsbptato2024-01-063-18/+40
| | | | | | | | | | Intended parent must be passed to createElement, or it becomes impossible to get intended parent's node document.
| * Update todo, readmebptato2024-01-032-2/+0
| | | | | | | | | | | | | | * Removing getParentNode seems to be too much effort that would yield dubious benefits (if any) in a corner case. * As far as I can tell, custom elements can be implemented using the existing set of hooks in htmlparser, so no extra work in Chame is necessary.
| * Update readmebptato2024-01-021-3/+1
| |
| * minidom: UTF8 validate strings in strToAtombptato2024-01-021-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | If we UTF8 validate, then let's go all the way. Doing this in atomToStr would be horrible, because then different atoms could potentially be represented by the same string. To avoid this problem, we validate in strToAtom instead. Since htmltokenizer/htmlparser does not keep record of strings used to produce atoms, and never compares the string representation of atoms, this is safe to do. (In fact, no atom stringifier is required or used by the parser at all.)
| * Do not use dynamic dispatch for optional hooksbptato2024-01-028-78/+113
| | | | | | | | | | | | | | | | Now we use `when compiles' for statically checking if implementations exists for these. minidom still uses dynamic dispatch for setEncodingImpl so that minidom_cs can override minidom's implementation.
| * htmlparseriface: make addAttrsIfMissingImpl non-optionalbptato2024-01-022-18/+15
| | | | | | | | | | | | The "kind of functional implementation" angle has already been dropped by making getTemplateContentImpl is non-optional, so it makes no sense to provide a broken default implementation for addAttrsIfMissingImpl.
| * htmlparseriface: use converter instead of manual castingbptato2024-01-021-72/+4
| | | | | | | | | | | | | | This way, we will be able to replace the method hack with static dispatch. (Not done yet, because I have to think of a way to provide interface definitions for optional procs. Maybe just a comment will suffice...)
| * Reduce func use, reduce dead codebptato2024-01-021-37/+30
| | | | | | | | | | * Remove func from procs that call external code * Remove unused findLastActiveFormatting overload
| * Separate HTML attributes from adjusted XML attrsbptato2024-01-027-177/+153
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * Use a table in tokenizer for attributes * Pass a separate xmlAttrs seq for adjusted XML attributes This way, deduplication is easier, and atoms only need a hash function instead of a cmp function. Also, the number of copies is reduced in the most common case (which is elements with html-only attributes). Since the HTML standard does not specify the ordering of attributes, it seems wiser to just output the table we use for de-duplication and leave any further sorting to the consumer than to implement it inside the library.
| * htmlparser: use popElementsIncl morebptato2024-01-011-4/+3
| |
| * htmlparser: get rid of some todosbptato2024-01-012-12/+2
| | | | | | | | | | | | | | | | * No namespace is correct. * Queue a microtask can be implemented in elementPoppedImpl, because the stack of open elements is not visible to scripts. * We can just change <image> tag name and reproces, no problem * Update todo file
| * htmltokenizer: fix some todosbptato2024-01-011-41/+33
| | | | | | | | | | | | | | * Only check for start tag attributes where a start tag with attributes could be emitted * Do not unnecessarily hash tag names for is_appropriate_end_tag_token * Unify code paths for the numeric char ref end tag state
| * htmltokenizer: remove large internal bufferbptato2024-01-016-128/+138
| | | | | | | | | | | | We still store characters retrieved for peek in a separate buffer; otherwise, the getChar routine is used (which is provided by DOMBuilder).
| * New interface part 2bptato2023-12-317-182/+178
| | | | | | | | | | Now we have a somewhat hacky solution for defining optional procs. Still WIP...
| * New interface part 1bptato2023-12-309-426/+455
| | | | | | | | | | | | | | * Use mixins for mandatory functions (through htmlparseriface) * Get rid of AtomFactory; instead, pass DOMBuilder to tokenizer and specify atomToStr etc. on DOMBuilder * Call atomToTagType with dombuilder as a param
| * Do not emit EOF token in tokenizerbptato2023-12-302-4/+4
| | | | | | | | | | Instead, pretend that one had been emitted after the main constructTree loop. (This way we can get rid of an unnecessary test.)
| * Get rid of tagNameEquals, reduce getLocalName usebptato2023-12-302-22/+12
| | | | | | | | | | Compare token tag names where we can get away with it, since that's faster.
| * Remove unnecessary getNamespace callsbptato2023-12-301-4/+2
| | | | | | | | getTagType already checks for it
| * Pass all tree construction testsbptato2023-12-306-191/+383
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Many bugfixes: * getTagType now always returns TAG_UNKNOWN for non-HTML namespaced elements * Fix doctype public identifiers being compared case-sensitively * Fix adoption agency algorithm iteration count (again :D) * Add <font color> etc. to foreign content accepted element list * Fix pushInTemplate parser option * Fix SVG/MathML tags being used in table scope * Use table scope where appropriate (IN_TABLE) * minidom: fix parseHTMLFragment for non-HTML namespaces * minidom: fix UTF-8 validator/converter/whatever * Also, fix some test case parsing bugs/omissions (so they actually run :P) * Update readme
| * tests21bptato2023-12-283-15/+17
| | | | | | | | | | | | | | * Fix CDATA section bracket state bug * Fix peekStr bug * Simplify peekStrNoCase * Replace toUpperAscii calls with toLowerAscii
| * tests 18 .. 20bptato2023-12-285-23/+61
| | | | | | | | | | | | | | * Implement template stuff in minidom * Foreign content fixes * Fix </tbody> in "in row" switching to "in body" instead of "in table body"
| * Fix tests 10 .. 17, add todobptato2023-12-285-48/+139
| |
| * htmltokenizer: refactor peek_str, peek_str_nocasebptato2023-12-281-41/+33
| | | | | | | | | | | | Now they are functions. Also, slightly reduce the number of nested templates.
| * htmltokenizer: use static assertionsbptato2023-12-281-8/+11
| |
| * Update readmebptato2023-12-281-6/+4
| |
| * htmltokenizer: null -> \0bptato2023-12-281-28/+26
| | | | | | | | aesthetics
| * Comment out function overload for testingbptato2023-12-281-0/+3
| |
| * Fixes for test9.datbptato2023-12-289-175/+419
| | | | | | | | Now it runs without errors.
| * Add string interning for attribute namesbptato2023-12-279-132/+249
| |
| * Add string interning supportbptato2023-12-2712-484/+694
| | | | | | | | WIP
| * htmltokenizer: refactor EOF handlingbptato2023-12-261-267/+303
| | | | | | | | Now it is done outside of the main loop.
| * tests/tokenizer: remove unused parambptato2023-12-261-5/+5
| |
| * Re-add chakasu for testsbptato2023-12-261-0/+2
| | | | | | | | doesn't work otherwise
| * Remove chakasu from nimble filebptato2023-12-201-1/+0
| | | | | | | | not a mandatory dependency anymore
| * add missing tests/shared folderbptato2023-12-201-0/+262
| | | | | | | | Needed for tree tests, but gitignore blocked it.
| * htmlparser: fix bug in reconstructActiveFormattingbptato2023-12-201-1/+1
| | | | | | | | this needs isNone, not isSome
| * Separate out character encoding support from htmlparserbptato2023-12-2014-730/+584
| | | | | | | | | | | | | | This removes Chakasu as a hard dependency. Now users of this library must either implement encoding support themselves, or use minidom_cs (which still depends on Chakasu).
| * htmlparser: add getDocument getter to DOMBuilderbptato2023-12-202-17/+29
| | | | | | | | | | | | | | This replaces DOMBuilder.document with a getter function, mainly for consistency and flexibility. (Also, it removes the need to convert back DOMBuilder.document into a document node after parsing has finished.)
| * htmlparser: add callbacks for rewinding the input streambptato2023-12-181-5/+27
| |
| * htmlparser: remove superflous setPosition callsbptato2023-12-181-2/+0
| | | | | | | | | | These were made disregarding canReinterpret and would crash any parseHTML call with a stream that cannot be re-interpreted.
| * Fix typosbptato2023-12-051-6/+6
| |