Skip to content

Commit 4264457

Browse files
authored
Merge pull request #1 from shgysk8zer0/release/0.0.1
Initial release code
2 parents 28f677f + 73ece75 commit 4264457

File tree

8 files changed

+990
-921
lines changed

8 files changed

+990
-921
lines changed

CHANGELOG.md

Lines changed: 1 addition & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -6,65 +6,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9-
### Changed
10-
- Setup to transpile all `./*.js` to `./cjs/*.cjs` (except `*.config.js`)
11-
- Update `exports` and `main` accordingly
12-
13-
## [v1.1.1] - 2023-09-24
14-
15-
### Added
16-
- Add `unpkg` to `package.json`
17-
- Add badges in README
18-
19-
### Changed
20-
- Update `exports` to `package.json` to handle wider variety
21-
22-
### Fixed
23-
- Fix typo in `fix:js` script
24-
25-
### [v1.1.0] - 2023-07-03
26-
27-
### Changed
28-
- Update to node 20
29-
- Update npm publishing GH Action
30-
31-
## [v1.0.5] - 2023-07-02
32-
33-
### Added
34-
- Add `funding`
35-
36-
### Changed
37-
- Updated GitHub Actions workflows
38-
- Update versioning & lock-file scripts
39-
- Update `.npmignore` & `.gitignore`
40-
41-
## [v1.0.4] - 2023-06-08
42-
43-
### Added
44-
- Install `@shgysk8zer0/npm-utils`
45-
- Add `exports` to package config
46-
47-
### Removed
48-
- Uninstall `rollup`, `eslint`
49-
50-
### Changed
51-
- Use `getConfig()` from `@shgysk8zer0/js-utils/rollup` for rollup config
52-
53-
## [v1.0.3] - 2023-06-01
54-
55-
### Fixed
56-
- Revert to old Release Action, now with permissions & link to changelog
57-
58-
## [v1.0.2] - 2023-06-01
59-
60-
### Fixed
61-
- Fix `changelog-entry` to match `[$version]` instead of `$version`
62-
63-
## [v1.0.1] - 2023-05-31
64-
65-
### Fixed
66-
- Update GitHub Release workflow to use [Auto Release](https://github.com/marketplace/actions/auto-release)
67-
68-
## [v1.0.0] - 2023-05-31
9+
## [v0.0.1] - 2024-02-05
6910

7011
Initial Release

README.md

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
# npm-template
1+
# `@shgysk8zer0/aegis-markdown`
22

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

5-
[![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)
6-
![Node CI](https://github.com/shgysk8zer0/node-http/workflows/Node%20CI/badge.svg)
7-
![Lint Code Base](https://github.com/shgysk8zer0/node-http/workflows/Lint%20Code%20Base/badge.svg)
5+
[![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)
6+
![Node CI](https://github.com/shgysk8zer0/aegis-markdown/workflows/Node%20CI/badge.svg)
7+
![Lint Code Base](https://github.com/shgysk8zer0/aegis-markdown/workflows/Lint%20Code%20Base/badge.svg)
88

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

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

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

2424
[![Donate using Liberapay](https://img.shields.io/liberapay/receives/shgysk8zer0.svg?logo=liberapay)](https://liberapay.com/shgysk8zer0/donate "Donate using Liberapay")
@@ -27,3 +27,11 @@ A template repo for npm packages
2727
- [Code of Conduct](./.github/CODE_OF_CONDUCT.md)
2828
- [Contributing](./.github/CONTRIBUTING.md)
2929
<!-- - [Security Policy](./.github/SECURITY.md) -->
30+
31+
## Example
32+
33+
```js
34+
import { md } from '@shgysk8zer0/aegis-markdown';
35+
36+
document.body.append(md`# Hello, World!`);
37+
```

cjs/.gitkeep

Whitespace-only changes.

index.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

markdown.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { Marked } from 'marked';
2+
import { markedHighlight } from 'marked-highlight';
3+
import hljs from 'highlight.js';
4+
import { createHTMLParser, text } from '@shgysk8zer0/aegis';
5+
6+
const parseStr = args => text.apply(null, args);
7+
8+
export function createMDParser({
9+
gfm = true,
10+
breaks = false,
11+
silent = false,
12+
langPrefix = 'hljs language-',
13+
fallbackLang = 'plaintext',
14+
allowElements,
15+
allowAttributes,
16+
allowCustomElements,
17+
allowUnknownMarkup,
18+
allowComments,
19+
} = {}) {
20+
const parser = createHTMLParser({
21+
allowElements, allowAttributes, allowCustomElements, allowUnknownMarkup,
22+
allowComments,
23+
});
24+
25+
const marked = new Marked(
26+
markedHighlight({
27+
langPrefix,
28+
highlight(code, lang) {
29+
const language = hljs.getLanguage(lang) ? lang : fallbackLang;
30+
return hljs.highlight(code, { language }).value;
31+
}
32+
})
33+
);
34+
35+
return (...args) => parser([marked.parse(parseStr(args), { gfm, breaks, silent })]);
36+
}
37+
38+
export const md = createMDParser({});

0 commit comments

Comments
 (0)