Commit graph

238 commits

Author SHA1 Message Date
Jakub Jirutka
9ee9575eae Remove mathRenderer option
The current approach doesn't work with nodom because KaTeX's
renderMathInElement() works on an element with full DOM and we have
only element with innerHTML string.
2019-09-16 22:54:52 +02:00
Jakub Jirutka
61c3b5feab Fix escapeHTML() to escape even "&" and refactor it 2019-09-16 22:54:52 +02:00
Jakub Jirutka
f19a70416e Completely refactor renderer and add tests for utils 2019-09-16 22:54:51 +02:00
Jakub Jirutka
9775f6f3bd Rename index.ts to renderer.ts 2019-09-16 22:53:06 +02:00
Jakub Jirutka
eb55e17525 Rename makeElement() to el() 2019-09-16 22:52:40 +02:00
Jakub Jirutka
34195169a6 Sort display renderers by priority and refactor text/svg+xml alias 2019-09-16 22:52:40 +02:00
Jakub Jirutka
9d07316d71 Move katex config out of renderer function 2019-09-16 22:52:40 +02:00
Jakub Jirutka
b736cb1ff2 Don't code-highlight Stream and Error outputs
1. We don't know the language of the stdout/stderr and error outputs
   anyway and typically it's just a text.

2. stdout/stderr output may contain ANSI escape sequences, so we convert
   them into HTML first. ANSI converter returns an HTML as a string;
   highlight.js doesn't recognize this as HTML, it simply highlights the
   given string as a code containing HTML. Actually I don't understand
   how else this should work and how it does work in the original
   notebookjs...
2019-09-16 22:52:39 +02:00
Jakub Jirutka
30acfa337a Don't pass elements to highlighter 2019-09-16 22:08:24 +02:00
Jakub Jirutka
f332972ec0 Minimize calling DOM methods in render functions 2019-09-15 20:28:12 +02:00
Jakub Jirutka
a3ba8bb60b Replace bloated jsdom with nodom 2019-09-15 20:28:12 +02:00
Jakub Jirutka
2668ccd23d Don't import marked and ansi_up, let user provide them
And move them from dependencies to devDependencies and peerDependencies.
2019-09-15 20:28:12 +02:00
Jakub Jirutka
aab1c75272 Import nbformat types without namespace 2019-09-15 20:28:12 +02:00
Jakub Jirutka
cd4313f298 Rewrite classes to pure functions 2019-09-15 20:28:12 +02:00
Jakub Jirutka
4e8c683ec3 DRY usage of joinText() 2019-09-15 20:28:12 +02:00
Jakub Jirutka
80099e328f Simplify creating of new element 2019-09-15 20:28:12 +02:00
Jakub Jirutka
9b4e0ed0cf Convert to TypeScript (with type errors for now) 2019-09-15 20:28:12 +02:00
Jakub Jirutka
0977d6b097 Add types for nbformat v4.3 2019-09-15 20:28:12 +02:00
Jakub Jirutka
a495bdfc13 Remove compat. with nbformat <4.0: worksheets
This was removed from nbformat 4.0+.
2019-09-15 20:28:12 +02:00
Jakub Jirutka
5c661af4b8 Remove compat. with nbformat <4.0: error
https://nbformat.readthedocs.io/en/latest/format_description.html#error:
> pyerr renamed to error
2019-09-15 20:28:12 +02:00
Jakub Jirutka
c982a7db3f Remove compat. with nbformat <4.0: execute_result
https://nbformat.readthedocs.io/en/latest/format_description.html#execute-result:
> pyout renamed to execute_result
2019-09-15 20:28:12 +02:00
Jakub Jirutka
acbb3ca3cb Remove compat. with nbformat <4.0: display_data
https://nbformat.readthedocs.io/en/latest/format_description.html#display-data:
> mime-types are used for keys, instead of a combination of short names
> (text) and mime-types, and are stored in a data key, rather than the
> top-level. i.e. output.data['image/png'] instead of output.png.
2019-09-15 20:28:12 +02:00
Jakub Jirutka
dbfe5b500b Remove compat. with nbformat <4.0: stream output
https://nbformat.readthedocs.io/en/latest/format_description.html#stream-output:
> The stream key was changed to name to match the stream message.
2019-09-15 20:28:12 +02:00
Jakub Jirutka
467e5218c1 Remove compat. with nbformat <4.0: code cell
https://nbformat.readthedocs.io/en/latest/format_description.html#code-cells:
> `input` was renamed to `source`, for consistency among cell types.

https://nbformat.readthedocs.io/en/latest/format_description.html#code-cells:
> prompt_number renamed to execution_count

Key `language` was removed from the code cell in 4.0.
2019-09-15 20:28:12 +02:00
Jakub Jirutka
6a3daeb30c Remove compat. with nbformat <4.0: markdown heading cell
https://nbformat.readthedocs.io/en/latest/format_description.html#markdown-cells:
> Heading cells have been removed, in favor of simple headings in markdown.
2019-09-15 20:28:12 +02:00
Jakub Jirutka
613580d0b9 First refactoring 2019-09-15 20:28:12 +02:00
Jakub Jirutka
983629aaa2 Convert CommonJS to ES modules 2019-09-15 20:28:12 +02:00
Jakub Jirutka
d3b3bddf51 Use ES6 classes 2019-09-15 20:28:12 +02:00
Jakub Jirutka
3fcddfb836 Fix variable names to camelCase 2019-09-15 20:28:12 +02:00
Jakub Jirutka
94762b8216 Convert from ES5 to ES6 syntax using Lebab tool 2019-09-15 20:28:12 +02:00
Jakub Jirutka
213c197cd1 Remove spaces inside brackets 2019-09-15 20:28:12 +02:00
Jakub Jirutka
ef96ea9209 Replace double quotes with single quotes 2019-09-15 20:28:12 +02:00
Jakub Jirutka
143eaf5b4d Remove semicolons 2019-09-15 20:28:12 +02:00
Jakub Jirutka
17402cfd18 Change indentation to 2 spaces 2019-09-15 20:28:12 +02:00
Jakub Jirutka
30d55d9126 Remove IIFE wrapper 2019-09-15 20:28:12 +02:00
Jakub Jirutka
7bd698f837 Import source from notebookjs package
https://github.com/jsvine/notebookjs
2019-09-15 20:28:12 +02:00
Jakub Jirutka
b1f3ca8cb7 Prepare project 2019-09-15 20:28:11 +02:00
Jakub Jirutka
f258556f09 Initial commit 2019-08-28 23:53:26 +02:00