Skip to content

Commit

Permalink
Merge pull request #34 from the-turk/analysis-APPNL9
Browse files Browse the repository at this point in the history
Apply fixes from StyleCI
  • Loading branch information
the-turk committed Jul 22, 2022
2 parents 30f474c + d41b328 commit ec828bb
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 34 deletions.
13 changes: 7 additions & 6 deletions extend.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,22 @@
* For detailed copyright and license information, please view the
* LICENSE file that was distributed with this source code.
*/

namespace TheTurk\MathRen;

use Flarum\Api\Serializer\ForumSerializer;
use Flarum\Extend;

return [
(new Extend\Frontend('forum'))
->css(__DIR__ . '/less/forum.less')
->js(__DIR__ . '/js/dist/forum.js'),
->css(__DIR__.'/less/forum.less')
->js(__DIR__.'/js/dist/forum.js'),

(new Extend\Frontend('admin'))
->css(__DIR__ . '/less/admin.less')
->js(__DIR__ . '/js/dist/admin.js'),
->css(__DIR__.'/less/admin.less')
->js(__DIR__.'/js/dist/admin.js'),

(new Extend\Locales(__DIR__ . '/locale')),
(new Extend\Locales(__DIR__.'/locale')),

(new Extend\ApiSerializer(ForumSerializer::class))
->attributes(LoadSettings::class),
Expand Down Expand Up @@ -51,5 +52,5 @@
function ($setting) {
return \boolval($setting) ? 'true' : 'false';
}
)
),
];
9 changes: 5 additions & 4 deletions src/ConfigureTextFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* For detailed copyright and license information, please view the
* LICENSE file that was distributed with this source code.
*/

namespace TheTurk\MathRen;

use Illuminate\Support\Arr;
Expand Down Expand Up @@ -69,15 +70,15 @@ public function __invoke(Configurator $config)

