fix(core): update

This commit is contained in:
Philipp Kunz 2021-10-04 13:35:20 +02:00
parent 64b50eeb1c
commit 2a5013fb56
6 changed files with 18516 additions and 2243 deletions

21
license Normal file
View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2016 Push.Rocks
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
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
SOFTWARE.

20684
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -12,19 +12,19 @@
"build": "tsbuild --web" "build": "tsbuild --web"
}, },
"devDependencies": { "devDependencies": {
"@gitzone/tsbuild": "^2.1.25", "@gitzone/tsbuild": "^2.1.27",
"@gitzone/tsrun": "^1.2.12", "@gitzone/tsrun": "^1.2.17",
"@gitzone/tstest": "^1.0.52", "@gitzone/tstest": "^1.0.57",
"@pushrocks/tapbundle": "^3.2.14", "@pushrocks/tapbundle": "^3.2.14",
"@types/node": "^14.14.37", "@types/node": "^16.10.2",
"tslint": "^6.1.3", "tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0" "tslint-config-prettier": "^1.18.0"
}, },
"dependencies": { "dependencies": {
"@types/marked": "^2.0.1", "@types/turndown": "^5.0.1",
"@types/turndown": "^5.0.0", "remark": "^13.0.0",
"marked": "^2.0.3", "remark-html": "^13.0.0",
"turndown": "^7.0.0", "turndown": "^7.1.1",
"turndown-plugin-gfm": "^1.0.2" "turndown-plugin-gfm": "^1.0.2"
}, },
"files": [ "files": [

View File

@ -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 () => {

View File

@ -7,11 +7,12 @@ 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',

View File

@ -1,5 +1,16 @@
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 };