DonJayamanne / typescript-notebook

Run JavaScript and TypeScript in node.js within VS Code notebooks with excellent support for debugging, tensorflowjs visulizations, plotly, danfojs, etc
https://marketplace.visualstudio.com/items?itemName=donjayamanne.typescript-notebook
MIT License
904 stars 39 forks source link

Node.js kernel text output and new line issues #60

Closed RandomFractals closed 2 years ago

RandomFractals commented 2 years ago

When using fs.readFileSync with utf-8 encoding, Node.js kernel outputs odd text data, especially around new lines with some escape characters:

typescript-notebook-text-output

Which results in the following data table display:

image

Expected:

Raw plain text CSV content of this data file: https://raw.githubusercontent.com/RandomFractals/vscode-data-table/main/data/usa-airports.csv

The same happens for JSON string: https://github.com/RandomFractals/vscode-data-table/blob/main/data/usa-airports.json

image

RandomFractals commented 2 years ago

I resolved it by using display.text(string) method, but I expected string vars to be outputted without concat or any escape characters as above. This works for now:

image

DonJayamanne commented 2 years ago

console.log( or the like would resolve this. Basically if you just dump a raw string, its the same as dumping output into a shell and the output is formatted by the shell to escape ansi codes. And VS Codes renderer supports ANSI codes hence you get a green output, but when you open it as a plain text output due to the large content, then VS Code doesn't escape any of that output.

If you would like a change in that behavior please file an issue in VSCode as thats beyond the control of this extension.