// add custom BBCode
$config->BBCodes->addCustom(
$delimiter['left'] . '{TEXT}' . $delimiter['right'],
$delimiter['left'].'{TEXT}'.$delimiter['right'],
'<span>
<xsl:attribute name="class">' . $classes[$className] . '</xsl:attribute>
<xsl:attribute name="data-s9e-livepreview-onupdate">if(typeof katex!==\'undefined\')katex.render(this.innerText, this, ' . $options . ')</xsl:attribute>
<xsl:attribute name="class">'.$classes[$className].'</xsl:attribute>
<xsl:attribute name="data-s9e-livepreview-onupdate">if(typeof katex!==\'undefined\')katex.render(this.innerText, this, '.$options.')</xsl:attribute>
<xsl:apply-templates/>
<script defer="" crossorigin="anonymous">
<xsl:attribute name="data-s9e-livepreview-onrender">if(typeof katex!==\'undefined\')this.parentNode.removeChild(this)</xsl:attribute>
<xsl:attribute name="integrity">sha384-X/XCfMm41VSsqRNQgDerQczD69XqmjOOOwYQvr/uuC+j4OPoNhVgjdGFwhvN02Ja</xsl:attribute>
<xsl:attribute name="onload">katex.render(this.parentNode.innerText, this.parentNode, ' . $options . ')</xsl:attribute>
<xsl:attribute name="onload">katex.render(this.parentNode.innerText, this.parentNode, '.$options.')</xsl:attribute>
<xsl:attribute name="src">https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.js</xsl:attribute>
</script>
</span>'
Expand Down
33 changes: 17 additions & 16 deletions src/Helpers/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* For detailed copyright and license information, please view the
* LICENSE file that was distributed with this source code.
*/

namespace TheTurk\MathRen\Helpers;

use Flarum\Settings\SettingsRepositoryInterface;
Expand Down Expand Up @@ -42,7 +43,7 @@ public function __construct(SettingsRepositoryInterface $settings)
*/
public function get(string $key, string $default = ''): string
{
return $this->settings->get($this->prefix . $key, $default);
return $this->settings->get($this->prefix.$key, $default);
}

/**
Expand All @@ -56,15 +57,15 @@ public function get(string $key, string $default = ''): string
public function getKatexOptions(): array
{
return [
'fleqn' => \boolval($this->get('enable_fleqn')),
'leqno' => \boolval($this->get('enable_leqno')),
'output' => $this->get('output_mode'),
'throwOnError' => \boolval($this->get('throw_on_error')),
'errorColor' => $this->get('error_color'),
'fleqn' => \boolval($this->get('enable_fleqn')),
'leqno' => \boolval($this->get('enable_leqno')),
'output' => $this->get('output_mode'),
'throwOnError' => \boolval($this->get('throw_on_error')),
'errorColor' => $this->get('error_color'),
'minRuleThickness' => \floatval($this->get('min_rule_thickness')),
'maxSize' => \floatval($this->get('max_size')),
'maxExpand' => \intval($this->get('max_expand')),
'macros' => \json_decode('{' . $this->get('macros') . '}'),
'maxSize' => \floatval($this->get('max_size')),
'maxExpand' => \intval($this->get('max_expand')),
'macros' => \json_decode('{'.$this->get('macros').'}'),
'colorIsTextColor' => \boolval($this->get('color_is_text_color')),
];
}
Expand Down Expand Up @@ -93,9 +94,9 @@ public function getClasses(): array
private function _getDelimitersByType(): array
{
return [
'block' => $this->_commaToArray($this->get('block_delimiters')),
'inline' => $this->_commaToArray($this->get('inline_delimiters')),
'aliasBlock' => $this->_commaToArray($this->get('alias_block_delimiters')),
'block' => $this->_commaToArray($this->get('block_delimiters')),
'inline' => $this->_commaToArray($this->get('inline_delimiters')),
'aliasBlock' => $this->_commaToArray($this->get('alias_block_delimiters')),
'aliasInline' => $this->_commaToArray($this->get('alias_inline_delimiters')),
];
}
Expand Down Expand Up @@ -152,8 +153,8 @@ public function getDelimitersWithOptions(string $type): array
array_push(
$delimitersWithOptions,
[
'left' => '\\\begin{' . $environment . '}',
'right' => '\\\end{' . $environment . '}',
'left' => '\\\begin{'.$environment.'}',
'right' => '\\\end{'.$environment.'}',
'display' => true,
]
);
Expand Down Expand Up @@ -187,8 +188,8 @@ private function _setOptions(string $syntax, bool $displayMode = false): array
array_push(
$r,
[
'left' => $left,
'right' => $right,
'left' => $left,
'right' => $right,
'display' => $displayMode,
]
);
Expand Down
17 changes: 9 additions & 8 deletions src/LoadSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* For detailed copyright and license information, please view the
* LICENSE file that was distributed with this source code.
*/

namespace TheTurk\MathRen;

use Illuminate\Support\Arr;
Expand Down Expand Up @@ -45,21 +46,21 @@ public function __invoke(): array

foreach ($bbCodeDelimiters as $delimiter) {
$explicitBBCodeDelimiters[] = [
'left' => Str::before($delimiter['left'], ']') . ':0' . ']',
'right' => Str::before($delimiter['right'], ']') . ':0' . ']',
'display' => $delimiter['display']
'left' => Str::before($delimiter['left'], ']').':0'.']',
'right' => Str::before($delimiter['right'], ']').':0'.']',
'display' => $delimiter['display'],
];
}

return [
'mathren.katex_options' => $this->util->getKatexOptions(),
'mathren.katex_options' => $this->util->getKatexOptions(),
'mathren.enable_editor_buttons' => \boolval($this->util->get('enable_editor_buttons')),
'mathren.aliases_as_primary' => \boolval($this->util->get('aliases_as_primary')),
'mathren.enable_copy_tex' => \boolval($this->util->get('enable_copy_tex')),
'mathren.aliases_as_primary' => \boolval($this->util->get('aliases_as_primary')),
'mathren.enable_copy_tex' => \boolval($this->util->get('enable_copy_tex')),

// Get type-specific delimiters.
'mathren.bbcode_delimiters' => $bbCodeDelimiters,
'mathren.alias_delimiters' => $aliasDelimiters,
'mathren.bbcode_delimiters' => $bbCodeDelimiters,
'mathren.alias_delimiters' => $aliasDelimiters,
'mathren.explicit_bbcode_delimiters' => $explicitBBCodeDelimiters,

// Set primary delimiters.
Expand Down

0 comments on commit ec828bb

Please sign in to comment.