Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/simonecorsi/declarative-markdown
📑 Zero dependencies javascript declarative markdown generator!
https://github.com/simonecorsi/declarative-markdown
github hacktoberfest javascript js markdown markdown-generator nodejs npm typescript
Last synced: 2 days ago
JSON representation
📑 Zero dependencies javascript declarative markdown generator!
- Host: GitHub
- URL: https://github.com/simonecorsi/declarative-markdown
- Owner: simonecorsi
- License: mit
- Created: 2021-10-05T08:06:10.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-12-18T13:45:55.000Z (11 months ago)
- Last Synced: 2023-12-18T15:17:30.059Z (11 months ago)
- Topics: github, hacktoberfest, javascript, js, markdown, markdown-generator, nodejs, npm, typescript
- Language: TypeScript
- Homepage:
- Size: 5.03 MB
- Stars: 8
- Watchers: 2
- Forks: 1
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# declarative-markdown
- [About The Project](#about-the-project)
- [Installation](#installation)
- [Usage](#usage)
- [Contributing](#contributing)
- [License](#license)
- [Contact](#contact)## About The Project
The purpose of this package is to generate markdown with javascript/typescript in a declarative way without having to deal with string templating!
This is already what I need for my project but feel free to open PR if you have some ideas!
## Installation
```sh
npm i --save @scdev/declarative-markdown
# OR
yarn add
```## Usage
You can see output of the following snippet [here](./test/fixtures/output)
```javascript
import {
Markdown,
italic,
bold,
link,
quote,
inlineCode,
code,
} from '@scdev/declarative-markdown';const mkd = new Markdown('Declarative Markdown Generator');
mkd
.header('Paragraphs', 2)
.paragraph(`My ${italic('Italic')} text and the ${bold('bold')} one`)
.paragraph(
`Let's add a ${link('link', 'http://google.com')}, why not a quote: ${quote(
"I've become death, destructor of worlds"
)}`
)
.paragraph(
`Do you want to see my fancy ${inlineCode(
"alert('x')"
)}, but I've a better example here: ${code(
'package main\n func main(){}',
'go'
)}`
)
.header('Table', 2)
.table(['id', 'name'], [['1', 'Simone']])
.header('List', 2)
.list([
{ text: 'list1', depth: 0 },
{ text: 'nested', depth: 1 },
{ text: 'nested2', depth: 1 },
{ text: 'list2' },
{ text: 'nested', depth: 1 },
{ text: 'nested2', depth: 1 },
])
.header('Numbered List', 2)
.list(
[
{ text: 'list1' },
{ text: 'nested' },
{ text: 'nested2' },
{ text: 'list2' },
{ text: 'nested' },
{ text: 'nested2' },
],
true
)
.header('Task List', 2)
.tasks([
{ text: 'list1', checked: true },
{ text: 'nested' },
{ text: 'nested2' },
{ text: 'list2' },
{ text: 'nested' },
{ text: 'nested2' },
])
.header('images', 2)
.image('http://ajeje.com/image.png')
.image('http://ajeje.com/image.png', 'ALTTEXT')
.tableOfContent();const string = mkd.render();
// write it where you want
```## Contributing
Project is pretty simple and straight forward for what is my needs, but if you have any idea you're welcome.
This projects uses [commitizen](https://github.com/commitizen/cz-cli) so be sure to use standard commit format or PR won't be accepted
1. Fork the Project
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
3. Commit your Changes (`git commit -m 'feat(scope): some AmazingFeature'`)
4. Push to the Branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request## License
Distributed under the MIT License. See `LICENSE` for more information.
## Contact
Simone Corsi - [@im_simonecorsi](https://twitter.com/im_simonecorsi)