Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mystjs #35

Merged
merged 90 commits into from
Feb 26, 2022
Merged
Show file tree
Hide file tree
Changes from 85 commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
0241a17
Use amsmath package
rowanc1 Jul 5, 2021
bcd0eaf
Remove port in favour of new ams package
rowanc1 Jul 5, 2021
efe24a8
Move from texmath --> dollarmath
rowanc1 Jul 5, 2021
b45a8d5
🔄 REFACTOR: Add markdown-it-docutils dependency
fwkoch Feb 7, 2022
3df9d29
Move to NPM, and change package name
rowanc1 Feb 8, 2022
8e31fce
npm install
rowanc1 Feb 8, 2022
7eecdce
Just test on Node 12 & 14 for now.
rowanc1 Feb 8, 2022
78d12ed
Ignore .yalc for cross linking in development
rowanc1 Feb 9, 2022
033b51e
Documentation updates
rowanc1 Feb 9, 2022
65dc5c9
Initial working unified exxport
rowanc1 Feb 10, 2022
f04f54d
Simplify framework code
rowanc1 Feb 10, 2022
9f0e80c
Initial working commit
rowanc1 Feb 10, 2022
a22a502
Admonitions
rowanc1 Feb 10, 2022
d14b74a
Converting more tests
rowanc1 Feb 10, 2022
7e69b71
Trailing commas
rowanc1 Feb 11, 2022
80ac103
Figures and images
rowanc1 Feb 11, 2022
5bdc151
Updates to figure directives
rowanc1 Feb 11, 2022
230bb99
hast
rowanc1 Feb 11, 2022
3c8ab6f
Math blocks
rowanc1 Feb 11, 2022
594ffb9
AMS Math tests
rowanc1 Feb 11, 2022
8416a23
Unecessary tests
rowanc1 Feb 11, 2022
bce68a6
Ensure common mark is supported
rowanc1 Feb 12, 2022
947878d
Footnotes, definitions, dollarmath
rowanc1 Feb 13, 2022
c262359
Ignore docs in jest
rowanc1 Feb 14, 2022
ed7b0c0
Enable definitions
rowanc1 Feb 14, 2022
13085fc
Update docs
rowanc1 Feb 14, 2022
651c8e4
Include demo code directly
rowanc1 Feb 14, 2022
d297950
Include the build process in the docs
rowanc1 Feb 14, 2022
fbcf482
Merge pull request #36 from executablebooks/mdast
rowanc1 Feb 14, 2022
9fbdc2d
Remove example.md, this is now in the html
rowanc1 Feb 14, 2022
dbef7fa
Add a todo to the figure!
rowanc1 Feb 14, 2022
1b1fd2b
Initial move to blocks
rowanc1 Feb 14, 2022
16d36e8
Add packagejson fomr now
rowanc1 Feb 14, 2022
0b721f4
Support for unknown directives
fwkoch Feb 15, 2022
ff56bbe
Support block breaks and block break metadata
fwkoch Feb 15, 2022
fa95d58
Bring the custom class first in admonitions
rowanc1 Feb 15, 2022
12ec7e0
Support comment lines
fwkoch Feb 15, 2022
85f0ce4
Merge branch 'mystjs' of github.com:executablebooks/mystjs into mystjs
fwkoch Feb 15, 2022
ca66ab2
Support block targets on headers
fwkoch Feb 15, 2022
e41f024
Update math packages
rowanc1 Feb 15, 2022
b230704
Use ElementContent type instead of any in directive handler
fwkoch Feb 16, 2022
31105a6
Merge branch 'mystjs' of github.com:executablebooks/mystjs into mystjs
fwkoch Feb 16, 2022
552d895
Support unknown roles
fwkoch Feb 16, 2022
658a1ab
Add a bunch of doc page placeholders
fwkoch Feb 16, 2022
165d22f
Commonmark break tests
fwkoch Feb 16, 2022
889c79e
Spelling
rowanc1 Feb 16, 2022
8670603
Add a bunch of commonmark tests in the yml tests
fwkoch Feb 17, 2022
b7808da
Reorgainze docs to divide among clearer purposes
fwkoch Feb 17, 2022
baaa32c
Merge branch 'mystjs' of github.com:executablebooks/mystjs into mystjs
fwkoch Feb 17, 2022
6b794b8
Lift images out of paragraphs fro mdast, not hast
rowanc1 Feb 17, 2022
022c6cf
References start
rowanc1 Feb 17, 2022
3d08f01
Dump more example features into the docs
fwkoch Feb 18, 2022
e388d1b
Remove unused blocks code
fwkoch Feb 21, 2022
a916e7f
Add state management for references independent of markdown-it
fwkoch Feb 21, 2022
6c6df41
Move to rollup
rowanc1 Feb 21, 2022
77d2f0d
Types, semicolons, and block-breaks --> blocks
rowanc1 Feb 21, 2022
0397cee
Bring state into mdast transforms
rowanc1 Feb 22, 2022
9724cd1
Update build
rowanc1 Feb 22, 2022
fdb6685
Add spaces after caption figure numbers
fwkoch Feb 22, 2022
0168dce
First pass at tables into myst mdast
fwkoch Feb 23, 2022
d194117
Proposal for more granular docs table of contents
fwkoch Feb 23, 2022
7f2716b
Pass at documentation
rowanc1 Feb 24, 2022
5826af9
Improve table mdast and html output
fwkoch Feb 24, 2022
8c6a494
Remove space at the end of figure caption number
fwkoch Feb 24, 2022
4e59894
Merge branch 'mystjs' of github.com:executablebooks/mystjs into mystjs
fwkoch Feb 24, 2022
e46232d
More documentation!
rowanc1 Feb 24, 2022
922c8ed
Merge branch 'mystjs' of github.com:executablebooks/markdown-it-myst …
rowanc1 Feb 24, 2022
b1f4bf0
Docs
rowanc1 Feb 24, 2022
891faf3
More attention to classes coming from meta info
rowanc1 Feb 24, 2022
6434855
Update the gitignore to cover the copied file on build
rowanc1 Feb 24, 2022
8c31829
Add covered roles to the readme
rowanc1 Feb 24, 2022
1293d4a
Refactoring
rowanc1 Feb 24, 2022
4b92da7
Rearrange exports
rowanc1 Feb 24, 2022
b97437b
Add alignment to tableCol mdast nodes
fwkoch Feb 24, 2022
81c9243
Code blocks with highlighting, linenos, etc.
rowanc1 Feb 24, 2022
a6c437d
Update readme
rowanc1 Feb 24, 2022
ee92df3
Typos, new references in the docs
fwkoch Feb 24, 2022
10f1a1e
Merge branch 'mystjs' of github.com:executablebooks/mystjs into mystjs
fwkoch Feb 24, 2022
9bba2a1
Doc touchups
rowanc1 Feb 24, 2022
cb20083
Blocks docs
rowanc1 Feb 24, 2022
8c7682c
tableCol --> tableCell (as per mdast)
rowanc1 Feb 24, 2022
646fa25
Move node helper functions to utils
fwkoch Feb 25, 2022
e2caebb
Support link-style references, e.g. [](my-ref)
fwkoch Feb 25, 2022
e0e64ec
Eliminate circular import
fwkoch Feb 25, 2022
2ad4bbe
Fix block break target in docs
fwkoch Feb 25, 2022
e2340d2
Remove 'resolved: false' from mdast
fwkoch Feb 25, 2022
eaf5fb7
Add exports for roles/directives
rowanc1 Feb 25, 2022
1ce4c91
Add and test extension
rowanc1 Feb 25, 2022
8fb427f
Github actions and pin docutils
rowanc1 Feb 26, 2022
9225e91
Updates to readme.
rowanc1 Feb 26, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 8 additions & 19 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,11 @@
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module",
"project": [
"./tsconfig.json"
]
"project": ["./tsconfig.json"]
},
"plugins": [
"@typescript-eslint",
"no-skip-tests",
"no-only-tests"
],
"plugins": ["@typescript-eslint", "no-skip-tests", "no-only-tests"],
"rules": {
"quotes": [
"error",
"single"
],
"quotes": ["error", "single"],
"prettier/prettier": [
"error",
{
Expand All @@ -43,17 +34,15 @@
],
"import/prefer-default-export": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/camelcase": "off"
"@typescript-eslint/camelcase": "off",
"jest/no-export": "off",
"jest/valid-title": "off"
},
"settings": {
"import/resolver": {
"node": {
"extensions": [
".js",
".ts",
".spec.ts"
]
"extensions": [".js", ".ts", ".spec.ts"]
}
}
}
}
}
83 changes: 34 additions & 49 deletions .github/workflows/lint_and_unittests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,65 +2,50 @@ name: CI

