diff --git a/src/PygmentsHighlighterRenderer.php b/src/PygmentsHighlighterRenderer.php index 6bcf489..9c3f9ca 100644 --- a/src/PygmentsHighlighterRenderer.php +++ b/src/PygmentsHighlighterRenderer.php @@ -61,11 +61,21 @@ public function render( } else { $pygments = new Pygments( $path ); } + $options = []; + if ( count( $infoWords ) > 1 ) { + foreach ( array_slice( $infoWords, 1 ) as $opt ) { + $parts = explode( '=', $opt ); + if ( count( $parts ) === 2 ) { + $options[ $parts[0] ] = $parts[1]; + } + } + } try { $rendered = $pygments->highlight( $node->getLiteral(), $lang, - 'html' + 'html', + $options ); } catch ( PygmentizeProcessFailed $e ) { $onException = $this->config->get( diff --git a/tests/data/extra-options.html b/tests/data/extra-options.html new file mode 100644 index 0000000..a8de3cb --- /dev/null +++ b/tests/data/extra-options.html @@ -0,0 +1,14 @@ +

Testing

+

Before

+
class User {
+	private int $id;
+	private string $name;
+
+	public function __construct( int $id, string $name ) {
+		$this->id = $id;
+		$this->name = $name;
+	}
+}
+
+
+

after

diff --git a/tests/data/extra-options.md b/tests/data/extra-options.md new file mode 100644 index 0000000..e032543 --- /dev/null +++ b/tests/data/extra-options.md @@ -0,0 +1,17 @@ +# Testing + +Before + +```php startinline=True +class User { + private int $id; + private string $name; + + public function __construct( int $id, string $name ) { + $this->id = $id; + $this->name = $name; + } +} +``` + +after diff --git a/tests/data/extra-options.xml b/tests/data/extra-options.xml new file mode 100644 index 0000000..7e82b47 --- /dev/null +++ b/tests/data/extra-options.xml @@ -0,0 +1,22 @@ + + + + Testing + + + Before + + class User { + private int $id; + private string $name; + + public function __construct( int $id, string $name ) { + $this->id = $id; + $this->name = $name; + } +} + + + after + +