Skip to content

Commit

Permalink
Merge pull request #431 from thematters/develop
Browse files Browse the repository at this point in the history
Release: v0.2.0
  • Loading branch information
robertu7 authored Jun 28, 2023
2 parents 2ae73ab + 0c79e2c commit aa6949d
Show file tree
Hide file tree
Showing 134 changed files with 19,776 additions and 19,584 deletions.
27 changes: 27 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"env": {
"browser": true,
"es2021": true,
"node": true
},
"extends": [
"plugin:react/recommended",
"standard-with-typescript",
"prettier"
],
"overrides": [
],
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"plugins": [
"react",
"simple-import-sort"
],
"rules": {
"simple-import-sort/imports": "error",
"simple-import-sort/exports": "error",
"react-hooks/exhaustive-deps": "off"
}
}
47 changes: 47 additions & 0 deletions .github/workflows/deploy_demo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Deploy Demo

on:
push:
branches:
- master

jobs:
build:
name: Build
runs-on: ubuntu-latest

steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Setup Node
uses: actions/setup-node@v3

- name: Install dependencies
uses: bahmutov/npm-install@v1

- name: Build project
run: npm run build:demo

- name: Upload production-ready build files
uses: actions/upload-artifact@v3
with:
name: production-files
path: ./demo

deploy:
name: Deploy
needs: build
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
steps:
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: production-files
path: ./demo
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./demo
6 changes: 3 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Setup Node.js
uses: actions/[email protected]
with:
node-version: '12.16'
node-version: '16.14'
registry-url: 'https://registry.npmjs.org'
always-auth: true

Expand All @@ -37,15 +37,15 @@ jobs:
run: npm ci

- name: Test
run: npm run lint
run: npm run lint && npm run test

- name: Build
run: npm run build

# === `master` branch ===
- name: Publish to NPM
if: github.ref == 'refs/heads/master'
run: npm publish
run: npm publish ./dist
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Setup Node.js
uses: actions/[email protected]
with:
node-version: '12.16'
node-version: '16.14'
registry-url: 'https://registry.npmjs.org'
always-auth: true

Expand All @@ -35,7 +35,7 @@ jobs:
run: npm ci

- name: Test
run: npm run lint
run: npm run lint && npm run test

- name: Build
run: npm run build
116 changes: 16 additions & 100 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,107 +4,23 @@ logs
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# generated files
__generated__

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# next.js build output
.next

# nuxt.js build output
.nuxt

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# Elastic Beanstalk Files
.elasticbeanstalk/*
!.elasticbeanstalk/*.cfg.yml
!.elasticbeanstalk/*.global.yml

# Local System
.DS_Store

build
node_modules
dist
static-site-build
yarn.lock
dist-ssr
*.local

# ctags
/tags
/tags.*

# exclude sources.list
sources.list
*.rdb
.ebextensions/http-basic-auth.config

src/themes/*.json
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

.parcel-cache
types/**/*
types
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npm test && npm run lint
2 changes: 2 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
unsafe-perm=true
legacy-peer-deps=true
11 changes: 0 additions & 11 deletions .postcssrc

This file was deleted.

39 changes: 39 additions & 0 deletions benchmark/html2md.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { suite, add, cycle, complete, save } from 'benny'
import fs from 'fs'
import path from 'path'
import naturalCompare from 'natural-compare-lite'

import { html2md } from '../src'

const originalDir = path.resolve('./examples/original')

const htmls: { [key: string]: any } = {}
const adds: any[] = []

const filenames = fs
.readdirSync(originalDir, { encoding: 'utf-8' })
.sort(naturalCompare)

for (let filename of filenames) {
const html = fs.readFileSync(path.resolve(originalDir, filename), 'utf-8')
htmls[filename] = html
adds.push(
add(`~${filename.split('.')[0]} characters`, async () => {
html2md(htmls[filename])
})
)
}

suite(
'HTML to Markdown',
...adds,
cycle(),
complete(() => {
const used = process.memoryUsage().heapUsed / 1024 / 1024
console.log(
`\nThe script uses approximately ${Math.round(used * 100) / 100} MB`
)
}),
save({ file: 'html2md' }),
save({ file: 'html2md', format: 'chart.html' })
)
2 changes: 2 additions & 0 deletions benchmark/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import './html2md'
import './md2html'
39 changes: 39 additions & 0 deletions benchmark/md2html.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { suite, add, cycle, complete, save } from 'benny'
import fs from 'fs'
import path from 'path'
import naturalCompare from 'natural-compare-lite'

import { md2html } from '../src'

const markdownDir = path.resolve('./examples/markdown')

const mds: { [key: string]: any } = {}
const adds: any[] = []

const filenames = fs
.readdirSync(markdownDir, { encoding: 'utf-8' })
.sort(naturalCompare)

for (let filename of filenames) {
const md = fs.readFileSync(path.resolve(markdownDir, filename), 'utf-8')
mds[filename] = md
adds.push(
add(`~${filename.split('.')[0]} characters`, async () => {
md2html(mds[filename])
})
)
}

suite(
'Markdown to HTML',
...adds,
cycle(),
complete(() => {
const used = process.memoryUsage().heapUsed / 1024 / 1024
console.log(
`\nThe script uses approximately ${Math.round(used * 100) / 100} MB`
)
}),
save({ file: 'md2html' }),
save({ file: 'md2html', format: 'chart.html' })
)
Loading

0 comments on commit aa6949d

Please sign in to comment.