• Resolved maxiclo

    (@maxiclo)


    Support to RUST language for the code block will be really appreciated.

    Thanks

    • This topic was modified 6 years, 1 month ago by maxiclo.
Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author maximebj

    (@maximebj)

    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' ); 
    
    Thread Starter maxiclo

    (@maxiclo)

    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 6 years, 1 month ago by maxiclo.
    Plugin Author maximebj

    (@maximebj)

    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

    Thread Starter maxiclo

    (@maxiclo)

    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)

    Thread Starter maxiclo

    (@maxiclo)

    Just to confirm that yes:
    RUST is a C-like language

    Plugin Author maximebj

    (@maximebj)

    OK ! 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.

    Thread Starter maxiclo

    (@maxiclo)

    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 ??

    Plugin Author maximebj

    (@maximebj)

    Weird. It worked for me and others.

    No PHP errors? the child theme is active (not parent)?

    Thread Starter maxiclo

    (@maxiclo)

    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!

    Plugin Author maximebj

    (@maximebj)

    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)

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Code block: Support to RUST language’ is closed to new replies.