-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Performance issue because of lots of nested layers #78
Comments
Could place this file to the root and execute. "use strict";
const fs = require("fs");
const Convert = require("./lib/ansi_to_html");
const convert = new Convert();
let content = "";
for (let i = 0; i < 10000; i++) {
content += '\x1b[30mblack\x1b[37mwhite\r\n\r\n';
}
fs.writeFileSync("./bench.html", `
<html>
<body>
${convert.toHtml(content)}
</body>
</html>
`); And will get a html file |
thanks for writing a test for that. There have been pending changes that I thought might make that kind of problem worse, but have just been speculating. #53 (comment) #59 (comment) |
If you want to be more faithful to how ANSI works, e.g., so as to use the "undo"-type commands to undo a previous style if applied, you really have to use nesting. (And to support However, you might be able to find an HTML/CSS cleaner which optimizes the final result to potentially avoid some redundancy. A quick search of npm though didn't turn up useful results for me. |
you could also just close the tag of the previous applied style to 'undo' it. Text decoration might require nesting, depending on how you want to solve it, but not to billions of layers. Some additional logic could just close the previous tag, figure out the combined style of the next section and open a new tag |
Use the example on readme:
this will generated a html structure like this:
But I think it's better to generate a html like this:
Lots of unnecessary nested layers will slow down the browser. Another package ansi-html doesn't have this problem.
The text was updated successfully, but these errors were encountered: