Skip to content

Commit 5681c90

Browse files
Initial commit
0 parents  commit 5681c90

31 files changed

+8700
-0
lines changed

.editorconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
root = true
2+
3+
[*]
4+
end_of_line = lf
5+
insert_final_newline = true
6+
7+
# Matches multiple files with brace expansion notation
8+
[*.{js,html,json,css,yml}]
9+
charset = utf-8
10+
indent_style = tab
11+
indent_size = 2
12+
trim_trailing_whitespace = true
13+
14+
[*.md]
15+
trim_trailing_whitespace = false

.eslintrc.json

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
{
2+
"root": true,
3+
"env": {
4+
"browser": true,
5+
"es2021": true
6+
},
7+
"extends": [
8+
"eslint:recommended",
9+
"plugin:eslint-plugin/recommended",
10+
"plugin:import/recommended"
11+
],
12+
"globals": {
13+
"Atomics": "readonly",
14+
"SharedArrayBuffer": "readonly"
15+
},
16+
"parserOptions": {
17+
"ecmaVersion": 12,
18+
"sourceType": "module"
19+
},
20+
"plugins": [
21+
"eslint-plugin",
22+
"import"
23+
],
24+
"extends": [
25+
"eslint:recommended",
26+
"plugin:eslint-plugin/recommended",
27+
"plugin:import/recommended"
28+
],
29+
"rules": {
30+
"comma-style": [1, "last"],
31+
"curly": [1, "multi-line"],
32+
"eol-last": [1, "always"],
33+
"eqeqeq": [1, "allow-null"],
34+
"func-call-spacing": 1,
35+
"no-unused-vars": 1,
36+
"indent": ["warn", "tab"],
37+
"max-len": [1, 99, 2],
38+
"no-cond-assign": [1, "always"],
39+
"no-return-assign": [1, "always"],
40+
"no-shadow": 1,
41+
"no-var": 1,
42+
"object-curly-spacing": [1, "always"],
43+
"one-var": [1, "never"],
44+
"prefer-const": 2,
45+
"quotes": [1, "double", {
46+
"allowTemplateLiterals": true,
47+
"avoidEscape": true
48+
}],
49+
"semi": [1, "never"],
50+
"eslint-plugin/consistent-output": [
51+
"warn",
52+
"always"
53+
],
54+
"eslint-plugin/meta-property-ordering": "warn",
55+
"eslint-plugin/no-deprecated-context-methods": "warn",
56+
"eslint-plugin/no-deprecated-report-api": "off",
57+
"eslint-plugin/prefer-replace-text": "warn",
58+
"eslint-plugin/report-message-format": "warn",
59+
"eslint-plugin/require-meta-schema": "warn",
60+
"eslint-plugin/require-meta-type": "warn",
61+
"import/no-extraneous-dependencies": "warn",
62+
"import/unambiguous": "off"
63+
}
64+
}

.github/workflows/docs.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Generate docs and push to another branch
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
name: Generate docs and Push
12+
steps:
13+
- name: git-checkout
14+
uses: actions/checkout@v2
15+
16+
- name: Install all dependencies
17+
run: npm install
18+
19+
- name: Build
20+
run: npm run generate-docs # The build command of your project
21+
22+
- name: Push
23+
uses: s0/git-publish-subdir-action@develop
24+
env:
25+
REPO: self
26+
BRANCH: docs # The branch name where you want to push the assets
27+
FOLDER: docs # The directory where your assets are generated
28+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # GitHub will automatically add this - you don't need to bother getting a token

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules/

.jsdoc.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"tags": {
3+
"allowUnknownTags": true,
4+
"dictionaries": ["jsdoc"]
5+
},
6+
"source": {
7+
"include": ["src", "README.md"],
8+
"includePattern": ".js$",
9+
"excludePattern": "(node_modules/|docs)"
10+
},
11+
"sourceType": "module",
12+
"plugins": [
13+
"plugins/markdown"
14+
],
15+
"templates": {
16+
"cleverLinks": false,
17+
"monospaceLinks": true,
18+
"useLongnameInNav": false,
19+
"showInheritedInNav": true
20+
},
21+
"markdown": {
22+
"idInHeadings": true
23+
},
24+
"opts": {
25+
"destination": "./docs/",
26+
"encoding": "utf8",
27+
"private": true,
28+
"recurse": true,
29+
"template": "./node_modules/docdash"
30+
},
31+
"docdash": {
32+
"sort": false,
33+
"search": true,
34+
"menu": {
35+
"Github": {
36+
"href":"https://github.com/thoughtsunificator/bbcode-parser",
37+
"target":"_blank"
38+
}
39+
}
40+
}
41+
}

LICENSE

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

README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# bbcode-parser [![Build Status](https://travis-ci.com/thoughtsunificator/bbcode-parser.svg?branch=master)](https://travis-ci.com/thoughtsunificator/bbcode-parser)
2+
3+
bbcode-parser is a JavaScript implementation of the lightweight markup language [BBCode](https://en.wikipedia.org/wiki/BBCode).
4+
5+
If you wish to convert BBCode to HTML or HTML to BBCode see [bbcode-parser-template](https://github.com/thoughtsunificator/bbcode-parser-template).
6+
7+
## Getting Started
8+
9+
### Installing
10+
11+
#### Browser
12+
13+
- ``git submodule add https://github.com/thoughtsunificator/bbcode-parser lib/bbcode-parser``
14+
15+
#### Node.js
16+
17+
- ``npm install @thoughtsunificator/bbcode-parser``
18+
- Add ``type: "module"`` to your package.json.
19+
20+
### Usage
21+
22+
````javascript
23+
import { Parser } from '@thoughtsunificator/bbcode-parser' // or ./lib/bbcode-parser/index.js
24+
25+
const bbDocument = Parser.parse("[b]Hey, thanks![/b]") // return a BBDocument instance
26+
27+
const bbElement bbDocument.documentElement.children[0] // Returns a bbElement
28+
const text = bbDocument.documentElement.children[0].textContent // returns "Hey, thanks!"
29+
````
30+
31+
## API
32+
33+
See [https://thoughtsunificator.github.io/bbcode-parser](https://thoughtsunificator.github.io/bbcode-parser).
34+
35+
## Try it out!
36+
37+
See [https://codesandbox.io/s/bbcode-parser-gth53](https://codesandbox.io/s/bbcode-parser-gth53).

index.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
export * as Parser from "./src/parser.js"
2+
export * as Tokenizer from "./src/tokenizer.js"
3+
export * as Util from "./src/util.js"
4+
export { default as BBDocument } from "./src/bbdocument/bbdocument.js"
5+
export { default as BBNode } from "./src/bbdocument/bbnode.js"
6+
export { default as BBElement } from "./src/bbdocument/bbelement.js"
7+
export { default as BBText } from "./src/bbdocument/bbtext.js"
8+
export { default as TreeWalker } from "./src/bbdocument/treewalker.js"
9+
export { default as Token } from "./src/token/token.js"
10+
export { default as Key } from "./src/token/key.js"
11+
export { default as TextToken } from "./src/token/texttoken.js"
12+
export { default as TagToken } from "./src/token/tagtoken.js"

0 commit comments

Comments
 (0)