Giter Club home page Giter Club logo

markdown-it-plugin-template's Issues

Add documentation

Quite possibly using sphinx + myst-parser + RTD.

It would also be quite nice to have a simple way of "showcasing" the markdown source -> rendered HTML from the plugin.

Master to Main

As per a discussion in the EBP slack, I have opened a PR #3, that moves this to main. The default branch/branch protection has been updated.

I will let @chrisjsewell merge that in after review of the (minor) changes.

Module Resolution Node

I think that we should add this to the tsconfig:
"moduleResolution": "node"

Ran into some places where we had to change this in a downstream package.

Utility to run local demo

Right now I believe the process is commenting on/off the local script and just opening this up in any webserver or file://.

It would be great to add a npm run start or dev to bring up a live reloading server on file changes (including styles where appropriate). This is more helpful for the more complicated repos like docutils.

This also means the deploy might need to go into a github action (e.g. have done that here), that would allow us to rely on the locally built package rather than the deployed npm package (e.g. not ready to release, but still want the demo updated).

npm run lint:format

Add prettier to our lint test in the ci.

I have done this as npm run lint:format in the past (as well as a npm run lint:format:fix)

See example.

Happy to make the various PRs for this and #5.

`npm i` fails

Describe the bug

When you git clone the template, npm i fails due to eslint-config-standard.

Removing eslint-config-standard from package.json appears to be a quick fix, but I am sure that is not the intended solution.

Most likely the solution is a version bump, but I'm not great at node/js in gerneral

Reproduce the bug

acn@jy-virtual-machine ~/acn> ls
deployment  markdown-it-question-answer  note_plugin  notes  start_ssh_tunnel.sh  start_vms.sh  svm0860
acn@jy-virtual-machine ~/acn> git clone [email protected]:executablebooks/markdown-it-plugin-template.git
Cloning into 'markdown-it-plugin-template'...
The authenticity of host 'github.com (140.82.121.4)' can't be established.
ED25519 key fingerprint is SHA256:+DiY3wvvV6TuJJhbpZisF/zLDA0zPMSvHdkr4UvCOqU.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'github.com' (ED25519) to the list of known hosts.
remote: Enumerating objects: 157, done.
remote: Counting objects: 100% (157/157), done.
remote: Compressing objects: 100% (112/112), done.
remote: Total 157 (delta 77), reused 105 (delta 33), pack-reused 0
Receiving objects: 100% (157/157), 211.87 KiB | 704.00 KiB/s, done.
Resolving deltas: 100% (77/77), done.
acn@jy-virtual-machine ~/acn> cd markdown-it-plugin-template/
acn@jy-virtual-machine ~/a/markdown-it-plugin-template (main)> npm i
Command 'npm' not found, but can be installed with:
sudo apt install npm
acn@jy-virtual-machine ~/a/markdown-it-plugin-template (main) [127]> nvm use lts
Now using Node v18.12.1 (npm 8.19.2) ~/.local/share/nvm/v18.12.1/bin/node
acn@jy-virtual-machine ~/a/markdown-it-plugin-template (main)> npm i
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR! 
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/eslint-plugin-promise
npm ERR!   dev eslint-plugin-promise@"^6.0.0" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer eslint-plugin-promise@"^4.2.1 || ^5.0.0" from [email protected]
npm ERR! node_modules/eslint-config-standard
npm ERR!   dev eslint-config-standard@"^16.0.3" from the root project
npm ERR! 
npm ERR! Conflicting peer dependency: [email protected]
npm ERR! node_modules/eslint-plugin-promise
npm ERR!   peer eslint-plugin-promise@"^4.2.1 || ^5.0.0" from [email protected]
npm ERR!   node_modules/eslint-config-standard
npm ERR!     dev eslint-config-standard@"^16.0.3" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR! 
npm ERR! See /home/acn/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/acn/.npm/_logs/2022-11-08T12_47_32_108Z-debug-0.log

List your environment

Using Fish on Ubuntu

acn@jy-virtual-machine ~/a/markdown-it-plugin-template (main)> uname -a
Linux jy-virtual-machine 5.15.0-52-generic #58-Ubuntu SMP Thu Oct 13 08:03:55 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
acn@jy-virtual-machine ~/a/markdown-it-plugin-template (main) [1]> npm --version
8.19.2
acn@jy-virtual-machine ~/a/markdown-it-plugin-template (main)> node --version
v18.12.1

What distribution(s) to target (CJS, ESM, ...)?

Certainly compared to Python (one distribution works for all v3.x), JS/TS is a bit of a mess when it comes to packaging libraries: not only do you need to think about the version/format of javascript (and compatibility with third-party modules), but also node vs browser compatibility.

Essentially CommonJS modules are a legacy format, that many third party packages still use, whereas ES modules are now the ~official standard and "future" of javascript (and are now basically supported in all browsers: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules, see also https://hacks.mozilla.org/2018/03/es-modules-a-cartoon-deep-dive/).
Again comparing to Python, it feels like JS/TS is in a similar situation to when python packages were transitioning from v2 to v3 (and so support was necessary for both).

Using rollup you can actually target multiple build formats:

Currently, I have it set to do a "hybrid" build with: https://github.com/executablebooks/markdown-it-plugin-template/blob/master/rollup.config.js, and in package.json pointing to either with:

"main": "dist/cjs/index.js",
"module": "dist/mjs/index.js",
"types": "dist/index.d.ts",
"files": [
"dist"
],
"exports": {
".": {
"import": "./dist/mjs/index.js",
"require": "./dist/cjs/index.js"
}
},

This is essentially what is recommended here, but then here it mentions a danger in "double transpiling".

Additionally confusing, is what to target in the tsconfig:

"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', 'ES2021', or 'ESNEXT'. */
"module": "es2015", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */

and also how babel fits in with rollup, and if @rollup/plugin-babel is actually needed (if you remove this plugin, it still builds fine at present):

babel({ babelHelpers: "bundled" }), // transpile ES6/7 code

It is of note that markdown-it itself uses the umd format (amd, cjs and iife), in its rollup config: https://github.com/markdown-it/markdown-it/blob/064d602c6890715277978af810a903ab014efc73/support/rollup.config.js#L13

Also a consideration of what is required for unpkg: mjackson/unpkg#34

Here is also a bunch of links about CommonJS vs ES Modules and building hybrid packages:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.