开发者 |
mkaz
westonruter memuller jazanne jeherve eclev91 |
---|---|
更新时间 | 2024年5月8日 19:03 |
捐献地址: | 去捐款 |
PHP版本: | 5.6 及以上 |
WordPress版本: | 6.5 |
版权: | GPLv2 or later |
版权网址: | 版权信息 |
The Code Syntax Block plugin uses the Prism autoloader plugin to support all of the languages Prism supports. See the list of supported languages here.
The default color theme is A11y Dark optimized for accessibility. If you want to change the colorscheme, you can select from the plugin settings page a few different themes shipped with the plugin. You can also use a theme from the Prism themes repo or create your own. The color theme is a single CSS file, there are a couple ways to customize:
assets/prism/prism.css
and use that file if it exists. Add your custom file in that location, and it will be used.mkaz_prism_css_path
and specify a path relative to your theme to use.mkaz_prism_css_url
and specify a full URL to the stylesheet to use.Use the filter mkaz_code_syntax_language_list
to customize the list of languages to select displayed in the editor. By default the code syntax block shows a shorter list of popular languages, but Prism supports close to 200, see list.
Use this filter to extend to support the languages you need. Additionally you can use the filter to shorten the list to just the languages you use to make it easier to select.
Here is an example shortening the list to a smaller set:
add_filter( 'mkaz_code_syntax_language_list', function() {
return array(
"bash" => "Bash",
"go" => "Go",
"html" => "HTML",
"javascript" => "JavaScript",
"json" => "JSON",
"markdown" => "Markdown",
"php" => "PHP",
"python" => "Python",
"jsx" => "React JSX",
"sass" => "Sass",
"sql" => "SQL",
"svg" => "SVG",
"toml" => "TOML",
"vim" => "vim",
"xml" => "XML",
"yaml" => "YAML",
);
} );
Yes, on the plugin settings page in the dashboard you can set a default language when inserting a code block. You can still change if you wish to show code not using the default language.
Yes, use the filter mkaz_code_syntax_force_loading
to force always loading assets, otherwise it users has_block to check.
Example:
add_filter( 'mkaz_code_syntax_force_loading', '__return_true' );