@bscotch/steam-bbcode 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +29 -0
- package/README.md +145 -0
- package/dist/errors.d.ts +5 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +13 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +99 -0
- package/dist/index.js.map +1 -0
- package/dist/index.test.d.ts +2 -0
- package/dist/index.test.d.ts.map +1 -0
- package/dist/index.test.js +14 -0
- package/dist/index.test.js.map +1 -0
- package/package.json +38 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# License for the Stitch Monorepo
|
|
2
|
+
|
|
3
|
+
License information for the content of this git repository. The various packages in this repo are developed by [Butterscotch Shenanigans](https://www.bscotch.net) ("Bscotch").
|
|
4
|
+
|
|
5
|
+
## License files
|
|
6
|
+
|
|
7
|
+
Whenever a `LICENSE` file is found in a folder, or a license is specified by a `package.json` or similar manifest file, that license takes precedence for all files in that folder and its subfolders.
|
|
8
|
+
|
|
9
|
+
This is the root-most `LICENSE` file, and therefore dictates the default licensing in this repository.
|
|
10
|
+
|
|
11
|
+
## Stitch name and logo
|
|
12
|
+
|
|
13
|
+

|
|
14
|
+
|
|
15
|
+
Stitch™ and its logo are trademarks of Bscotch. Bscotch reserves all rights to Stitch and its logo.
|
|
16
|
+
|
|
17
|
+
Stitch Logo ©2022 by Bscotch. All rights reserved.
|
|
18
|
+
|
|
19
|
+
## Other code and content
|
|
20
|
+
|
|
21
|
+
Everything found in this project, except for the Stitch name and logo as described above or unless otherwise specified by a more proximal LICENSE file, falls under the MIT license (https://opensource.org/license/mit/):
|
|
22
|
+
|
|
23
|
+
Copyright 2023 Butterscotch Shenanigans
|
|
24
|
+
|
|
25
|
+
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:
|
|
26
|
+
|
|
27
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
28
|
+
|
|
29
|
+
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.
|
package/README.md
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
# Steam BBCode Generator
|
|
2
|
+
|
|
3
|
+
[Steam](https://store.steampowered.com/) has been around for a while, and many parts of its content management system still [use legacy BBCode formats](https://steamcommunity.com/comment/ForumTopic/formattinghelp). This tool helps generate Steam-compatible BBCode from Markdown.
|
|
4
|
+
|
|
5
|
+
Note: currently only supports _pure_ Markdown (embedded HTML is left as-is).
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- Supports most of [Steam's BBCode format](https://steamcommunity.com/comment/ForumTopic/formattinghelp)
|
|
10
|
+
- Leaves YouTube and Steam links as-is, allowing Steam to convert them into widgets.
|
|
11
|
+
|
|
12
|
+
## Missing Features
|
|
13
|
+
|
|
14
|
+
- Only the BBCode markup [documented by Steam](https://steamcommunity.com/comment/ForumTopic/formattinghelp) is supported
|
|
15
|
+
- Only supports pure Markdown input, with the exception of `<img>` tags. HTML is left as-is.
|
|
16
|
+
- Does not support tags that have no equivalent in Markdown
|
|
17
|
+
- ❌ `[spoiler]`
|
|
18
|
+
- ❌ `[noparse]`
|
|
19
|
+
- ❌ `[u]`
|
|
20
|
+
- Does not support tag options that don't have standard support in Markdown
|
|
21
|
+
- ❌ `[quote=author]` (`[quote]` is supported, but there isn't a way to provide an author)
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import { md2bbcode } from '@bscotch/steam-bbcode';
|
|
27
|
+
|
|
28
|
+
const converted = md2bbcode('# Hello, world!');
|
|
29
|
+
const bbcode = converted.bbcode;
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Example
|
|
33
|
+
|
|
34
|
+
The following Markdown input:
|
|
35
|
+
|
|
36
|
+
```md
|
|
37
|
+
# H1 Heading
|
|
38
|
+
|
|
39
|
+
## H2 Heading
|
|
40
|
+
|
|
41
|
+
### H3 Heading
|
|
42
|
+
|
|
43
|
+
Steam only supports h1-h3, the rest should just be bold.
|
|
44
|
+
|
|
45
|
+
#### H4 Heading
|
|
46
|
+
|
|
47
|
+
##### H5 Heading
|
|
48
|
+
|
|
49
|
+
###### H6 Heading
|
|
50
|
+
|
|
51
|
+
Some **Bold text**
|
|
52
|
+
|
|
53
|
+
Some _Italic text_
|
|
54
|
+
|
|
55
|
+
A [Link](https://example.com 'With a title')
|
|
56
|
+
|
|
57
|
+
Some ~~Strikethrough text~~
|
|
58
|
+
|
|
59
|
+
- Unordered list item 1
|
|
60
|
+
- Unordered list item 2
|
|
61
|
+
|
|
62
|
+
1. **Ordered** list item 1
|
|
63
|
+
1. Ordered list item 2
|
|
64
|
+
|
|
65
|
+
> Blockquote
|
|
66
|
+
|
|
67
|
+
Some `Inline Code!`!
|
|
68
|
+
|
|
69
|
+
\`\`\`
|
|
70
|
+
Block Code!
|
|
71
|
+
\`\`\`
|
|
72
|
+
|
|
73
|
+

|
|
74
|
+
|
|
75
|
+
[](https://example.com)
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
Plain steam (store.steampowered.com, steamcommunity.com) and youtube links on their own lines should be left as-is since they'll create widgets
|
|
80
|
+
|
|
81
|
+
https://store.steampowered.com/app/1401730/Crashlands_2/
|
|
82
|
+
|
|
83
|
+
https://www.youtube.com/watch?v=yR_Opccn1n4
|
|
84
|
+
|
|
85
|
+
<!-- Image HTML should get converted even though HTML isn't fully supported by this tool -->
|
|
86
|
+
<img src="https://example.com/image.jpg" alt="Image" />
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Yields the following BBCode output:
|
|
90
|
+
|
|
91
|
+
```bbcode
|
|
92
|
+
[h1]H1 Heading[/h1]
|
|
93
|
+
|
|
94
|
+
[h2]H2 Heading[/h2]
|
|
95
|
+
|
|
96
|
+
[h3]H3 Heading[/h3]
|
|
97
|
+
|
|
98
|
+
Steam only supports h1-h3, the rest should just be bold.
|
|
99
|
+
|
|
100
|
+
[b]H4 Heading[/b]
|
|
101
|
+
|
|
102
|
+
[b]H5 Heading[/b]
|
|
103
|
+
|
|
104
|
+
[b]H6 Heading[/b]
|
|
105
|
+
|
|
106
|
+
Some [b]Bold text[/b]
|
|
107
|
+
|
|
108
|
+
Some [i]Italic text[/i]
|
|
109
|
+
|
|
110
|
+
A [url=https://example.com]Link[/url]
|
|
111
|
+
|
|
112
|
+
Some [strike]Strikethrough text[/strike]
|
|
113
|
+
|
|
114
|
+
[list]
|
|
115
|
+
[*] Unordered list item 1
|
|
116
|
+
[*] Unordered list item 2
|
|
117
|
+
[/list]
|
|
118
|
+
|
|
119
|
+
[olist]
|
|
120
|
+
[*] [b]Ordered[/b] list item 1
|
|
121
|
+
[*] Ordered list item 2
|
|
122
|
+
[/olist]
|
|
123
|
+
|
|
124
|
+
[quote]Blockquote[/quote]
|
|
125
|
+
|
|
126
|
+
Some [code]Inline Code![/code]!
|
|
127
|
+
|
|
128
|
+
[code]
|
|
129
|
+
Block Code!
|
|
130
|
+
[/code]
|
|
131
|
+
|
|
132
|
+
[img alt="Image"]https://example.com/image.jpg[/img]
|
|
133
|
+
|
|
134
|
+
[url=https://example.com][img alt="Image"]https://example.com/image.jpg[/img][/url]
|
|
135
|
+
|
|
136
|
+
[hr][/hr]
|
|
137
|
+
|
|
138
|
+
Plain steam (store.steampowered.com, steamcommunity.com) and youtube links on their own lines should be left as-is since they'll create widgets
|
|
139
|
+
|
|
140
|
+
https://store.steampowered.com/app/1401730/Crashlands_2/
|
|
141
|
+
|
|
142
|
+
https://www.youtube.com/watch?v=yR_Opccn1n4
|
|
143
|
+
|
|
144
|
+
[img alt="Image"]https://example.com/image.jpg[/img]
|
|
145
|
+
```
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,gBAAiB,SAAQ,KAAK;gBAC7B,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,QAAQ;CAKjD;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAIjE"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export class SteamBbCodeError extends Error {
|
|
2
|
+
constructor(message, asserter) {
|
|
3
|
+
super(message);
|
|
4
|
+
this.name = 'SteamBbCode';
|
|
5
|
+
Error.captureStackTrace?.(this, asserter || this.constructor);
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
export function assert(claim, message) {
|
|
9
|
+
if (!claim) {
|
|
10
|
+
throw new SteamBbCodeError(message, assert);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IACzC,YAAY,OAAe,EAAE,QAAmB;QAC9C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;QAC1B,KAAK,CAAC,iBAAiB,EAAE,CAAC,IAAI,EAAE,QAAQ,IAAI,IAAI,CAAC,WAAW,CAAC,CAAC;IAChE,CAAC;CACF;AAED,MAAM,UAAU,MAAM,CAAC,KAAU,EAAE,OAAe;IAChD,IAAI,CAAC,KAAK,EAAE;QACV,MAAM,IAAI,gBAAgB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;KAC7C;AACH,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAoFA;;GAEG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG;IACzC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAEhB,CAMA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { Marked } from 'marked';
|
|
2
|
+
const marked = new Marked({
|
|
3
|
+
renderer: {
|
|
4
|
+
heading(src) {
|
|
5
|
+
// Steam only supports h1-h3, the rest should just be bold.
|
|
6
|
+
const text = this.parser.parseInline(src.tokens);
|
|
7
|
+
if (src.depth <= 3) {
|
|
8
|
+
return `[h${src.depth}]${text}[/h${src.depth}]\n\n`;
|
|
9
|
+
}
|
|
10
|
+
else {
|
|
11
|
+
return `[b]${text}[/b]\n\n`;
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
image(src) {
|
|
15
|
+
return bbImage(src.href, src.text);
|
|
16
|
+
},
|
|
17
|
+
link(src) {
|
|
18
|
+
return `[url=${src.href}]${this.parser.parseInline(src.tokens)}[/url]`;
|
|
19
|
+
},
|
|
20
|
+
em(src) {
|
|
21
|
+
return `[i]${this.parser.parseInline(src.tokens)}[/i]`;
|
|
22
|
+
},
|
|
23
|
+
strong(src) {
|
|
24
|
+
return `[b]${this.parser.parseInline(src.tokens)}[/b]`;
|
|
25
|
+
},
|
|
26
|
+
del(src) {
|
|
27
|
+
return `[strike]${this.parser.parseInline(src.tokens)}[/strike]`;
|
|
28
|
+
},
|
|
29
|
+
codespan(src) {
|
|
30
|
+
return `[code]${src.text}[/code]`;
|
|
31
|
+
},
|
|
32
|
+
code(src) {
|
|
33
|
+
return `[code]\n${src.text}\n[/code]\n\n`;
|
|
34
|
+
},
|
|
35
|
+
paragraph(src) {
|
|
36
|
+
// For lines that are just URLs,
|
|
37
|
+
// if they are steam or youtube links, leave them as-is
|
|
38
|
+
if (src.tokens.length === 1 &&
|
|
39
|
+
src.tokens[0].type === 'link' &&
|
|
40
|
+
src.tokens[0].raw.match(/^(https?:\/\/)(www\.)?(store\.steampowered\.com|steamcommunity\.com|youtube\.com|youtu\.be)/)) {
|
|
41
|
+
return src.tokens[0].raw + '\n\n';
|
|
42
|
+
}
|
|
43
|
+
return this.parser.parseInline(src.tokens) + '\n\n';
|
|
44
|
+
},
|
|
45
|
+
listitem(src) {
|
|
46
|
+
return ` [*] ${this.parser.parseInline(src.tokens).trim()}`;
|
|
47
|
+
},
|
|
48
|
+
list(src) {
|
|
49
|
+
const el = src.ordered ? 'olist' : 'list';
|
|
50
|
+
let indent = ' ';
|
|
51
|
+
let rendered = `[${el}]\n`;
|
|
52
|
+
for (const item of src.items) {
|
|
53
|
+
rendered += `${indent}[*] ${this.parser.parseInline(item.tokens).trim()}\n`;
|
|
54
|
+
}
|
|
55
|
+
return `${rendered}[/${el}]\n\n`;
|
|
56
|
+
},
|
|
57
|
+
hr() {
|
|
58
|
+
return '[hr][/hr]\n\n';
|
|
59
|
+
},
|
|
60
|
+
br() {
|
|
61
|
+
return '\n\n';
|
|
62
|
+
},
|
|
63
|
+
blockquote(src) {
|
|
64
|
+
return `[quote]${this.parser.parse(src.tokens).trim()}[/quote]\n\n`;
|
|
65
|
+
},
|
|
66
|
+
html(src) {
|
|
67
|
+
if (src.raw.startsWith('<img')) {
|
|
68
|
+
const alt = src.raw.match(/alt="([^"]+)"/)?.[1] || '';
|
|
69
|
+
const source = src.raw.match(/src="([^"]+)"/)?.[1] || '';
|
|
70
|
+
return bbImage(source, alt);
|
|
71
|
+
}
|
|
72
|
+
else if (src.raw.startsWith('<!-')) {
|
|
73
|
+
// Remove HTML comments
|
|
74
|
+
return '';
|
|
75
|
+
}
|
|
76
|
+
// Otherwise return as-is for manual editing
|
|
77
|
+
return src.text;
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
/**
|
|
82
|
+
* Convert Markdown (or HTML) to Steam-compatible BBCode. Also returns the HTML content.
|
|
83
|
+
*/
|
|
84
|
+
export function md2bbcode(source) {
|
|
85
|
+
const bbcode = marked.parse(source).replaceAll(''', "'");
|
|
86
|
+
return {
|
|
87
|
+
source,
|
|
88
|
+
bbcode,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
function bbImage(src, alt) {
|
|
92
|
+
let bb = '[img';
|
|
93
|
+
if (alt) {
|
|
94
|
+
bb += ` alt="${alt.replaceAll('"', '"')}"`;
|
|
95
|
+
}
|
|
96
|
+
bb += `]${src}[/img]`;
|
|
97
|
+
return bb;
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC;IACxB,QAAQ,EAAE;QACR,OAAO,CAAC,GAAG;YACT,2DAA2D;YAC3D,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YACjD,IAAI,GAAG,CAAC,KAAK,IAAI,CAAC,EAAE;gBAClB,OAAO,KAAK,GAAG,CAAC,KAAK,IAAI,IAAI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e,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;gBACzD,OAAO,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;aAC7B;iBAAM,IAAI,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE;gBACpC,uBAAuB;gBACvB,OAAO,EAAE,CAAC;aACX;YACD,4CAA4C;YAC5C,OAAO,GAAG,CAAC,IAAI,CAAC;QAClB,CAAC;KACF;CACF,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,MAAc;IAKtC,MAAM,MAAM,GAAI,MAAM,CAAC,KAAK,CAAC,MAAM,CAAY,CAAC,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;IACzE,OAAO;QACL,MAAM;QACN,MAAM;KACP,CAAC;AACJ,CAAC;AAED,SAAS,OAAO,CAAC,GAAW,EAAE,GAAmB;IAC/C,IAAI,EAAE,GAAG,MAAM,CAAC;IAChB,IAAI,GAAG,EAAE;QACP,EAAE,IAAI,SAAS,GAAG,CAAC,UAAU,CAAC,GAAG,EAAE,QAAQ,CAAC,GAAG,CAAC;KACjD;IACD,EAAE,IAAI,IAAI,GAAG,QAAQ,CAAC;IACtB,OAAO,EAAE,CAAC;AACZ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../src/index.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { expect } from 'chai';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import { md2bbcode } from './index.js';
|
|
4
|
+
/** Sample Markdown containing all kinds of Steam-compatible components */
|
|
5
|
+
const sample = fs.readFileSync('samples/input.md', 'utf-8');
|
|
6
|
+
const expectedSampleBbcode = fs.readFileSync('samples/output.bbcode', 'utf-8');
|
|
7
|
+
describe('BBCode generator', () => {
|
|
8
|
+
it('should convert Markdown to BBCode', () => {
|
|
9
|
+
const converted = md2bbcode(sample).bbcode;
|
|
10
|
+
// fs.writeFileSync('samples/output.bbcode', converted);
|
|
11
|
+
expect(expectedSampleBbcode).to.equal(converted);
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
//# sourceMappingURL=index.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.test.js","sourceRoot":"","sources":["../src/index.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,0EAA0E;AAC1E,MAAM,MAAM,GAAG,EAAE,CAAC,YAAY,CAAC,kBAAkB,EAAE,OAAO,CAAC,CAAC;AAC5D,MAAM,oBAAoB,GAAG,EAAE,CAAC,YAAY,CAAC,uBAAuB,EAAE,OAAO,CAAC,CAAC;AAE/E,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAChC,EAAE,CAAC,mCAAmC,EAAE,GAAG,EAAE;QAC3C,MAAM,SAAS,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC;QAC3C,wDAAwD;QACxD,MAAM,CAAC,oBAAoB,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IACnD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@bscotch/steam-bbcode",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Generate Steam-compatible BBCode from Markdown.",
|
|
5
|
+
"homepage": "https://github.com/bscotch/stitch/tree/develop/packages/steam-bbcode#readme",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/bscotch/stitch.git",
|
|
9
|
+
"directory": "packages/steam-bbcode"
|
|
10
|
+
},
|
|
11
|
+
"type": "module",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"import": "./dist/index.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"main": "dist/index.js",
|
|
19
|
+
"types": "dist/index.d.ts",
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"marked": "14.1.2"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"chai": "^4.3.10",
|
|
25
|
+
"mocha": "^10.2.0",
|
|
26
|
+
"prettier": "^3.1.0",
|
|
27
|
+
"typescript": "5.2.2"
|
|
28
|
+
},
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public"
|
|
31
|
+
},
|
|
32
|
+
"scripts": {
|
|
33
|
+
"build": "tsc --build",
|
|
34
|
+
"test": "mocha --config ../../config/.mocharc.cjs --parallel=false --timeout=30000",
|
|
35
|
+
"test:dev": "mocha --config ../../config/.mocharc.cjs --forbid-only=false --parallel=false --timeout=9999999999 --bail=false",
|
|
36
|
+
"watch": "tsc --build --watch"
|
|
37
|
+
}
|
|
38
|
+
}
|