Dart not detected by the Preformated text block on forum

Hello raywenderlich team :wave:

The beautifully displayed code blocks in Raywenderlich’s online books and articles are one of the reasons why I enjoy the site :heart_eyes:

But unlike the books and articles, the code blocks in the forum do not highlight Dart code correctly. The example Dart code further below is detected as Rust by the Highlight.js library that Discourse utilises, and in a post I made on another topic, the Dart code was detected as Python

A potential solution might be to check if Dart is listed under the highlighted languages setting in Discourse’s admin area and enable it, if necessary.

I have tested the preformatted text block on Swift, Dart and Objective-C code, trying both the standard opening tag for automatic detection ``` and the one to set a language.

Swift code is detected, but cannot be specifically set using ```swift
So Swift might also not be enabled under highlighted languages setting.

Dart is not detected and cannot be set using ```dart

Objective-C is detected automatically and can also be set using ```objectivec

Thanks for reading :+1:

Example code from highlight.js demo page:

library app;
import 'dart:html';

part 'app2.dart';

 * Class description and [link](http://dartlang.org/).
@Awesome('it works!')
class SomeClass<S extends Iterable> extends BaseClass<S> implements Comparable {
  factory SomeClass(num param);
  SomeClass._internal(int q) : super() {
    assert(q != 1);
    double z = 0.0;

  /// **Sum** function
  int sum(int a, int b) => a + b;

  ElementList els() => querySelectorAll('.dart');

String str = ' (${'parameter' + 'zxc'})';
String str = " (${true ? 2 + 2 / 2 : null})";
String str = " ($variable)";
String str = r'\nraw\';
String str = r"\nraw\";
var str = '''
Something ${2+3}
var str = r"""
Something ${2+3}

checkVersion() async {
  var version = await lookUpVersion();
1 Like

Thanks for bringing this up! I’m forwarding it to the team.

1 Like

Thank you! The preformatted text block in this topic and in the linked post, are now both highlighted correctly as Dart :+1:


Yay! Thanks for testing.