20 Commits

Author SHA1 Message Date
5654e6ed72 2.0.5 2020-01-18 16:55:30 +00:00
b3047fed9a fix(core): update 2020-01-18 16:55:29 +00:00
ae580dd09e 2.0.4 2020-01-18 16:45:06 +00:00
f470e591cc fix(core): update 2020-01-18 16:45:05 +00:00
945b0ae8b8 2.0.3 2020-01-18 16:43:45 +00:00
ba90bb50a2 fix(core): update 2020-01-18 16:43:45 +00:00
72de4bfb7d 2.0.2 2019-06-17 14:41:57 +02:00
d195535ca0 fix(core): update 2019-06-17 14:41:57 +02:00
989febe988 2.0.1 2019-06-17 12:08:57 +02:00
ebaa68a2fe fix(core): update 2019-06-17 12:08:56 +02:00
effc3b10b1 2.0.0 2019-06-17 11:56:40 +02:00
1361e825fe BREAKING CHANGE(core): switch to class based design and support html to markdown 2019-06-17 11:56:39 +02:00
a66e795432 1.0.6 2019-05-05 17:43:45 +02:00
1712f8e628 fix(core): update 2019-05-05 17:43:44 +02:00
366856e904 1.0.5 2019-05-05 17:41:39 +02:00
173536be39 fix(core): update 2019-05-05 17:41:39 +02:00
af04a3d04b 1.0.4 2018-09-23 00:45:18 +02:00
efce7dfe6a fix(core): update 2018-09-23 00:45:18 +02:00
502fc9815f 1.0.3 2018-09-23 00:21:32 +02:00
a372e507f4 fix(core): update 2018-09-23 00:21:31 +02:00
10 changed files with 2002 additions and 478 deletions

18
.gitignore vendored
View File

@ -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

View File

@ -1,10 +1,10 @@
# gitzone standard # gitzone ci_default
image: hosttoday/ht-docker-node:npmci image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
cache: cache:
paths: paths:
- .npmci_cache/ - .npmci_cache/
key: "$CI_BUILD_STAGE" key: '$CI_BUILD_STAGE'
stages: stages:
- security - security
@ -20,49 +20,27 @@ mirror:
script: script:
- npmci git mirror - npmci git mirror
tags: tags:
- lossless
- docker - docker
- notpriv - notpriv
snyk: snyk:
image: registry.gitlab.com/hosttoday/ht-docker-node:snyk
stage: security stage: security
script: script:
- npmci npm prepare - npmci npm prepare
- npmci command npm install -g snyk
- npmci command npm install --ignore-scripts - npmci command npm install --ignore-scripts
- npmci command snyk test - npmci command snyk test
tags: tags:
- lossless
- docker - docker
- notpriv - notpriv
# ==================== # ====================
# 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: testStable:
stage: test
script:
- npmci npm prepare
- npmci node install lts
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
- notpriv
testSTABLE:
stage: test stage: test
script: script:
- npmci npm prepare - npmci npm prepare
@ -71,6 +49,20 @@ testSTABLE:
- npmci npm test - npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/ coverage: /\d+.?\d+?\%\s*coverage/
tags: tags:
- lossless
- docker
- priv
testBuild:
stage: test
script:
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci command npm run build
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- lossless
- docker - docker
- notpriv - notpriv
@ -82,6 +74,7 @@ release:
only: only:
- tags - tags
tags: tags:
- lossless
- docker - docker
- notpriv - notpriv
@ -90,20 +83,14 @@ 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 prepare
--env SOURCE_CODE="$PWD" - npmci npm install
--volume "$PWD":/code - npmci command "tslint -c tslint.json ./ts/**/*.ts"
--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:
- lossless
- docker - docker
- priv - priv
@ -114,18 +101,20 @@ trigger:
only: only:
- tags - tags
tags: tags:
- lossless
- docker - docker
- notpriv - notpriv
pages: pages:
image: hosttoday/ht-docker-node:npmci
stage: metadata stage: metadata
script: script:
- npmci command npm install -g typedoc typescript - npmci node install lts
- 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:
- lossless
- docker - docker
- notpriv - notpriv
only: only:
@ -135,13 +124,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

View File

@ -1,8 +1,16 @@
{ {
"npmci": { "npmci": {
"npmGlobalTools": [ "npmGlobalTools": [],
"@gitzone/npmts", "npmAccessLevel": "public"
"ts-node" },
] "gitzone": {
"module": {
"githost": "gitlab.com",
"gitscope": "pushrocks",
"gitrepo": "smartmarkdown",
"shortDescription": "do more with markdown files",
"npmPackagename": "@pushrocks/smartmarkdown",
"license": "MIT"
}
} }
} }

2173
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,7 @@
{ {
"name": "@pushrocks/smartmarkdown", "name": "@pushrocks/smartmarkdown",
"version": "1.0.2", "version": "2.0.5",
"private": false,
"description": "do more with markdown files", "description": "do more with markdown files",
"main": "dist/index.js", "main": "dist/index.js",
"typings": "dist/index.d.ts", "typings": "dist/index.d.ts",
@ -8,16 +9,33 @@
"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": {
"private": true "@types/marked": "^0.7.2",
"@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/**/*",
"dist_ts_web/**/*",
"assets/**/*",
"cli.js",
"npmextra.json",
"readme.md"
]
} }

31
readme.md Normal file
View File

@ -0,0 +1,31 @@
# @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
[![build status](https://gitlab.com/pushrocks/smartmarkdown/badges/master/build.svg)](https://gitlab.com/pushrocks/smartmarkdown/commits/master)
[![coverage report](https://gitlab.com/pushrocks/smartmarkdown/badges/master/coverage.svg)](https://gitlab.com/pushrocks/smartmarkdown/commits/master)
[![npm downloads per month](https://img.shields.io/npm/dm/@pushrocks/smartmarkdown.svg)](https://www.npmjs.com/package/@pushrocks/smartmarkdown)
[![Known Vulnerabilities](https://snyk.io/test/npm/@pushrocks/smartmarkdown/badge.svg)](https://snyk.io/test/npm/@pushrocks/smartmarkdown)
[![TypeScript](https://img.shields.io/badge/TypeScript->=%203.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-prettier-ff69b4.svg)](https://prettier.io/)
## Usage
## Contribution
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
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)
[![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com)

View File

@ -1,8 +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;
console.log(smartmarkdown.standardExport);
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();

View File

@ -1,3 +1,22 @@
import * as plugins from './smartmarkdown.plugins'; import * as plugins from './smartmarkdown.plugins';
export let standardExport = 'Hi there! :) This is an exported string'; 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);
}
}

View File

@ -1,2 +1,5 @@
const removeme = {}; import marked = require('marked');
export { removeme }; import turndown from 'turndown';
import * as turndownPluginGfm from 'turndown-plugin-gfm';
export { marked, turndown, turndownPluginGfm };

View File

@ -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"
}