nemo157 / hamlet Goto Github PK
View Code? Open in Web Editor NEWHTML streaming token definitions for Rust
Home Page: https://nemo157.com/hamlet
License: Apache License 2.0
HTML streaming token definitions for Rust
Home Page: https://nemo157.com/hamlet
License: Apache License 2.0
hamlet
is about 75% slower than horrorshow
on a very simple hello world benchmark (hamlet bench code, horrorshow bench code, my results). There should be no reason for anywhere near this performance difference, at a guess it's from std::fmt
.
It would be easier to collaborate if you just leave an initial commit in master adding a README.md
(saying "WIP"), Cargo.toml
and .gitignore
, and open a PR for the rest of the commits. It'd be easier to add inline comments and all... We'll finalize on a design and merge it?
Also, can you add me as a collaborator?
What I could come up with: html-duck, html-dodge, hornbill, hairtail, hamlet, ...
Suggest more and let's choose one...
It could be good to add a generic Token::Error(E)
variant, so that parsers may convey that an error occurred.
pub enum Token<'a, E> {
...
Error(pub E),
}
I'll leave this open till someone gets time to think about the nitty-gritty details, and issue a PR...
I'm not sure if Cow<[_]>
is a clear winner over Vec<_>
. The reason behind sticking to Cow[_]
is that for empty attribute list, creating a Cow::Borrowed(&[])
must be faster than vec![]
. But then again if there's not much gain, or if empty attribute list is not that common, then having Cow
is just an overhead.
General discussion thread!
Okay, the name is dumb! Anyway, here's the API I'd like:
impl<E> CloserWriter<E> {
pub fn from_io(w: &mut io::Write) -> CloserWriter<io::Error>;
pub fn from_fmt(w: &mut fmt::Write) -> CloserWriter<fmt::Error>;
// Returns the current depth (number of unclosed start_tags).
// If an `EndTag` is given, verifies if it is correct.
pub fn write(&mut self, token) -> Result<usize, CloserError<E>>;
// closes the last tag and returns the new depth
pub fn close_tag(&mut self) -> Result<usize, CloserError<E>>;
// closes tags until the specified depth is reached
pub fn close_till(&mut self, depth) -> Result<(), CloserError<E>>; // useful?
}
enum CloserError<E> {
CloseUnmatched, // zero-depth close or invalid end-tag
StreamError(E),
}
Maintaining a stack of tag names will do to accomplish this. Document that raw text, tag names or attribute names are not verified. May be we can provide another wrapper over this called SafeWriter
in future. Another possible extension is pretty printing the tags.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.