Skip to content

highlight using directives in code snippets #2845

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 22, 2023
Merged
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
28 changes: 28 additions & 0 deletions resources/js/hljs-scala3.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,33 @@ function highlightDotty(hljs) {
]
}

// glob all non-whitespace characters as a "string"
const DIRECTIVE_VALUE = {
className: 'string',
begin: /\S+/,
}

// glob all non-whitespace characters as a "type", so that we can highlight differently to values
const DIRECTIVE_KEY = {
className: 'type',
begin: /\S+/,
}

// directives
const USING_DIRECTIVE = hljs.COMMENT('//>', '\n', {
contains: [
{
begin: /using /,
end: /\s/,
keywords: 'using',
contains: [
DIRECTIVE_KEY
]
},
DIRECTIVE_VALUE,
]
})

// Documentation
const SCALADOC = hljs.COMMENT('/\\*\\*', '\\*/', {
contains: [
Expand Down Expand Up @@ -454,6 +481,7 @@ function highlightDotty(hljs) {
NUMBER,
CHAR,
STRING,
USING_DIRECTIVE,
SCALADOC,
hljs.C_LINE_COMMENT_MODE,
hljs.C_BLOCK_COMMENT_MODE,
Expand Down