Skip to content

Commit 5b51b4a

Browse files
authored
Merge pull request #8 from OI-wiki/remark-13
Update to micromark
2 parents b04d795 + 5a1127f commit 5b51b4a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+5218
-1873
lines changed

.editorconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
trim_trailing_whitespace = true
6+
insert_final_newline = true
7+
8+
[*.{js,jsx,json,ts,tsx,yml}]
9+
indent_size = 4
10+
indent_style = tab
11+
indent_style/tab_width = 4

.eslintrc.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
extends: ["eslint:recommended", "plugin:prettier/recommended"],
3+
env: { es6: true, node: true },
4+
parserOptions: { ecmaVersion: 8 },
5+
};

.github/workflows/release.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
with:
14+
fetch-depth: 0
15+
- uses: actions/setup-node@v2
16+
with:
17+
node-version: '14'
18+
registry-url: https://registry.npmjs.org/
19+
- run: npm i -g pnpm @antfu/ni
20+
- run: nci
21+
- run: nr test --if-present
22+
- run: npm publish --access public
23+
env:
24+
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
25+
- run: npx conventional-github-releaser -p angular
26+
env:
27+
CONVENTIONAL_GITHUB_RELEASER_TOKEN: ${{secrets.GITHUB_TOKEN}}

.github/workflows/test.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Test
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build:
7+
runs-on: ${{ matrix.os }}
8+
9+
strategy:
10+
matrix:
11+
node-version: [14.x, 16.x]
12+
os: [ubuntu-latest, macos-latest]
13+
fail-fast: false
14+
15+
steps:
16+
- uses: actions/checkout@v2
17+
18+
- name: Use Node.js ${{ matrix.node-version }}
19+
uses: actions/setup-node@v1
20+
with:
21+
node-version: ${{ matrix.node-version }}
22+
23+
- name: Setup
24+
run: npm i -g pnpm @antfu/ni
25+
26+
- name: Install
27+
run: nci
28+
29+
- name: Test
30+
run: nr test --if-present

.gitignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
# Build results
2+
*.js
3+
!/lib/**/*.js
4+
*.d.ts
5+
!/lib/**/*.d.ts
6+
7+
# Source maps
8+
*.map
9+
10+
# Test result
11+
/tests/output
12+
113
# Logs
214
logs
315
*.log

.npmignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/*
2+
!/lib
3+
!/LICENSE
4+
!/package.json
5+
!/README.md
6+
!/yarn.lock

.prettierrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"endOfLine": "auto",
3+
"semi": true,
4+
"singleQuote": true,
5+
"trailingComma": "all"
6+
}

index.js

Lines changed: 0 additions & 238 deletions
This file was deleted.

lib/index.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { Plugin } from 'unified';
2+
declare const remarkDetails: Plugin;
3+
export default remarkDetails;

lib/index.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { h } from 'hastscript';
2+
import { visit } from 'unist-util-visit';
3+
import { fromMarkdownDetails } from './mdast-util-details/index.js';
4+
import { syntax } from './micromark-details/index.js';
5+
let warningIssued = false;
6+
const remarkDetails = function (options) {
7+
var _a, _b, _c, _d;
8+
const data = this.data();
9+
// warning for old remarks
10+
if (!warningIssued &&
11+
(((_b = (_a = this.Parser) === null || _a === void 0 ? void 0 : _a.prototype) === null || _b === void 0 ? void 0 : _b.blockTokenizers) ||
12+
((_d = (_c = this.Compiler) === null || _c === void 0 ? void 0 : _c.prototype) === null || _d === void 0 ? void 0 : _d.visitors))) {
13+
warningIssued = true;
14+
console.warn('[remark-details] Warning: please upgrade to remark 13 to use this plugin');
15+
}
16+
function add(field, value) {
17+
/* istanbul ignore if - other extensions. */
18+
if (data[field])
19+
data[field].push(value);
20+
else
21+
data[field] = [value];
22+
}
23+
add('micromarkExtensions', syntax);
24+
add('fromMarkdownExtensions', fromMarkdownDetails);
25+
return transform;
26+
function transform(tree) {
27+
visit(tree, ['detailsContainer', 'detailsContainerSummary'], ondetails);
28+
}
29+
function ondetails(node) {
30+
var data = node.data || (node.data = {});
31+
var hast = h(node.name, node.attributes);
32+
data.hName = hast.tagName;
33+
data.hProperties = hast.properties;
34+
}
35+
};
36+
export default remarkDetails;

0 commit comments

Comments
 (0)