about summary refs log tree commit diff stats
Commit message (Collapse)AuthorAgeFilesLines
...
| * entity: reduce size somewhatbptato2024-05-053-1060/+764
| | | | | | | | with GCC this shaves 64K off the output
| * Version 0.14.5bptato2024-04-093-2/+8
| |
| * doc: update manualbptato2024-04-091-3/+9
| |
| * tags: remove duplicate definitionURLbptato2024-04-092-8/+7
| | | | | | | | | | | | it causes problems with the naive implementation of TagType enum extension (as we do it in Chawan); better to just convert it dynamically in the very very very rare case that it's needed.
| * htmltokenizer: fix entities starting with `z'bptato2024-04-093-2/+12
| | | | | | | | | | lower-case `z' was missing from the list of generated end indices, which broke character entities starting with `z'.
| * Update readmebptato2024-03-221-0/+4
| |
| * misc refactoringsbptato2024-03-066-335/+218
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | htmlparser: * use when declared() to avoid taskRequires for low nim versions * remove MappedAtom, use TagType instead * remove TokenResult enum (just use ParseResult) * use result of atomToTagType instead of re-doing it everywhere * simplify until() * simplify closeP() htmltokenizer: * simplify numericCharacterReferenceEndState * unify generated eatStrNoCase functions doc: * fix incorrect header tags
| * Version 0.14.4bptato2024-03-033-2/+5
| |
| * htmltokenizer: clean up tokenizeEOFbptato2024-03-031-171/+143
| | | | | | | | | | | | | | This was getting miscompiled on ARM Nim 1.6.14 + GCC into an infinite loop, so we get rid of the loop completely. (Also, remove the reconsumes where possible, and make infinite looping impossible by only doing a second pass when reconsume is absolutely necessary.)
| * Version 0.14.3bptato2024-02-213-2/+5
| |
| * Fix another variation of the entity reference bugbptato2024-02-212-1/+16
| | | | | | | | | | | | | | | | | | | | | | | | 8de948e was an incomplete fix, and of course I only realize this after pushing out a new version :( Specifically, the inner loop of findCharRef can exit in *two* places: a) when an entry with a non-matching initial char is found b) when no more entries exist and the previous patch only fixed case a).
| * Version 0.14.2bptato2024-02-213-2/+7
| |
| * htmltokenizer: fix entity reference parsing bugbptato2024-02-212-0/+14
| | | | | | | | | | | | See the attached test case; the last consumed character in findCharRef reference was being incorrectly flushed, even when it was meant to be reconsumed as markup.
| * Update docsbptato2024-02-102-7/+7
| |
| * Version 0.14.1bptato2024-02-082-2/+2
| |
| * Update readme, newsbptato2024-02-082-2/+7
| |
| * htmlparser: fix associateWithForm callback regressionbptato2024-02-081-1/+2
| | | | | | | | | | | | Introduced in ff757ac0, by an incorrect replacement of `attrs.findAttr(parser.atomMap[ATOM_FORM]) == -1` with `parser.atomMap[ATOM_FORM] in htmlAttrs` flipping the logic.
| * remove utils/ directorybptato2024-02-074-57/+62
| |
| * Version 0.14.0bptato2024-02-072-2/+2
| |
| * Update docsbptato2024-02-075-15/+371
| |
| * htmltokenizer: reduce reconsume_in usebptato2024-02-031-19/+49
| |
| * htmltokenizer: get rid of an unnecessary bufferbptato2024-02-031-13/+14
| | | | | | | | We can just use tmp instead of attrn.
| * Update readmebptato2024-02-021-3/+3
| |
| * doc generation workbptato2024-02-025-121/+217
| |
| * Make parser re-entrantbptato2024-02-0110-407/+562
| | | | | | | | enables document.write
| * 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.)