Compare commits

...

45 commits
dev ... master

Author SHA1 Message Date
dependabot[bot]
35c1cd6141 Bump minimist from 1.2.5 to 1.2.6
Bumps [minimist](https://github.com/substack/minimist) from 1.2.5 to 1.2.6.
- [Release notes](https://github.com/substack/minimist/releases)
- [Commits](https://github.com/substack/minimist/compare/1.2.5...1.2.6)

---
updated-dependencies:
- dependency-name: minimist
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-06 14:09:33 +02:00
dependabot[bot]
6a4308cb11 Bump ajv from 6.11.0 to 6.12.6
Bumps [ajv](https://github.com/ajv-validator/ajv) from 6.11.0 to 6.12.6.
- [Release notes](https://github.com/ajv-validator/ajv/releases)
- [Commits](https://github.com/ajv-validator/ajv/compare/v6.11.0...v6.12.6)

---
updated-dependencies:
- dependency-name: ajv
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-02-12 17:48:34 +01:00
Jakub Jirutka
a865a53327
Add FUNDING.yml 2021-12-28 11:35:23 +01:00
dependabot[bot]
e5bcf84b3c Bump tmpl from 1.0.4 to 1.0.5
Bumps [tmpl](https://github.com/daaku/nodejs-tmpl) from 1.0.4 to 1.0.5.
- [Release notes](https://github.com/daaku/nodejs-tmpl/releases)
- [Commits](https://github.com/daaku/nodejs-tmpl/commits/v1.0.5)

---
updated-dependencies:
- dependency-name: tmpl
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-11-15 18:55:20 +01:00
dependabot[bot]
3d93c7fdf5 Bump tar from 5.0.5 to 5.0.10
Bumps [tar](https://github.com/npm/node-tar) from 5.0.5 to 5.0.10.
- [Release notes](https://github.com/npm/node-tar/releases)
- [Changelog](https://github.com/npm/node-tar/blob/main/CHANGELOG.md)
- [Commits](https://github.com/npm/node-tar/compare/v5.0.5...v5.0.10)

---
updated-dependencies:
- dependency-name: tar
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-11-15 18:53:23 +01:00
dependabot[bot]
050e4515ca Bump path-parse from 1.0.6 to 1.0.7
Bumps [path-parse](https://github.com/jbgutierrez/path-parse) from 1.0.6 to 1.0.7.
- [Release notes](https://github.com/jbgutierrez/path-parse/releases)
- [Commits](https://github.com/jbgutierrez/path-parse/commits/v1.0.7)

---
updated-dependencies:
- dependency-name: path-parse
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-11-15 18:49:49 +01:00
Jakub Jirutka
dd783a0daf CI: Replace Travis with GitHub Actions 2021-06-12 01:31:49 +02:00
Jakub Jirutka
6c26d381f0 Bump katex from 0.11.1 to 0.13.11 2021-06-12 00:40:40 +02:00
Jakub Jirutka
e1ba5039e4 Bump ansi_up from 4.0.4 to 5.0.1 2021-06-12 00:24:30 +02:00
Jakub Jirutka
1defdcd4ca Don't use deprecated highlight.js API
Deprecated as of 10.7.0. highlight(lang, code, ...args) has been deprecated.

    Deprecated as of 10.7.0. Please use highlight(code, options) instead.
    https://github.com/highlightjs/highlight.js/issues/2277
2021-06-12 00:24:30 +02:00
Jakub Jirutka
ccf16ab7c6 Remove @types/highlight.js (not needed anymore)
highlight.js already provides TypeScript types.
2021-06-12 00:13:22 +02:00
Jakub Jirutka
3eee5ebd60 Bump highlight.js from 10.1.1 to 10.7.3 2021-06-11 23:58:20 +02:00
Jakub Jirutka
8bd46774dd Bump marked from 1.0.0 to 2.0.7
Resolves #22
2021-06-11 23:47:33 +02:00
dependabot[bot]
b7216ab089 Bump acorn from 6.4.0 to 6.4.2
Bumps [acorn](https://github.com/acornjs/acorn) from 6.4.0 to 6.4.2.
- [Release notes](https://github.com/acornjs/acorn/releases)
- [Commits](https://github.com/acornjs/acorn/compare/6.4.0...6.4.2)

---
updated-dependencies:
- dependency-name: acorn
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-11 23:47:33 +02:00
dependabot[bot]
a182883320 Bump glob-parent from 5.1.0 to 5.1.2
Bumps [glob-parent](https://github.com/gulpjs/glob-parent) from 5.1.0 to 5.1.2.
- [Release notes](https://github.com/gulpjs/glob-parent/releases)
- [Changelog](https://github.com/gulpjs/glob-parent/blob/main/CHANGELOG.md)
- [Commits](https://github.com/gulpjs/glob-parent/compare/v5.1.0...v5.1.2)

---
updated-dependencies:
- dependency-name: glob-parent
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-11 23:47:33 +02:00
dependabot[bot]
fd04dc508d Bump ws from 7.2.1 to 7.4.6
Bumps [ws](https://github.com/websockets/ws) from 7.2.1 to 7.4.6.
- [Release notes](https://github.com/websockets/ws/releases)
- [Commits](https://github.com/websockets/ws/compare/7.2.1...7.4.6)

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-11 23:47:33 +02:00
dependabot[bot]
953ca11aa8 Bump browserslist from 4.8.5 to 4.16.6
Bumps [browserslist](https://github.com/browserslist/browserslist) from 4.8.5 to 4.16.6.
- [Release notes](https://github.com/browserslist/browserslist/releases)
- [Changelog](https://github.com/browserslist/browserslist/blob/main/CHANGELOG.md)
- [Commits](https://github.com/browserslist/browserslist/compare/4.8.5...4.16.6)

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-11 23:47:33 +02:00
dependabot[bot]
9d528485ab Bump hosted-git-info from 2.8.5 to 2.8.9
Bumps [hosted-git-info](https://github.com/npm/hosted-git-info) from 2.8.5 to 2.8.9.
- [Release notes](https://github.com/npm/hosted-git-info/releases)
- [Changelog](https://github.com/npm/hosted-git-info/blob/v2.8.9/CHANGELOG.md)
- [Commits](https://github.com/npm/hosted-git-info/compare/v2.8.5...v2.8.9)

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-11 23:47:33 +02:00
dependabot[bot]
32c109f1d0 Bump lodash from 4.17.19 to 4.17.21
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.19 to 4.17.21.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.19...4.17.21)

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-11 23:47:33 +02:00
dependabot[bot]
122471a52f Bump y18n from 4.0.0 to 4.0.1
Bumps [y18n](https://github.com/yargs/y18n) from 4.0.0 to 4.0.1.
- [Release notes](https://github.com/yargs/y18n/releases)
- [Changelog](https://github.com/yargs/y18n/blob/master/CHANGELOG.md)
- [Commits](https://github.com/yargs/y18n/commits)

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-11 23:47:33 +02:00
Jakub Jirutka
fbecff633a Release version 0.3.0 2020-10-28 18:51:56 +01:00
Jakub Jirutka
5ec93ba9e4 Patch yarn-version-bump to fix compatibility with yarn 1.22.4 2020-10-28 18:50:52 +01:00
dependabot[bot]
9f43fc595c Bump lodash from 4.17.15 to 4.17.19
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.15 to 4.17.19.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.15...4.17.19)

Signed-off-by: dependabot[bot] <support@github.com>
2020-10-28 18:37:06 +01:00
Jakub Jirutka
b363818364 CI: Add Node.js 14 to build matrix 2020-10-28 18:32:06 +01:00
Jakub Jirutka
f5a283ba72 Adjust ESLint rule @typescript-eslint/ban-types - allow {} and object 2020-06-21 13:19:44 +02:00
Jakub Jirutka
ec76650a93 Disable ESLint rule import/order
When there are local typings for a third-party module, this rule classifies
import from the module as local instead of external.

See Also:
- 7e35810c7f
- bbbcd2398e
- 381caf644d
2020-06-21 13:11:09 +02:00
Jakub Jirutka
6ca8858d64 Disable ESLint rule @typescript-eslint/no-invalid-void-type 2020-06-21 12:29:08 +02:00
Jakub Jirutka
6944ff1b82 Move ipynb2html's devDependencies from parent to ipynb2html package 2020-06-21 11:08:04 +02:00
Jakub Jirutka
7fbd5b5d8b Bump all devDependencies to their latest minor version 2020-06-21 01:23:40 +02:00
Jakub Jirutka
a31ddbe203 Enable more ESLint rules 2020-06-21 01:23:40 +02:00
Jakub Jirutka
2f3d7ae4c6 Fix default HTML title in CLI 2020-06-21 01:23:40 +02:00
Jakub Jirutka
49d16ec079 Use no delimiter for members in interfaces 2020-06-21 01:23:40 +02:00
Jakub Jirutka
d29f006090 Bump eslint and its plugins, update rules and fix new violations 2020-06-21 01:23:39 +02:00
Jakub Jirutka
0b098983b5 Bump @types/node from ^10.13.0 to ^10.17.25 2020-06-21 00:46:08 +02:00
Jakub Jirutka
5f7c2dfb4b Bump typescript from ~3.7.5 to ~3.9.5 2020-06-21 00:46:08 +02:00
Jakub Jirutka
06ab09f278 Bump rollup from 1.x to 2.x and its plugins 2020-06-21 00:43:49 +02:00
Jakub Jirutka
110c8ca82a Use property signature syntax for methods
See 4c9293bd5e/packages/eslint-plugin/docs/rules/method-signature-style.md
2020-06-20 12:47:35 +02:00
Jakub Jirutka
d9bea2feb2 Bump highlight.js to 10.1.1 2020-06-17 00:39:07 +02:00
Jakub Jirutka
76c9a1e67f Bump node-html-parser from ^1.2.14 to ^1.2.19 2020-06-17 00:37:12 +02:00
Jakub Jirutka
9685b5d8b8 Bump marked to 1.0.0
The latest version is 1.1.0 but they changed rendering of img from
`<img ...>` to `<img ... />` which breaks our tests.
2020-06-17 00:37:07 +02:00
Jakub Jirutka
1d9ce38eb4 Bump @types/marked from ^0.7.2 to ^0.7.4 2020-06-15 18:07:56 +02:00
Jakub Jirutka
e4549711f1 Fix font-size of <h1> inside <section>
See https://stackoverflow.com/a/26291186/2217862.
2020-04-19 19:10:15 +02:00
Jakub Jirutka
3a312385f6 Wrap cells in <section> instead of <div> 2020-04-19 18:50:36 +02:00
Jakub Jirutka
19b41d9c22 Allow to include own style(s) into HTML produced by CLI
Resolves #6
2020-04-19 18:23:50 +02:00
Jakub Jirutka
6461e84fe7 Bump @babel/* from ^7.8.7 to ^7.9.0
This should fix build error on Node.js 13,
https://www.reddit.com/r/Nuxt/comments/g32jr5/babel_breaking_changes/.
2020-04-19 18:19:27 +02:00
37 changed files with 2145 additions and 2205 deletions

View file

@ -28,7 +28,6 @@ module.exports = {
},
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'standard-with-typescript',
@ -37,52 +36,63 @@ module.exports = {
],
rules: {
'comma-dangle': ['error', 'always-multiline'],
// Disable in favour of TypeScript rule.
'func-call-spacing': 'off',
'linebreak-style': ['error', 'unix'],
'lines-between-class-members': 'off',
// Disable in favour of TypeScript rule.
'no-extra-semi': 'off',
// Changed from error to warn and enabled ignoreEOLComments.
'no-multi-spaces': ['warn', {
ignoreEOLComments: true,
}],
// Changed from error to warn and adjusted options.
'no-multiple-empty-lines': ['warn', {
max: 2,
maxEOF: 1,
maxBOF: 1,
}],
'no-template-curly-in-string': 'off',
// Changed from 'after' to 'before'.
'operator-linebreak': ['error', 'before'],
// Changed from error and all 'never' to warn and switches 'never'.
'padded-blocks': ['warn', {
switches: 'never',
}],
// Changed from 'as-needed' to 'consistent-as-needed'.
'quote-props': ['error', 'consistent-as-needed'],
// Disable in favour of TypeScript rule.
'semi': 'off',
// Import
// Some packages have wrong type declarations.
'import/default': 'off',
'import/newline-after-import': 'warn',
'import/no-absolute-path': 'error',
// This rule disallows using both wildcard and selective imports from the same module.
'import/no-duplicates': 'off',
// Some packages has it wrong in type declarations (e.g. katex, marked).
// Some packages have it wrong in type declarations (e.g. katex, marked).
'import/no-named-as-default-member': 'off',
'import/order': ['warn', {
'groups': [['builtin', 'external']],
'newlines-between': 'always-and-inside-groups',
}],
// TypeScript
// Changed options.
'@typescript-eslint/ban-types': ['error', {
// Allow to use {} and object - they are actually useful.
types: {
'{}': false,
'object': false,
},
extendDefaults: true,
}],
'@typescript-eslint/class-literal-property-style': ['error', 'fields'],
// Changed from error to off.
'@typescript-eslint/consistent-type-definitions': 'off',
// Changed from error to off.
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-member-accessibility': ['warn', {
'@typescript-eslint/explicit-member-accessibility': ['error', {
accessibility: 'no-public',
overrides: {
parameterProperties: 'off',
},
}],
'@typescript-eslint/func-call-spacing': ['error', 'never'],
// Changed from warn to error and adjusted options.
'@typescript-eslint/explicit-module-boundary-types': ['error', {
allowArgumentsExplicitlyTypedAsAny: true,
}],
'@typescript-eslint/indent': ['error', 2, {
SwitchCase: 1,
VariableDeclarator: 1,
@ -101,34 +111,55 @@ module.exports = {
flatTernaryExpressions: true,
ignoreComments: false,
}],
// Changed from error to warn.
'@typescript-eslint/lines-between-class-members': 'warn',
// Changed delimiter for type literals from none to comma.
// The reason is just aesthetic symmetry with object literals.
'@typescript-eslint/member-delimiter-style': ['error', {
multiline: { delimiter: 'comma', requireLast: true },
singleline: { delimiter: 'comma', requireLast: false },
overrides: {
interface: {
multiline: { delimiter: 'none' },
},
},
}],
'@typescript-eslint/member-ordering': 'warn',
// Changed from warn to off.
'@typescript-eslint/no-explicit-any': 'off',
// Changed from error to warn.
'@typescript-eslint/no-extra-semi': 'warn',
// It disallows using void even in valid cases.
'@typescript-eslint/no-invalid-void-type': 'off',
// Changed from error to warn.
'@typescript-eslint/no-namespace': 'warn',
// Changed from error to warn.
'@typescript-eslint/no-non-null-assertion': 'warn',
'@typescript-eslint/no-require-imports': 'error',
// Changed from error to warn.
'@typescript-eslint/no-unsafe-assignment': 'warn',
// Changed from error to warn.
'@typescript-eslint/no-unsafe-member-access': 'warn',
// Disabled in favour of the next rule.
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars-experimental': 'error',
// Changed options.
'@typescript-eslint/no-use-before-define': ['error', {
classes: true,
functions: false,
typedefs: false,
variables: true,
}],
'@typescript-eslint/prefer-for-of': 'warn',
// Changed from error to warn.
'@typescript-eslint/prefer-includes': 'warn',
// Changed from error to warn.
'@typescript-eslint/prefer-regexp-exec': 'warn',
'@typescript-eslint/prefer-string-starts-ends-with': 'warn',
'@typescript-eslint/promise-function-async': ['error', {
allowAny: true,
}],
// It has too many false positives.
'@typescript-eslint/restrict-template-expressions': 'off',
'@typescript-eslint/semi': ['error', 'never'],
// Changed from error to off.
'@typescript-eslint/strict-boolean-expressions': 'off',
'@typescript-eslint/switch-exhaustiveness-check': 'error',
// Changed from error to warn and adjusted options.
'@typescript-eslint/unbound-method': ['warn', {
ignoreStatic: true,
}],
@ -144,9 +175,9 @@ module.exports = {
objects: 'always-multiline',
imports: 'always-multiline',
exports: 'always-multiline',
// Changed to not require comma in a multiline expect().
functions: 'only-multiline',
}],
'comma-spacing': 'off',
'object-curly-spacing': 'off',
'no-multi-spaces': 'off',
'standard/array-bracket-even-spacing': 'off',
@ -154,6 +185,10 @@ module.exports = {
'space-in-parens': 'off',
// jest.mock() must be above imports.
'import/first': 'off',
'@typescript-eslint/comma-spacing': 'off',
// False positive on expect() functions.
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-return': 'warn',
},
},
],

3
.github/FUNDING.yml vendored Normal file
View file

@ -0,0 +1,3 @@
# These are supported funding model platforms
github: jirutka

68
.github/workflows/ci.yml vendored Normal file
View file

@ -0,0 +1,68 @@
name: CI
on:
- push
- pull_request
jobs:
test:
name: Test on Node.js ${{ matrix.node-version }}
runs-on: ubuntu-20.04
strategy:
matrix:
node-version: [10, 12, 13, 14]
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # fetch all history to make `git describe` work
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- run: yarn install
- run: yarn build
- run: yarn bundle
- run: yarn test
- run: yarn lint
publish:
name: Publish to npmjs and GitHub Releases
needs: [test]
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # fetch all history to make `git describe` work
- run: sudo apt-get install asciidoctor pandoc
- uses: actions/setup-node@v2
with:
node-version: 14
registry-url: https://registry.npmjs.org
- run: yarn install
- name: Generate source tarball
run: ./scripts/create-src-tarball dist/ipynb2html-${GITHUB_REF/refs\/tags\//}-src.tar.gz
- run: yarn build
- run: yarn bundle
- name: Publish packages to npmjs
run: yarn publish-all --non-interactive
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Upload tarballs to Releases
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
fail_on_unmatched_files: true
files: |
dist/*.tar.gz
packages/ipynb2html-cli/dist/*.tar.gz
packages/ipynb2html-cli/dist/*.zip

View file

@ -1,56 +0,0 @@
dist: bionic
language: node_js
node_js:
- '13'
- '12'
- '10'
- lts/*
- node
addons:
apt:
packages:
- asciidoctor
- pandoc
env:
global:
- secure: "DrPA1eYBRjS+1/w/sRq/r5wQyOewuh1PGPzFtQR62TJeAyO6AvKQ6wfesxMA898b+0D3SCNxrCVK12XB3auySEOZocQuN7N51hsteA/QtPoBBbnoHy8Dap2YbiJ5fbCVnM/Wl/Z2rZmQWFBM3rmqXggCyEhKEw3kkz8WMm/7UCGVxmoHUelpMnDEII0RiJdPCGT19IA90KpJDsqbSzTVY+TsqjSNuN91LQ23ApwSHKklvbvKWxcgrtAzJDXLeS9CS3QqSHucurOM2Kpv0umOkBzds4da+NtWKYZC3XxThmMB5wT7b60EZPIc/iFftQFy2qiDAFxeGN+j9kwsNX68aXl4MuCGlzdvGj0KkeXYYhl1Jusc30uTzXYMlz2b3u+AcsMLLxFs2HvUU94SpAfe9VrarSnQK+6CZz0eCtF/NCCi6J9GqlBTsqzZDmdVaJpFDG1FidC4Ka9FcteKcWXqffowQ5KjIhqaearSmRESMqepV7T8tDUCb217PE0C+L0NGfg6RaY4DtGsJAawDeh/09aXrP6NakAKjWUfaJqjhkMexB8JTb+yanjVXsgj4VUfvTgvWjMi+yU3DIfopL+mawvgckRRL9DTEIf5ICjSruyEH8FWEz+kMzas41zboabR12YMLuorHfgZu31DiDsJkSD292t/lwWW6oybRl0iJBk=" # NPM_TOKEN=ceed......2bf2
cache: yarn
install:
- yarn install
- test -z "$TRAVIS_TAG" || ./scripts/create-src-tarball dist/ipynb2html-$TRAVIS_TAG-src.tar.gz
script:
- yarn run build
- yarn run bundle
- yarn run test
- yarn run lint
before_deploy:
- echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}' >> "$HOME"/.npmrc
deploy:
- provider: script
script: yarn publish-all --non-interactive
skip_cleanup: true
on:
repo: jirutka/ipynb2html
tags: true
node_js: '10'
- provider: releases
api_key:
secure: j5Ks+lUUE2NkUKKC4A+FRKVia3oRyanMKp25jZwF2jLOQxZp0/BggNOduw7zMLzPizmMbz7CkYV/pLyXH+rwCjOdQPnSGLorzfp6ztzG49SqPUK5i5PdSctYT7+C2HdYR25xtw6f06HXzLWTIeYb0JG+5pUCkI4R+z1JEqZhx3PMOkAx9Ec9UoYNKcbHe1E78y8zH0pDccVJ1ejrbmizEqZALpYNR+qCWhTfLVbwYlpJJGIKCIXVYI9tU/3y/6JOO+gCX2m8jqNVBPrwWWD//gGExn2lR6BK0WiXTE71FbM7GyVjoeh93Zg1WifF+7DBtaTI9qs+928afLn28AcWqB6P/HgoRgt/4oLvJU2hkdkIoNqQONqYZeglW1A5qYp6T3nURLpcn1cg2yBD6vNi8cet4ntgOsPu9Soa8pzsm9xcITMJNUlFOEWyYPyvgTXHUjZwbZvrZHRVYeHrDOuq9EEAz+11u1FYG49uSBZf3+H6CmL7n2qeoYhlMhT94bgIkF4ByFmP+OTUcMcWvDdA7uD8JqPMaxQI0hhjrszxPT7C5YNXsJ1Q0vU2zZSMF74fygsXlnr6VeqwxSzgF/6mAAuSwtKSg/pFPPLdevIeehw4oLCz+ZdxVk5kpfymKvqvueDdMMoV4Fse4Yhv81Z76tAPM35TtqJa77DJwqOVOCE=
file_glob: true
file:
- dist/*.tar.gz
- packages/ipynb2html-cli/dist/*.tar.gz
- packages/ipynb2html-cli/dist/*.zip
skip_cleanup: true
on:
repo: jirutka/ipynb2html
tags: true
node_js: '10'

View file

@ -2,15 +2,15 @@
:npm-name: ipynb2html
:gh-name: jirutka/{npm-name}
:gh-branch: master
:version: 0.2.1
:ansiup-version: 4.0.4
:hljs-version: 9.15.10
:katex-version: 0.11.1
:marked-version: 0.7.0
:version: 0.3.0
:ansiup-version: 5.0.1
:hljs-version: 10.7.3
:katex-version: 0.13.11
:marked-version: 2.0.7
:vs-marketplace-uri: https://marketplace.visualstudio.com/items?itemName=
ifdef::env-github[]
image:https://travis-ci.com/{gh-name}.svg?branch={gh-branch}[Build Status, link="https://travis-ci.com/{gh-name}"]
image:https://github.com/{gh-name}/workflows/CI/badge.svg[CI Status, link=https://github.com/{gh-name}/actions?query=workflow%3A%22CI%22]
endif::env-github[]
{npm-name} is a converter (renderer) of the https://nbformat.readthedocs.io/en/stable/[Jupyter Notebook Format] 4.0+ to static HTML.

View file

@ -7,11 +7,11 @@
<link rel="stylesheet" href="../packages/ipynb2html/dist/notebook.min.css">
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.min.css"
href="https://cdn.jsdelivr.net/npm/katex@0.13.11/dist/katex.min.css"
crossorigin="anonymous">
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@9.15.10/build/styles/default.min.css"
href="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@10.7.3/build/styles/default.min.css"
crossorigin="anonymous">
<script defer src="../packages/ipynb2html/dist/ipynb2html-full.js" onload="ipynb2html.autoRender();"></script>
<style>

View file

@ -7,16 +7,16 @@
<link rel="stylesheet" href="../packages/ipynb2html/dist/notebook.min.css">
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.min.css"
href="https://cdn.jsdelivr.net/npm/katex@0.13.11/dist/katex.min.css"
crossorigin="anonymous">
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@9.15.10/build/styles/default.min.css"
href="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@10.7.3/build/styles/default.min.css"
crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/marked@0.7.0/marked.min.js" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/ansi_up@4.0.4/ansi_up.js" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@9.15.10/build/highlight.min.js" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.min.js" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/marked@2.0.7/marked.min.js" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/ansi_up@5.0.1/ansi_up.js" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@10.7.3/build/highlight.min.js" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/katex@0.13.11/dist/katex.min.js" crossorigin="anonymous"></script>
<script defer src="../packages/ipynb2html/dist/ipynb2html.js" onload="ipynb2html.autoRender();"></script>
<style>
html, body {

View file

@ -1,6 +1,6 @@
{
"name": "ipynb2html-parent",
"version": "0.2.1",
"version": "0.3.0",
"private": true,
"scripts": {
"build": "ttsc --build",
@ -17,56 +17,52 @@
"node": ">=10.13.0"
},
"devDependencies": {
"@babel/core": "^7.8.7",
"@babel/preset-env": "^7.8.7",
"@rollup/plugin-commonjs": "^11.0.1",
"@rollup/plugin-node-resolve": "^7.0.0",
"@babel/core": "^7.10.3",
"@babel/preset-env": "^7.10.3",
"@rollup/plugin-babel": "^5.0.3",
"@rollup/plugin-commonjs": "^13.0.0",
"@rollup/plugin-node-resolve": "^8.0.1",
"@types/dedent": "^0.7.0",
"@types/highlight.js": "^9.12.3",
"@types/jest": "^24.9.0",
"@types/katex": "^0.11.0",
"@types/marked": "^0.7.2",
"@types/node": "^10.13.0",
"@typescript-eslint/eslint-plugin": "^2.17.0",
"@typescript-eslint/parser": "^2.17.0",
"ansi_up": "^4.0.4",
"@types/jest": "^24.9.1",
"@types/node": "^10.17.25",
"@typescript-eslint/eslint-plugin": "^3.3.0",
"@typescript-eslint/parser": "^3.3.0",
"arrify": "^2.0.1",
"common-path-prefix": "^3.0.0",
"core-js": "^3.6.4",
"core-js": "^3.6.5",
"csso-cli": "^3.0.0",
"dedent": "^0.7.0",
"eslint": "^6.8.0",
"eslint-config-standard-with-typescript": "^12.0.1",
"eslint": "^7.3.0",
"eslint-config-standard-with-typescript": "^18.0.2",
"eslint-import-resolver-typescript": "^2.0.0",
"eslint-plugin-import": "^2.20.0",
"eslint-plugin-node": "^11.0.0",
"eslint-plugin-import": "^2.21.2",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.0",
"fs-extra": "^8.1.0",
"jest": "^25.1.0",
"jest-chain": "^1.1.2",
"node-html-parser": "^1.2.14",
"jest": "^25.5.4",
"jest-chain": "^1.1.5",
"node-html-parser": "^1.2.19",
"nodom": "^2.3.0",
"npm-run-all": "^4.1.5",
"patch-package": "^6.2.0",
"postinstall-postinstall": "^2.0.0",
"rimraf": "^3.0.0",
"rollup": "^1.29.1",
"patch-package": "^6.2.2",
"postinstall-postinstall": "^2.1.0",
"rimraf": "^3.0.2",
"rollup": "^2.17.1",
"rollup-plugin-add-git-msg": "^1.1.0",
"rollup-plugin-babel": "^4.3.3",
"rollup-plugin-executable": "^1.5.2",
"rollup-plugin-node-externals": "^2.1.3",
"rollup-plugin-executable": "^1.6.0",
"rollup-plugin-node-externals": "^2.2.0",
"rollup-plugin-node-license": "^0.2.0",
"rollup-plugin-terser": "^5.2.0",
"rollup-plugin-typescript2": "^0.25.3",
"tar": "^5.0.5",
"ts-jest": "^25.0.0",
"ts-node": "^8.6.2",
"rollup-plugin-terser": "^6.1.0",
"rollup-plugin-typescript2": "^0.27.1",
"tar": "^5.0.10",
"ts-jest": "^25.5.1",
"ts-node": "^8.10.2",
"ts-transformer-export-default-name": "^0.1.0",
"ts-transformer-inline-file": "^0.1.1",
"ttypescript": "^1.5.10",
"typescript": "~3.7.5",
"wsrun": "^5.2.0",
"typescript": "~3.9.5",
"wsrun": "^5.2.1",
"yarn-version-bump": "^0.0.3",
"yazl": "^2.5.1"
},

View file

@ -1,6 +1,6 @@
{
"name": "ipynb2html-cli",
"version": "0.2.1",
"version": "0.3.0",
"description": "CLI tool for converting Jupyter Notebooks to static HTML",
"author": "Jakub Jirutka <jakub@jirutka.cz>",
"license": "MIT",
@ -41,8 +41,8 @@
"node": ">=10.13.0"
},
"dependencies": {
"ipynb2html": "0.2.1",
"minimist": "^1.2.5",
"ipynb2html": "0.3.0",
"minimist": "^1.2.6",
"minimist-options": "^4.0.2",
"nodom": "^2.3.0",
"source-map-support": "^0.5.16"

View file

@ -26,9 +26,6 @@ export default {
incremental: true,
},
},
// This is needed for node-license plugin. :(
// https://github.com/ezolenko/rollup-plugin-typescript2#plugins-using-asyncawait
objectHashIgnoreUnknownHack: true,
clean: true,
}),
// Make node builtins external.

View file

@ -3,14 +3,17 @@ import minimist from 'minimist'
import minimistOptions from 'minimist-options'
import { Document } from 'nodom'
import { exit } from 'process'
import { $INLINE_JSON } from 'ts-transformer-inline-file'
import { $INLINE_FILE, $INLINE_JSON } from 'ts-transformer-inline-file'
import * as ipynb2html from 'ipynb2html'
import renderPage from './page'
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const { version, bugs: bugsUrl } = $INLINE_JSON('../package.json')
const notebookCss = $INLINE_FILE('../../ipynb2html/styles/notebook.css')
const pageCss = $INLINE_FILE('./page.css')
const progName = 'ipynb2html'
const helpMsg = `\
@ -24,13 +27,20 @@ Arguments:
provided, the output will be written to STDOUT.
Options:
-d --debug Print debug messages.
-h --help Show this message and exit.
-V --version Print version and exit.
-d --debug Print debug messages.
-s --style <file,...> Comma separated stylesheet(s) to embed into the output
HTML. The stylesheet may be a path to a CSS file,
"@base" for the base ipynb2html style, or "@default"
for the default full page style. Default is @default.
-h --help Show this message and exit.
-V --version Print version and exit.
Exit Codes:
1 Generic error code.
2 Missing required arguments or invalid option.
1 Generic error code.
2 Missing required arguments or invalid option.
Please report bugs at <${bugsUrl}>.
`
@ -39,9 +49,14 @@ function logErr (msg: string): void {
console.error(`${progName}: ${msg}`)
}
function arrify <T> (obj: T | T[]): T[] {
return Array.isArray(obj) ? obj : [obj]
}
function parseCliArgs (argv: string[]) {
const opts = minimist(argv, minimistOptions({
debug: { alias: 'd', type: 'boolean' },
style: { alias: 's', type: 'string', default: '@default' },
version: { alias: 'V', type: 'boolean' },
help: { alias: 'h', type: 'boolean' },
arguments: 'string',
@ -73,24 +88,35 @@ function parseCliArgs (argv: string[]) {
const [input, output] = opts._
return {
styles: arrify(opts.style).join(',').split(/,\s*/),
debug: opts.debug as boolean,
input: input === '-' ? 0 : input, // 0 = stdin
output,
}
}
function loadStyle (name: string): string {
switch (name) {
case '@base': return notebookCss
case '@default': return pageCss + notebookCss
default: return fs.readFileSync(name, 'utf8')
}
}
export default (argv: string[]): void => {
const opts = parseCliArgs(argv)
try {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const notebook = JSON.parse(fs.readFileSync(opts.input, 'utf-8'))
const style = opts.styles.map(loadStyle).join('\n')
const title = ipynb2html.readNotebookTitle(notebook) ?? 'Notebook'
const title = ipynb2html.readNotebookTitle(notebook) || 'Notebook'
const renderNotebook = ipynb2html.createRenderer(new Document())
const contents = renderNotebook(notebook).outerHTML
const html = renderPage(contents, title)
const html = renderPage({ contents, title, style })
if (opts.output) {
fs.writeFileSync(opts.output, html)
@ -101,7 +127,7 @@ export default (argv: string[]): void => {
if (opts.debug) {
console.debug(err)
} else {
logErr(err.message)
logErr((err as Error).message)
}
return exit(1)
}

View file

@ -15,6 +15,9 @@ h1, h2, h3, h4, h5, h6 {
margin-top: 1.6em;
position: relative;
}
h1 {
font-size: 2em;
}
h1 .anchor,
h2 .anchor,

View file

@ -1,11 +1,13 @@
import { version } from 'ipynb2html'
import { $INLINE_FILE } from 'ts-transformer-inline-file'
const notebookCss = $INLINE_FILE('../../ipynb2html/styles/notebook.css')
const pageCss = $INLINE_FILE('./page.css')
export default (contents: string, title: string): string => `\
export type Options = {
contents: string,
title: string,
style: string,
}
export default ({ contents, title, style }: Options): string => `\
<!DOCTYPE html>
<html>
<head>
@ -14,15 +16,15 @@ export default (contents: string, title: string): string => `\
<meta name="generator" content="ipynb2html ${version}">
<title>${title}</title>
<link rel="stylesheet"
href="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@9.15.10/build/styles/default.min.css"
integrity="sha384-ut3ELVx81ErZQaaMTknSmGb0CEGAKoBFTamRcY1ddG4guN0aoga4C+B6B7Kv1Ll1"
href="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@10.7.3/build/styles/default.min.css"
integrity="sha384-s4RLYRjGGbVqKOyMGGwfxUTMOO6D7r2eom7hWZQ6BjK2Df4ZyfzLXEkonSm0KLIQ"
crossorigin="anonymous">
<link rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/katex@0.11.0/dist/katex.min.css"
integrity="sha384-BdGj8xC2eZkQaxoQ8nSLefg4AV4/AwB3Fj+8SUSo7pnKP6Eoy18liIKTPn9oBYNG"
href="https://cdn.jsdelivr.net/npm/katex@0.13.11/dist/katex.min.css"
integrity="sha384-Um5gpz1odJg5Z4HAmzPtgZKdTBHZdw8S29IecapCSB31ligYPhHQZMIlWLYQGVoc"
crossorigin="anonymous">
<style>
${(pageCss + notebookCss).slice(0, -1).replace(/\n\n/g, '\n').replace(/^/gm, ' ')}
${style.replace(/\n\n/g, '\n').replace(/\n$/, '').replace(/^/gm, ' ')}
</style>
</head>
<body>

View file

@ -1,6 +1,6 @@
{
"name": "ipynb2html-core",
"version": "0.2.1",
"version": "0.3.0",
"description": "Convert Jupyter Notebook to static HTML",
"author": "Jakub Jirutka <jakub@jirutka.cz>",
"license": "MIT",

View file

@ -4,8 +4,8 @@ type Attributes = { [k: string]: string }
// for this module's function.
export type MinimalElement = {
innerHTML: string,
setAttribute (name: string, value: string): void,
appendChild (child: any): any,
setAttribute: (name: string, value: string) => void,
appendChild: (child: any) => unknown,
}
export type ElementCreator<TElement = HTMLElement> =

View file

@ -1,22 +1,27 @@
const htmlEntities = {
const htmlEntities: Record<string, string> = {
'&': '&amp;',
'<': '&lt;',
'>': '&gt;',
}
type CallableConstructor = new <T> () => T extends { __call__: Function }
type Callable = (...args: any[]) => any
type CallableConstructor = new <T> () => T extends { __call__: Callable }
? T['__call__']
: 'subclass does not implement method __call__'
/* eslint-disable @typescript-eslint/no-unsafe-assignment,
@typescript-eslint/no-unsafe-member-access,
@typescript-eslint/ban-types */
export const CallableInstance: CallableConstructor = function Callable (
this: object,
): Function {
): Callable {
const func = this.constructor.prototype.__call__ as Function
const func = this.constructor.prototype.__call__ as Callable
const cls = function (...args: any[]) {
return func.apply(cls, args)
return func.apply(cls, args) as unknown
}
Object.setPrototypeOf(cls, this.constructor.prototype)
@ -33,13 +38,16 @@ export const CallableInstance: CallableConstructor = function Callable (
return cls
} as any
CallableInstance.prototype = Object.create(Function.prototype)
/* eslint-enable @typescript-eslint/no-unsafe-assignment,
@typescript-eslint/no-unsafe-member-access,
@typescript-eslint/ban-types */
/**
* Escapes characters with special meaning in HTML with the corresponding
* HTML entities.
*/
export function escapeHTML (str: string): string {
return str.replace(/[&<>]/g, c => (htmlEntities as any)[c])
return str.replace(/[&<>]/g, c => htmlEntities[c])
}
/**

View file

@ -1,78 +1,79 @@
// These types are based on https://github.com/jupyter/nbformat/blob/b6b5a18e5a40d37f1cc0f71f65108288bdec9bb7/nbformat/v4/nbformat.v4.schema.json.
// This file was originally generated using json-schema-to-typescript 7.0.0 and
// then manually polished.
/* eslint-disable @typescript-eslint/member-ordering */
/** Jupyter Notebook v4.3. */
export interface Notebook {
/** Notebook root-level metadata. */
metadata: NotebookMetadata,
metadata: NotebookMetadata
/** Notebook format (minor number). Incremented for backward compatible changes to the notebook format. */
nbformat_minor: number,
nbformat_minor: number
/** Notebook format (major number). Incremented between backwards incompatible changes to the notebook format. */
nbformat: 4,
nbformat: 4
/** Array of cells of the current notebook. */
cells: Cell[],
cells: Cell[]
}
/** Notebook root-level metadata. */
export interface NotebookMetadata {
/** Kernel information. */
kernelspec?: KernelSpec,
kernelspec?: KernelSpec
/** Kernel information. */
language_info?: LanguageInfo,
language_info?: LanguageInfo
/** Original notebook format (major number) before converting the notebook between versions. This should never be written to a file. */
orig_nbformat?: number,
orig_nbformat?: number
/** The title of the notebook document */
title?: string,
title?: string
/** The author(s) of the notebook document */
authors?: any[],
authors?: any[]
/** Extra properties. */
[key: string]: any,
[key: string]: any
}
/** Kernel information. */
export interface KernelSpec {
/** Name of the kernel specification. */
name: string,
name: string
/** Name to display in UI. */
display_name: string,
display_name: string
/** Extra properties. */
[key: string]: any,
[key: string]: any
}
/** Kernel information. */
export interface LanguageInfo {
/** The programming language which this kernel runs. */
name: string,
name: string
/** The codemirror mode to use for code in this language. */
codemirror_mode?: string | { [k: string]: any },
codemirror_mode?: string | { [k: string]: any }
/** The file extension for files in this language. */
file_extension?: string,
file_extension?: string
/** The mimetype corresponding to files in this language. */
mimetype?: string,
mimetype?: string
/** The pygments lexer to use for code in this language. */
pygments_lexer?: string,
pygments_lexer?: string
/** Extra properties. */
[key: string]: any,
[key: string]: any
}
@ -89,46 +90,46 @@ export enum CellType {
interface BaseCell {
/** String identifying the type of cell. */
cell_type: CellType,
cell_type: CellType
/** Cell-level metadata. */
metadata: CellMetadata,
metadata: CellMetadata
/** Contents of the cell, represented as an array of lines. */
source: MultilineString,
source: MultilineString
}
/** Notebook raw nbconvert cell. */
export interface RawCell extends BaseCell {
/** String identifying the type of cell. */
cell_type: CellType.Raw,
cell_type: CellType.Raw
/** Cell-level metadata. */
metadata: CellMetadata & {
/** Raw cell metadata format for nbconvert. */
format?: string,
},
}
/** Media attachments (e.g. inline images), stored as mimebundle keyed by filename. */
attachments?: MediaAttachments,
attachments?: MediaAttachments
}
/** Notebook markdown cell. */
export interface MarkdownCell extends BaseCell {
/** String identifying the type of cell. */
cell_type: CellType.Markdown,
cell_type: CellType.Markdown
/** Media attachments (e.g. inline images), stored as mimebundle keyed by filename. */
attachments?: MediaAttachments,
attachments?: MediaAttachments
}
/** Notebook code cell. */
export interface CodeCell extends BaseCell {
/** String identifying the type of cell. */
cell_type: CellType.Code,
cell_type: CellType.Code
/** Cell-level metadata. */
metadata: CellMetadata & {
@ -138,38 +139,38 @@ export interface CodeCell extends BaseCell {
/** Whether the cell's output is scrolled, unscrolled, or autoscrolled. */
scrolled?: true | false | 'auto',
},
}
/** Execution, display, or stream outputs. */
outputs: Output[],
outputs: Output[]
/** The code cell's prompt number. Will be null if the cell has not been run. */
execution_count: number | null,
execution_count: number | null
}
export interface CellMetadata {
/** Official Jupyter Metadata for Raw Cells */
jupyter?: { [k: string]: any },
jupyter?: { [k: string]: any }
/**
* The cell's name. If present, must be a non-empty string. Cell names are expected to be unique
* across all the cells in a given notebook. This criterion cannot be checked by the json schema
* and must be established by an additional check.
*/
name?: string,
name?: string
/** The cell's tags. Tags must be unique, and must not contain commas. */
tags?: string[],
tags?: string[]
/** Extra properties. */
[key: string]: any,
[key: string]: any
}
export interface MediaAttachments {
/** The attachment's data stored as a mimebundle. */
[filename: string]: MimeBundle,
[filename: string]: MimeBundle
}
@ -188,62 +189,62 @@ export enum OutputType {
export interface ExecuteResult {
/** Type of cell output. */
output_type: OutputType.ExecuteResult,
output_type: OutputType.ExecuteResult
/** A result's prompt number. */
execution_count: number | null,
execution_count: number | null
/** A mime-type keyed dictionary of data */
data: MimeBundle,
data: MimeBundle
/** Cell output metadata. */
metadata: {
[k: string]: any,
},
}
}
/** Data displayed as a result of code cell execution. */
export interface DisplayData {
/** Type of cell output. */
output_type: OutputType.DisplayData,
output_type: OutputType.DisplayData
/** A mime-type keyed dictionary of data */
data: MimeBundle,
data: MimeBundle
/** Cell output metadata. */
metadata: {
[k: string]: any,
},
}
}
/** Stream output from a code cell. */
export interface StreamOutput {
/** Type of cell output. */
output_type: OutputType.Stream,
output_type: OutputType.Stream
/** The name of the stream (stdout, stderr). */
name: string,
name: string
/** The stream's text output, represented as an array of strings. */
text: MultilineString,
text: MultilineString
}
/** Output of an error that occurred during code cell execution. */
export interface ErrorOutput {
/** Type of cell output. */
output_type: OutputType.Error,
output_type: OutputType.Error
/** The name of the error. */
ename: string,
ename: string
/** The value, or message, of the error. */
evalue: string,
evalue: string
/** The error's traceback, represented as an array of strings. */
traceback: string[],
traceback: string[]
}
@ -252,7 +253,7 @@ export interface ErrorOutput {
export interface MimeBundle {
/** mimetype output (e.g. text/plain), represented as either an array of strings or a string. */
[mediaType: string]: MultilineString,
[mediaType: string]: MultilineString
}
export type MultilineString = string | string[]

View file

@ -147,6 +147,7 @@ class NbRenderer <TElement> extends CallableInstance<NbRenderer<TElement>> {
__call__ (notebook: Notebook): TElement {
return this.render(notebook)
}
/**
* Renders the given Jupyter *notebook*.
*/
@ -165,11 +166,11 @@ class NbRenderer <TElement> extends CallableInstance<NbRenderer<TElement>> {
}
renderMarkdownCell (cell: MarkdownCell, _notebook: Notebook): TElement {
return this.el('div', ['cell', 'markdown-cell'], this.renderMarkdown(joinText(cell.source)))
return this.el('section', ['cell', 'markdown-cell'], this.renderMarkdown(joinText(cell.source)))
}
renderRawCell (cell: RawCell, _notebook: Notebook): TElement {
return this.el('div', ['cell', 'raw-cell'], joinText(cell.source))
return this.el('section', ['cell', 'raw-cell'], joinText(cell.source))
}
renderCodeCell (cell: CodeCell, notebook: Notebook): TElement {
@ -180,7 +181,7 @@ class NbRenderer <TElement> extends CallableInstance<NbRenderer<TElement>> {
const outputs = coalesceStreams(cell.outputs ?? [])
.map(output => this.renderOutput(output, cell))
return this.el('div', ['cell', 'code-cell'], [source, ...outputs])
return this.el('section', ['cell', 'code-cell'], [source, ...outputs])
}
renderSource (cell: CodeCell, notebook: Notebook): TElement {

View file

@ -1,5 +1,6 @@
import { $INLINE_JSON } from 'ts-transformer-inline-file'
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const { version } = $INLINE_JSON('../package.json')
export default version as string

View file

@ -102,11 +102,11 @@ describe('built renderer', () => {
eachMultilineVariant(fixtures.MarkdownCell, 'source', (cell) => {
const source = join(cell.source)
it('returns div.cell.markdown-cell with the $source converted using markdownRenderer() as content', () => {
it('returns section.cell.markdown-cell with the $source converted using markdownRenderer() as content', () => {
expect( renderer.renderMarkdownCell(cell, notebook) ).toHtmlEqual(
<div class="cell markdown-cell">
<section class="cell markdown-cell">
{{__html: mockLastResult(markdownRenderer) }}
</div>
</section>
)
expect( markdownRenderer ).toBeCalledWith(source)
})
@ -117,11 +117,11 @@ describe('built renderer', () => {
describe('.renderRawCell', () => {
eachMultilineVariant(fixtures.RawCell, 'source', (cell) => {
it('returns div.cell.raw-cell with the $source as content', () => {
it('returns section.cell.raw-cell with the $source as content', () => {
expect( renderer.renderRawCell(cell, notebook) ).toHtmlEqual(
<div class="cell raw-cell">
<section class="cell raw-cell">
{{__html: join(cell.source) }}
</div>
</section>
)
})
})
@ -139,9 +139,9 @@ describe('built renderer', () => {
result = renderer.renderCodeCell(cell, notebook)
})
it('returns div.cell.code-cell', () => {
it('returns section.cell.code-cell', () => {
expect( result ).toMatchElement(
<div class="cell code-cell"><Anything /></div>
<section class="cell code-cell"><Anything /></section>
)
})
@ -149,7 +149,7 @@ describe('built renderer', () => {
it('returns element with $source rendered using .renderSource() as children[0]', () => {
expect( renderer.renderSource ).toBeCalledWith(cell, notebook)
expect( result.children[0] ).toHtmlEqual(mockLastResult(renderer.renderSource))
expect( result.children[0] ).toHtmlEqual(mockLastResult(renderer.renderSource)!)
})
})
@ -291,7 +291,7 @@ describe('built renderer', () => {
it(`returns element with the output rendered using .${funcName}() as the only child`, () => {
expect( renderer[funcName] ).toBeCalledWith(output)
expect( result.children ).toHtmlEqual([mockLastResult(renderer[funcName])])
expect( result.children ).toHtmlEqual([mockLastResult(renderer[funcName])!])
})
describe('when the cell has non-null execution_count', () => {
@ -437,7 +437,7 @@ describe('built renderer', () => {
it('renders the data using the associated external renderer', () => {
expect( renderer.renderDisplayData(output) ).toHtmlEqual(
mockLastResult(dataRenderers['text/custom'])
mockLastResult(dataRenderers['text/custom'])!
)
expect( dataRenderers['text/custom'] ).toBeCalledWith(join(data))
})
@ -468,7 +468,7 @@ describe('built renderer', () => {
const output = displayDataWith(mimeBundle)
expect( renderer.renderDisplayData(output) ).toHtmlEqual(
mockLastResult(dataRenderers['text/custom'])
mockLastResult(dataRenderers['text/custom'])!
)
})
})

View file

@ -1,6 +1,6 @@
{
"name": "ipynb2html",
"version": "0.2.1",
"version": "0.3.0",
"description": "Convert Jupyter Notebook to static HTML",
"author": "Jakub Jirutka <jakub@jirutka.cz>",
"license": "MIT",
@ -44,10 +44,15 @@
},
"dependencies": {
"anser": "^1.4.9",
"highlight.js": "^9.18.1",
"ipynb2html-core": "0.2.1",
"katex": "^0.11.1",
"marked": "^0.8.2"
"highlight.js": "^10.7.3",
"ipynb2html-core": "0.3.0",
"katex": "^0.13.11",
"marked": "^2.0.7"
},
"devDependencies": {
"@types/katex": "^0.11.0",
"@types/marked": "^2.0.3",
"ansi_up": "^5.0.1"
},
"peerDependencies": {
"nodom": "^2.3.0"

View file

@ -1,5 +1,5 @@
import addGitMsg from 'rollup-plugin-add-git-msg'
import babel from 'rollup-plugin-babel'
import babel from '@rollup/plugin-babel'
import commonjs from '@rollup/plugin-commonjs'
import license from 'rollup-plugin-node-license'
import resolve from '@rollup/plugin-node-resolve'
@ -33,9 +33,6 @@ const plugins = [
incremental: true,
},
},
// This is needed for node-license plugin. :(
// https://github.com/ezolenko/rollup-plugin-typescript2#plugins-using-asyncawait
objectHashIgnoreUnknownHack: true,
clean: true,
}),
// Resolve node modules.
@ -48,6 +45,7 @@ const plugins = [
// Transpile all sources for older browsers and inject needed polyfills.
babel({
babelrc: false,
babelHelpers: 'bundled',
// To avoid Babel injecting core-js polyfills into core-js.
exclude: [/node_modules\/core-js\//],
extensions,
@ -72,22 +70,23 @@ const plugins = [
}),
// Generate table of the bundled packages at top of the file.
license({ format: 'table' }),
// Minify JS.
terser({
ecma: 5,
include: [/^.+\.min\.js$/],
output: {
// Preserve comment injected by addGitMsg and license.
comments: RegExp(`(?:\\$\\{${pkg.name}\\}|Bundled npm packages)`),
},
}),
]
const output = (filename, extra = {}) => ['.js', '.min.js'].map(ext => ({
const output = (filename, extra = {}) => [false, true].map(minify => ({
name: pkg.name,
file: `${filename}${ext}`,
file: `${filename}${minify ? '.min.js' : '.js'}`,
format: 'umd',
sourcemap: true,
plugins: [
// Minify JS when building .min.js file.
minify && terser({
ecma: 5,
output: {
// Preserve comment injected by addGitMsg and license.
comments: RegExp(`(?:\\$\\{${pkg.name}\\}|Bundled npm packages)`),
},
}),
].filter(Boolean),
...extra,
}))

View file

@ -39,6 +39,7 @@ export function autoRender (opts: NbRendererOpts = {}): void {
document.querySelectorAll(selector).forEach(script => {
if (script.textContent && script.parentElement) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const notebook = JSON.parse(unescapeHTML(script.textContent))
const nbElement = render(notebook)
script.parentElement.replaceChild(nbElement, script)

View file

@ -2,6 +2,5 @@
// via global variable. It's an alternative to Anser that doesn't provide
// bundle for browsers.
declare class AnsiUp {
// eslint-disable-next-line @typescript-eslint/camelcase
ansi_to_html (input: string): string
}

View file

@ -42,7 +42,7 @@ export type NbRendererOpts<TElement = HTMLElement> = BaseOptions<TElement> & {
* for this module's function.
*/
type MinimalDocument<TElement extends MinimalElement> = {
createElement (tag: string): TElement,
createElement: (tag: string) => TElement,
}
const defaultKatexOpts: KatexOptions = {
@ -57,7 +57,7 @@ const defaultMarkedOpts: MarkedOptions = {
function hljsCodeHighlighter (code: string, lang: string): string {
return hljs.getLanguage(lang)
? hljs.highlight(lang, code).value
? hljs.highlight(code, { language: lang }).value
: code
}

View file

@ -5,10 +5,12 @@ import marked, { Slugger } from 'marked'
import { mathExtractor } from 'ipynb2html-core'
export type MarkdownRenderer = (markdown: string) => string
export interface MarkedOptions extends marked.MarkedOptions {
/** Generate heading anchors (this implies headingIds). */
headerAnchors?: boolean,
headerIdsStripAccents?: boolean,
headerAnchors?: boolean
headerIdsStripAccents?: boolean
}
// Removes accents from the given string.
@ -48,7 +50,7 @@ class Renderer extends marked.Renderer {
function highlight (code: string, lang: string): string {
return hljs.getLanguage(lang)
? hljs.highlight(lang, code, true).value
? hljs.highlight(code, { language: lang, ignoreIllegals: true }).value
: code
}
@ -71,7 +73,7 @@ const rendererWithMath = (markedOpts: MarkedOptions, katexOpts: KatexOptions) =>
* @param {MarkedOptions} markedOpts Options for the marked Markdown renderer.
* @param {KatexOptions} katexOpts Options for the KaTeX math renderer.
*/
export default (markedOpts: MarkedOptions = {}, katexOpts: KatexOptions = {}) => {
export default (markedOpts: MarkedOptions = {}, katexOpts: KatexOptions = {}): MarkdownRenderer => {
markedOpts = { renderer: new Renderer(markedOpts), ...markedOpts }
if (hljs) { // highlight.js may be an optional dependency (in browser bundle)

View file

@ -7,12 +7,14 @@ class EmptyRenderer extends marked.Renderer {}
// Override all the EmptyRenderer's methods inherited from marked.Renderer to
// always return an empty string.
const RendererProto: any = marked.Renderer.prototype
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
const RendererProto = marked.Renderer.prototype
for (const prop of Object.getOwnPropertyNames(RendererProto)) {
if (prop !== 'constructor' && typeof RendererProto[prop] === 'function') {
;(EmptyRenderer.prototype as any)[prop] = () => ''
if (prop !== 'constructor' && typeof (RendererProto as any)[prop] === 'function') {
(EmptyRenderer.prototype as any)[prop] = () => ''
}
}
/* eslint-enable @typescript-eslint/no-unsafe-member-access */
class MainTitleRenderer extends EmptyRenderer {
_titleFound = false

View file

@ -1,5 +1,6 @@
import { $INLINE_JSON } from 'ts-transformer-inline-file'
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const { version } = $INLINE_JSON('../package.json')
export default version as string

View file

@ -133,10 +133,12 @@ describe('image', () => {
describe('code', () => {
it('highlights fenced code block', () => {
expect( render('```js\nconsole.log("Hello, world!")\n```') ).toHtmlEqual(
// Note: We use `backticks` in this example to avoid problem that JSX
// implicitly decodes HTML entities, but node-html-parser does not.
expect( render('```js\nconsole.log(`Hello, world!`)\n```') ).toHtmlEqual(
<pre>
<code class="language-js">
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">"Hello, world!"</span>)
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">`Hello, world!`</span>)
</code>
</pre>
)
@ -145,5 +147,6 @@ describe('code', () => {
function render (text: string) {
return parseHtml(markdownRenderer(markedOpts, katexOpts)(text), { pre: true }).childNodes[0]
const html = markdownRenderer(markedOpts, katexOpts)(text).replace(/\n/, '')
return parseHtml(html, { pre: true }).childNodes[0]
}

View file

@ -1,38 +0,0 @@
Remove after https://github.com/DefinitelyTyped/DefinitelyTyped/pull/43732
is merged and released.
diff --git a/node_modules/@types/marked/index.d.ts b/node_modules/@types/marked/index.d.ts
index e89b2cf..2dc01dc 100644
--- a/node_modules/@types/marked/index.d.ts
+++ b/node_modules/@types/marked/index.d.ts
@@ -129,8 +129,8 @@ declare namespace marked {
codespan(code: string): string;
br(): string;
del(text: string): string;
- link(href: string, title: string, text: string): string;
- image(href: string, title: string, text: string): string;
+ link(href: string | null, title: string | null, text: string): string;
+ image(href: string | null, title: string | null, text: string): string;
text(text: string): string;
}
@@ -140,8 +140,8 @@ declare namespace marked {
codespan(text: string): string;
del(text: string): string;
text(text: string): string;
- link(href: string, title: string, text: string): string;
- image(href: string, title: string, text: string): string;
+ link(href: string | null, title: string | null, text: string): string;
+ image(href: string | null, title: string | null, text: string): string;
br(): string;
}
@@ -182,7 +182,7 @@ declare namespace marked {
type TokensList = Token[] & {
links: {
- [key: string]: { href: string; title: string; }
+ [key: string]: { href: string | null; title: string | null; }
}
};

View file

@ -1,25 +0,0 @@
Remove after https://github.com/taoqf/node-html-parser/pull/39
is merged and released.
diff --git a/node_modules/node-html-parser/dist/nodes/html.js b/node_modules/node-html-parser/dist/nodes/html.js
index a3c33b1..8b4c2b2 100644
--- a/node_modules/node-html-parser/dist/nodes/html.js
+++ b/node_modules/node-html-parser/dist/nodes/html.js
@@ -176,15 +176,11 @@ var HTMLElement = /** @class */ (function (_super) {
HTMLElement.prototype.toString = function () {
var tag = this.tagName;
if (tag) {
- var is_un_closed = /^meta$/i.test(tag);
- var is_self_closed = /^(img|br|hr|area|base|input|doctype|link)$/i.test(tag);
+ const is_void = /^(area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/i.test(tag);
var attrs = this.rawAttrs ? ' ' + this.rawAttrs : '';
- if (is_un_closed) {
+ if (is_void) {
return "<" + tag + attrs + ">";
}
- else if (is_self_closed) {
- return "<" + tag + attrs + " />";
- }
else {
return "<" + tag + attrs + ">" + this.innerHTML + "</" + tag + ">";
}

View file

@ -0,0 +1,15 @@
TODO: Remove after https://github.com/chrisdarroch/yarn-bump/pull/1 is merged and released.
diff --git a/node_modules/yarn-version-bump/src/workspace.js b/node_modules/yarn-version-bump/src/workspace.js
index 28b1dd1..0cf2ecb 100644
--- a/node_modules/yarn-version-bump/src/workspace.js
+++ b/node_modules/yarn-version-bump/src/workspace.js
@@ -9,7 +9,7 @@ class Workspace {
get workspaceSnapshot() {
return runCommand('yarn',
- ['workspaces', 'info', '--silent'],
+ ['--silent', 'workspaces', 'info'],
{ cwd: this.root }
)
.then(data => JSON.parse(data))

View file

@ -1,5 +1,5 @@
type Callable = (...args: any[]) => any
type Callable = (...args: any[]) => unknown
export type Mock<F extends Callable> = jest.Mock<ReturnType<F>, Parameters<F>>
@ -13,9 +13,9 @@ export function asMock <F extends Callable> (fn: F): Mock<F> {
export function mockResults <F extends Callable> (fn: F): Array<ReturnType<F>> {
return asMock(fn).mock.results
.filter(x => x.type === 'return')
.map(x => x.value)
.map(x => x.value as ReturnType<F>)
}
export function mockLastResult <F extends Callable> (fn: F): ReturnType<F> {
return mockResults(fn).pop() as ReturnType<F>
export function mockLastResult <F extends Callable> (fn: F): ReturnType<F> | undefined {
return mockResults(fn).pop()
}

View file

@ -60,7 +60,8 @@ export function createElement (
} else if (child instanceof NNode) {
el.appendChild(child)
} else if (typeof child === 'object' && '__html' in child) {
el.innerHTML = child.__html
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
el.innerHTML = child.__html as string
} else {
el.appendChild(document.createTextNode(String(child)))
}
@ -68,6 +69,7 @@ export function createElement (
return el
}
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
(global as any).JSX = {
createElement,
}

View file

@ -7,7 +7,7 @@ declare global {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace jest {
interface Matchers<R, T> {
toHtmlEqual (expected: HTMLElement | string | Array<HTMLElement | string>): R,
toHtmlEqual: (expected: HTMLElement | string | Array<HTMLElement | string>) => R
}
}
}

View file

@ -11,7 +11,7 @@ declare global {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace jest {
interface Matchers<R, T> {
toMatchElement (expected: HTMLElement, opts?: Options): R,
toMatchElement: (expected: HTMLElement, opts?: Options) => R
}
}
}
@ -21,7 +21,7 @@ export const AnythingNode = new class extends Node {
toString () { return this.render() }
}()
export const Anything = () => AnythingNode
export const Anything = (): Node => AnythingNode
function isWritable (obj: any, prop: string): boolean {
const desc = Object.getOwnPropertyDescriptor(obj, prop)
@ -35,7 +35,7 @@ function filterWildcardChildren (rec: Node, exp: Node): void {
&& (rec as HTMLElement).innerHTML
) {
if (isWritable(rec, 'innerHTML')) {
;(rec as HTMLElement).innerHTML = ''
(rec as HTMLElement).innerHTML = ''
}
rec.childNodes.splice(0, rec.childNodes.length, AnythingNode)
return

3633
yarn.lock

File diff suppressed because it is too large Load diff