Skip to content

Commit e58ae54

Browse files
committed
Initial commit
0 parents  commit e58ae54

20 files changed

+262
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
hashes.json
2+
_build/
3+
_releases/
4+
_data/

BbCode/Math.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
namespace Inforge\BbMath\BbCode;
4+
5+
class Math
6+
{
7+
private static function loadMathjax(\XF\BbCode\Renderer\AbstractRenderer $renderer)
8+
{
9+
$renderer->getTemplater()->includeJs([
10+
'src' => 'inforge/bbmath/mathjax-loader.js',
11+
'addon' => 'Inforge/BbMath',
12+
'min' => true,
13+
]);
14+
}
15+
16+
public static function renderMathTag($tagChildren, $tagOption, $tag,
17+
array $options, \XF\BbCode\Renderer\AbstractRenderer $renderer)
18+
{
19+
self::loadMathjax($renderer);
20+
return '$$\[' . $tagChildren[0] . '$$\]';
21+
}
22+
23+
public static function renderInlineMathTag($tagChildren, $tagOption, $tag,
24+
array $options, \XF\BbCode\Renderer\AbstractRenderer $renderer)
25+
{
26+
self::loadMathjax($renderer);
27+
return '$$\(' . $tagChildren[0] . '$$\)';
28+
}
29+
}

