diff --git a/README.md b/README.md index 1a681c3..79917ee 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,7 @@ This extension defines three parser functions: For valid icon names see https://fontawesome.com/v6/search. ### Styling + * `{{#far:... ...}}` to insert an icon from the FontAwesome Regular font with additional classes * `{{#fas:... ...}}` to insert an icon from the FontAwesome Solid font with additional classes * `{{#fab:... ...}}` to insert an icon from the FontAwesome Brands font with additional classes @@ -77,6 +78,13 @@ For valid icon names see https://fontawesome.com/v6/search. **Example:** `{{#fab:wikipedia-w fa-spin}}` will insert a spinning Wikipedia-W +* `{{#far:...|...}}` to insert an icon from the FontAwesome Regular font with additional style +* `{{#fas:...|...}}` to insert an icon from the FontAwesome Solid font with additional style +* `{{#fab:...|...}}` to insert an icon from the FontAwesome Brands font with additional style + +**Example:** +`{{#fab:wikipedia-w|color:red; background-color: green; }}` will insert a red Wikipedia-W on a green background + For valid Font Awesome class names see https://docs.fontawesome.com/web/style/styling. ## Professional Support diff --git a/src/IconRenderers/JavascriptRenderer.php b/src/IconRenderers/JavascriptRenderer.php index 50bf493..9f6542f 100644 --- a/src/IconRenderers/JavascriptRenderer.php +++ b/src/IconRenderers/JavascriptRenderer.php @@ -62,7 +62,13 @@ public function __construct( public function render( Parser $parser, PPFrame $frame, array $args ): string { $this->registerRlModule( $parser ); - return Html::element( 'i', [ 'class' => [ $this->fontClass, 'fa-' . trim( $frame->expand( $args[ 0 ] ) ) ] ] ); + switch (count($args)) { + case "1": + return Html::element( 'i', [ 'class' => [ $this->fontClass, 'fa-' . trim( $frame->expand( $args[ 0 ] ) ) ] ] ); + default: + return Html::element( 'i', [ 'class' => [ $this->fontClass, 'fa-' . trim( $frame->expand( $args[ 0 ] ) ) ], + 'style' => trim( $frame->expand( $args[ 1 ] ) ) ] ); + } } private function registerRlModule( Parser $parser ): void { diff --git a/src/IconRenderers/WebfontRenderer.php b/src/IconRenderers/WebfontRenderer.php index 237962b..b53cb2e 100644 --- a/src/IconRenderers/WebfontRenderer.php +++ b/src/IconRenderers/WebfontRenderer.php @@ -61,8 +61,13 @@ public function __construct( */ public function render( Parser $parser, PPFrame $frame, array $args ): string { $this->registerRlModule( $parser ); - - return Html::element( 'i', [ 'class' => [ $this->fontClass, 'fa-' . trim( $frame->expand( $args[ 0 ] ) ) ] ] ); + switch (count($args)) { + case "1": + return Html::element( 'i', ['class' => [ $this->fontClass, 'fa-' . trim( $frame->expand( $args[ 0 ] ) ) ] ] ); + default: + return Html::element( 'i', ['class' => [ $this->fontClass, 'fa-' . trim( $frame->expand( $args[ 0 ] ) ) ], + 'style' => trim( $frame->expand( $args[ 1 ] ) ) ] ); + } } /**