Skip to content

Commit 8c30961

Browse files
Initial release to wrap table in markdown-it
0 parents  commit 8c30961

27 files changed

+5737
-0
lines changed

.editorconfig

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
indent_size = 2
7+
indent_style = space
8+
quote_type = single
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true

.eslintrc

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"root": true,
3+
"env": {
4+
"es6": true,
5+
"node": true,
6+
"mocha": true
7+
},
8+
"extends": [
9+
"eslint:recommended"
10+
],
11+
"overrides": [
12+
{
13+
"files": [
14+
"*.ts",
15+
"*.tsx"
16+
],
17+
"parser": "@typescript-eslint/parser",
18+
"plugins": [
19+
"@typescript-eslint"
20+
],
21+
"extends": [
22+
"plugin:@typescript-eslint/recommended"
23+
]
24+
}
25+
],
26+
"rules": {
27+
"@typescript-eslint/ban-ts-comment": [
28+
"error",
29+
{
30+
"ts-ignore": "allow-with-description"
31+
}
32+
]
33+
}
34+
}

.gitattributes

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Set the default behavior, in case people don't have `core.autocrlf` set.
2+
* text=auto
3+
4+
# Declare files that will always have LF line endings on checkout.
5+
*.ts text eol=lf
6+
7+
# Remove files for archives generated using `git archive`.
8+
.* export-ignore
9+
appveyor.yml export-ignore
10+
fixup export-ignore
11+
package-lock.json export-ignore
12+
src export-ignore
13+
test export-ignore
14+
tsconfig.json export-ignore
15+
tsconfig-cjs.json export-ignore
16+
tsconfig-esm.json export-ignore
17+
types/ export-ignore

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.DS_Store
2+
node_modules
3+
npm-debug.log
4+
yarn-error.log

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# markdown-it-table-wrap changelog
2+
3+
## 1.0.0 - May 03, 2024
4+
5+
- Initial Release

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2023 TrunkCode
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# markdown-it-table-wrap
2+
3+
[![NPM version][npm-image]][npm-url]
4+
[![Downloads][downloads-image]][npm-url]
5+
[![AppVeyor Build Status][appveyor-image]][appveyor-url]
6+
7+
[markdown-it](https://www.npmjs.com/package/markdown-it) plugin which wraps table into div and add class for custom styling.
8+
9+
## Install
10+
11+
Via `npm`
12+
13+
```bash
14+
npm install markdown-it-table-wrap
15+
```
16+
17+
Via Yarn
18+
19+
```bash
20+
yarn add markdown-it-table-wrap
21+
```
22+
23+
## Usage
24+
25+
```javascript
26+
const markdownit = require('markdown-it');
27+
const markdownitTableWrap = require('markdown-it-table-wrap').default;
28+
const md = markdownit();
29+
30+
const testString = `
31+
| Syntax | Description |
32+
| ----------- | ----------- |
33+
| Header | Title |
34+
| Paragraph | Text |
35+
`;
36+
37+
md.use(markdownitTableWrap);
38+
39+
console.log(md.render(testString));
40+
```
41+
42+
[npm-image]: https://img.shields.io/npm/v/markdown-it-table-wrap.svg
43+
[npm-url]: https://www.npmjs.com/package/markdown-it-table-wrap
44+
[downloads-image]: https://img.shields.io/npm/dm/markdown-it-table-wrap.svg
45+
46+
[appveyor-url]: https://ci.appveyor.com/project/trunkcode/markdown-it-table-wrap
47+
[appveyor-image]: https://img.shields.io/appveyor/ci/trunkcode/markdown-it-table-wrap.svg?label=appveyor

appveyor.yml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
version: "{build}"
2+
3+
# branches to build
4+
branches:
5+
only:
6+
- main
7+
8+
environment:
9+
matrix:
10+
# node.js
11+
- nodejs_version: "16"
12+
- nodejs_version: "18"
13+
- nodejs_version: ""
14+
15+
install:
16+
- ps: Install-Product node $env:nodejs_version
17+
- npm install
18+
19+
test_script:
20+
- npm run lint
21+
- npm run test
22+
23+
build: off

dist/cjs/index.d.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import markdownit from 'markdown-it';
2+
3+
export default function markdownitTableWrap (md: markdownit): void;

dist/cjs/index.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
3+
function markdownitTableWrap(md) {
4+
md.renderer.rules.table_open = function () {
5+
return '<div class="table-responsive"><table class="table table-striped">';
6+
};
7+
md.renderer.rules.table_close = function () {
8+
return '</table></div>';
9+
};
10+
}
11+
exports.default = markdownitTableWrap;

dist/cjs/index.test-d.ts

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
'use strict';
2+
3+
import markdownit from 'markdown-it';
4+
import markdownitTableWrap from './index';
5+
6+
const testString = `
7+
| Syntax | Description |
8+
| ----------- | ----------- |
9+
| Header | Title |
10+
| Paragraph | Text |
11+
`;
12+
13+
const md = new markdownit();
14+
15+
md.use(markdownitTableWrap);
16+
md.render(testString);

dist/cjs/package.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"type": "commonjs"
3+
}

dist/esm/index.d.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import markdownit from 'markdown-it';
2+
3+
export default function markdownitTableWrap (md: markdownit): void;

dist/esm/index.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export default function markdownitTableWrap(md) {
2+
md.renderer.rules.table_open = function () {
3+
return '<div class="table-responsive"><table class="table table-striped">';
4+
};
5+
md.renderer.rules.table_close = function () {
6+
return '</table></div>';
7+
};
8+
}

dist/esm/index.test-d.ts

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
'use strict';
2+
3+
import markdownit from 'markdown-it';
4+
import markdownitTableWrap from './index';
5+
6+
const testString = `
7+
| Syntax | Description |
8+
| ----------- | ----------- |
9+
| Header | Title |
10+
| Paragraph | Text |
11+
`;
12+
13+
const md = new markdownit();
14+
15+
md.use(markdownitTableWrap);
16+
md.render(testString);

dist/esm/package.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"type": "module"
3+
}

fixup

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
#
3+
# Add package.json files to cjs/esm subtrees.
4+
#
5+
6+
cat >dist/cjs/package.json <<!EOF
7+
{
8+
"type": "commonjs"
9+
}
10+
!EOF
11+
12+
cat >dist/esm/package.json <<!EOF
13+
{
14+
"type": "module"
15+
}
16+
!EOF
17+
18+
find types -name '*d.ts' -exec cp {} dist/esm \;
19+
find types -name '*d.ts' -exec cp {} dist/cjs \;

0 commit comments

Comments
 (0)