aboutsummaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)Author
2023-09-28break!: rename State variantsMartin Fischer
The spec refers to them only as RCDATA, RAWTEXT and PLAINTEXT. See https://rust-lang.github.io/api-guidelines/naming.html.
2023-09-28break!: remove CdataActionMartin Fischer
Which action the tokenizer takes depending on whether or not an adjusted current node is present but not in the HTML namespace, is an implementation detail and shouldn't be exposed in the API.
2023-09-28feat: add span to Trace::CharMartin Fischer
2023-09-28chore: use let...elseMartin Fischer
2023-09-28refactor: remove needless match & mapMartin Fischer
2023-09-28chore: rename variableMartin Fischer
2023-09-28feat: add offset to Trace::EndOfFileMartin Fischer
2023-09-28feat: implement BasicEmitterMartin Fischer
2023-09-28break!: move offsets out of TokenMartin Fischer
Previously the Token enum contained the offsets using the O generic type parameter, which could be a usize if you're tracking offsets or a zero-sized type if you didn't care about offsets. This commit moves all the byte offset and syntax information to a new Trace enum, which has several advantages: * Traces can now easily be stored separately, while the tokens are fed to the tree builder. (The tree builder only has to keep track of which tree nodes originate from which tokens.) * No needless generics for functions that take a token but don't care about offsets (a tree construction implementation is bound to have many of such functions). * The FromIterator<(String, String)> impl for AttributeMap no longer has to specify arbitrary values for the spans and the value_syntax). * The PartialEq implementation of Token is now much more useful (since it no longer includes all the offsets). * The Debug formatting of Token is now more readable (since it no longer includes all the offsets). * Function pointers to functions accepting tokens are possible. (Since function pointer types may not have generic parameters.)
2023-09-28refactor: make TracingEmitter only work with usizesMartin Fischer
2023-09-28chore: add BasicEmitter stubMartin Fischer
2023-09-28break!: rename DefaultEmitter to TracingEmitterMartin Fischer
2023-09-28refactor: simplify attribute logic in DefaultEmitterMartin Fischer
2023-09-28refactor: clean up DefaultEmitter codeMartin Fischer
2023-09-28chore: reorder DefaultEmitter methods as wellMartin Fischer
See the previous commit.
2023-09-28docs: put Emitter methods in a more logical orderMartin Fischer
2023-09-28refactor: make NaiveParser new* signatures more readableMartin Fischer
2023-09-28break!: remove NaiveParser::new_with_spansMartin Fischer
The method never really made much sense since you could just as well use NaiveParser::new.
2023-09-28break!: make DefaultEmitter::emit_eof emit EndOfFileMartin Fischer
2023-09-28break!: add Token::EndOfFileMartin Fischer
While the end-of-file token can also be represented by None, this is less clear than having an explicit variant. Especially when it comes to tree construction, the spec explicitly has conditions named "An end-of-file token", and it's nice if the code for tree construction can match the spec text closely.
2023-09-28break!: emit chars instead of stringsMartin Fischer
The HTML spec specifies that the tokenizer emits character tokens. That html5gum always emitted strings instead was probably just done to make the token consumption more convenient. When it comes to tree construction character tokens are however actually more convenient than string tokens since the spec defines that specific character tokens should be ignored in specific states (and character tokens let us avoid string manipulation for these conditions). This should also make the DefaultEmitter more performant for cases where you don't actually need the strings at all (or only a few) since it avoids string allocations. Though I haven't benchmarked it.
2023-09-28refactor: proxy emit_string calls through utilsMartin Fischer
This is done separately so that the next commit has a cleaner diff.
2023-09-28refactor: move machine impl details to machine moduleMartin Fischer
This commit separates the public API (the "Tokenizer") from the internal implementation (the "Machine") to make the code more readable.
2023-09-28refactor: move utils module under tokenizer::machineMartin Fischer
2023-09-28refactor: only use InternalState re-export for feature-gated internal APIMartin Fischer
2023-09-28refactor: move machine module under tokenizerMartin Fischer
2023-09-28//: remove wrong commentMartin Fischer
Methods defined in another module don't have access to private fields, so the function could very well have been implemented as a method.
2023-09-28break!: remove Token::ErrorMartin Fischer
An error isn't a token (in general and also according to the spec). You shouldn't have to filter out errors when you're just interested in tokens but most importantly having errors in the Token enum is annoying when implementing tree construction (since the spec conditions exhaustively cover all Token variants except Token::Error).
2023-09-28refactor: remove DefaultEmitter::push_error helper fnMartin Fischer
2023-09-28break!: rename Emitter::emit_error to report_errorMartin Fischer
2023-09-28chore: move emit_error method upMartin Fischer
2023-09-28feat: add blanket impl of Reader for boxed readersMartin Fischer
2023-09-27break!: remove Emitter::pop_token, use Iterator insteadMartin Fischer
2023-09-27chore: move bounds to where clauseMartin Fischer
2023-09-12docs: move warning from DefaultEmitter to TokenizerMartin Fischer
2023-09-11chore: move DefaultEmitter to own moduleMartin Fischer
2023-09-09refactor: merge token types with attr to new token moduleMartin Fischer
2023-09-09chore: group public modules togetherMartin Fischer
2023-09-09docs: stop referencing Emitter from token typesMartin Fischer
2023-09-03docs: add spans exampleMartin Fischer
2023-09-03feat: add Doctype::name_spanMartin Fischer
2023-09-03break!: make Doctype name field optionalMartin Fischer
2023-09-03fix!: make comment data spans encoding-independentMartin Fischer
2023-09-03fix: make doctype id spans encoding-independentMartin Fischer
2023-09-03fix!: make set_self_closing encoding-independentMartin Fischer
2023-09-03fix!: make attribute spans encoding-independentMartin Fischer
2023-09-03fix!: make start/end tag name spans encoding-independentMartin Fischer
2023-09-03fix: don't assume UTF-8 in machine/tokenizerMartin Fischer
2023-09-03refactor: inline internal method only used onceMartin Fischer
2023-09-03fix!: make PosTrackingReader encoding-independentMartin Fischer
While much of the span logic currently assumes UTF-8, we also want to support other character encodings, such as e.g. UTF-16 where characters can take up more or less bytes than in UTF-8.