on:
push:
branches: [ main, ci-* ]
branches: [main, ci-*]
pull_request:
branches: [ main ]
branches: [main]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Cache packages
id: cache-npm
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-npm-${{ hashFiles('**/yarn.lock') }}
restore-keys:
${{ runner.os }}-npm-
- name: Use Node.js 12.x
uses: actions/setup-node@v1
with:
node-version: 12.x
- name: install dependencies
run: |
yarn install
- name: lint
run: |
yarn run lint
- uses: actions/checkout@v2
- name: Cache packages
id: cache-npm
uses: actions/cache@v2
with:
path: node_modules
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: ${{ runner.os }}-npm
- name: Use Node.js 12.x
uses: actions/setup-node@v1
with:
node-version: 12.x
- run: npm install
- run: npm run lint

build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x, 14.x]

steps:
- uses: actions/checkout@v2
- name: Cache packages
id: cache-npm
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-npm-${{ hashFiles('**/yarn.lock') }}
restore-keys:
${{ runner.os }}-npm-
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- name: install dependencies
run: |
yarn install

- name: Run the tests and generate coverage reportst
run: |
yarn test --coverage

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1

- name: Run the build
run: yarn run build
- uses: actions/checkout@v2
- name: Cache packages
id: cache-npm
uses: actions/cache@v2
with:
path: node_modules
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: ${{ runner.os }}-npm
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- name: Run the tests and generate coverage reportst
run: npm run test --coverage
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
- run: npm run build
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@ dist/
node_modules/
docs/_build/*
coverage/
.yalc/*
yalc.lock

# The following is built for the docs
docs/_static/myst.min.js
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tests/*.md
4 changes: 1 addition & 3 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{
"singleQuote": true,
"trailingComma": "none",
"arrowParens": "avoid",
"semi": false,
"trailingComma": "all",
"printWidth": 88
}
129 changes: 92 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
# markdown-it-myst
[![markdown-it-myst on npm](https://img.shields.io/npm/v/markdown-it-myst.svg)](https://www.npmjs.com/package/markdown-it-myst)
[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/executablebooks/markdown-it-myst/blob/master/LICENSE)
[![CI](https://github.com/executablebooks/markdown-it-myst/workflows/CI/badge.svg)](https://github.com/executablebooks/markdown-it-myst/actions)
[![docs](https://github.com/executablebooks/markdown-it-myst/workflows/docs/badge.svg)](https://executablebooks.github.io/markdown-it-myst)
[![demo](https://img.shields.io/badge/live-demo-blue)](https://executablebooks.github.io/markdown-it-myst/demo/index.html)
# mystjs

> :warning: **Note:** `markdown-it-myst` is alpha, expect changes! (January, 2021)
[![mystjs on npm](https://img.shields.io/npm/v/mystjs.svg)](https://www.npmjs.com/package/mystjs)
[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/executablebooks/mystjs/blob/master/LICENSE)
[![CI](https://github.com/executablebooks/mystjs/workflows/CI/badge.svg)](https://github.com/executablebooks/mystjs/actions)
[![docs](https://github.com/executablebooks/mystjs/workflows/docs/badge.svg)](https://executablebooks.github.io/mystjs)
[![demo](https://img.shields.io/badge/live-demo-blue)](https://executablebooks.github.io/mystjs/demo/index.html)

> :warning: **Note:** `mystjs` is alpha, expect changes! (January, 2021)

A javascript parser for [MyST](https://myst-parser.readthedocs.io) based on [markdown-it](https://github.com/markdown-it/markdown-it)

## Goals
* Provide a Javascript implementation of [MyST](https://myst-parser.readthedocs.io) markdown extensions
* Uses standard html for all known roles and directives, with no styling enforced or provided
* Provide functionality for cross-referencing that is usually completed by Sphinx (e.g. in the [Python implementation](https://github.com/executablebooks/MyST-Parser))

- Provide a Javascript implementation of [MyST](https://myst-parser.readthedocs.io) markdown extensions
- Uses standard html for all known roles and directives, with no styling enforced or provided
- Provide functionality for cross-referencing that is usually completed by Sphinx (e.g. in the [Python implementation](https://github.com/executablebooks/MyST-Parser))

## Usage

```bash
npm install markdown-it-myst
npm install mystjs
```

In a node environment:

```javascript
import { MyST } from 'markdown-it-myst';
import { MyST } from 'mystjs';

const myst = MyST();
const html = myst.render('# Hello to the world!');
Expand All @@ -32,46 +35,98 @@ console.log(html);
```

In a browser:

```html
<html>
<head>
<script src="https://unpkg.com/markdown-it-myst"></script>
</head>
<body onload="init();">
<div id="output"></div>
<script>
function init() {
const myst = MyST();
const html = myst.render('# Hello to the world!');
document.getElementById('output').innerHTML = html;
}
</script>
</body>
<head>
<script src="https://unpkg.com/mystjs"></script>
</head>
<body onload="init();">
<div id="output"></div>
<script>
function init() {
const myst = MyST();
const html = myst.render('# Hello to the world!');
document.getElementById('output').innerHTML = html;
}
</script>
</body>
</html>
```

## `mystjs` Features

- CommonMark
- Admonitions
- Figures
- Images
- Math
- role
- directive (equations)
- dollar
- amsmath
- Tables
- GFM
- List Tables
- References
- ref
- numref
- eq
- links
- Including numbering (single document)
- Citations (parse only)
- Code Directives
- Code
- Code blocks
- Code cell
- Blocks
- Comments
- Targets
- HTML: sub, sup, abbr
- Definition List
- Footnotes

Not yet complete:

- div
- proof
- margin
- sidebar
- colon fence
- Bibliography
- Epigraph
- Glosary
- Terms
- Tabs
- Panels
- CSV Tables
- Multi-document

## Developer Install

For installing the package locally, we suggest [Yarn](https://yarnpkg.com/), which can be installed using these [instructions](https://yarnpkg.com/getting-started/install), you will need [node](https://nodejs.org/), both can use a global install on your system.
For installing the package locally, you will need [node](https://nodejs.org/) and [npm](https://docs.npmjs.com/about-npm), both can use a global install on your system.

Once you have `yarn` installed globally, navigate into this project folder and install the dependencies:
Once you have `npm` installed globally, navigate into this project folder and install the dependencies:

```bash
cd markdown-it-myst
yarn install
yarn start # Start a development server to play with the library! 🚀
cd mystjs
npm install
npm run start # Start a development server to play with the library! 🚀
```

The scripts for building, testing, and serving the project are in the [package.json](package.json), the main ones to use are
`yarn test`, `yarn build`, and `yarn start`.
`npm run test`, `npm run build`, and `npm run start`.

### `npm run build`

### `yarn build`
Builds the library, including compiling the typescript and bundling/minification to create `myst.min.js`.
Builds the library, including compiling the typescript and bundling/minification to create `index.umd.min.js`.
This outputs to the `dist` folder, and also includes all type definitions (`*.d.ts`).

### `yarn test`
Run the tests, these are mostly based on the [fixtures](fixtures) folder. You can also use `yarn test:watch` to run on any file changes.
### `npm run test`

Run the tests, these are mostly based on the [fixtures](fixtures) folder. You can also use `npm run test:watch` to run on any file changes.

### `npm run start`

### `yarn start`
Starts a server for manually testing and playing with `markdown-it-myst`, this uses a in-memory bundle of what would go in the `dist` folder.
Starts a server for manually testing and playing with `mystjs`, this uses a in-memory bundle of what would go in the `dist` folder.
Note that this does not actually build the library!
15 changes: 12 additions & 3 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
.PHONY: build serve watch

build:
cd ..; npm run build
jupyter-book build .
rm -r _build/html/dist | true;
rm -r _build/html/demo | true;
cp -r ../dist _build/html/demo
cp ../dist/index.umd.min.js _static/myst.min.js
sed -i '' "s/NAVIGATION_WITH_KEYS: true/NAVIGATION_WITH_KEYS: false/g" _build/html/_static/documentation_options.js

watch:
nodemon -w './**' -e yml,md,ipynb --exec jupyter-book build .
build-watch:
jupyter-book build .
cp ../dist/index.umd.min.js _build/html/_static/myst.min.js
sed -i '' "s/NAVIGATION_WITH_KEYS: true/NAVIGATION_WITH_KEYS: false/g" _build/html/_static/documentation_options.js

watch: clean
make build
nodemon -w './**' --ignore _build/ -e yml,md,ipynb,js --exec make build-watch

serve:
cd _build/html; python -m http.server 9000
Expand Down
Loading