Git Product home page Git Product logo

saxophone's People

Contributors

cbonnissent avatar dependabot[bot] avatar matteodelabre avatar mattgson avatar normanrz avatar winston01 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

saxophone's Issues

Add basic `DOCTYPE` support

Hey @matteodelabre, I am considering using your library for my XML minifier minify-xml, however parsing documents with a DOCTYPE resulting in a error is a blocker for me at this point in time. How about and how would you judge the effort adding basic DOCTYPE support, similar to processing instructions soon? Content parsing, similar to parseAttrs could be added later on and for my (many other purpose) getting an event with a content field would be enough for me and is in fact much better than just throwing an error for an otherwise valid document.

What do you think? Any chance of you adding this, or could you explain what was the complication to not having it added in the first place? Thanks!

Change Node.js dependency

Would it be possible to remove (or update) the dependency on Node.js versions, see this line? Node.js version 20.9 is a LTS release and as far as I can tell this package works just fine on 20.9.

Node 14 support

With nodejs 14 now on LTS, the library fails to install (due to the limitations set in the package.json).
I tested it briefly and I had no issues with node 14.

Would it be possible to support it or do you think there could be any issues?
Thank you!

Parser has a small probability of throwing an error on a valid comment when streaming.

The way the parser handles comments is not safe at the moment.
One in every ~10,000 comments in a stream throws an error.

This is because of the check for comments containing "--" in the section starting line 284.

I have fixed this by changing the code as below and opened a PR.
The important part is the check:

input[commentClose + 2] === undefined

Full code:

if (
	nextNextChar === '-' &&
	(input[chunkPos + 1] === undefined || input[chunkPos + 1] === '-')
) {
	chunkPos += 2;
	const commentClose = input.indexOf('--', chunkPos);

	// Incomplete comment node, we need to wait for
	// upcoming data
	if (commentClose === -1 || input[commentClose + 2] === undefined) {
		this._wait(Node.comment, input.slice(chunkPos - 4));
		break;
	}

	if (input[commentClose + 2] !== '>') {
		callback(new Error('Unexpected -- inside comment: ' + input.slice(chunkPos - 4)));
		return;
	}

	this.emit(Node.comment, { contents: input.slice(chunkPos, commentClose) });

	chunkPos = commentClose + 3;
	continue;
}

Add type declarations for TypeScript users

It would be nice to have type declarations for TypeScript for this parser. Unfortunately the JSDoc type declarations aren't enough for TypeScript to work.

I will create the declarations based on your code and submit a pull request when it's done.

Node 15 support

Please bump the version to support node v15. There is xlstream package I use that depends on yours.

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.