update tsconfig
This commit is contained in:
parent
99718af936
commit
1d518b4f55
@ -9,12 +9,26 @@
|
|||||||
"githost": "code.foss.global",
|
"githost": "code.foss.global",
|
||||||
"gitscope": "push.rocks",
|
"gitscope": "push.rocks",
|
||||||
"gitrepo": "smartmarkdown",
|
"gitrepo": "smartmarkdown",
|
||||||
"description": "do more with markdown files",
|
"description": "Enhances Markdown file handling with parsing, conversion, and frontmatter support.",
|
||||||
"npmPackagename": "@push.rocks/smartmarkdown",
|
"npmPackagename": "@push.rocks/smartmarkdown",
|
||||||
"license": "MIT"
|
"license": "MIT",
|
||||||
|
"keywords": [
|
||||||
|
"markdown",
|
||||||
|
"html conversion",
|
||||||
|
"markdown parsing",
|
||||||
|
"frontmatter",
|
||||||
|
"remark",
|
||||||
|
"unified",
|
||||||
|
"turndown",
|
||||||
|
"YAML",
|
||||||
|
"plugin system",
|
||||||
|
"text processing",
|
||||||
|
"documentation",
|
||||||
|
"content management"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"tsdocs": {
|
"tsdoc": {
|
||||||
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
|
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
|
||||||
}
|
}
|
||||||
}
|
}
|
18
package.json
18
package.json
@ -2,7 +2,7 @@
|
|||||||
"name": "@push.rocks/smartmarkdown",
|
"name": "@push.rocks/smartmarkdown",
|
||||||
"version": "3.0.3",
|
"version": "3.0.3",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "do more with markdown files",
|
"description": "Enhances Markdown file handling with parsing, conversion, and frontmatter support.",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
"typings": "dist_ts/index.d.ts",
|
"typings": "dist_ts/index.d.ts",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
@ -45,5 +45,19 @@
|
|||||||
],
|
],
|
||||||
"browserslist": [
|
"browserslist": [
|
||||||
"last 1 chrome versions"
|
"last 1 chrome versions"
|
||||||
|
],
|
||||||
|
"keywords": [
|
||||||
|
"markdown",
|
||||||
|
"html conversion",
|
||||||
|
"markdown parsing",
|
||||||
|
"frontmatter",
|
||||||
|
"remark",
|
||||||
|
"unified",
|
||||||
|
"turndown",
|
||||||
|
"YAML",
|
||||||
|
"plugin system",
|
||||||
|
"text processing",
|
||||||
|
"documentation",
|
||||||
|
"content management"
|
||||||
]
|
]
|
||||||
}
|
}
|
1
readme.hints.md
Normal file
1
readme.hints.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
|
142
readme.md
142
readme.md
@ -1,39 +1,129 @@
|
|||||||
# @push.rocks/smartmarkdown
|
# @push.rocks/smartmarkdown
|
||||||
do more with markdown files
|
do more with markdown files
|
||||||
|
|
||||||
## Availabililty and Links
|
## Install
|
||||||
* [npmjs.org (npm package)](https://www.npmjs.com/package/@push.rocks/smartmarkdown)
|
To install `@push.rocks/smartmarkdown`, you can use npm or yarn. Run one of the following commands in your terminal:
|
||||||
* [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
|
```bash
|
||||||
|
npm install @push.rocks/smartmarkdown --save
|
||||||
|
```
|
||||||
|
|
||||||
Status Category | Status Badge
|
or if you use yarn:
|
||||||
-- | --
|
|
||||||
GitLab Pipelines | [![pipeline status](https://gitlab.com/pushrocks/smartmarkdown/badges/master/pipeline.svg)](https://lossless.cloud)
|
```bash
|
||||||
GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/pushrocks/smartmarkdown/badges/master/coverage.svg)](https://lossless.cloud)
|
yarn add @push.rocks/smartmarkdown
|
||||||
npm | [![npm downloads per month](https://badgen.net/npm/dy/@push.rocks/smartmarkdown)](https://lossless.cloud)
|
```
|
||||||
Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/pushrocks/smartmarkdown)](https://lossless.cloud)
|
|
||||||
TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud)
|
This module is designed to be used in a Node.js environment or in a frontend project that supports ES Modules.
|
||||||
node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
|
||||||
Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud)
|
|
||||||
PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@push.rocks/smartmarkdown)](https://lossless.cloud)
|
|
||||||
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@push.rocks/smartmarkdown)](https://lossless.cloud)
|
|
||||||
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@push.rocks/smartmarkdown)](https://lossless.cloud)
|
|
||||||
Platform support | [![Supports Windows 10](https://badgen.net/badge/supports%20Windows%2010/yes/green?icon=windows)](https://lossless.cloud) [![Supports Mac OS X](https://badgen.net/badge/supports%20Mac%20OS%20X/yes/green?icon=apple)](https://lossless.cloud)
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
`@push.rocks/smartmarkdown` offers powerful tools to work with markdown files, including parsing markdown to HTML, extracting frontmatter data, and converting HTML back to markdown. Below, we'll explore how to utilize these features effectively.
|
||||||
|
|
||||||
Use TypeScript for best in class intellisense.
|
### **Parsing Markdown to HTML**
|
||||||
|
|
||||||
## Contribution
|
Let's start by converting a simple Markdown string to HTML:
|
||||||
|
|
||||||
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). :)
|
```typescript
|
||||||
|
import { SmartMarkdown } from '@push.rocks/smartmarkdown';
|
||||||
|
|
||||||
For further information read the linked docs at the top of this readme.
|
async function parseMarkdown() {
|
||||||
|
const mdString = `# Hello World
|
||||||
|
|
||||||
|
This is a simple markdown string.`;
|
||||||
|
const htmlString = await SmartMarkdown.easyMarkdownToHtml(mdString);
|
||||||
|
console.log(htmlString); // Logs the HTML string
|
||||||
|
}
|
||||||
|
|
||||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
parseMarkdown();
|
||||||
| 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)
|
In this example, `SmartMarkdown.easyMarkdownToHtml` is a convenient static method that takes a markdown string and returns its HTML representation.
|
||||||
|
|
||||||
|
### **Working with Frontmatter**
|
||||||
|
|
||||||
|
Markdown files often contain frontmatter, which is metadata specified at the top of the file. `@push.rocks/smartmarkdown` can extract this data along with converting the content.
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { SmartMarkdown } from '@push.rocks/smartmarkdown';
|
||||||
|
|
||||||
|
async function parseMarkdownWithFrontmatter() {
|
||||||
|
const markdownWithFrontmatter = `---
|
||||||
|
title: "My First Post"
|
||||||
|
date: 2023-01-01
|
||||||
|
tags: ["blog", "post"]
|
||||||
|
---
|
||||||
|
|
||||||
|
# Hello World
|
||||||
|
|
||||||
|
This is a post with frontmatter.`;
|
||||||
|
|
||||||
|
const smartmarkdownInstance = new SmartMarkdown();
|
||||||
|
const mdParsedResult = await smartmarkdownInstance.getMdParsedResultFromMarkdown(markdownWithFrontmatter);
|
||||||
|
console.log(mdParsedResult.frontmatterData); // Logs: { title: "My First Post", date: "2023-01-01", tags: ["blog", "post"] }
|
||||||
|
console.log(mdParsedResult.html); // Logs: HTML content
|
||||||
|
}
|
||||||
|
|
||||||
|
parseMarkdownWithFrontmatter();
|
||||||
|
```
|
||||||
|
|
||||||
|
In the code above, we manually create an instance of `SmartMarkdown` to access the `getMdParsedResultFromMarkdown` method, which returns an object containing both the HTML and the frontmatter data.
|
||||||
|
|
||||||
|
### **HTML to Markdown Conversion**
|
||||||
|
|
||||||
|
Sometimes, you may need to convert HTML back to Markdown. Here's how you can do it:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { SmartMarkdown } from '@push.rocks/smartmarkdown';
|
||||||
|
|
||||||
|
const smartmarkdownInstance = new SmartMarkdown();
|
||||||
|
const htmlString = '<h1>Hello World</h1><p>This is a simple HTML string.</p>';
|
||||||
|
const markdownString = smartmarkdownInstance.htmlToMarkdown(htmlString);
|
||||||
|
console.log(markdownString);
|
||||||
|
```
|
||||||
|
|
||||||
|
In this example, we use the `htmlToMarkdown` method to convert an HTML string back to Markdown. This is particularly useful when working with content editing interfaces that support both formats.
|
||||||
|
|
||||||
|
### **Advanced Usage: Parsing Markdown with Custom Plugins**
|
||||||
|
|
||||||
|
`@push.rocks/smartmarkdown` leverages Unified, Remark, and Turndown to provide its functionality. You can extend its capabilities by using custom plugins.
|
||||||
|
|
||||||
|
For instance, if you wanted to use a custom Remark plugin to highlight code blocks, you would:
|
||||||
|
|
||||||
|
1. Create a new SmartMarkdown instance.
|
||||||
|
2. Configure it to use your custom plugins.
|
||||||
|
3. Process your markdown content.
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
// This is a hypothetical example. Please refer to the respective plugin documentation for actual implementation details.
|
||||||
|
|
||||||
|
import { SmartMarkdown } from '@push.rocks/smartmarkdown';
|
||||||
|
import myRemarkPlugin from 'remark-myplugin';
|
||||||
|
|
||||||
|
async function parseMarkdownWithPlugin(mdString: string) {
|
||||||
|
const smartMarkdownInstance = new SmartMarkdown();
|
||||||
|
smartMarkdownInstance.useRemarkPlugin(myRemarkPlugin, pluginOptions);
|
||||||
|
const result = await smartMarkdownInstance.getMdParsedResultFromMarkdown(mdString);
|
||||||
|
// Now `result` will include transformations done by your custom plugin.
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
`@push.rocks/smartmarkdown` provides a solid base for performing various markdown related tasks in your projects. Whether parsing, transforming, or exporting content, its utilities and integrations offer flexibility for most needs. By leveraging ES Modules and TypeScript, it ensures type safety and enhances developer experience with excellent IntelliSense support.
|
||||||
|
|
||||||
|
## License and Legal Information
|
||||||
|
|
||||||
|
This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository.
|
||||||
|
|
||||||
|
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
### Trademarks
|
||||||
|
|
||||||
|
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.
|
||||||
|
|
||||||
|
### Company Information
|
||||||
|
|
||||||
|
Task Venture Capital GmbH
|
||||||
|
Registered at District court Bremen HRB 35230 HB, Germany
|
||||||
|
|
||||||
|
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
|
||||||
|
|
||||||
|
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
|
||||||
|
Loading…
Reference in New Issue
Block a user