Skip to content

Need easier way to enable languages #3

@bvibber

Description

@bvibber

Awesome, I got this working on my blog (after updating PHP) and it's great! :D

However I had to enable Rust and NASM for my recent blog posts, and these languages currently aren't included.

Per the readme I was able to add a mini plugin with a filter to enable the languages:

add_filter( 'shiny_code_languages', function ($data) {
	$data['rust'] = [
		'name' => 'Rust',
		'codemirror' => [
			'autoCloseBrackets' => true,
			'matchBrackets' => true,
		],
	];
	$data['nasm'] = [
		'name' => 'NASM',
		'codemirror' => [
			'autoCloseBrackets' => false,
			'matchBrackets' => false,
		],
	];
	return $data;
});

which got them selectable in the block options, but there's no highlighting either in the editor or the output.

I was able to fix output by rebuilding the prism.js and prism.css files in the main shiny-code distribution with the additional languages, and it's running pretty great! I'm not sure what to do to add languages for CodeMirror for the editing, but for now I'm just living with it. ;)

Thanks again -- I've been wanting to add a syntax highlight plugin for my recent blog series but everything out there apparently interacts badly with Gutenberg, which I've fallen in love with. ;)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions