Skip to content

Commit

Permalink
Merge pull request #8 from OI-wiki/remark-13
Browse files Browse the repository at this point in the history
Update to micromark
  • Loading branch information
Ahacad authored Sep 7, 2021
2 parents b04d795 + 5a1127f commit 5b51b4a
Show file tree
Hide file tree
Showing 66 changed files with 5,218 additions and 1,873 deletions.
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
root = true

[*]
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.{js,jsx,json,ts,tsx,yml}]
indent_size = 4
indent_style = tab
indent_style/tab_width = 4
5 changes: 5 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
extends: ["eslint:recommended", "plugin:prettier/recommended"],
env: { es6: true, node: true },
parserOptions: { ecmaVersion: 8 },
};
27 changes: 27 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Release

on:
push:
tags:
- 'v*'

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-node@v2
with:
node-version: '14'
registry-url: https://registry.npmjs.org/
- run: npm i -g pnpm @antfu/ni
- run: nci
- run: nr test --if-present
- run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
- run: npx conventional-github-releaser -p angular
env:
CONVENTIONAL_GITHUB_RELEASER_TOKEN: ${{secrets.GITHUB_TOKEN}}
30 changes: 30 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Test

on: [push, pull_request]

jobs:
build:
runs-on: ${{ matrix.os }}

strategy:
matrix:
node-version: [14.x, 16.x]
os: [ubuntu-latest, macos-latest]
fail-fast: false

steps:
- uses: actions/checkout@v2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- name: Setup
run: npm i -g pnpm @antfu/ni

- name: Install
run: nci

- name: Test
run: nr test --if-present
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
# Build results
*.js
!/lib/**/*.js
*.d.ts
!/lib/**/*.d.ts

# Source maps
*.map

# Test result
/tests/output

# Logs
logs
*.log
Expand Down
6 changes: 6 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/*
!/lib
!/LICENSE
!/package.json
!/README.md
!/yarn.lock
6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"endOfLine": "auto",
"semi": true,
"singleQuote": true,
"trailingComma": "all"
}
238 changes: 0 additions & 238 deletions index.js

This file was deleted.

3 changes: 3 additions & 0 deletions lib/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { Plugin } from 'unified';
declare const remarkDetails: Plugin;
export default remarkDetails;
36 changes: 36 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { h } from 'hastscript';
import { visit } from 'unist-util-visit';
import { fromMarkdownDetails } from './mdast-util-details/index.js';
import { syntax } from './micromark-details/index.js';
let warningIssued = false;
const remarkDetails = function (options) {
var _a, _b, _c, _d;
const data = this.data();
// warning for old remarks
if (!warningIssued &&
(((_b = (_a = this.Parser) === null || _a === void 0 ? void 0 : _a.prototype) === null || _b === void 0 ? void 0 : _b.blockTokenizers) ||
((_d = (_c = this.Compiler) === null || _c === void 0 ? void 0 : _c.prototype) === null || _d === void 0 ? void 0 : _d.visitors))) {
warningIssued = true;
console.warn('[remark-details] Warning: please upgrade to remark 13 to use this plugin');
}
function add(field, value) {
/* istanbul ignore if - other extensions. */
if (data[field])
data[field].push(value);
else
data[field] = [value];
}
add('micromarkExtensions', syntax);
add('fromMarkdownExtensions', fromMarkdownDetails);
return transform;
function transform(tree) {
visit(tree, ['detailsContainer', 'detailsContainerSummary'], ondetails);
}
function ondetails(node) {
var data = node.data || (node.data = {});
var hast = h(node.name, node.attributes);
data.hName = hast.tagName;
data.hProperties = hast.properties;
}
};
export default remarkDetails;
3 changes: 3 additions & 0 deletions lib/mdast-util-details/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { Extension } from 'mdast-util-from-markdown/lib';
export declare const fromMarkdownDetails: Extension;
export declare const detailsToMarkdown: {};
Loading

0 comments on commit 5b51b4a

Please sign in to comment.