Commit graph

149 commits

Author SHA1 Message Date
Jakub Jirutka
e8ed255646 Don't escape text passed to ansiCodeRenderer
The current version of ansi_up does it implicitly.
2019-09-16 23:02:40 +02:00
Jakub Jirutka
431fb1331d CI: Add API Key for npm 2019-09-16 22:54:52 +02:00
Jakub Jirutka
016fae6eb8 mathExtractor: Parse extracted delimited expressions 2019-09-16 22:54:52 +02:00
Jakub Jirutka
cd11e47f54 mathExtractor: Improve docs and function names 2019-09-16 22:54:52 +02:00
Jakub Jirutka
327856497c mathExtractor: Don't modify delimiters in replaceMath() 2019-09-16 22:54:52 +02:00
Jakub Jirutka
4e15e76573 mathExtractor: Modernize and refactor 2019-09-16 22:54:52 +02:00
Jakub Jirutka
443603dd4f mathExtractor: Convert to TypeScript 2019-09-16 22:54:52 +02:00
Jakub Jirutka
464a0b24de mathExtractor: Remove unnecessary escapes in regexps 2019-09-16 22:54:52 +02:00
Jakub Jirutka
aa3b063413 mathExtractor: Change under_score names to camelCase 2019-09-16 22:54:52 +02:00
Jakub Jirutka
92e00f7df8 mathExtractor: Fix code-style
- semicolons
- indentation and alignment
- quotes
2019-09-16 22:54:52 +02:00
Jakub Jirutka
fceb1f8e23 Import math extractor utils from jupyter/notebook repository
Source copied from https://github.com/jupyter/notebook/blob/6.0.1/notebook/static/notebook/js/mathjaxutils.js
with the following modifications:

- indentation converted to 2 spaces
- init function removed
- MSE fix removed
2019-09-16 22:54:52 +02:00
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