Commit graph

261 commits

Author SHA1 Message Date
Jakub Jirutka
20f4dec62c Release version 0.1.0-beta.2 2019-09-20 18:17:28 +02:00
Jakub Jirutka
745346150e Add module readNotebookTitle 2019-09-20 18:15:25 +02:00
Jakub Jirutka
526a7b51ea Fix wrong type of Notebook.nbformat 2019-09-18 13:18:00 +02:00
Jakub Jirutka
1d4dd89b21 Release version 0.1.0-beta.1 2019-09-18 00:00:05 +02:00
Jakub Jirutka
cee6f20158 Replace ansi_up with anser
It's smaller...
2019-09-17 23:54:58 +02:00
Jakub Jirutka
a944bf2d27 Pre-configure renderer with all external components 2019-09-17 23:54:58 +02:00
Jakub Jirutka
030b4297ba Add markdownRenderer with marked, katex and highlight.js 2019-09-17 23:54:58 +02:00
Jakub Jirutka
457e1716d9 mathExtractor: Escape marker-like sequences instead of returning them 2019-09-17 23:54:57 +02:00
Jakub Jirutka
34cf2c4620 Replace if-else-if statements with switch statement
I think that it's a bit more readable. But still, why TypeScript still
doesn't have pattern matching, only this crappy C-like switch? :(
2019-09-17 22:06:03 +02:00
Jakub Jirutka
86754fbd98 Reformat comments on renderer.Options 2019-09-17 22:06:03 +02:00
Jakub Jirutka
ca9bae9483 Don't escape math that will be passed to math renderer
KaTeX doesn't interpret escaped <>& correctly and it escapes unsafe
characters in the output implicitly.
2019-09-17 22:06:02 +02:00
Jakub Jirutka
18a7a512cc Don't escape text passed to codeHighlighter
highlight.js does it implicitly.
2019-09-16 23:08:32 +02:00
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