Skip to content

Commit

Permalink
Merge pull request #1 from shgysk8zer0/release/0.0.1
Browse files Browse the repository at this point in the history
Initial release code
  • Loading branch information
shgysk8zer0 authored Feb 6, 2024
2 parents 28f677f + 73ece75 commit 4264457
Show file tree
Hide file tree
Showing 8 changed files with 990 additions and 921 deletions.
61 changes: 1 addition & 60 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,65 +6,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed
- Setup to transpile all `./*.js` to `./cjs/*.cjs` (except `*.config.js`)
- Update `exports` and `main` accordingly

## [v1.1.1] - 2023-09-24

### Added
- Add `unpkg` to `package.json`
- Add badges in README

### Changed
- Update `exports` to `package.json` to handle wider variety

### Fixed
- Fix typo in `fix:js` script

### [v1.1.0] - 2023-07-03

### Changed
- Update to node 20
- Update npm publishing GH Action

## [v1.0.5] - 2023-07-02

### Added
- Add `funding`

### Changed
- Updated GitHub Actions workflows
- Update versioning & lock-file scripts
- Update `.npmignore` & `.gitignore`

## [v1.0.4] - 2023-06-08

### Added
- Install `@shgysk8zer0/npm-utils`
- Add `exports` to package config

### Removed
- Uninstall `rollup`, `eslint`

### Changed
- Use `getConfig()` from `@shgysk8zer0/js-utils/rollup` for rollup config

## [v1.0.3] - 2023-06-01

### Fixed
- Revert to old Release Action, now with permissions & link to changelog

## [v1.0.2] - 2023-06-01

### Fixed
- Fix `changelog-entry` to match `[$version]` instead of `$version`

## [v1.0.1] - 2023-05-31

### Fixed
- Update GitHub Release workflow to use [Auto Release](https://github.com/marketplace/actions/auto-release)

## [v1.0.0] - 2023-05-31
## [v0.0.1] - 2024-02-05

Initial Release
28 changes: 18 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# npm-template
# `@shgysk8zer0/aegis-markdown`

A template repo for npm packages
Markdown parser for [`@shgysk8zer0/aegis`](https://github.com/shgysk8zer0/aegis)

[![CodeQL](https://github.com/shgysk8zer0/node-http/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/shgysk8zer0/npm-template/actions/workflows/codeql-analysis.yml)
![Node CI](https://github.com/shgysk8zer0/node-http/workflows/Node%20CI/badge.svg)
![Lint Code Base](https://github.com/shgysk8zer0/node-http/workflows/Lint%20Code%20Base/badge.svg)
[![CodeQL](https://github.com/shgysk8zer0/aegis-markdown/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/shgysk8zer0/npm-template/actions/workflows/codeql-analysis.yml)
![Node CI](https://github.com/shgysk8zer0/aegis-markdown/workflows/Node%20CI/badge.svg)
![Lint Code Base](https://github.com/shgysk8zer0/aegis-markdown/workflows/Lint%20Code%20Base/badge.svg)

[![GitHub license](https://img.shields.io/github/license/shgysk8zer0/node-http.svg)](https://github.com/shgysk8zer0/node-http/blob/master/LICENSE)
[![GitHub last commit](https://img.shields.io/github/last-commit/shgysk8zer0/node-http.svg)](https://github.com/shgysk8zer0/node-http/commits/master)
[![GitHub release](https://img.shields.io/github/release/shgysk8zer0/node-http?logo=github)](https://github.com/shgysk8zer0/node-http/releases)
[![GitHub license](https://img.shields.io/github/license/shgysk8zer0/aegis-markdown.svg)](https://github.com/shgysk8zer0/aegis-markdown/blob/master/LICENSE)
[![GitHub last commit](https://img.shields.io/github/last-commit/shgysk8zer0/aegis-markdown.svg)](https://github.com/shgysk8zer0/aegis-markdown/commits/master)
[![GitHub release](https://img.shields.io/github/release/shgysk8zer0/aegis-markdown?logo=github)](https://github.com/shgysk8zer0/aegis-markdown/releases)
[![GitHub Sponsors](https://img.shields.io/github/sponsors/shgysk8zer0?logo=github)](https://github.com/sponsors/shgysk8zer0)

[![npm](https://img.shields.io/npm/v/@shgysk8zer0/npm-template)](https://www.npmjs.com/package/@shgysk8zer0/npm-template)
Expand All @@ -17,8 +17,8 @@ A template repo for npm packages
[![npm](https://img.shields.io/npm/dw/@shgysk8zer0/npm-template?logo=npm)](https://www.npmjs.com/package/@shgysk8zer0/npm-template)

[![GitHub followers](https://img.shields.io/github/followers/shgysk8zer0.svg?style=social)](https://github.com/shgysk8zer0)
![GitHub forks](https://img.shields.io/github/forks/shgysk8zer0/node-http.svg?style=social)
![GitHub stars](https://img.shields.io/github/stars/shgysk8zer0/node-http.svg?style=social)
![GitHub forks](https://img.shields.io/github/forks/shgysk8zer0/aegis-markdown.svg?style=social)
![GitHub stars](https://img.shields.io/github/stars/shgysk8zer0/aegis-markdown.svg?style=social)
[![Twitter Follow](https://img.shields.io/twitter/follow/shgysk8zer0.svg?style=social)](https://twitter.com/shgysk8zer0)

[![Donate using Liberapay](https://img.shields.io/liberapay/receives/shgysk8zer0.svg?logo=liberapay)](https://liberapay.com/shgysk8zer0/donate "Donate using Liberapay")
Expand All @@ -27,3 +27,11 @@ A template repo for npm packages
- [Code of Conduct](./.github/CODE_OF_CONDUCT.md)
- [Contributing](./.github/CONTRIBUTING.md)
<!-- - [Security Policy](./.github/SECURITY.md) -->

## Example

```js
import { md } from '@shgysk8zer0/aegis-markdown';

document.body.append(md`# Hello, World!`);
```
Empty file removed cjs/.gitkeep
Empty file.
1 change: 0 additions & 1 deletion index.js

This file was deleted.

38 changes: 38 additions & 0 deletions markdown.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { Marked } from 'marked';
import { markedHighlight } from 'marked-highlight';
import hljs from 'highlight.js';
import { createHTMLParser, text } from '@shgysk8zer0/aegis';

const parseStr = args => text.apply(null, args);

export function createMDParser({
gfm = true,
breaks = false,
silent = false,
langPrefix = 'hljs language-',
fallbackLang = 'plaintext',
allowElements,
allowAttributes,
allowCustomElements,
allowUnknownMarkup,
allowComments,
} = {}) {
const parser = createHTMLParser({
allowElements, allowAttributes, allowCustomElements, allowUnknownMarkup,
allowComments,
});

const marked = new Marked(
markedHighlight({
langPrefix,
highlight(code, lang) {
const language = hljs.getLanguage(lang) ? lang : fallbackLang;
return hljs.highlight(code, { language }).value;
}
})
);

return (...args) => parser([marked.parse(parseStr(args), { gfm, breaks, silent })]);
}

export const md = createMDParser({});
Loading

0 comments on commit 4264457

Please sign in to comment.