Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions grammars/swift.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,18 @@
}
]
},
"swiftdoc": {
"patterns": [
{
"name": "entity.name.tag.documentation.swift",
"match": "(-\\s+[A-Za-z]+:)|@[a-zA-Z]+"
},
{
"name": "markup.inline.raw.swift",
"match": "`[^`]+`"
}
]
},
"keywords": {
"patterns": [
{
Expand Down
12 changes: 12 additions & 0 deletions grammars/typescript.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,18 @@
}
]
},
"tsdoc": {
"patterns": [
{
"name": "entity.name.tag.documentation.typescript",
"match": "@[a-zA-Z]+"
},
{
"name": "markup.inline.raw.typescript",
"match": "`[^`]+`"
}
]
},
"keywords": {
"patterns": [
{
Expand Down
50 changes: 50 additions & 0 deletions test/syntax_highlight_test.dart
Original file line number Diff line number Diff line change
@@ -1 +1,51 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:syntax_highlight/syntax_highlight.dart';

void main() {
TestWidgetsFlutterBinding.ensureInitialized();

late HighlighterTheme theme;

setUpAll(() async {
await Highlighter.initialize(['typescript', 'swift']);
theme = await HighlighterTheme.loadLightTheme();
});

group('documentation comments', () {
test('highlights TypeScript doc comments without throwing', () {
const source = '''
/**
* @remarks Example
*/
export function answer(): number {
return 42;
}
''';

final span = Highlighter(
language: 'typescript',
theme: theme,
).highlight(source);

expect(span.toPlainText(), source);
});

test('highlights Swift doc comments without throwing', () {
const source = '''
/**
* - Returns: Example
*/
func answer() -> Int {
42
}
''';

final span = Highlighter(
language: 'swift',
theme: theme,
).highlight(source);

expect(span.toPlainText(), source);
});
});
}