Code block: Support to RUST language
-
Support to RUST language for the code block will be really appreciated.
Thanks
-
This topic was modified 7 years, 2 months ago by
maxiclo.
-
This topic was modified 7 years, 2 months ago by
-
Hello,
You can add a filter to set more languages. add this in your functions.php for example and tell me if it works :
function my_custom_languages( $languages ) { $languages[] = array('slug' => 'rust', mode => 'rust', 'label' => 'RUST') ; return $languages; } add_filters( 'advanced_gutenberg_blocks_code_languages', 'my_custom_languages' );I have a child theme installed.
Unfortunately, I got:
Your PHP code changes were rolled back due to an error on line 35 of file wp-content/themes/theme-child/functions.php. Please fix and try saving again.
Uncaught Error: Call to undefined function add_filters() in wp-content/themes/theme-child/functions.php:35
If I change:
add_filters( ‘advanced_gutenberg_blocks_code_languages’, ‘my_custom_languages’ );
with
add_action( ‘advanced_gutenberg_blocks_code_languages’, ‘my_custom_languages’ );The functions.php will update.
However, if I select RUST as the language the preview on backend side works but the view post never show up and the page gets stuck!!
Still, works if I select C++ for example as language.
Thanks for the support!
-
This reply was modified 7 years, 2 months ago by
maxiclo.
Oops it’s add_filter() and not add_filterS()
if RUST is a C-like language I need to make some changes in my code in order to fully work.
Let me know if it works already with add_filter
Hi,
thanks for supporting this!!Now:
function my_custom_languages( $languages ) {
$languages[] = array(‘slug’ => ‘rust’, mode => ‘rust’, ‘label’ => ‘RUST’) ;return $languages;
}
add_filter( ‘advanced_gutenberg_blocks_code_languages’, ‘my_custom_languages’ );is correctly added to theme Functions – (functions.php) but again, if I select RUST as the language the preview on backend side works but the view post never show up and the page gets stuck trying to load 🙁 (blank page)
Just to confirm that yes:
RUST is a C-like languageOK ! Found the issue.
Rust language needs an addon named simplemode so I added it as a dependency whenever Rust is called.
View source of : https://codemirror.net/mode/rust/index.html
It’s working in the today new release. Feel free to reopen this issue if something is still wrong.
Hi sorry for the late answer and thanks for looking at this.
After your notes I have added back the following code to the Child: Theme Functions (functions.php):
function my_custom_languages( $languages ) {
$languages[] = array(‘slug’ => ‘rust’, mode => ‘rust’, ‘label’ => ‘RUST’) ;return $languages;
}
add_filter( ‘advanced_gutenberg_blocks_code_languages’, ‘my_custom_languages’ );Unfortunately, RUST language do not appear as a Language option 🙁
Weird. It worked for me and others.
No PHP errors? the child theme is active (not parent)?
Hi,
The child theme was NOT active. My bad!It works now!!
Why you don’t put RUST in the standard list and/or an option to activate more languages??
Thanks a lot for your support!!
Keep it on this great job!
Aaah 😀
Ok case closed! ^^I didn’t added rust and other languages to avoid loading too much scripts at once in the editor and stick to the most used ones
(shame but I didn’t even knew rust prior to work on the Block code)
-
This reply was modified 7 years, 2 months ago by
The topic ‘Code block: Support to RUST language’ is closed to new replies.