Skip to content

Commit

Permalink
prototype
Browse files Browse the repository at this point in the history
  • Loading branch information
shotanue committed Dec 16, 2023
1 parent 3332549 commit 6121730
Show file tree
Hide file tree
Showing 12 changed files with 541 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Code quality

on:
push:
pull_request:

jobs:
quality:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup bun
uses: oven-sh/setup-bun@v1
with:
bun-version: 1.0.18
- run: bun install
- run: bun run ci
- run: bun run test
48 changes: 48 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Release

on:
push:
tags:
- '*'

jobs:
build:
name: Release binary
strategy:
matrix:
include:
- os: ubuntu-22.04
asset_name: md2hype-linux-amd64
- os: macos-12
asset_name: md2hype-darwin-amd64
- os: macos-13-xlarge
asset_name: md2hype-darwin-arm64

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

steps:
- name: Dump runner information
run: |
echo "Runner Name: ${{ runner.name }}"
echo "Operating System: ${{ runner.os }}"
echo "CPU Architecture: ${{ runner.arch}}"
- name: Checkout
uses: actions/checkout@v4
- name: Setup bun
uses: oven-sh/setup-bun@v1
with:
bun-version: 1.0.18

- run: bun install
- run: bun ci
- run: bun test
- run: bun run build

- name: Upload binaries to release
uses: svenstaro/[email protected]
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: md2hype
asset_name: ${{ matrix.asset_name }}
tag: ${{ github.ref }}
overwrite: true
183 changes: 183 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore

# Logs

logs
_.log
npm-debug.log_
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Caches

.cache

# Diagnostic reports (https://nodejs.org/api/report.html)

report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json

# Runtime data

pids
_.pid
_.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover

lib-cov

# Coverage directory used by tools like istanbul

coverage
*.lcov

# 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/Release

# Dependency directories

node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)

web_modules/

# TypeScript cache

*.tsbuildinfo

# Optional npm cache directory

.npm

# Optional eslint cache

.eslintcache

# Optional stylelint cache

.stylelintcache

# Microbundle cache

.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history

.node_repl_history

# Output of 'npm pack'

*.tgz

# Yarn Integrity file

.yarn-integrity

# dotenv environment variable files

.env
.env.development.local
.env.test.local
.env.production.local
.env.local

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

.parcel-cache

# Next.js build output

.next
out

# Nuxt.js build / generate output

.nuxt
dist

# Gatsby files

# Comment in the public line in if your project uses Gatsby and not Next.js

# https://nextjs.org/blog/next-9-1#public-directory-support

# public

# vuepress build output

.vuepress/dist

# vuepress v2.x temp and cache directory

.temp

# Docusaurus cache and generated files

.docusaurus

# Serverless directories

.serverless/

# FuseBox cache

.fusebox/

# DynamoDB Local files

.dynamodb/

# TernJS port file

.tern-port

# Stores VSCode versions used for testing VSCode extensions

.vscode-test

# yarn v2

.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

# IntelliJ based IDEs
.idea

# Finder (MacOS) folder config
.DS_Store


# ------

test.html
test.md

md2hype
56 changes: 56 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,61 @@
# md2hype

A text converter, markdown to html, powered by [unified.js](https://unifiedjs.com)

## Built-in unifiedjs plugins

for markdown parsing
- remark-breaks
- remark-frontmatter
- remark-gfm
- remark-parse

## Installation

WIP

Install the excutable, built by [bun.sh](https://bun.sh)

```bash
brew install shotanue/tap/md2hype
```

## How to use


```bash
md2hype --file foo.md
```

- foo.md

```md
---
tag:
- foo
---
hello world
```

- output

```json
{
"html": "<p>hello world</p>",
"frontmatter": {
"tag": ["foo"]
}
}
```

### If you want output only html

```bash
md2hype --file foo.md --html
```

```html
<p>hello world</p>
```


20 changes: 20 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"$schema": "https://biomejs.dev/schemas/1.4.1/schema.json",
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
}
},
"formatter": {
"enabled": true,
"formatWithErrors": false,
"indentStyle": "space",
"indentWidth": 2,
"lineWidth": 120,
"ignore": []
}
}
4 changes: 4 additions & 0 deletions bunfig.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[install.lockfile]
# This project pins versions, due to using renovete.
save = false

35 changes: 35 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "md2hype",
"module": "index.ts",
"type": "module",
"dependencies": {
"arg": "5.0.2",
"chalk-template": "1.1.0",
"rehype-stringify": "10.0.0",
"remark-breaks": "4.0.0",
"remark-frontmatter": "5.0.0",
"remark-gfm": "4.0.0",
"remark-parse": "11.0.0",
"remark-rehype": "11.0.0",
"smol-toml": "1.1.3",
"unified": "11.0.4",
"unist-util-flat-filter": "2.0.0",
"yaml": "2.3.4",
"zod": "3.22.4"
},
"devDependencies": {
"@biomejs/biome": "1.4.1",
"bun-types": "latest"
},
"peerDependencies": {
"typescript": "^5.0.0"
},
"scripts": {
"run": "bun run ./src/index.ts",
"build": "bun build ./src/index.ts --compile --outfile md2hype",
"test": "bun test",
"check": "biome check .",
"check:fix": "biome check --apply-unsafe .",
"ci": "biome ci ."
}
}
6 changes: 6 additions & 0 deletions renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["config:base"],
"labels": ["renovate"],
"automerge": true
}
9 changes: 9 additions & 0 deletions resource/help.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{bold # md2hype}

{bold ## USAGE}

{dim $} {bold md2hype} [--help, -h] --file {underline path}

{bold ## OPTIONS}
--help, -h Shows this help message
--file {underline path} Markdown file path
Loading

0 comments on commit 6121730

Please sign in to comment.