CONTRIBUTING.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Contributing to BbMath
2+
3+
## First setup
4+
5+
1. You need [XenForo 2.x](https://xenforo.com/). You can setup a Scotch Box
6+
environment as described in the [Xenforo 2.x Development
7+
Documentation](https://xenforo.com/xf2-docs/dev/scotchbox/)
8+
2. Fork TwitchPiper
9+
3. Move in the `src/addon/` folder of your development enviroment and `mkdir Inforge && cd Inforge`
10+
4. `git clone https://github.com/<your-username>/BbMath && cd BbMath`
11+
5. `git remote add upstream https://github.com/InforgeNet/BbMath`
12+
13+
## Pull request
14+
15+
Each time you want to submit a pull request, do the following:
16+
17+
1. Download latest upstream modifications: `git fetch upstream`
18+
2. Ceate a new branch: `git checkout -b whatever-you-want-feature upstream/master`
19+
3. Make you changes, add them and commit
20+
4. `git push -u origin whatever-you-want-feature`
21+
5. Visit `https://github.com/<your-username>/BbMath` and create a new pull request
22+
23+
### Commit message
24+
25+
Follow these guidelines to write a proper commit message: [How to Write a Git
26+
Commit Message](https://chris.beams.io/posts/git-commit/).
27+
28+
### Code style
29+
30+
General guidelines:
31+
32+
* Indent code with a **single tab**
33+
* Avoid brackets when they are not necessary
34+
* Try to keep lines under 80 columns, assuming a tab width equal to 8 spaces
35+
(yes!)
36+
* Follow the [XenForo 2.x](https://xenforo.com/xf2-docs/dev/) code style
37+
conventions
38+
* In general, I like the [Linux Kernel Coding
39+
Style](https://www.kernel.org/doc/html/latest/process/coding-style.html) and
40+
try to adapt it to PHP, JS and every other C-like language
41+
* Check out the code already in the repository and try to follow the same style
42+
* Use common sense

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 Niccolò Scatena (Inforge)
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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# BbMath
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
window.MathJax = {
2+
loader: {
3+
load: ['ui/safe']
4+
},
5+
options: {
6+
enableMenu: false
7+
},
8+
tex: {
9+
inlineMath: [['$$\\(', '$$\\)']],
10+
displayMath: [['$$\\[', '$$\\]']],
11+
processEscapes: false,
12+
processRefs: true,
13+
processEnvironments: false,
14+
tags: 'ams'
15+
},
16+
svg: {
17+
fontCache: 'global'
18+
}
19+
};
20+
21+
(function() {
22+
var script = document.createElement('script');
23+
script.src = 'https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js';
24+
script.async = true;
25+
document.head.appendChild(script);
26+
})();

_output/bb_codes/_metadata.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"imath.json": {
3+
"hash": "2608cc85133fd555483293fb02c28a5a"
4+
},
5+
"math.json": {
6+
"hash": "0e73d0c917ba4a663b3fb8481e3e5287"
7+
}
8+
}

_output/bb_codes/imath.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"bb_code_mode": "callback",
3+
"has_option": "no",
4+
"replace_html": "",
5+
"replace_html_email": "",
6+
"replace_text": "",
7+
"callback_class": "Inforge\\BbMath\\BbCode\\Math",
8+
"callback_method": "renderInlineMathTag",
9+
"option_regex": "",
10+
"trim_lines_after": 1,
11+
"plain_children": true,
12+
"disable_smilies": false,
13+
"disable_nl2br": false,
14+
"disable_autolink": true,
15+
"allow_empty": false,
16+
"allow_signature": false,
17+
"editor_icon_type": "fa",
18+
"editor_icon_value": "fas fa-function",
19+
"active": true
20+
}

_output/bb_codes/math.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"bb_code_mode": "callback",
3+
"has_option": "no",
4+
"replace_html": "",
5+
"replace_html_email": "",
6+
"replace_text": "",
7+
"callback_class": "Inforge\\BbMath\\BbCode\\Math",
8+
"callback_method": "renderMathTag",
9+
"option_regex": "",
10+
"trim_lines_after": 1,
11+
"plain_children": true,
12+
"disable_smilies": false,
13+
"disable_nl2br": false,
14+
"disable_autolink": true,
15+
"allow_empty": false,
16+
"allow_signature": false,
17+
"editor_icon_type": "fa",
18+
"editor_icon_value": "fas fa-sigma",
19+
"active": true
20+
}

_output/phrases/_metadata.json

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
"custom_bb_code_desc.imath.txt": {
3+
"global_cache": false,
4+
"version_id": 1000070,
5+
"version_string": "1.0.0",
6+
"hash": "25e1a125b615656d98e1e9a0d86aed23"
7+
},
8+
"custom_bb_code_desc.math.txt": {
9+
"global_cache": false,
10+
"version_id": 1000070,
11+
"version_string": "1.0.0",
12+
"hash": "a57476785e78e7548ee37d0dac689b89"
13+
},
14+
"custom_bb_code_example.imath.txt": {
15+
"global_cache": false,
16+
"version_id": 1000070,
17+
"version_string": "1.0.0",
18+
"hash": "8c7879343f05c33e441c866208774770"
19+
},
20+
"custom_bb_code_example.math.txt": {
21+
"global_cache": false,
22+
"version_id": 1000070,
23+
"version_string": "1.0.0",
24+
"hash": "29cdf8f73f4470841a427c6c1567d148"
25+
},
26+
"custom_bb_code_output.imath.txt": {
27+
"global_cache": false,
28+
"version_id": 1000070,
29+
"version_string": "1.0.0",
30+
"hash": "d41d8cd98f00b204e9800998ecf8427e"
31+
},
32+
"custom_bb_code_output.math.txt": {
33+
"global_cache": false,
34+
"version_id": 1000070,
35+
"version_string": "1.0.0",
36+
"hash": "d41d8cd98f00b204e9800998ecf8427e"
37+
},
38+
"custom_bb_code_title.imath.txt": {
39+
"global_cache": false,
40+
"version_id": 1000070,
41+
"version_string": "1.0.0",
42+
"hash": "f6b210b4351f3ce4b04695f8b3b122ce"
43+
},
44+
"custom_bb_code_title.math.txt": {
45+
"global_cache": false,
46+
"version_id": 1000070,
47+
"version_string": "1.0.0",
48+
"hash": "aa8a105043d90127c760e67170853c2c"
49+
}
50+
}

0 commit comments

Comments
 (0)