Compare commits
14 Commits
Author | SHA1 | Date | |
---|---|---|---|
ae580dd09e | |||
f470e591cc | |||
945b0ae8b8 | |||
ba90bb50a2 | |||
72de4bfb7d | |||
d195535ca0 | |||
989febe988 | |||
ebaa68a2fe | |||
effc3b10b1 | |||
1361e825fe | |||
a66e795432 | |||
1712f8e628 | |||
366856e904 | |||
173536be39 |
18
.gitignore
vendored
18
.gitignore
vendored
@ -1,6 +1,22 @@
|
|||||||
.nogit/
|
.nogit/
|
||||||
node_modules/
|
|
||||||
|
# artifacts
|
||||||
coverage/
|
coverage/
|
||||||
public/
|
public/
|
||||||
pages/
|
pages/
|
||||||
|
|
||||||
|
# installs
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# caches
|
||||||
.yarn/
|
.yarn/
|
||||||
|
.cache/
|
||||||
|
.rpt2_cache
|
||||||
|
|
||||||
|
# builds
|
||||||
|
dist/
|
||||||
|
dist_web/
|
||||||
|
dist_serve/
|
||||||
|
dist_ts_web/
|
||||||
|
|
||||||
|
# custom
|
@ -1,4 +1,4 @@
|
|||||||
# gitzone standard
|
# gitzone ci_default
|
||||||
image: hosttoday/ht-docker-node:npmci
|
image: hosttoday/ht-docker-node:npmci
|
||||||
|
|
||||||
cache:
|
cache:
|
||||||
@ -37,18 +37,6 @@ snyk:
|
|||||||
# ====================
|
# ====================
|
||||||
# test stage
|
# test stage
|
||||||
# ====================
|
# ====================
|
||||||
testLEGACY:
|
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci node install legacy
|
|
||||||
- npmci npm install
|
|
||||||
- npmci npm test
|
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
allow_failure: true
|
|
||||||
|
|
||||||
testLTS:
|
testLTS:
|
||||||
stage: test
|
stage: test
|
||||||
@ -90,19 +78,11 @@ release:
|
|||||||
# ====================
|
# ====================
|
||||||
codequality:
|
codequality:
|
||||||
stage: metadata
|
stage: metadata
|
||||||
image: docker:stable
|
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
services:
|
|
||||||
- docker:stable-dind
|
|
||||||
script:
|
script:
|
||||||
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
|
- npmci command npm install -g tslint typescript
|
||||||
- docker run
|
- npmci npm install
|
||||||
--env SOURCE_CODE="$PWD"
|
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
|
||||||
--volume "$PWD":/code
|
|
||||||
--volume /var/run/docker.sock:/var/run/docker.sock
|
|
||||||
"registry.gitlab.com/gitlab-org/security-products/codequality:$SP_VERSION" /code
|
|
||||||
artifacts:
|
|
||||||
paths: [codeclimate.json]
|
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
- priv
|
- priv
|
||||||
@ -121,10 +101,10 @@ pages:
|
|||||||
image: hosttoday/ht-docker-node:npmci
|
image: hosttoday/ht-docker-node:npmci
|
||||||
stage: metadata
|
stage: metadata
|
||||||
script:
|
script:
|
||||||
- npmci command npm install -g typedoc typescript
|
- npmci command npm install -g @gitzone/tsdoc
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci command typedoc --module "commonjs" --target "ES2016" --out public/ ts/
|
- npmci command tsdoc
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
- notpriv
|
||||||
@ -135,13 +115,3 @@ pages:
|
|||||||
paths:
|
paths:
|
||||||
- public
|
- public
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
|
|
||||||
windowsCompatibility:
|
|
||||||
image: stefanscherer/node-windows:10-build-tools
|
|
||||||
stage: metadata
|
|
||||||
script:
|
|
||||||
- npm install & npm test
|
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
|
||||||
tags:
|
|
||||||
- windows
|
|
||||||
allow_failure: true
|
|
||||||
|
@ -2,5 +2,15 @@
|
|||||||
"npmci": {
|
"npmci": {
|
||||||
"npmGlobalTools": [],
|
"npmGlobalTools": [],
|
||||||
"npmAccessLevel": "public"
|
"npmAccessLevel": "public"
|
||||||
|
},
|
||||||
|
"gitzone": {
|
||||||
|
"module": {
|
||||||
|
"githost": "gitlab.com",
|
||||||
|
"gitscope": "pushrocks",
|
||||||
|
"gitrepo": "smartmarkdown",
|
||||||
|
"shortDescription": "do more with markdown files",
|
||||||
|
"npmPackagename": "@pushrocks/smartmarkdown",
|
||||||
|
"license": "MIT"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
2181
package-lock.json
generated
2181
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
36
package.json
36
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartmarkdown",
|
"name": "@pushrocks/smartmarkdown",
|
||||||
"version": "1.0.4",
|
"version": "2.0.4",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "do more with markdown files",
|
"description": "do more with markdown files",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
@ -9,18 +9,32 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "tstest test/",
|
"test": "tstest test/",
|
||||||
"format": "(gitzone format)",
|
"build": "tsbuild --web"
|
||||||
"build": "tsbuild"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.0.22",
|
"@gitzone/tsbuild": "^2.1.17",
|
||||||
"@gitzone/tsrun": "^1.1.12",
|
"@gitzone/tsrun": "^1.2.8",
|
||||||
"@gitzone/tstest": "^1.0.15",
|
"@gitzone/tstest": "^1.0.28",
|
||||||
"@pushrocks/tapbundle": "^3.0.7",
|
"@pushrocks/tapbundle": "^3.2.0",
|
||||||
"@types/node": "^10.10.3"
|
"@types/node": "^13.1.8",
|
||||||
|
"tslint": "^5.20.1",
|
||||||
|
"tslint-config-prettier": "^1.18.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/marked": "^0.4.1",
|
"@types/marked": "^0.7.2",
|
||||||
"marked": "^0.5.0"
|
"@types/turndown": "^5.0.0",
|
||||||
}
|
"marked": "^0.8.0",
|
||||||
|
"turndown": "^5.0.3",
|
||||||
|
"turndown-plugin-gfm": "^1.0.2"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"ts/*",
|
||||||
|
"ts_web/*",
|
||||||
|
"dist/*",
|
||||||
|
"dist_web/*",
|
||||||
|
"assets/*",
|
||||||
|
"cli.js",
|
||||||
|
"npmextra.json",
|
||||||
|
"readme.md"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
26
readme.md
Normal file
26
readme.md
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
# @pushrocks/smartmarkdown
|
||||||
|
do more with markdown files
|
||||||
|
|
||||||
|
## Availabililty and Links
|
||||||
|
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartmarkdown)
|
||||||
|
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartmarkdown)
|
||||||
|
* [github.com (source mirror)](https://github.com/pushrocks/smartmarkdown)
|
||||||
|
* [docs (typedoc)](https://pushrocks.gitlab.io/smartmarkdown/)
|
||||||
|
|
||||||
|
## Status for master
|
||||||
|
[](https://gitlab.com/pushrocks/smartmarkdown/commits/master)
|
||||||
|
[](https://gitlab.com/pushrocks/smartmarkdown/commits/master)
|
||||||
|
[](https://www.npmjs.com/package/@pushrocks/smartmarkdown)
|
||||||
|
[](https://snyk.io/test/npm/@pushrocks/smartmarkdown)
|
||||||
|
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||||
|
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||||
|
[](https://prettier.io/)
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
For further information read the linked docs at the top of this readme.
|
||||||
|
|
||||||
|
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||||
|
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
||||||
|
|
||||||
|
[](https://maintainedby.lossless.com)
|
20
test/test.ts
20
test/test.ts
@ -1,9 +1,23 @@
|
|||||||
import { expect, tap } from '@pushrocks/tapbundle';
|
import { expect, tap } from '@pushrocks/tapbundle';
|
||||||
import * as smartmarkdown from '../ts/index';
|
import * as smartmarkdown from '../ts/index';
|
||||||
|
|
||||||
tap.test('first test', async () => {
|
let smartMarkdownInstance: smartmarkdown.SmartMarkdown;
|
||||||
const mdString = smartmarkdown.markdownToHtml('# Hi!');
|
|
||||||
expect(mdString).to.equal('<h1 id="hi-">Hi!</h1>\n');
|
tap.test('should create a valid instance of SmartMarkdown', async () => {
|
||||||
|
smartMarkdownInstance = new smartmarkdown.SmartMarkdown();
|
||||||
|
expect(smartMarkdownInstance).to.be.instanceOf(smartmarkdown.SmartMarkdown);
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test('should convert a markdown string to html', async () => {
|
||||||
|
const markdownString = '# Hi!';
|
||||||
|
const htmlString = smartMarkdownInstance.markdownToHtml(markdownString);
|
||||||
|
expect(htmlString).to.equal('<h1 id="hi">Hi!</h1>\n');
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test('should convert a html string to markdown', async () => {
|
||||||
|
const htmlString = '<h1 id="hi">Hi!</h1>\n<h2>This is it!</h2>';
|
||||||
|
const markdownString = smartMarkdownInstance.htmlToMarkdown(htmlString);
|
||||||
|
console.log(markdownString);
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.start();
|
tap.start();
|
||||||
|
21
ts/index.ts
21
ts/index.ts
@ -1,3 +1,22 @@
|
|||||||
import * as plugins from './smartmarkdown.plugins';
|
import * as plugins from './smartmarkdown.plugins';
|
||||||
|
|
||||||
export const markdownToHtml = (mdString: string): string => plugins.marked(mdString);
|
export class SmartMarkdown {
|
||||||
|
constructor() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* converts markdown to html
|
||||||
|
* @param mdString
|
||||||
|
*/
|
||||||
|
public markdownToHtml(mdString: string): string {
|
||||||
|
return plugins.marked(mdString);
|
||||||
|
}
|
||||||
|
|
||||||
|
public htmlToMarkdown(htmlString): string {
|
||||||
|
const turndownInstance = new plugins.turndown({
|
||||||
|
headingStyle: 'atx',
|
||||||
|
codeBlockStyle: 'fenced'
|
||||||
|
});
|
||||||
|
turndownInstance.use(plugins.turndownPluginGfm.gfm);
|
||||||
|
return turndownInstance.turndown(htmlString);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
import marked = require('marked');
|
import marked = require('marked');
|
||||||
|
import turndown from 'turndown';
|
||||||
|
import * as turndownPluginGfm from 'turndown-plugin-gfm';
|
||||||
|
|
||||||
export { marked };
|
export { marked, turndown, turndownPluginGfm };
|
||||||
|
20
tslint.json
20
tslint.json
@ -1,7 +1,17 @@
|
|||||||
{
|
{
|
||||||
"extends": ["tslint:latest", "tslint-config-prettier"],
|
"extends": ["tslint:latest", "tslint-config-prettier"],
|
||||||
"rules": {
|
"rules": {
|
||||||
"semicolon": [true, "always"]
|
"semicolon": [true, "always"],
|
||||||
|
"no-console": false,
|
||||||
|
"ordered-imports": false,
|
||||||
|
"object-literal-sort-keys": false,
|
||||||
|
"member-ordering": {
|
||||||
|
"options":{
|
||||||
|
"order": [
|
||||||
|
"static-method"
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
"defaultSeverity": "warning"
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user