Skip to content
Merged
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
78 changes: 39 additions & 39 deletions src/languages/c.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,48 +37,48 @@ export default {
$insertBefore: {
'string': {
char,
},
'macro': {
// allow for multiline macro definitions
// spaces after the # character compile fine with gcc
pattern:
/(^[\t ]*)#\s*[a-z](?:[^\r\n\\/]|\/(?!\*)|\/\*(?:[^*]|\*(?!\/))*\*\/|\\(?:\r\n|[\s\S]))*/im,
lookbehind: true,
greedy: true,
alias: 'property',
inside: {
'string': [
{
// highlight the path of the include statement as a string
pattern: /^(#\s*include\s*)<[^>]+>/,
'macro': {
// allow for multiline macro definitions
// spaces after the # character compile fine with gcc
pattern:
/(^[\t ]*)#\s*[a-z](?:[^\r\n\\/]|\/(?!\*)|\/\*(?:[^*]|\*(?!\/))*\*\/|\\(?:\r\n|[\s\S]))*/im,
lookbehind: true,
greedy: true,
alias: 'property',
inside: {
'string': [
{
// highlight the path of the include statement as a string
pattern: /^(#\s*include\s*)<[^>]+>/,
lookbehind: true,
},
string,
],
'char': char,
'comment': comment,
'macro-name': [
{
pattern: /(^#\s*define\s+)\w+\b(?!\()/i,
lookbehind: true,
},
{
pattern: /(^#\s*define\s+)\w+\b(?=\()/i,
lookbehind: true,
alias: 'function',
},
],
// highlight macro directives as keywords
'directive': {
pattern: /^(#\s*)[a-z]+/,
lookbehind: true,
alias: 'keyword',
},
string,
],
'char': char,
'comment': comment,
'macro-name': [
{
pattern: /(^#\s*define\s+)\w+\b(?!\()/i,
lookbehind: true,
'directive-hash': /^#/,
'punctuation': /##|\\(?=[\r\n])/,
'expression': {
pattern: /\S[\s\S]*/,
inside: { $rest: 'c' },
},
{
pattern: /(^#\s*define\s+)\w+\b(?=\()/i,
lookbehind: true,
alias: 'function',
},
],
// highlight macro directives as keywords
'directive': {
pattern: /^(#\s*)[a-z]+/,
lookbehind: true,
alias: 'keyword',
},
'directive-hash': /^#/,
'punctuation': /##|\\(?=[\r\n])/,
'expression': {
pattern: /\S[\s\S]*/,
inside: { $rest: 'c' },
},
},
},
Expand Down
3 changes: 1 addition & 2 deletions src/languages/csharp.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { insertBefore } from '../util/insert';
import clike from './clike';
import type { LanguageProto } from '../types';

Expand Down Expand Up @@ -33,7 +32,7 @@ function nested (pattern: string, depthLog2: number) {

export default {
id: 'csharp',
require: clike,
base: clike,
alias: ['c#', 'cs', 'dotnet'],
grammar ({ languages }) {
// https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/
Expand Down
2 changes: 1 addition & 1 deletion src/languages/fsharp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { LanguageProto } from '../types';
export default {
id: 'fsharp',
alias: 'f#',
require: clike,
base: clike,
optional: 'markup',
grammar ({ languages }) {
return {
Expand Down
2 changes: 1 addition & 1 deletion src/languages/markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export default {
// code block
// ```
pattern:
/^```(?<codeLanguage>[a-z-]+).+(?:\n|\r\n?)(?<codeBlock>[\s\S]*)?(?:\n|\r\n?)```$/i,
/^```(?<codeLanguage>[a-z-]+)(?:.+)?(?:\n|\r\n?)(?<codeBlock>[\s\S]*)?(?:\n|\r\n?)```$/i,
inside: {
'code-block': groups => groups.codeLanguage,
'punctuation': /```/,
Expand Down
1 change: 1 addition & 0 deletions src/languages/php.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ export default {

const embedded = embeddedIn('markup');
return {
...php,
'php': {
pattern:
/<\?(?:[^"'/#]|\/(?![*/])|("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|(?:\/\/|#(?!\[))(?:[^?\n\r]|\?(?!>))*(?=$|\?>|[\r\n])|#\[|\/\*(?:[^*]|\*(?!\/))*(?:\*\/|$))*?(?:\?>|$)/,
Expand Down
7 changes: 2 additions & 5 deletions src/languages/vbnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,8 @@ export default {
pattern: /'''.*/,
greedy: true,
alias: 'comment',
// TODO do better
get inside () {
if (languages.markup) {
return languages.markup.tag;
}
inside: {
'tag': languages.markup?.tag,
},
},
'comment': [
Expand Down
2 changes: 1 addition & 1 deletion src/util/extend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export function extend (base: Grammar, grammar: Grammar): Grammar {
}
}
else if (relToken) {
lang[all][relToken][tokenName] = token;
(lang[all][relToken] ??= {})[tokenName] = token;
}
else {
lang[tokenName] = token;
Expand Down