Add C highlighting support
Some checks failed
timw4mail/scroll/pipeline/head There was a failure building this commit

This commit is contained in:
Timothy Warren 2024-07-22 15:33:01 -04:00
parent 6101132a15
commit d90d685ef2
2 changed files with 8 additions and 0 deletions

View File

@ -5,6 +5,8 @@ import Option, { None } from '../option.ts';
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
export enum FileLang { export enum FileLang {
C = 'C',
CPP = 'C++',
TypeScript = 'TypeScript', TypeScript = 'TypeScript',
JavaScript = 'JavaScript', JavaScript = 'JavaScript',
PHP = 'PHP', PHP = 'PHP',
@ -16,6 +18,7 @@ export enum FileLang {
} }
export interface HighlightingOptions { export interface HighlightingOptions {
characters: boolean;
numbers: boolean; numbers: boolean;
octalNumbers: boolean; octalNumbers: boolean;
hexNumbers: boolean; hexNumbers: boolean;
@ -51,6 +54,7 @@ export abstract class AbstractFileType implements IFileType {
public readonly keywords2: string[] = []; public readonly keywords2: string[] = [];
public readonly operators: string[] = []; public readonly operators: string[] = [];
public readonly hlOptions: HighlightingOptions = { public readonly hlOptions: HighlightingOptions = {
characters: false,
numbers: false, numbers: false,
octalNumbers: false, octalNumbers: false,
hexNumbers: false, hexNumbers: false,
@ -78,6 +82,7 @@ export abstract class AbstractFileType implements IFileType {
} }
export const defaultHighlightOptions: HighlightingOptions = { export const defaultHighlightOptions: HighlightingOptions = {
characters: false,
numbers: true, numbers: true,
octalNumbers: false, octalNumbers: false,
hexNumbers: false, hexNumbers: false,

View File

@ -1,5 +1,6 @@
import { node_path as path } from '../runtime/mod.ts'; import { node_path as path } from '../runtime/mod.ts';
import { AbstractFileType } from './base.ts'; import { AbstractFileType } from './base.ts';
import { CFile } from './c.ts'
import { CSSFile } from './css.ts'; import { CSSFile } from './css.ts';
import { JavaScriptFile, TypeScriptFile } from './javascript.ts'; import { JavaScriptFile, TypeScriptFile } from './javascript.ts';
import { ShellFile } from './shell.ts'; import { ShellFile } from './shell.ts';
@ -10,6 +11,8 @@ import { ShellFile } from './shell.ts';
export class FileType extends AbstractFileType { export class FileType extends AbstractFileType {
static #fileTypeMap = new Map([ static #fileTypeMap = new Map([
['.c', CFile],
['.h', CFile],
['.css', CSSFile], ['.css', CSSFile],
['.json', JavaScriptFile], ['.json', JavaScriptFile],
['.js', JavaScriptFile], ['.js', JavaScriptFile],