Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
6bd015e5bb | |||
97248d63db | |||
e6ef461347 | |||
fd52655e63 | |||
9a8dd46cdb | |||
d29d5dd07a | |||
8732b27445 | |||
2a5013fb56 | |||
64b50eeb1c | |||
7f1777e38b |
4
.gitignore
vendored
4
.gitignore
vendored
@ -15,8 +15,6 @@ node_modules/
|
|||||||
|
|
||||||
# builds
|
# builds
|
||||||
dist/
|
dist/
|
||||||
dist_web/
|
dist_*/
|
||||||
dist_serve/
|
|
||||||
dist_ts_web/
|
|
||||||
|
|
||||||
# custom
|
# custom
|
@ -19,22 +19,36 @@ mirror:
|
|||||||
stage: security
|
stage: security
|
||||||
script:
|
script:
|
||||||
- npmci git mirror
|
- npmci git mirror
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
- notpriv
|
||||||
|
|
||||||
snyk:
|
auditProductionDependencies:
|
||||||
image: registry.gitlab.com/hosttoday/ht-docker-node:snyk
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
stage: security
|
||||||
|
script:
|
||||||
|
- npmci npm prepare
|
||||||
|
- npmci command npm install --production --ignore-scripts
|
||||||
|
- npmci command npm config set registry https://registry.npmjs.org
|
||||||
|
- npmci command npm audit --audit-level=high --only=prod --production
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
allow_failure: true
|
||||||
|
|
||||||
|
auditDevDependencies:
|
||||||
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
stage: security
|
stage: security
|
||||||
script:
|
script:
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
- npmci command npm install --ignore-scripts
|
- npmci command npm install --ignore-scripts
|
||||||
- npmci command snyk test
|
- npmci command npm config set registry https://registry.npmjs.org
|
||||||
|
- npmci command npm audit --audit-level=high --only=dev
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
allow_failure: true
|
||||||
|
|
||||||
# ====================
|
# ====================
|
||||||
# test stage
|
# test stage
|
||||||
@ -49,9 +63,7 @@ testStable:
|
|||||||
- npmci npm test
|
- npmci npm test
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
|
||||||
- docker
|
- docker
|
||||||
- priv
|
|
||||||
|
|
||||||
testBuild:
|
testBuild:
|
||||||
stage: test
|
stage: test
|
||||||
@ -62,9 +74,7 @@ testBuild:
|
|||||||
- npmci command npm run build
|
- npmci command npm run build
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
|
||||||
|
|
||||||
release:
|
release:
|
||||||
stage: release
|
stage: release
|
||||||
@ -84,6 +94,8 @@ release:
|
|||||||
codequality:
|
codequality:
|
||||||
stage: metadata
|
stage: metadata
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
script:
|
script:
|
||||||
- npmci command npm install -g tslint typescript
|
- npmci command npm install -g tslint typescript
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
|
11
.vscode/launch.json
vendored
Normal file
11
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"command": "npm test",
|
||||||
|
"name": "Run npm test",
|
||||||
|
"request": "launch",
|
||||||
|
"type": "node-terminal"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
26
.vscode/settings.json
vendored
Normal file
26
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"json.schemas": [
|
||||||
|
{
|
||||||
|
"fileMatch": ["/npmextra.json"],
|
||||||
|
"schema": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"npmci": {
|
||||||
|
"type": "object",
|
||||||
|
"description": "settings for npmci"
|
||||||
|
},
|
||||||
|
"gitzone": {
|
||||||
|
"type": "object",
|
||||||
|
"description": "settings for gitzone",
|
||||||
|
"properties": {
|
||||||
|
"projectType": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": ["website", "element", "service", "npm", "wcc"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -1,3 +0,0 @@
|
|||||||
merge:
|
|
||||||
- ../gitignore
|
|
||||||
- ../ci_default
|
|
@ -1,6 +1,4 @@
|
|||||||
The MIT License (MIT)
|
Copyright (c) 2014 Lossless GmbH (hello@lossless.com)
|
||||||
|
|
||||||
Copyright (c) 2016 Push.Rocks
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
@ -18,4 +16,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
SOFTWARE.
|
SOFTWARE.
|
@ -4,6 +4,7 @@
|
|||||||
"npmAccessLevel": "public"
|
"npmAccessLevel": "public"
|
||||||
},
|
},
|
||||||
"gitzone": {
|
"gitzone": {
|
||||||
|
"projectType": "npm",
|
||||||
"module": {
|
"module": {
|
||||||
"githost": "gitlab.com",
|
"githost": "gitlab.com",
|
||||||
"gitscope": "pushrocks",
|
"gitscope": "pushrocks",
|
||||||
|
27419
package-lock.json
generated
27419
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
32
package.json
32
package.json
@ -1,10 +1,10 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartmarkdown",
|
"name": "@pushrocks/smartmarkdown",
|
||||||
"version": "2.0.5",
|
"version": "2.0.10",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "do more with markdown files",
|
"description": "do more with markdown files",
|
||||||
"main": "dist/index.js",
|
"main": "dist_ts/index.js",
|
||||||
"typings": "dist/index.d.ts",
|
"typings": "dist_ts/index.d.ts",
|
||||||
"author": "Lossless GmbH",
|
"author": "Lossless GmbH",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@ -12,30 +12,34 @@
|
|||||||
"build": "tsbuild --web"
|
"build": "tsbuild --web"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.17",
|
"@gitzone/tsbuild": "^2.1.27",
|
||||||
"@gitzone/tsrun": "^1.2.8",
|
"@gitzone/tsrun": "^1.2.17",
|
||||||
"@gitzone/tstest": "^1.0.28",
|
"@gitzone/tstest": "^1.0.57",
|
||||||
"@pushrocks/tapbundle": "^3.2.0",
|
"@pushrocks/tapbundle": "^3.2.14",
|
||||||
"@types/node": "^13.1.8",
|
"@types/node": "^16.10.2",
|
||||||
"tslint": "^5.20.1",
|
"tslint": "^6.1.3",
|
||||||
"tslint-config-prettier": "^1.18.0"
|
"tslint-config-prettier": "^1.18.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/marked": "^0.7.2",
|
"@types/turndown": "^5.0.1",
|
||||||
"@types/turndown": "^5.0.0",
|
"remark": "^13.0.0",
|
||||||
"marked": "^0.8.0",
|
"remark-html": "^13.0.0",
|
||||||
"turndown": "^5.0.3",
|
"turndown": "^7.1.1",
|
||||||
"turndown-plugin-gfm": "^1.0.2"
|
"turndown-plugin-gfm": "^1.0.2"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"ts/**/*",
|
"ts/**/*",
|
||||||
"ts_web/**/*",
|
"ts_web/**/*",
|
||||||
"dist/**/*",
|
"dist/**/*",
|
||||||
"dist_web/**/*",
|
"dist_*/**/*",
|
||||||
|
"dist_ts/**/*",
|
||||||
"dist_ts_web/**/*",
|
"dist_ts_web/**/*",
|
||||||
"assets/**/*",
|
"assets/**/*",
|
||||||
"cli.js",
|
"cli.js",
|
||||||
"npmextra.json",
|
"npmextra.json",
|
||||||
"readme.md"
|
"readme.md"
|
||||||
|
],
|
||||||
|
"browserslist": [
|
||||||
|
"last 1 chrome versions"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
22
readme.md
22
readme.md
@ -8,16 +8,24 @@ do more with markdown files
|
|||||||
* [docs (typedoc)](https://pushrocks.gitlab.io/smartmarkdown/)
|
* [docs (typedoc)](https://pushrocks.gitlab.io/smartmarkdown/)
|
||||||
|
|
||||||
## Status for master
|
## Status for master
|
||||||
[](https://gitlab.com/pushrocks/smartmarkdown/commits/master)
|
|
||||||
[](https://gitlab.com/pushrocks/smartmarkdown/commits/master)
|
Status Category | Status Badge
|
||||||
[](https://www.npmjs.com/package/@pushrocks/smartmarkdown)
|
-- | --
|
||||||
[](https://snyk.io/test/npm/@pushrocks/smartmarkdown)
|
GitLab Pipelines | [](https://lossless.cloud)
|
||||||
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
GitLab Pipline Test Coverage | [](https://lossless.cloud)
|
||||||
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
npm | [](https://lossless.cloud)
|
||||||
[](https://prettier.io/)
|
Snyk | [](https://lossless.cloud)
|
||||||
|
TypeScript Support | [](https://lossless.cloud)
|
||||||
|
node Support | [](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||||
|
Code Style | [](https://lossless.cloud)
|
||||||
|
PackagePhobia (total standalone install weight) | [](https://lossless.cloud)
|
||||||
|
PackagePhobia (package size on registry) | [](https://lossless.cloud)
|
||||||
|
BundlePhobia (total size when bundled) | [](https://lossless.cloud)
|
||||||
|
Platform support | [](https://lossless.cloud) [](https://lossless.cloud)
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
|
Use TypeScript for best in class intellisense.
|
||||||
|
|
||||||
## Contribution
|
## Contribution
|
||||||
|
|
||||||
|
@ -10,8 +10,8 @@ tap.test('should create a valid instance of SmartMarkdown', async () => {
|
|||||||
|
|
||||||
tap.test('should convert a markdown string to html', async () => {
|
tap.test('should convert a markdown string to html', async () => {
|
||||||
const markdownString = '# Hi!';
|
const markdownString = '# Hi!';
|
||||||
const htmlString = smartMarkdownInstance.markdownToHtml(markdownString);
|
const htmlString = await smartMarkdownInstance.markdownToHtml(markdownString);
|
||||||
expect(htmlString).to.equal('<h1 id="hi">Hi!</h1>\n');
|
expect(htmlString).to.equal('<h1>Hi!</h1>\n');
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('should convert a html string to markdown', async () => {
|
tap.test('should convert a html string to markdown', async () => {
|
||||||
|
@ -7,14 +7,15 @@ export class SmartMarkdown {
|
|||||||
* converts markdown to html
|
* converts markdown to html
|
||||||
* @param mdString
|
* @param mdString
|
||||||
*/
|
*/
|
||||||
public markdownToHtml(mdString: string): string {
|
public async markdownToHtml(mdString: string): Promise<string> {
|
||||||
return plugins.marked(mdString);
|
const result = await plugins.remark().use(plugins.remarkHtml).process(mdString);
|
||||||
|
return result.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public htmlToMarkdown(htmlString): string {
|
public htmlToMarkdown(htmlString: string): string {
|
||||||
const turndownInstance = new plugins.turndown({
|
const turndownInstance = new plugins.turndown({
|
||||||
headingStyle: 'atx',
|
headingStyle: 'atx',
|
||||||
codeBlockStyle: 'fenced'
|
codeBlockStyle: 'fenced',
|
||||||
});
|
});
|
||||||
turndownInstance.use(plugins.turndownPluginGfm.gfm);
|
turndownInstance.use(plugins.turndownPluginGfm.gfm);
|
||||||
return turndownInstance.turndown(htmlString);
|
return turndownInstance.turndown(htmlString);
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
import marked = require('marked');
|
// third party remark
|
||||||
|
import remark from 'remark';
|
||||||
|
import remarkHtml from 'remark-html';
|
||||||
|
|
||||||
|
export { remark, remarkHtml };
|
||||||
|
|
||||||
|
// other third party stuff
|
||||||
import turndown from 'turndown';
|
import turndown from 'turndown';
|
||||||
|
// @ts-ignore
|
||||||
import * as turndownPluginGfm from 'turndown-plugin-gfm';
|
import * as turndownPluginGfm from 'turndown-plugin-gfm';
|
||||||
|
|
||||||
export { marked, turndown, turndownPluginGfm };
|
export { turndown, turndownPluginGfm };
|
||||||
|
Reference in New Issue
Block a user