Fix issue with picture upload and rendering based on 4 modes how Obsidian can store images.

Add there option to view other files and uplod/download files from main view
This commit is contained in:
nahakubuilde
2025-06-28 12:41:34 +01:00
parent 4b73367544
commit 3e4355d20d
647 changed files with 74316 additions and 897 deletions

4
.gitignore vendored
View File

@@ -1,4 +1,8 @@
notes/**/
.github
mynotes_*
settings.ini
__pycache__/
*.py[cod]
*.pyo

View File

@@ -4,3 +4,47 @@
## Configuration
This app uses a `settings.ini` file for configuration. On first run, it will be created automatically if missing, and any missing values will be filled in with defaults.
##
- Markdown and code block `https://highlightjs.org/#usage`
## App Summary
- View and browse Obsidian-compatible markdown notes and folders in a web browser
- Supports image and file uploads with configurable allowed extensions and secure type checking
- Edit app settings (including allowed file types) via a web UI
- Hide or skip folders/files as per settings
- Download files and view images, text, and documents (PDF, CSV, JSON, YAML, XML, etc.)
- Drag & drop or button-based file upload, with progress and notifications
- Context menu for file/folder actions (open, download)
- Syntax highlighting for code/text files and pretty-printing for JSON/YAML/XML
- Consistent notification system using a modal
- Sidebar navigation with persistent expand/collapse state
- Multiple image storage modes to match Obsidian's attachment handling
- Secure file handling and upload validation to prevent malicious uploads
## Image storing trying to follow Obsidian settings
Let me break this down step by step to make sure we fix all parts correctly.
First, let me make sure I understand each mode's requirements:
1. Mode 1 (Root directory):
- Images are stored directly in NOTES_DIR root
- In .md file: just filename like `![[image.png]]`
- When showing: serve from NOTES_DIR root
2. Mode 2 (Specific folder):
- Images stored in IMAGE_STORAGE_PATH
- In .md file: just filename like `![[image.png]]`
- When showing: serve from IMAGE_STORAGE_PATH
3. Mode 3 (Same as note):
- Images stored in same directory as the .md file
- In .md file: just filename like `![[image.png]]` (since it's in same dir)
- When showing: serve from note's directory
4. Mode 4 (Subfolder under note):
- Images stored in IMAGE_SUBFOLDER_NAME under note's directory
- In .md file: `![[<IMAGE_SUBFOLDER_NAME>/image.png]]`
- When showing: serve from note's directory/IMAGE_SUBFOLDER_NAME

371
app.py
View File

@@ -1,21 +1,37 @@
# app.py
from flask import Flask, render_template, request, redirect, url_for, jsonify, abort
from werkzeug.exceptions import HTTPException
import os
import mistune
from flask import Flask, render_template
from werkzeug.exceptions import HTTPException
from pathlib import Path
import re
from app_settings_loader import ensure_settings_ini, FLASK_HOST, FLASK_PORT, SECRET_KEY, DEBUG, NOTES_DIR, MAX_CONTENT_LENGTH
from md_viewer import md_viewer_bp
from app_settings_loader import (
ensure_settings_ini, get_setting, FLASK_HOST, FLASK_PORT
)
import logging
# Setup logger
logger = logging.getLogger(__name__)
app = Flask(__name__)
# Ensure settings.ini exists and is up to date on app launch
ensure_settings_ini()
app.config['SECRET_KEY'] = SECRET_KEY
app.config['DEBUG'] = DEBUG
app.config['NOTES_DIR'] = NOTES_DIR
max_content_length = MAX_CONTENT_LENGTH * 1024 * 1024 # Convert MB to bytes
app.config['SECRET_KEY'] = get_setting('FLASK', 'SECRET_KEY',)
app.config['DEBUG'] = get_setting('FLASK', 'DEBUG', type_=bool)
app.config['NOTES_DIR'] = Path(get_setting('MD_NOTES_APP', 'NOTES_DIR')).resolve()
max_content_length = int(get_setting('FLASK', 'MAX_CONTENT_LENGTH')) * 1024 * 1024 # Convert MB to bytes
app.config['MAX_CONTENT_LENGTH'] = max_content_length
# Initialize image storage settings
app.config['IMAGE_STORAGE_MODE'] = get_setting('MD_NOTES_APP', 'IMAGE_STORAGE_MODE')
app.config['IMAGE_STORAGE_PATH'] = get_setting('MD_NOTES_APP', 'IMAGE_STORAGE_PATH')
app.config['IMAGE_SUBFOLDER_NAME'] = get_setting('MD_NOTES_APP', 'IMAGE_SUBFOLDER_NAME')
# Register the md_viewer blueprint
app.register_blueprint(md_viewer_bp)
# Custom error handler using base.html
@app.errorhandler(Exception)
def handle_error(error):
@@ -29,342 +45,7 @@ def handle_error(error):
# Create directory for notes if it doesn't exist
if not app.config['NOTES_DIR'].exists():
os.makedirs(app.config['NOTES_DIR'])
def build_tree_structure(directory, base_path=None, level=0):
"""Build a tree structure from the directory."""
if base_path is None:
base_path = directory
tree = []
try:
for item in sorted(directory.iterdir(), key=lambda x: (not x.is_dir(), x.name.lower())):
if item.name.startswith('.'): # Skip hidden files
continue
rel_path = str(item.relative_to(base_path))
node = {
'name': item.name,
'type': 'dir' if item.is_dir() else 'file',
'path': rel_path,
'level': level,
'expanded': False # Default to collapsed
}
if item.is_dir():
node['children'] = build_tree_structure(item, base_path, level + 1)
elif item.suffix == '.md': # Only include .md files
node['display_name'] = item.stem # Just use filename without extension
else:
continue # Skip non-markdown files
tree.append(node)
except Exception as e:
print(f"Error reading directory {directory}: {str(e)}")
return tree
def get_path_components(path):
"""Convert a file path into a list of directory names."""
if not path:
return []
parts = path.split('/')
return ['/'.join(parts[:i+1]) for i in range(len(parts)-1)]
def generate_breadcrumbs(note_path, title=None):
"""Generate breadcrumb data for a given note path."""
crumbs = []
parts = note_path.split('/')
current_path = ''
# Add root
crumbs.append({'name': '/', 'url': url_for('index')})
# Add directories
for i, part in enumerate(parts[:-1]): # Skip the file name
current_path = current_path + '/' + part if current_path else part
crumbs.append({
'name': part,
'url': url_for('folder', folder_path=current_path)
})
# Add the file name (always use file name without .md)
if len(parts) > 0:
name = parts[-1][:-3] if parts[-1].endswith('.md') else parts[-1]
url = None if parts[-1].endswith('.md') else url_for('folder', folder_path=current_path + '/' + parts[-1] if current_path else parts[-1])
crumbs.append({'name': name, 'url': url})
return crumbs
@app.route('/')
def index():
folder_contents = []
try:
for item in sorted(app.config['NOTES_DIR'].iterdir(), key=lambda x: (not x.is_dir(), x.name.lower())):
if item.name.startswith('.'): # Skip hidden files
continue
is_dir = item.is_dir()
rel_path = str(item.relative_to(app.config['NOTES_DIR']))
if is_dir or item.suffix == '.md': # Only include directories and markdown files
folder_contents.append({
'name': item.name,
'type': 'dir' if is_dir else 'file',
'path': rel_path,
'display_name': item.name if is_dir else item.stem # Show full name for folders, remove .md for files
})
except Exception as e:
print(f"Error reading root directory: {str(e)}")
notes_tree = build_tree_structure(app.config['NOTES_DIR'])
return render_template('folder.html',
folder_path='',
folder_contents=folder_contents,
notes_tree=notes_tree,
active_path=[],
current_note=None,
breadcrumbs=generate_breadcrumbs(''))
@app.route('/note/<path:note_path>')
def note(note_path):
full_path = Path(app.config['NOTES_DIR']) / note_path
if not full_path.is_file() or not note_path.endswith('.md'):
return "Note not found", 404
try:
with open(full_path, 'r', encoding='utf-8') as f:
content = f.read()
# Convert markdown to HTML
renderer = mistune.HTMLRenderer()
markdown_parser = mistune.Markdown(renderer=renderer)
html_content = markdown_parser(content)
# Build tree and get path components
notes_tree = build_tree_structure(app.config['NOTES_DIR'])
active_path = get_path_components(note_path)
# Use file name (without .md) for breadcrumbs and title
title = full_path.stem
breadcrumbs = generate_breadcrumbs(note_path, title)
return render_template('note.html',
content=content,
html_content=html_content,
title=title,
notes_tree=notes_tree,
active_path=active_path,
current_note=note_path,
breadcrumbs=breadcrumbs)
except Exception as e:
return f"Error reading note: {str(e)}", 500
@app.route('/edit/<path:note_path>', methods=['GET', 'POST'])
def edit_note(note_path):
full_path = Path(app.config['NOTES_DIR']) / note_path
if not full_path.is_file() or not note_path.endswith('.md'):
return "Note not found", 404
if request.method == 'POST':
new_content = request.form.get('content', '')
try:
with open(full_path, 'w', encoding='utf-8') as f:
f.write(new_content)
return redirect(url_for('note', note_path=note_path))
except Exception as e:
return f"Error saving note: {str(e)}", 500
try:
with open(full_path, 'r', encoding='utf-8') as f:
content = f.read()
title = full_path.stem
notes_tree = build_tree_structure(app.config['NOTES_DIR'])
active_path = get_path_components(note_path)
breadcrumbs = generate_breadcrumbs(note_path, f"Edit {title}")
return render_template('edit.html',
content=content,
title=title,
notes_tree=notes_tree,
active_path=active_path,
current_note=note_path,
breadcrumbs=breadcrumbs)
except Exception as e:
return f"Error reading note: {str(e)}", 500
def get_all_folders(directory, base_path=None, level=0):
"""Get a flat list of all folders in the directory with their paths and levels."""
if base_path is None:
base_path = directory
folders = []
try:
for item in sorted(directory.iterdir(), key=lambda x: x.name.lower()):
if item.name.startswith('.'): # Skip hidden files
continue
if item.is_dir():
rel_path = str(item.relative_to(base_path))
folders.append({
'name': item.name,
'path': rel_path,
'level': level
})
# Recursively get subfolders
folders.extend(get_all_folders(item, base_path, level + 1))
except Exception as e:
print(f"Error reading directory {directory}: {str(e)}")
return folders
@app.route('/create', methods=['GET', 'POST'])
def create_note():
if request.method == 'POST':
title = request.form.get('title', '').strip()
if not title:
abort(400, description="Note title is required")
# Validate file name: only allow safe characters
# Letters, numbers, dash, underscore, dot (no slashes)
if not re.match(r'^[\w\-. ]+$', title):
return "Invalid file name. Only letters, numbers, dash, underscore, dot, and space are allowed.", 400
if '/' in title or '\\' in title:
return "Invalid file name. Slashes are not allowed.", 400
if title.startswith('.') or title.endswith('.'):
return "Invalid file name. Cannot start or end with a dot.", 400
if title in ['CON', 'PRN', 'AUX', 'NUL'] or re.match(r'^COM[1-9]$|^LPT[1-9]$', title, re.IGNORECASE):
return "Invalid file name.", 400
content = request.form.get('content', '').strip()
path = request.form.get('path', '').strip()
# Use the title as the file name
filename = f"{title}.md"
try:
# Safely resolve the full path to ensure it's within NOTES_DIR
if path:
dir_path = (Path(app.config['NOTES_DIR']) / path).resolve()
if not str(dir_path).startswith(str(app.config['NOTES_DIR'].resolve())):
return "Invalid folder path", 400
os.makedirs(dir_path, exist_ok=True)
file_path = dir_path / filename
else:
file_path = Path(app.config['NOTES_DIR']) / filename
# Final safety check
file_path = file_path.resolve()
if not str(file_path).startswith(str(app.config['NOTES_DIR'].resolve())):
return "Invalid file path", 400
# Check if file already exists
if file_path.exists():
return "A note with this name already exists in the selected folder. Please choose a different name.", 400
with open(file_path, 'w', encoding='utf-8') as f:
f.write(content)
# Use os.path.relpath for robust path calculation
rel_path = os.path.relpath(str(file_path), str(app.config['NOTES_DIR']))
return redirect(url_for('note', note_path=rel_path))
except Exception as e:
abort(500, description=f"Error creating note: {str(e)}")
# Get all available folders for autocomplete
available_folders = get_all_folders(app.config['NOTES_DIR'])
# Get current folder from query parameter if provided
current_folder = request.args.get('folder', '')
notes_tree = build_tree_structure(app.config['NOTES_DIR'])
return render_template('create.html',
notes_tree=notes_tree,
available_folders=available_folders,
current_folder=current_folder,
active_path=current_folder.split('/') if current_folder else [],
current_note=None)
@app.route('/delete/<path:note_path>', methods=['POST'])
def delete_note(note_path):
full_path = Path(app.config['NOTES_DIR']) / note_path
if not full_path.is_file() or not note_path.endswith('.md'):
return "Note not found", 404
try:
os.remove(full_path)
return redirect(url_for('index'))
except Exception as e:
return f"Error deleting note: {str(e)}", 500
@app.route('/search')
def search():
query = request.args.get('q', '').lower()
if not query:
return jsonify([])
results = []
for root, _, files in os.walk(app.config['NOTES_DIR']):
for file in files:
if not file.endswith('.md'):
continue
try:
file_path = Path(root) / file
with open(file_path, 'r', encoding='utf-8') as f:
content = f.read()
if query in content.lower():
title = file_path.stem # Always use file name without .md
# Find context for the match
pos = content.lower().find(query)
start = max(0, pos - 50)
end = min(len(content), pos + len(query) + 50)
snippet = content[start:end].strip()
results.append({
'title': title,
'url': url_for('note', note_path=str(file_path.relative_to(app.config['NOTES_DIR']))),
'snippet': snippet
})
except Exception as e:
print(f"Error reading {file_path}: {str(e)}")
return jsonify(results)
@app.route('/folder/<path:folder_path>')
def folder(folder_path):
folder_full_path = Path(app.config['NOTES_DIR']) / folder_path
if not folder_full_path.is_dir():
return "Folder not found", 404
notes_tree = build_tree_structure(app.config['NOTES_DIR'])
# Get the current folder's contents
current_folder = folder_full_path
folder_contents = []
try:
for item in sorted(current_folder.iterdir(), key=lambda x: (not x.is_dir(), x.name.lower())):
if item.name.startswith('.'): # Skip hidden files
continue
is_dir = item.is_dir()
rel_path = str(item.relative_to(app.config['NOTES_DIR']))
if is_dir or item.suffix == '.md': # Only include directories and markdown files
folder_contents.append({
'name': item.name,
'type': 'dir' if is_dir else 'file',
'path': rel_path,
'display_name': item.name if is_dir else item.stem # Show full name for folders, remove .md for files
})
except Exception as e:
return f"Error reading folder: {str(e)}", 500
return render_template('folder.html',
folder_path=folder_path,
folder_contents=folder_contents,
notes_tree=notes_tree,
active_path=folder_path.split('/'),
current_note=None,
breadcrumbs=generate_breadcrumbs(folder_path))
os.makedirs(app.config['NOTES_DIR'], exist_ok=True)
if __name__ == '__main__':

View File

@@ -18,7 +18,23 @@ notes_dir = get_setting('FLASK', 'NOTES_DIR', fallback='notes')
import configparser
from pathlib import Path
import os
CONFIG_FILE_NAME = 'settings.ini'
# Define the root directory of the project
ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
CONFIG_FILE = os.path.join(ROOT_DIR, CONFIG_FILE_NAME)
class CaseSensitiveConfigParser(configparser.ConfigParser):
"""A ConfigParser that preserves key case"""
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# Make options case-sensitive
self.optionxform = str
# Use uppercase for all DEFAULT_CONFIG keys
DEFAULT_CONFIG = {
'FLASK': {
'FLASK_HOST': '0.0.0.0',
@@ -26,20 +42,40 @@ DEFAULT_CONFIG = {
'SECRET_KEY': 'change-this-secret',
'DEBUG': 'False',
'Specify location where your notes .md files are at - the root folder': None,
'NOTES_DIR': 'notes',
'Maximum content length in MB': None,
'MAX_CONTENT_LENGTH': '16',
},
'MD_NOTES_APP': {
'Name of the application to show in title and navbar': None,
'NOTE_APP_NAME': 'Flobidian',
'Location where all .md files are stored, you can pass in obsidian vault location too': None,
'NOTES_DIR': 'notes',
'These folders will not be showed in side panel navigation - used for hiding images for example': None,
'NOTES_DIR_HIDE_SIDEPANE': 'attatched, images',
'These folders will not be checked by the app - no .md will be viewed if is in': None,
'NOTES_DIR_SKIP': 'secret, private',
'Hide images from main view': None,
'IMAGES_FS_HIDE': 'False',
'Storage mode for images (1: root directory, 2: specific folder, 3: same as note, 4: subfolder of note)': None,
'IMAGE_STORAGE_MODE': '1',
'Path for storing images when mode 2 is selected': None,
'IMAGE_STORAGE_PATH': 'images',
'Subfolder name when mode 4 is selected': None,
'IMAGE_SUBFOLDER_NAME': 'attatched',
'Allowed image extensions what will be visible - png is default obsidian image file!': None,
'ALLOWED_IMAGE_EXTENSIONS': 'jpg, jpeg, png, webp',
'Allowed file extensions for text files what will be visible and viewable': None,
'ALLOWED_FILE_EXTENSIONS': 'txt, pdf, html, json, yaml, yml, conf, csv, cmd, bat, sh',
},
}
CONFIG_FILE = 'settings.ini'
def ensure_settings_ini():
"""
Ensure that settings.ini exists and contains all required settings.
- If the file does not exist, it is created with default values and comments.
- If the file exists but is missing any required setting, only the missing setting(s)
are added with default values (existing values and comments are not changed).
- All keys are normalized to uppercase.
"""
# First check if file exists at all
if not Path(CONFIG_FILE).exists():
@@ -163,29 +199,42 @@ def ensure_settings_ini():
f.write('\n'.join(new_lines) + '\n')
def get_setting(section, key, fallback=None, type_=str):
"""
Retrieve a setting from settings.ini.
Args:
section (str): The section in the ini file (e.g. 'FLASK').
key (str): The key to retrieve.
fallback: The value to return if the key is not found.
type_ (type): Optionally convert the value to int or bool. Default is str.
Returns:
The value from settings.ini, converted to the requested type if specified.
"""
config = configparser.ConfigParser()
"""Get a setting from settings.ini, converting to the specified type"""
config = CaseSensitiveConfigParser()
config.read(CONFIG_FILE)
if config.has_option(section, key):
value = config.get(section, key)
if type_ == int:
try:
return int(value)
except Exception:
return fallback if fallback is not None else 0
try:
section = section.upper()
key = key.upper()
if type_ == bool:
return value.lower() in ('true', '1', 'yes', 'on')
return value
return fallback
return config.getboolean(section, key, fallback=fallback)
elif type_ == int:
return config.getint(section, key, fallback=fallback)
elif type_ == float:
return config.getfloat(section, key, fallback=fallback)
else:
return config.get(section, key, fallback=fallback)
except Exception as e:
print(f"Error getting setting {section}.{key}: {str(e)}")
return fallback
def set_setting(section, key, value):
"""Set a setting in settings.ini"""
config = CaseSensitiveConfigParser()
config.read(CONFIG_FILE)
try:
section = section.upper()
key = key.upper()
if not config.has_section(section):
config.add_section(section)
config.set(section, key, str(value))
with open(CONFIG_FILE, 'w') as f:
config.write(f)
return True
except Exception as e:
print(f"Error setting {section}.{key}: {str(e)}")
return False
# Load settings from the configuration file settings.ini
FLASK_HOST = get_setting('FLASK', 'FLASK_HOST', fallback='0.0.0.0')

20
md_viewer/__init__.py Normal file
View File

@@ -0,0 +1,20 @@
from flask import Blueprint
import logging
# Create the main blueprint for markdown viewer
md_viewer_bp = Blueprint('md_viewer', __name__,
template_folder='templates',
static_folder='static',
static_url_path='/md_viewer/static')
# Setup logger
logger = logging.getLogger(__name__)
# Import all routes
from . import viewer # Has the main viewing routes (/, /note, /folder)
from . import editor # Has the edit/create/delete routes
from . import settings_page # Has the settings routes
from . import support_functions # Contains utility functions used across the app

150
md_viewer/editor.py Normal file
View File

@@ -0,0 +1,150 @@
from flask import (
render_template, request, redirect, url_for, jsonify, abort,
send_from_directory, current_app
)
import os
from pathlib import Path
import re
from md_viewer.support_functions import (
build_tree_structure, get_path_components, generate_breadcrumbs,
get_all_folders, get_image_storage_info, handle_uploaded_image,
as_path, NOTES_FOLDER
)
from md_viewer import md_viewer_bp
@md_viewer_bp.route('/edit/<path:note_path>', methods=['GET', 'POST'])
def edit_note(note_path):
full_path = Path(NOTES_FOLDER) / note_path
if not full_path.is_file() or not note_path.endswith('.md'):
return "Note not found", 404
if request.method == 'POST':
new_content = request.form.get('content', '')
try:
with open(full_path, 'w', encoding='utf-8') as f:
f.write(new_content)
# Check if it's an AJAX request
if request.headers.get('X-Requested-With') == 'XMLHttpRequest':
return jsonify({'success': True, 'message': 'Note saved successfully'})
else:
return redirect(url_for('md_viewer.note', note_path=note_path))
except Exception as e:
error_msg = f"Error saving note: {str(e)}"
if request.headers.get('X-Requested-With') == 'XMLHttpRequest':
return jsonify({'success': False, 'message': error_msg}), 500
return error_msg, 500
try:
with open(full_path, 'r', encoding='utf-8') as f:
content = f.read()
title = full_path.stem
notes_tree = build_tree_structure(NOTES_FOLDER)
active_path = get_path_components(note_path)
breadcrumbs = generate_breadcrumbs(note_path, f"Edit {title}")
note_dir = os.path.dirname(note_path)
# Get storage info for this note
storage_dir, storage_base = get_image_storage_info(note_path)
return render_template('edit.html',
content=content,
title=title,
notes_tree=notes_tree,
active_path=active_path,
current_note=note_path,
note_dir=note_dir,
breadcrumbs=breadcrumbs,
storage_mode=current_app.config['IMAGE_STORAGE_MODE'],
storage_base=storage_base)
except Exception as e:
return f"Error reading note: {str(e)}", 500
@md_viewer_bp.route('/create', methods=['GET', 'POST'])
def create_note():
if request.method == 'POST':
title = request.form.get('title', '').strip()
if not title:
abort(400, description="Note title is required")
# Validate file name: only allow safe characters
# Letters, numbers, dash, underscore, dot (no slashes)
if not re.match(r'^[\w\-. ]+$', title):
return "Invalid file name. Only letters, numbers, dash, underscore, dot, and space are allowed.", 400
if '/' in title or '\\' in title:
return "Invalid file name. Slashes are not allowed.", 400
if title.startswith('.') or title.endswith('.'):
return "Invalid file name. Cannot start or end with a dot.", 400
if title in ['CON', 'PRN', 'AUX', 'NUL'] or re.match(r'^COM[1-9]$|^LPT[1-9]$', title, re.IGNORECASE):
return "Invalid file name.", 400
content = request.form.get('content', '').strip()
path = request.form.get('path', '').strip()
# Use the title as the file name
filename = f"{title}.md"
try:
# Safely resolve the full path to ensure it's within NOTES_DIR
if path:
dir_path = (as_path(NOTES_FOLDER) / path).resolve()
if not str(dir_path).startswith(NOTES_FOLDER):
return "Invalid folder path", 400
os.makedirs(dir_path, exist_ok=True)
file_path = dir_path / filename
else:
file_path = as_path(NOTES_FOLDER) / filename
# Final safety check
file_path = file_path.resolve()
if not str(file_path).startswith(NOTES_FOLDER):
return "Invalid file path", 400
# Check if file already exists
if file_path.exists():
return "A note with this name already exists in the selected folder. Please choose a different name.", 400
with open(file_path, 'w', encoding='utf-8') as f:
f.write(content)
# Use os.path.relpath for robust path calculation
rel_path = os.path.relpath(str(file_path), str(NOTES_FOLDER))
return redirect(url_for('md_viewer.note', note_path=rel_path))
except Exception as e:
abort(500, description=f"Error creating note: {str(e)}")
# Get all available folders for autocomplete
available_folders = get_all_folders(NOTES_FOLDER)
# Get current folder from query parameter if provided
current_folder = request.args.get('folder', '')
notes_tree = build_tree_structure(NOTES_FOLDER)
return render_template('create.html',
notes_tree=notes_tree,
available_folders=available_folders,
current_folder=current_folder,
active_path=current_folder.split('/') if current_folder else [],
current_note=None)
@md_viewer_bp.route('/delete/<path:note_path>', methods=['POST'])
def delete_note(note_path):
full_path = Path(NOTES_FOLDER) / note_path
if not full_path.is_file() or not note_path.endswith('.md'):
return "Note not found", 404
try:
os.remove(full_path)
return redirect(url_for('md_viewer.index'))
except Exception as e:
return f"Error deleting note: {str(e)}", 500
@md_viewer_bp.route('/upload_image/<path:note_path>', methods=['POST'])
def upload_image(note_path):
return handle_uploaded_image(request.files, note_path)
@md_viewer_bp.route('/serve_image/<path:path>')
def serve_image(path):
# Ensure the path is safe and within NOTES_DIR
if '..' in path or path.startswith('/'):
return 'Invalid image path', 400
return send_from_directory(NOTES_FOLDER, path)

257
md_viewer/settings_page.py Normal file
View File

@@ -0,0 +1,257 @@
from flask import render_template, request, url_for, jsonify, current_app
from pathlib import Path
import os
from app_settings_loader import get_setting, set_setting
from md_viewer.support_functions import build_tree_structure, check_notes_dir_security, NOTES_FOLDER
from md_viewer import md_viewer_bp
@md_viewer_bp.route('/settings')
def image_storage_settings_page():
"""Show image storage settings page"""
notes_tree = build_tree_structure(NOTES_FOLDER)
return render_template('settings.html',
notes_tree=notes_tree,
active_path=[],
current_note=None,
breadcrumbs=[
{'name': '/', 'url': url_for('md_viewer.index')},
{'name': 'Settings', 'url': None}
])
@md_viewer_bp.route('/settings/image_storage', methods=['GET', 'POST'])
def image_storage_settings():
"""Handle image storage settings"""
if request.method == 'POST':
try:
mode = request.form.get('storage_mode')
path = request.form.get('storage_path', '').strip()
subfolder = request.form.get('subfolder_name', '').strip()
# Validate mode
if mode not in ['1', '2', '3', '4']:
return jsonify({'error': 'Invalid storage mode'}), 400
# Validate path for mode 2
if mode == '2' and not path:
return jsonify({'error': 'Storage path is required for mode 2'}), 400
# Validate subfolder name for mode 4
if mode == '4' and not subfolder:
return jsonify({'error': 'Subfolder name is required for mode 4'}), 400
# Save settings and update app config
settings = {
'IMAGE_STORAGE_MODE': mode,
'IMAGE_STORAGE_PATH': path if mode == '2' else 'images',
'IMAGE_SUBFOLDER_NAME': subfolder if mode == '4' else 'attatched'
}
# Update settings.ini and app config
for key, value in settings.items():
set_setting('MD_NOTES_APP', key, value)
current_app.config[key] = value
return jsonify({
'success': True,
'message': 'Image storage settings updated successfully',
'settings': settings,
'reload_required': True
})
except Exception as e:
current_app.logger.error(f"Error saving image storage settings: {str(e)}")
return jsonify({'error': str(e)}), 500
# For GET request, return current settings directly from settings.ini
try:
current_settings = {
'mode': get_setting('MD_NOTES_APP', 'IMAGE_STORAGE_MODE'),
'path': get_setting('MD_NOTES_APP', 'IMAGE_STORAGE_PATH'),
'subfolder': get_setting('MD_NOTES_APP', 'IMAGE_SUBFOLDER_NAME')
}
return jsonify(current_settings)
except Exception as e:
current_app.logger.error(f"Error reading image storage settings: {str(e)}")
return jsonify({'error': str(e)}), 500
@md_viewer_bp.route('/settings/notes_dir', methods=['GET', 'POST'])
def notes_dir_settings():
"""Handle notes directory settings"""
if request.method == 'POST':
try:
new_dir = request.form.get('notes_dir', '').strip()
if not new_dir:
return jsonify({'error': 'Notes directory is required'}), 400
# Convert to Path and resolve to absolute path
new_path = Path(new_dir).resolve()
# Security checks
is_valid, error_msg = check_notes_dir_security(new_path)
if not is_valid:
return jsonify({'error': error_msg}), 400
# Try to create directory if it doesn't exist
if not new_path.exists():
try:
os.makedirs(new_path)
except Exception as e:
return jsonify({'error': f'Failed to create directory: {str(e)}'}), 500
# Verify permissions
if not os.access(new_path, os.R_OK | os.W_OK):
return jsonify({'error': 'Directory is not readable and writable'}), 400
# Update settings.ini and app config
set_setting('MD_NOTES_APP', 'NOTES_DIR', str(new_path))
# Update the application configuration
current_app.config['NOTES_DIR'] = new_path
# Update the global NOTES_FOLDER variable
global NOTES_FOLDER
NOTES_FOLDER = new_path
return jsonify({
'success': True,
'message': 'Notes directory updated successfully. Reloading page...',
'notes_dir': str(new_path),
'reload_required': True # Signal frontend to reload the page
})
except Exception as e:
current_app.logger.error(f"Error saving notes directory: {str(e)}")
return jsonify({'error': str(e)}), 500
# For GET request, return current setting
try:
notes_dir = str(get_setting('MD_NOTES_APP', 'NOTES_DIR', fallback='notes'))
return jsonify({'notes_dir': notes_dir})
except Exception as e:
return jsonify({'error': str(e)}), 500
@md_viewer_bp.route('/settings/check_notes_dir')
def check_notes_dir():
"""Check if a directory path is valid and accessible"""
try:
path = request.args.get('path', '').strip()
if not path:
return jsonify({'valid': False, 'error': 'No path provided'})
# Convert to Path and resolve to absolute path
test_path = Path(path).resolve()
# Security check
is_valid, error_msg = check_notes_dir_security(test_path)
if not is_valid:
return jsonify({'valid': False, 'error': error_msg})
# Check if directory exists
exists = test_path.exists()
is_dir = test_path.is_dir() if exists else None
# If it doesn't exist, check if we can create it
if not exists:
try:
os.makedirs(test_path)
os.rmdir(test_path) # Clean up after test
can_create = True
except Exception:
can_create = False
return jsonify({
'valid': can_create,
'error': None if can_create else 'Cannot create directory at this location'
})
# If it exists but isn't a directory
if not is_dir:
return jsonify({'valid': False, 'error': 'Path exists but is not a directory'})
# Check permissions
can_read = os.access(test_path, os.R_OK)
can_write = os.access(test_path, os.W_OK)
if not (can_read and can_write):
return jsonify({
'valid': False,
'error': 'Directory exists but is not both readable and writable',
'can_read': can_read,
'can_write': can_write
})
return jsonify({
'valid': True,
'can_read': can_read,
'can_write': can_write
})
except Exception as e:
return jsonify({'valid': False, 'error': str(e)})
@md_viewer_bp.route('/settings/app', methods=['GET', 'POST'])
def app_settings():
"""Handle application settings"""
if request.method == 'POST':
try:
app_name = request.form.get('app_name', '').strip()
hide_sidepane = request.form.get('hide_sidepane', '').strip()
skip_folders = request.form.get('skip_folders', '').strip()
hide_images = request.form.get('hide_images', 'False')
allowed_image_extensions = request.form.get('allowed_image_extensions', '').strip()
allowed_file_extensions = request.form.get('allowed_file_extensions', '').strip()
# Validate app name
if not app_name:
return jsonify({'error': 'Application name is required'}), 400
# Clean and validate extensions (convert to lowercase and remove spaces)
if allowed_image_extensions:
allowed_image_extensions = ','.join(
ext.strip().lower() for ext in allowed_image_extensions.split(',') if ext.strip()
)
if allowed_file_extensions:
allowed_file_extensions = ','.join(
ext.strip().lower() for ext in allowed_file_extensions.split(',') if ext.strip()
)
# Update settings
settings = {
'NOTE_APP_NAME': app_name,
'NOTES_DIR_HIDE_SIDEPANE': hide_sidepane,
'NOTES_DIR_SKIP': skip_folders,
'IMAGES_FS_HIDE': hide_images,
'ALLOWED_IMAGE_EXTENSIONS': allowed_image_extensions,
'ALLOWED_FILE_EXTENSIONS': allowed_file_extensions
}
# Update each setting
for key, value in settings.items():
set_setting('MD_NOTES_APP', key, value)
current_app.config[key] = value
return jsonify({
'success': True,
'message': 'Application settings updated successfully',
'settings': settings,
'reload_required': True
})
except Exception as e:
current_app.logger.error(f"Error saving application settings: {str(e)}")
return jsonify({'error': str(e)}), 500
# For GET request, return current settings
try:
current_settings = {
'app_name': get_setting('MD_NOTES_APP', 'NOTE_APP_NAME', fallback='My Notes'),
'hide_sidepane': get_setting('MD_NOTES_APP', 'NOTES_DIR_HIDE_SIDEPANE', fallback=''),
'skip_folders': get_setting('MD_NOTES_APP', 'NOTES_DIR_SKIP', fallback=''),
'hide_images': get_setting('MD_NOTES_APP', 'IMAGES_FS_HIDE', fallback='False'),
'allowed_image_extensions': get_setting('MD_NOTES_APP', 'ALLOWED_IMAGE_EXTENSIONS',
fallback='jpg,jpeg,png,gif,bmp'),
'allowed_file_extensions': get_setting('MD_NOTES_APP', 'ALLOWED_FILE_EXTENSIONS',
fallback='txt,csv,json,html,htm,xml,yaml,yml,ini,log,js,css,py,md')
}
return jsonify(current_settings)
except Exception as e:
current_app.logger.error(f"Error reading application settings: {str(e)}")
return jsonify({'error': str(e)}), 500

View File

@@ -18,6 +18,8 @@ body { background: #181a1b; color: #f1f1f1; }
position: relative;
z-index: 2;
float: left;
display: flex !important;
flex-direction: column !important;
}
.sidebar .resize-handle {
position: absolute;
@@ -200,6 +202,11 @@ code { color: #b3e1ff !important; }
/* File Tree Styles */
.file-tree {
font-size: 0.95em;
flex: 1 1 auto;
overflow-y: auto;
overflow-x: hidden;
margin: -0.5rem;
padding: 0.5rem;
}
.file-tree-dir:hover > .file-tree-toggle {
background: rgba(255,255,255,0.05);
@@ -237,3 +244,134 @@ margin-left: 0;
#sidebar {
padding-bottom: 2.5rem !important;
}
.folder-suggestion {
padding: 0.5rem 1rem;
cursor: pointer;
display: flex;
align-items: center;
gap: 0.5rem;
color: white;
}
.folder-suggestion:hover {
background-color: rgba(255,255,255,0.1);
}
.folder-suggestion i {
opacity: 0.7;
width: 16px;
}
.folder-suggestion .folder-path {
opacity: 0.8;
font-size: 0.9em;
margin-left: 0.5rem;
color: #d0d0d0;
}
.dropdown-menu.show {
display: block;
background: #2d2d2d;
border: 1px solid rgba(255,255,255,0.1);
border-radius: 4px;
margin-top: 4px;
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}
.sidebar-buttons {
flex: 0 0 auto;
background-color: #23272b !important;
padding: 0.5rem;
margin: -0.5rem -0.5rem 0.5rem -0.5rem;
border-bottom: 1px solid #343a40;
}
/* Code block styling */
pre code {
display: block;
padding: 1em;
border-radius: 4px;
background-color: #282c34;
color: #abb2bf;
overflow-x: auto;
font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
line-height: 1.5;
font-size: 14px;
}
/* Inline code styling */
code:not(pre code) {
padding: 0.2em 0.4em;
background-color: rgba(40, 44, 52, 0.05);
border-radius: 3px;
font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
font-size: 85%;
}
/* Code block container */
pre {
margin: 1em 0;
padding: 0;
border-radius: 4px;
background-color: #282c34;
}
/* Light theme overrides */
@media (prefers-color-scheme: light) {
pre code {
background-color: #f6f8fa;
color: #24292e;
}
pre {
background-color: #f6f8fa;
border: 1px solid #e1e4e8;
}
code:not(pre code) {
background-color: rgba(27, 31, 35, 0.05);
color: #24292e;
}
}
.dropzone {
border: 2px dashed #ccc;
border-radius: 4px;
padding: 20px;
text-align: center;
background: rgba(255,255,255,0.05);
transition: all 0.3s ease;
display: none;
margin-bottom: 1rem;
}
.dropzone.drag-over {
background: rgba(255,255,255,0.1);
border-color: #0d6efd;
}
.upload-progress {
margin-top: 10px;
display: none;
}
.progress {
background-color: rgba(255,255,255,0.1);
}
/* Context menu styling */
.custom-context-menu {
position: fixed;
z-index: 1000;
background: #2c2c2c;
border: 1px solid #444;
border-radius: 4px;
padding: 5px 0;
min-width: 150px;
box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}
.custom-context-menu .menu-item {
padding: 8px 15px;
cursor: pointer;
display: flex;
align-items: center;
color: #fff;
text-decoration: none;
}
.custom-context-menu .menu-item:hover {
background: #3c3c3c;
}
.custom-context-menu .menu-item i {
margin-right: 8px;
width: 16px;
text-align: center;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@@ -0,0 +1,113 @@
## Subresource Integrity
If you are loading Highlight.js via CDN you may wish to use [Subresource Integrity](https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity) to guarantee that you are using a legimitate build of the library.
To do this you simply need to add the `integrity` attribute for each JavaScript file you download via CDN. These digests are used by the browser to confirm the files downloaded have not been modified.
```html
<script
src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.11.1/highlight.min.js"
integrity="sha384-5xdYoZ0Lt6Jw8GFfRP91J0jaOVUq7DGI1J5wIyNi0D+eHVdfUwHR4gW6kPsw489E"></script>
<!-- including any other grammars you might need to load -->
<script
src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.11.1/languages/go.min.js"
integrity="sha384-HdearVH8cyfzwBIQOjL/6dSEmZxQ5rJRezN7spps8E7iu+R6utS8c2ab0AgBNFfH"></script>
```
The full list of digests for every file can be found below.
### Digests
```
sha384-gRTR/fmk+6+ygbihH/fJvHgmffnOrd/eO7DW5zgu1uN9GBohtDx+OBs0DI0ejigB /es/languages/bash.js
sha384-Pg7b9hYE6kefjcNqAabhv8jOLCVoZubUaM4bZFjUJd0CaaQ14ksDI0GVllMtAF4S /es/languages/bash.min.js
sha384-xhohaHGp8S443Qn4JZUYAcKqIIl0bQkFA79EUxpbX8GWb5oufdvvSI9ipl/Dasev /es/languages/c.js
sha384-xaTVEdq02jgKStoYDcZD8NhTN1XV/TWpIu4OM53MtMiLl08+e9YJNENo+R/6Nwp0 /es/languages/c.min.js
sha384-Gmvct15f4Mo9AXQG5bk5w78N1YjBLXXU3KIV7no+mOVnApXlwfw1dwjfueAwljIV /es/languages/css.js
sha384-1D7DbOic0Z5nM2ldSO9O/EsBfsg/5x7X7So1qnMgscI2ucDevptcg7cTvrD9rL0D /es/languages/css.min.js
sha384-IZPwfVGChjxiFn/yRHid99p+81wHZKppqSWzWv3/VpfILbOfX+FBbsAEjyYEz+08 /es/languages/django.js
sha384-c6VNDV3sM+ivvQX1L4LuDW3MjiYsC6u70/NKATWDBfdRODoECdSJ7oUhpcU/WBUi /es/languages/django.min.js
sha384-GjF+59AA+OY/6RDsvWxm3u318l0CruHb/Fm3oywrHZWho96FKyPUFnoIKqCKiM4D /es/languages/dockerfile.js
sha384-qyGdaK2usg+DEmSJUcr3Rogi6miy7A1Rn8QlRc71wBlMHpN1Y4b3d8hh2hf31dCu /es/languages/dockerfile.min.js
sha384-y5tpDG/EgM93k2unGm4XFn8l9V12Ru1tnk2TxhduZWqrEqAK86BQlDLuVAILe3OB /es/languages/go.js
sha384-/UGh0AcfdC41Di2LsNVYCPOJ24RfaUWWXniaZoGuM52DaQR7fwStKAHJumI+u5yY /es/languages/go.min.js
sha384-uC39e4pRTIrenlpo9NQf2taOPhdRJNaZLFASSg+Q8BLjYqLXvxL8brjzQmJEQ0qn /es/languages/http.js
sha384-36ZwsK42N/jk3DquJeJr/r/oziBOtUxBcg0ZdTaaEDX+Zo/UMgBP4S2Sf4NEyq1y /es/languages/http.min.js
sha384-vZWLk+C+23/W/GAmv4PXkZSZo82LXul6DdSgWcMzutPxGltitIk38HyLrxRVsFvm /es/languages/ini.js
sha384-CVynu7LzwkkAUiajSi0jprssYhgg9Vi1WSd8iR84Vmi6JdRGq3DT4vvEfjzoxxOK /es/languages/ini.min.js
sha384-g7t9fKR5Tvod4iWv7BQXN+/JMn5GT9sD6FG3h7Fgl+KCv5k4NnnCzEqUe7BMJ9Mv /es/languages/javascript.js
sha384-f7huPivS1dV2T5V+g0aJpgsY7WBHWCsioIq30tpNoXGizD65fWJYGuXXVPNI52VB /es/languages/javascript.min.js
sha384-8CRS96Xb/ZkZlQU+5ffA03XTN6/xY40QAnsXKB0Y+ow1vza1LAkRNPSrZqGSNo53 /es/languages/json.js
sha384-UHzaYxI/rAo84TEK3WlG15gVfPk49XKax76Ccn9qPWYbUxePCEHxjGkV+xp9HcS/ /es/languages/json.min.js
sha384-5TnIBSbRIGDilxscXgaTNLZ8PZ9u7TEBPzF8b9z+wrbTN3e89MbD9zSSuDVdbDFj /es/languages/lua.js
sha384-HCBq0pjgKyOc3FNX31to33MxfNYza3HCbHLfWwdsnkH5r/VmmXTlRrvWSHTJyYvA /es/languages/lua.min.js
sha384-+KkqXkoHKtuOmUzhZ0BjyV0qjljnS+z6i4fELMEg5brFPtmDIog4zZMhylaBTsVi /es/languages/markdown.js
sha384-E7UvgBH6skA1FIOcn3B2c68GtJzrmZlOOC5p/fsxwihTZG/bBedJZu5PC1+kGX7q /es/languages/markdown.min.js
sha384-uat5CiOqKMoJM3KrhuhZShpWQriLSdeaJ4oT6XQFBg3YWhVDiofp4wa0SnBcV8LQ /es/languages/perl.js
sha384-doJqxKOhDf9Q9JYEBQXrTguSjzwPrbLiXJP2kdBkF+BYRNP55btwz9iH4b95mUTH /es/languages/perl.min.js
sha384-4OPZSHQbxzPqFMOXnndxQ6TZTI/B+J4W9aqTCHxAx/dsPS6GG25kT7wdsf66jJ1M /es/languages/php.js
sha384-VxmvZ2mUpp1EzFijS40RFvIc7vbv/d5PhMxVFG/3HMpVKD4sVvhdV9LThrJDiw9e /es/languages/php.min.js
sha384-i6sPjmXfHWLljAXTYYk0vBOwgsUnUKnKXKH41qzc9OMhaf5AFZqXH7azX4SYdUiR /es/languages/plaintext.js
sha384-OOrQLW97d+/1orj9gjftwbbQyV8LNAcgagqVKBhUYA08Hdi5w0p6VoB3yt2k7gnG /es/languages/plaintext.min.js
sha384-Cmq5lORXzyHraasLNqmfchH07JRXyEmjDF+j6tSggoXjYHwtgX/ySW6kkRytM5uu /es/languages/python.js
sha384-ZV5sgX70bBgLkDR5Mtox5UsbJedBc39hRKPdvTw6miK4lSkE/wv94cLY2iyZb/sB /es/languages/python.min.js
sha384-1mmBZmAs44b6FtD9wpMiLJa8bLZgZv9xoAhngN6B5Q22y9CtcsU2lat0zlRtyVgy /es/languages/shell.js
sha384-u9PV7oWG/lZlm+GnftX7kn0w4b8rRfFxSv5SmJJPHWKGI03rz6VLqgZdQ1B5ez6b /es/languages/shell.min.js
sha384-s1ZfN6xtlNKAZux8QYAG7upUsit3RwK5XDoCAN3g6Kj33RrIqbmkuGjdNF9RvzPM /es/languages/sql.js
sha384-y25cn06synxhYnlKVprZdpakuFWVrm2jvn8pqiF4L85a05CI/6bNeT2+qXbUYIyW /es/languages/sql.min.js
sha384-Z61gsCS2W7Q+3fT1fdya/Sz4wlmsotT9iEGzgIlNqP0soaKH1NzysutxWp08Hh3E /es/languages/typescript.js
sha384-Tv4mr9B7b+x2IynRXW/xcAxUj1+AoN9zyp0n9BWE1Nle3Zfm/zUeEztNLhIRjgE7 /es/languages/typescript.min.js
sha384-+oLsTqE/6U4SDuDg22FKIZztwj5DRzZgNJrI8A0xW2ejSVKNNytoKNiYAhlbgVaT /es/languages/vbscript.js
sha384-ZVOU05lYlww5C9caC+fbHEJd7urtWFvlMpItqceJD/yo3G0n5SKD8nYNGT9sGHYR /es/languages/vbscript.min.js
sha384-9ECFzM+oWDye4s/MFx3QUXGo4mW43+SyLpWUDeQtWup6GZJ+KHFxVS89PmZt/fzl /es/languages/xml.js
sha384-PQrsaWeWrBiE1CFRw8K335CaJuQRTjDGm73vn8bXvlwaw6RyqWObdvMTBS8B75NN /es/languages/xml.min.js
sha384-7HTgKp/l2rzlyrh5vUfbfZVy+Wx1lKO4iGmfqvakienApv21u55lo+Vi+iVg4jY0 /es/languages/yaml.js
sha384-4smueUtgWTorlNLbaQIawnVCcIAuw82NetPOGWN5PbZT/pMr0rjvZXj0EUzJV1nr /es/languages/yaml.min.js
sha384-Jrkpn2hK0TY04skYBXB9fj7mMpKYy7g726cPwXGXf6mdBXnFlTDXFduxikMCRXT7 /languages/bash.js
sha384-BbT8tZtvkh8HPXIvL5RtzuljBwI3gR5KIdYxZyYSyI5C/+KNAGdzAiexvmxuroag /languages/bash.min.js
sha384-lAz0Eyld5DmFJB7cxaZonrkUJzGefh+K3niV5d7+vzzS7/P7FEeCJeLNXzMjeo+N /languages/c.js
sha384-tMmX0hBMZeMrZhX6dUNxA94/DNJLl70ao6qu2N9+b/6Ep9Y2e1pBzVjxtLygIB+d /languages/c.min.js
sha384-bsb3QmLtUiyaiHwtrL4YoAVI9yLsjyqxgoAsk4Zd+ass9rSK1WWRiCDSu/hm8QRp /languages/css.js
sha384-0XGvxIU7Oq1DQMMBr1ORiozzBq3KpZPE/74mJysWRBAop1dZ9Ioq/qRWe8u30Ded /languages/css.min.js
sha384-JAYZMDzuElX+Ic47jwB+qzCzyKkmmEffC3mBnYYrJp2BlRjSorjliOzKSAG8KKTt /languages/django.js
sha384-krxOUFgiyevtYl4SsL416jqrUPU3K9W6fDe/TRvWeXwLYKWKq/f+XHL2AHwGYswO /languages/django.min.js
sha384-PF6NlDjoIfHgP6/hbKDRAswvI+dXitquVNX3GAJapyiu+AcQcdicRXJjIp8bj6pM /languages/dockerfile.js
sha384-hly+Rz036+A3/domxShxHoja13X3lfx8nyG3V8aMeOe7Efwu6gUaSrDxq9BKwYk4 /languages/dockerfile.min.js
sha384-uh0SMHiaDpf+y9t0NE6+t9c3aMlzs8mHPxmkEU3fY12P481V2wNrKoxPMlKVG61k /languages/go.js
sha384-HdearVH8cyfzwBIQOjL/6dSEmZxQ5rJRezN7spps8E7iu+R6utS8c2ab0AgBNFfH /languages/go.min.js
sha384-hV7ok3wrc7DrjvcAtn3jI6KlZtpbm+hC4HXrOyRjrl65HjGtTJ5ixGiMSpJRDiDq /languages/http.js
sha384-X50fiL5mByDvJRwn0hkUXIEttF5t8hlEFSPUMq42KoryxgI4niflBsviuhahhWJf /languages/http.min.js
sha384-izwcylRNWmKKRcyCyrYZyNQekUCyR7Fh1x8nYWNCRJoRDU5JXv6TcqlP4C+4MfIf /languages/ini.js
sha384-NrmnsdarwteQHPGjt70kaQTi1KE0XfOJNX9/VJSg6wWwU6U2nPzjl3iWkgU1cvyx /languages/ini.min.js
sha384-yxv7Fv9ToggiLsR67t98hV5ZRup6XX6xL1Rkbi/cGV5J8y7fosCi9POqlBkiBWFg /languages/javascript.js
sha384-tPOrIubtDHoQU7Rqw0o88ilthGO0/4xEZGB47XrQKWhrc1/SchwsDx+AP74u4nk0 /languages/javascript.min.js
sha384-pUlqdjoNePvHvdi7GVKJJnh/P2T3EvXXodl5j0JtTkbNC4DRH7gwGbcHFa84bFOP /languages/json.js
sha384-3C+cPClJZgjKFYAb0bh35D7im2jasLzgk9eRix3t1c5pk1+x6b+bHghWcdrKwIo3 /languages/json.min.js
sha384-IQZHDTDQQ0zpXf1FfEYOFIfjZrBbLbNXYCn4zukU6u9mLf6JI36vvIRaV6/d175T /languages/lua.js
sha384-dbTI+BVfiAlIfjWMYrH83f/x/GYSKbujaX4g4F7q5YxbGtlS7qTLcwBQQvDdsGf6 /languages/lua.min.js
sha384-Sk9XW/OOutdl6KS1M9Wson0imuqr0LkpoTRDHi5QFH4MWe0aViI5d86BOVkh8Ds0 /languages/markdown.js
sha384-Rv26WbhHH4MDPzeExq4ECmZUYF942tlfVhqA91Drw1P+Ey55KjihLF9RJENxjWr1 /languages/markdown.min.js
sha384-qLoCYnNDldQrhnuTfd5BAc54A/ulhuQYKYDYiU+iJRa87k5owWYLvnL0ttLWmFKQ /languages/perl.js
sha384-PK5CVcMiWQ08dZFregTL56n1urRNEsSuWT6oiH1sFm/2ac/epI35hC5lx+YzjH5U /languages/perl.min.js
sha384-0XBmTxpMLuDjB2zdfbi3Lv4Yokm2e1YFGZ9mCmI5887Kpi23jMF5N7rPrf0GdoU/ /languages/php.js
sha384-Bv/Sxv6HlOzYOdV1iQpJTG3xiqGWIIMq9xsFfEX8ss7oNWMgKqOa/J2WSFG2m7Jd /languages/php.min.js
sha384-MZKv9uidO1+VnHz8xWxPv6ACuLO5t823eanvTcKYnmi/ocdVYD8zKZNTxmF0nKEM /languages/plaintext.js
sha384-Z9EdtPaC8UiXHEq1WuQTdvqT+FwjLwaVTIwTCZW/dGfiU9nbF8Shvltrhqtw83Qb /languages/plaintext.min.js
sha384-ueSSFZFqg7cVD0dpEqIk9EefJiJUYan0PH6I8u/p+bNLLx7dMs4J2keMaFXqCN8P /languages/python.js
sha384-eXRt+aAa2ig1yFVDQCLis8k9s/1dikTcigj+/R07yNdIxc8BAG/b1uHDyEW3of17 /languages/python.min.js
sha384-BanM6jNzM3hgNw0Vu3gSe58a3MK3PSlMUzh5s8QaaDzIvTWgB0jNetV3rNxteKHy /languages/shell.js
sha384-mSZF08WaP0Llc4GMwE0KA2V9yfZQimO5PvfcXf2AATDdqri3Q7IdV7pfbhVPJCHV /languages/shell.min.js
sha384-2sXmcW3eKeNDWiLtuq9NgFJC4NsLBN/fDTzZevmcgBrSERv6iO/k+c7r9T09Fb8J /languages/sql.js
sha384-jrnLoVn13sB+/dTfoAYVPhg0tYGQzzuzSGP3WTk8OvKAY0hDejpUXFYYI3bohAyW /languages/sql.min.js
sha384-8v3YMaXFO9cmTNxsHWqwn9wJsV1jVO7rwx4huxqlEQpT/P2tuDbtm+Hs0EdYqu0a /languages/typescript.js
sha384-df1w1nJ43GNwmgbSCrT8YFIYyqFAm+lzj+b6ofuziX8Cfdg9QHFwbORDgAaj//wi /languages/typescript.min.js
sha384-QIqz8dDN+0gnTxcE4dXj3UlCXI3KCcqv5JGdOuW/qLByffT/5tgCDmlx91UaWxld /languages/vbscript.js
sha384-q4F1AGrMreQRFm4P6HrR+dLtRCcshPWWJ/0HW6ewizjoCBpBIsFxDVosvIHjLAY0 /languages/vbscript.min.js
sha384-Pgzg6a405W6U1xFjjSs5i8d7V81Tmt/TYn8HFOa+u1psDc8cbs8nC7BuyNXbWWRK /languages/xml.js
sha384-FQjSArDMJE4WMAJGcCNAV+IXIOljcIxM3UFAD2vxjedWmBnnDaAyqRG7AQHf/uM/ /languages/xml.min.js
sha384-6GXi9L5BnOWPU6bzwYL78Zscp23qyDdMLZpZvp4mLzvF2qt0eY/DfsPHiFVXq4hv /languages/yaml.js
sha384-A/iMReLA0Bo3tLydBIoOQXQzYnrwL90jkHYUubrtERUGCbIuU7U0EHge0Xd2s5sr /languages/yaml.min.js
sha384-no4dCXrCiC0sFJNJ4Pj5MpPrLfgj06j8BgDUrFJgwi0cgbq0zSSJS/IbWy6aOEp/ /highlight.js
sha384-b9cbIffNRZNWeI0hriOc27d9g2Nvy5JNzuzn+WMIAujJ3hOdzkSQVr/cWyp31eKP /highlight.min.js
```

View File

@@ -0,0 +1,29 @@
BSD 3-Clause License
Copyright (c) 2006, Ivan Sagalaev.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@@ -0,0 +1,45 @@
# Highlight.js CDN Assets
[![install size](https://packagephobia.now.sh/badge?p=highlight.js)](https://packagephobia.now.sh/result?p=highlight.js)
**This package contains only the CDN build assets of highlight.js.**
This may be what you want if you'd like to install the pre-built distributable highlight.js client-side assets via NPM. If you're wanting to use highlight.js mainly on the server-side you likely want the [highlight.js][1] package instead.
To access these files via CDN:<br>
https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@latest/build/
**If you just want a single .js file with the common languages built-in:
<https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@latest/build/highlight.min.js>**
---
## Highlight.js
Highlight.js is a syntax highlighter written in JavaScript. It works in
the browser as well as on the server. It works with pretty much any
markup, doesnt depend on any framework, and has automatic language
detection.
If you'd like to read the full README:<br>
<https://github.com/highlightjs/highlight.js/blob/main/README.md>
## License
Highlight.js is released under the BSD License. See [LICENSE][7] file
for details.
## Links
The official site for the library is at <https://highlightjs.org/>.
The Github project may be found at: <https://github.com/highlightjs/highlight.js>
Further in-depth documentation for the API and other topics is at
<http://highlightjs.readthedocs.io/>.
A list of the Core Team and contributors can be found in the [CONTRIBUTORS.md][8] file.
[1]: https://www.npmjs.com/package/highlight.js
[7]: https://github.com/highlightjs/highlight.js/blob/main/LICENSE
[8]: https://github.com/highlightjs/highlight.js/blob/main/CONTRIBUTORS.md

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,306 @@
/*!
Highlight.js v11.11.1 (git: 08cb242e7d)
(c) 2006-2025 Josh Goebel <hello@joshgoebel.com> and other contributors
License: BSD-3-Clause
*/
function e(t){return t instanceof Map?t.clear=t.delete=t.set=()=>{
throw Error("map is read-only")}:t instanceof Set&&(t.add=t.clear=t.delete=()=>{
throw Error("set is read-only")
}),Object.freeze(t),Object.getOwnPropertyNames(t).forEach((n=>{
const i=t[n],s=typeof i;"object"!==s&&"function"!==s||Object.isFrozen(i)||e(i)
})),t}class t{constructor(e){
void 0===e.data&&(e.data={}),this.data=e.data,this.isMatchIgnored=!1}
ignoreMatch(){this.isMatchIgnored=!0}}function n(e){
return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;")
}function i(e,...t){const n=Object.create(null);for(const t in e)n[t]=e[t]
;return t.forEach((e=>{for(const t in e)n[t]=e[t]})),n}const s=e=>!!e.scope
;class r{constructor(e,t){
this.buffer="",this.classPrefix=t.classPrefix,e.walk(this)}addText(e){
this.buffer+=n(e)}openNode(e){if(!s(e))return;const t=((e,{prefix:t})=>{
if(e.startsWith("language:"))return e.replace("language:","language-")
;if(e.includes(".")){const n=e.split(".")
;return[`${t}${n.shift()}`,...n.map(((e,t)=>`${e}${"_".repeat(t+1)}`))].join(" ")
}return`${t}${e}`})(e.scope,{prefix:this.classPrefix});this.span(t)}
closeNode(e){s(e)&&(this.buffer+="</span>")}value(){return this.buffer}span(e){
this.buffer+=`<span class="${e}">`}}const o=(e={})=>{const t={children:[]}
;return Object.assign(t,e),t};class a{constructor(){
this.rootNode=o(),this.stack=[this.rootNode]}get top(){
return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(e){
this.top.children.push(e)}openNode(e){const t=o({scope:e})
;this.add(t),this.stack.push(t)}closeNode(){
if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){
for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}
walk(e){return this.constructor._walk(e,this.rootNode)}static _walk(e,t){
return"string"==typeof t?e.addText(t):t.children&&(e.openNode(t),
t.children.forEach((t=>this._walk(e,t))),e.closeNode(t)),e}static _collapse(e){
"string"!=typeof e&&e.children&&(e.children.every((e=>"string"==typeof e))?e.children=[e.children.join("")]:e.children.forEach((e=>{
a._collapse(e)})))}}class c extends a{constructor(e){super(),this.options=e}
addText(e){""!==e&&this.add(e)}startScope(e){this.openNode(e)}endScope(){
this.closeNode()}__addSublanguage(e,t){const n=e.root
;t&&(n.scope="language:"+t),this.add(n)}toHTML(){
return new r(this,this.options).value()}finalize(){
return this.closeAllNodes(),!0}}function l(e){
return e?"string"==typeof e?e:e.source:null}function g(e){return h("(?=",e,")")}
function u(e){return h("(?:",e,")*")}function d(e){return h("(?:",e,")?")}
function h(...e){return e.map((e=>l(e))).join("")}function f(...e){const t=(e=>{
const t=e[e.length-1]
;return"object"==typeof t&&t.constructor===Object?(e.splice(e.length-1,1),t):{}
})(e);return"("+(t.capture?"":"?:")+e.map((e=>l(e))).join("|")+")"}
function p(e){return RegExp(e.toString()+"|").exec("").length-1}
const b=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./
;function m(e,{joinWith:t}){let n=0;return e.map((e=>{n+=1;const t=n
;let i=l(e),s="";for(;i.length>0;){const e=b.exec(i);if(!e){s+=i;break}
s+=i.substring(0,e.index),
i=i.substring(e.index+e[0].length),"\\"===e[0][0]&&e[1]?s+="\\"+(Number(e[1])+t):(s+=e[0],
"("===e[0]&&n++)}return s})).map((e=>`(${e})`)).join(t)}
const E="[a-zA-Z]\\w*",x="[a-zA-Z_]\\w*",_="\\b\\d+(\\.\\d+)?",y="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",w="\\b(0b[01]+)",O={
begin:"\\\\[\\s\\S]",relevance:0},k={scope:"string",begin:"'",end:"'",
illegal:"\\n",contains:[O]},v={scope:"string",begin:'"',end:'"',illegal:"\\n",
contains:[O]},N=(e,t,n={})=>{const s=i({scope:"comment",begin:e,end:t,
contains:[]},n);s.contains.push({scope:"doctag",
begin:"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",
end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0})
;const r=f("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/)
;return s.contains.push({begin:h(/[ ]+/,"(",r,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),s
},S=N("//","$"),M=N("/\\*","\\*/"),R=N("#","$");var A=Object.freeze({
__proto__:null,APOS_STRING_MODE:k,BACKSLASH_ESCAPE:O,BINARY_NUMBER_MODE:{
scope:"number",begin:w,relevance:0},BINARY_NUMBER_RE:w,COMMENT:N,
C_BLOCK_COMMENT_MODE:M,C_LINE_COMMENT_MODE:S,C_NUMBER_MODE:{scope:"number",
begin:y,relevance:0},C_NUMBER_RE:y,END_SAME_AS_BEGIN:e=>Object.assign(e,{
"on:begin":(e,t)=>{t.data._beginMatch=e[1]},"on:end":(e,t)=>{
t.data._beginMatch!==e[1]&&t.ignoreMatch()}}),HASH_COMMENT_MODE:R,IDENT_RE:E,
MATCH_NOTHING_RE:/\b\B/,METHOD_GUARD:{begin:"\\.\\s*"+x,relevance:0},
NUMBER_MODE:{scope:"number",begin:_,relevance:0},NUMBER_RE:_,
PHRASAL_WORDS_MODE:{
begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/
},QUOTE_STRING_MODE:v,REGEXP_MODE:{scope:"regexp",begin:/\/(?=[^/\n]*\/)/,
end:/\/[gimuy]*/,contains:[O,{begin:/\[/,end:/\]/,relevance:0,contains:[O]}]},
RE_STARTERS_RE:"!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",
SHEBANG:(e={})=>{const t=/^#![ ]*\//
;return e.binary&&(e.begin=h(t,/.*\b/,e.binary,/\b.*/)),i({scope:"meta",begin:t,
end:/$/,relevance:0,"on:begin":(e,t)=>{0!==e.index&&t.ignoreMatch()}},e)},
TITLE_MODE:{scope:"title",begin:E,relevance:0},UNDERSCORE_IDENT_RE:x,
UNDERSCORE_TITLE_MODE:{scope:"title",begin:x,relevance:0}});function j(e,t){
"."===e.input[e.index-1]&&t.ignoreMatch()}function I(e,t){
void 0!==e.className&&(e.scope=e.className,delete e.className)}function T(e,t){
t&&e.beginKeywords&&(e.begin="\\b("+e.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",
e.__beforeBegin=j,e.keywords=e.keywords||e.beginKeywords,delete e.beginKeywords,
void 0===e.relevance&&(e.relevance=0))}function L(e,t){
Array.isArray(e.illegal)&&(e.illegal=f(...e.illegal))}function B(e,t){
if(e.match){
if(e.begin||e.end)throw Error("begin & end are not supported with match")
;e.begin=e.match,delete e.match}}function P(e,t){
void 0===e.relevance&&(e.relevance=1)}const D=(e,t)=>{if(!e.beforeMatch)return
;if(e.starts)throw Error("beforeMatch cannot be used with starts")
;const n=Object.assign({},e);Object.keys(e).forEach((t=>{delete e[t]
})),e.keywords=n.keywords,e.begin=h(n.beforeMatch,g(n.begin)),e.starts={
relevance:0,contains:[Object.assign(n,{endsParent:!0})]
},e.relevance=0,delete n.beforeMatch
},H=["of","and","for","in","not","or","if","then","parent","list","value"]
;function C(e,t,n="keyword"){const i=Object.create(null)
;return"string"==typeof e?s(n,e.split(" ")):Array.isArray(e)?s(n,e):Object.keys(e).forEach((n=>{
Object.assign(i,C(e[n],t,n))})),i;function s(e,n){
t&&(n=n.map((e=>e.toLowerCase()))),n.forEach((t=>{const n=t.split("|")
;i[n[0]]=[e,$(n[0],n[1])]}))}}function $(e,t){
return t?Number(t):(e=>H.includes(e.toLowerCase()))(e)?0:1}const U={},z=e=>{
console.error(e)},W=(e,...t)=>{console.log("WARN: "+e,...t)},X=(e,t)=>{
U[`${e}/${t}`]||(console.log(`Deprecated as of ${e}. ${t}`),U[`${e}/${t}`]=!0)
},G=Error();function K(e,t,{key:n}){let i=0;const s=e[n],r={},o={}
;for(let e=1;e<=t.length;e++)o[e+i]=s[e],r[e+i]=!0,i+=p(t[e-1])
;e[n]=o,e[n]._emit=r,e[n]._multi=!0}function F(e){(e=>{
e.scope&&"object"==typeof e.scope&&null!==e.scope&&(e.beginScope=e.scope,
delete e.scope)})(e),"string"==typeof e.beginScope&&(e.beginScope={
_wrap:e.beginScope}),"string"==typeof e.endScope&&(e.endScope={_wrap:e.endScope
}),(e=>{if(Array.isArray(e.begin)){
if(e.skip||e.excludeBegin||e.returnBegin)throw z("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),
G
;if("object"!=typeof e.beginScope||null===e.beginScope)throw z("beginScope must be object"),
G;K(e,e.begin,{key:"beginScope"}),e.begin=m(e.begin,{joinWith:""})}})(e),(e=>{
if(Array.isArray(e.end)){
if(e.skip||e.excludeEnd||e.returnEnd)throw z("skip, excludeEnd, returnEnd not compatible with endScope: {}"),
G
;if("object"!=typeof e.endScope||null===e.endScope)throw z("endScope must be object"),
G;K(e,e.end,{key:"endScope"}),e.end=m(e.end,{joinWith:""})}})(e)}function Z(e){
function t(t,n){
return RegExp(l(t),"m"+(e.case_insensitive?"i":"")+(e.unicodeRegex?"u":"")+(n?"g":""))
}class n{constructor(){
this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}
addRule(e,t){
t.position=this.position++,this.matchIndexes[this.matchAt]=t,this.regexes.push([t,e]),
this.matchAt+=p(e)+1}compile(){0===this.regexes.length&&(this.exec=()=>null)
;const e=this.regexes.map((e=>e[1]));this.matcherRe=t(m(e,{joinWith:"|"
}),!0),this.lastIndex=0}exec(e){this.matcherRe.lastIndex=this.lastIndex
;const t=this.matcherRe.exec(e);if(!t)return null
;const n=t.findIndex(((e,t)=>t>0&&void 0!==e)),i=this.matchIndexes[n]
;return t.splice(0,n),Object.assign(t,i)}}class s{constructor(){
this.rules=[],this.multiRegexes=[],
this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(e){
if(this.multiRegexes[e])return this.multiRegexes[e];const t=new n
;return this.rules.slice(e).forEach((([e,n])=>t.addRule(e,n))),
t.compile(),this.multiRegexes[e]=t,t}resumingScanAtSamePosition(){
return 0!==this.regexIndex}considerAll(){this.regexIndex=0}addRule(e,t){
this.rules.push([e,t]),"begin"===t.type&&this.count++}exec(e){
const t=this.getMatcher(this.regexIndex);t.lastIndex=this.lastIndex
;let n=t.exec(e)
;if(this.resumingScanAtSamePosition())if(n&&n.index===this.lastIndex);else{
const t=this.getMatcher(0);t.lastIndex=this.lastIndex+1,n=t.exec(e)}
return n&&(this.regexIndex+=n.position+1,
this.regexIndex===this.count&&this.considerAll()),n}}
if(e.compilerExtensions||(e.compilerExtensions=[]),
e.contains&&e.contains.includes("self"))throw Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.")
;return e.classNameAliases=i(e.classNameAliases||{}),function n(r,o){const a=r
;if(r.isCompiled)return a
;[I,B,F,D].forEach((e=>e(r,o))),e.compilerExtensions.forEach((e=>e(r,o))),
r.__beforeBegin=null,[T,L,P].forEach((e=>e(r,o))),r.isCompiled=!0;let c=null
;return"object"==typeof r.keywords&&r.keywords.$pattern&&(r.keywords=Object.assign({},r.keywords),
c=r.keywords.$pattern,
delete r.keywords.$pattern),c=c||/\w+/,r.keywords&&(r.keywords=C(r.keywords,e.case_insensitive)),
a.keywordPatternRe=t(c,!0),
o&&(r.begin||(r.begin=/\B|\b/),a.beginRe=t(a.begin),r.end||r.endsWithParent||(r.end=/\B|\b/),
r.end&&(a.endRe=t(a.end)),
a.terminatorEnd=l(a.end)||"",r.endsWithParent&&o.terminatorEnd&&(a.terminatorEnd+=(r.end?"|":"")+o.terminatorEnd)),
r.illegal&&(a.illegalRe=t(r.illegal)),
r.contains||(r.contains=[]),r.contains=[].concat(...r.contains.map((e=>(e=>(e.variants&&!e.cachedVariants&&(e.cachedVariants=e.variants.map((t=>i(e,{
variants:null},t)))),e.cachedVariants?e.cachedVariants:V(e)?i(e,{
starts:e.starts?i(e.starts):null
}):Object.isFrozen(e)?i(e):e))("self"===e?r:e)))),r.contains.forEach((e=>{n(e,a)
})),r.starts&&n(r.starts,o),a.matcher=(e=>{const t=new s
;return e.contains.forEach((e=>t.addRule(e.begin,{rule:e,type:"begin"
}))),e.terminatorEnd&&t.addRule(e.terminatorEnd,{type:"end"
}),e.illegal&&t.addRule(e.illegal,{type:"illegal"}),t})(a),a}(e)}function V(e){
return!!e&&(e.endsWithParent||V(e.starts))}class q extends Error{
constructor(e,t){super(e),this.name="HTMLInjectionError",this.html=t}}
const J=n,Y=i,Q=Symbol("nomatch"),ee=n=>{
const i=Object.create(null),s=Object.create(null),r=[];let o=!0
;const a="Could not find the language '{}', did you forget to load/include a language module?",l={
disableAutodetect:!0,name:"Plain text",contains:[]};let p={
ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,
languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",
cssSelector:"pre code",languages:null,__emitter:c};function b(e){
return p.noHighlightRe.test(e)}function m(e,t,n){let i="",s=""
;"object"==typeof t?(i=e,
n=t.ignoreIllegals,s=t.language):(X("10.7.0","highlight(lang, code, ...args) has been deprecated."),
X("10.7.0","Please use highlight(code, options) instead.\nhttps://github.com/highlightjs/highlight.js/issues/2277"),
s=e,i=t),void 0===n&&(n=!0);const r={code:i,language:s};N("before:highlight",r)
;const o=r.result?r.result:E(r.language,r.code,n)
;return o.code=r.code,N("after:highlight",o),o}function E(e,n,s,r){
const c=Object.create(null);function l(){if(!N.keywords)return void M.addText(R)
;let e=0;N.keywordPatternRe.lastIndex=0;let t=N.keywordPatternRe.exec(R),n=""
;for(;t;){n+=R.substring(e,t.index)
;const s=w.case_insensitive?t[0].toLowerCase():t[0],r=(i=s,N.keywords[i]);if(r){
const[e,i]=r
;if(M.addText(n),n="",c[s]=(c[s]||0)+1,c[s]<=7&&(A+=i),e.startsWith("_"))n+=t[0];else{
const n=w.classNameAliases[e]||e;u(t[0],n)}}else n+=t[0]
;e=N.keywordPatternRe.lastIndex,t=N.keywordPatternRe.exec(R)}var i
;n+=R.substring(e),M.addText(n)}function g(){null!=N.subLanguage?(()=>{
if(""===R)return;let e=null;if("string"==typeof N.subLanguage){
if(!i[N.subLanguage])return void M.addText(R)
;e=E(N.subLanguage,R,!0,S[N.subLanguage]),S[N.subLanguage]=e._top
}else e=x(R,N.subLanguage.length?N.subLanguage:null)
;N.relevance>0&&(A+=e.relevance),M.__addSublanguage(e._emitter,e.language)
})():l(),R=""}function u(e,t){
""!==e&&(M.startScope(t),M.addText(e),M.endScope())}function d(e,t){let n=1
;const i=t.length-1;for(;n<=i;){if(!e._emit[n]){n++;continue}
const i=w.classNameAliases[e[n]]||e[n],s=t[n];i?u(s,i):(R=s,l(),R=""),n++}}
function h(e,t){
return e.scope&&"string"==typeof e.scope&&M.openNode(w.classNameAliases[e.scope]||e.scope),
e.beginScope&&(e.beginScope._wrap?(u(R,w.classNameAliases[e.beginScope._wrap]||e.beginScope._wrap),
R=""):e.beginScope._multi&&(d(e.beginScope,t),R="")),N=Object.create(e,{parent:{
value:N}}),N}function f(e,n,i){let s=((e,t)=>{const n=e&&e.exec(t)
;return n&&0===n.index})(e.endRe,i);if(s){if(e["on:end"]){const i=new t(e)
;e["on:end"](n,i),i.isMatchIgnored&&(s=!1)}if(s){
for(;e.endsParent&&e.parent;)e=e.parent;return e}}
if(e.endsWithParent)return f(e.parent,n,i)}function b(e){
return 0===N.matcher.regexIndex?(R+=e[0],1):(T=!0,0)}function m(e){
const t=e[0],i=n.substring(e.index),s=f(N,e,i);if(!s)return Q;const r=N
;N.endScope&&N.endScope._wrap?(g(),
u(t,N.endScope._wrap)):N.endScope&&N.endScope._multi?(g(),
d(N.endScope,e)):r.skip?R+=t:(r.returnEnd||r.excludeEnd||(R+=t),
g(),r.excludeEnd&&(R=t));do{
N.scope&&M.closeNode(),N.skip||N.subLanguage||(A+=N.relevance),N=N.parent
}while(N!==s.parent);return s.starts&&h(s.starts,e),r.returnEnd?0:t.length}
let _={};function y(i,r){const a=r&&r[0];if(R+=i,null==a)return g(),0
;if("begin"===_.type&&"end"===r.type&&_.index===r.index&&""===a){
if(R+=n.slice(r.index,r.index+1),!o){const t=Error(`0 width match regex (${e})`)
;throw t.languageName=e,t.badRule=_.rule,t}return 1}
if(_=r,"begin"===r.type)return(e=>{
const n=e[0],i=e.rule,s=new t(i),r=[i.__beforeBegin,i["on:begin"]]
;for(const t of r)if(t&&(t(e,s),s.isMatchIgnored))return b(n)
;return i.skip?R+=n:(i.excludeBegin&&(R+=n),
g(),i.returnBegin||i.excludeBegin||(R=n)),h(i,e),i.returnBegin?0:n.length})(r)
;if("illegal"===r.type&&!s){
const e=Error('Illegal lexeme "'+a+'" for mode "'+(N.scope||"<unnamed>")+'"')
;throw e.mode=N,e}if("end"===r.type){const e=m(r);if(e!==Q)return e}
if("illegal"===r.type&&""===a)return R+="\n",1
;if(I>1e5&&I>3*r.index)throw Error("potential infinite loop, way more iterations than matches")
;return R+=a,a.length}const w=O(e)
;if(!w)throw z(a.replace("{}",e)),Error('Unknown language: "'+e+'"')
;const k=Z(w);let v="",N=r||k;const S={},M=new p.__emitter(p);(()=>{const e=[]
;for(let t=N;t!==w;t=t.parent)t.scope&&e.unshift(t.scope)
;e.forEach((e=>M.openNode(e)))})();let R="",A=0,j=0,I=0,T=!1;try{
if(w.__emitTokens)w.__emitTokens(n,M);else{for(N.matcher.considerAll();;){
I++,T?T=!1:N.matcher.considerAll(),N.matcher.lastIndex=j
;const e=N.matcher.exec(n);if(!e)break;const t=y(n.substring(j,e.index),e)
;j=e.index+t}y(n.substring(j))}return M.finalize(),v=M.toHTML(),{language:e,
value:v,relevance:A,illegal:!1,_emitter:M,_top:N}}catch(t){
if(t.message&&t.message.includes("Illegal"))return{language:e,value:J(n),
illegal:!0,relevance:0,_illegalBy:{message:t.message,index:j,
context:n.slice(j-100,j+100),mode:t.mode,resultSoFar:v},_emitter:M};if(o)return{
language:e,value:J(n),illegal:!1,relevance:0,errorRaised:t,_emitter:M,_top:N}
;throw t}}function x(e,t){t=t||p.languages||Object.keys(i);const n=(e=>{
const t={value:J(e),illegal:!1,relevance:0,_top:l,_emitter:new p.__emitter(p)}
;return t._emitter.addText(e),t})(e),s=t.filter(O).filter(v).map((t=>E(t,e,!1)))
;s.unshift(n);const r=s.sort(((e,t)=>{
if(e.relevance!==t.relevance)return t.relevance-e.relevance
;if(e.language&&t.language){if(O(e.language).supersetOf===t.language)return 1
;if(O(t.language).supersetOf===e.language)return-1}return 0})),[o,a]=r,c=o
;return c.secondBest=a,c}function _(e){let t=null;const n=(e=>{
let t=e.className+" ";t+=e.parentNode?e.parentNode.className:""
;const n=p.languageDetectRe.exec(t);if(n){const t=O(n[1])
;return t||(W(a.replace("{}",n[1])),
W("Falling back to no-highlight mode for this block.",e)),t?n[1]:"no-highlight"}
return t.split(/\s+/).find((e=>b(e)||O(e)))})(e);if(b(n))return
;if(N("before:highlightElement",{el:e,language:n
}),e.dataset.highlighted)return void console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",e)
;if(e.children.length>0&&(p.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),
console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),
console.warn("The element with unescaped HTML:"),
console.warn(e)),p.throwUnescapedHTML))throw new q("One of your code blocks includes unescaped HTML.",e.innerHTML)
;t=e;const i=t.textContent,r=n?m(i,{language:n,ignoreIllegals:!0}):x(i)
;e.innerHTML=r.value,e.dataset.highlighted="yes",((e,t,n)=>{const i=t&&s[t]||n
;e.classList.add("hljs"),e.classList.add("language-"+i)
})(e,n,r.language),e.result={language:r.language,re:r.relevance,
relevance:r.relevance},r.secondBest&&(e.secondBest={
language:r.secondBest.language,relevance:r.secondBest.relevance
}),N("after:highlightElement",{el:e,result:r,text:i})}let y=!1;function w(){
if("loading"===document.readyState)return y||window.addEventListener("DOMContentLoaded",(()=>{
w()}),!1),void(y=!0);document.querySelectorAll(p.cssSelector).forEach(_)}
function O(e){return e=(e||"").toLowerCase(),i[e]||i[s[e]]}
function k(e,{languageName:t}){"string"==typeof e&&(e=[e]),e.forEach((e=>{
s[e.toLowerCase()]=t}))}function v(e){const t=O(e)
;return t&&!t.disableAutodetect}function N(e,t){const n=e;r.forEach((e=>{
e[n]&&e[n](t)}))}Object.assign(n,{highlight:m,highlightAuto:x,highlightAll:w,
highlightElement:_,
highlightBlock:e=>(X("10.7.0","highlightBlock will be removed entirely in v12.0"),
X("10.7.0","Please use highlightElement now."),_(e)),configure:e=>{p=Y(p,e)},
initHighlighting:()=>{
w(),X("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")},
initHighlightingOnLoad:()=>{
w(),X("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")
},registerLanguage:(e,t)=>{let s=null;try{s=t(n)}catch(t){
if(z("Language definition for '{}' could not be registered.".replace("{}",e)),
!o)throw t;z(t),s=l}
s.name||(s.name=e),i[e]=s,s.rawDefinition=t.bind(null,n),s.aliases&&k(s.aliases,{
languageName:e})},unregisterLanguage:e=>{delete i[e]
;for(const t of Object.keys(s))s[t]===e&&delete s[t]},
listLanguages:()=>Object.keys(i),getLanguage:O,registerAliases:k,
autoDetection:v,inherit:Y,addPlugin:e=>{(e=>{
e["before:highlightBlock"]&&!e["before:highlightElement"]&&(e["before:highlightElement"]=t=>{
e["before:highlightBlock"](Object.assign({block:t.el},t))
}),e["after:highlightBlock"]&&!e["after:highlightElement"]&&(e["after:highlightElement"]=t=>{
e["after:highlightBlock"](Object.assign({block:t.el},t))})})(e),r.push(e)},
removePlugin:e=>{const t=r.indexOf(e);-1!==t&&r.splice(t,1)}}),n.debugMode=()=>{
o=!1},n.safeMode=()=>{o=!0},n.versionString="11.11.1",n.regex={concat:h,
lookahead:g,either:f,optional:d,anyNumberOfTimes:u}
;for(const t in A)"object"==typeof A[t]&&e(A[t]);return Object.assign(n,A),n
},te=ee({});te.newInstance=()=>ee({});export{te as default};

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,306 @@
/*!
Highlight.js v11.11.1 (git: 08cb242e7d)
(c) 2006-2025 Josh Goebel <hello@joshgoebel.com> and other contributors
License: BSD-3-Clause
*/
function e(t){return t instanceof Map?t.clear=t.delete=t.set=()=>{
throw Error("map is read-only")}:t instanceof Set&&(t.add=t.clear=t.delete=()=>{
throw Error("set is read-only")
}),Object.freeze(t),Object.getOwnPropertyNames(t).forEach((n=>{
const i=t[n],s=typeof i;"object"!==s&&"function"!==s||Object.isFrozen(i)||e(i)
})),t}class t{constructor(e){
void 0===e.data&&(e.data={}),this.data=e.data,this.isMatchIgnored=!1}
ignoreMatch(){this.isMatchIgnored=!0}}function n(e){
return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;")
}function i(e,...t){const n=Object.create(null);for(const t in e)n[t]=e[t]
;return t.forEach((e=>{for(const t in e)n[t]=e[t]})),n}const s=e=>!!e.scope
;class r{constructor(e,t){
this.buffer="",this.classPrefix=t.classPrefix,e.walk(this)}addText(e){
this.buffer+=n(e)}openNode(e){if(!s(e))return;const t=((e,{prefix:t})=>{
if(e.startsWith("language:"))return e.replace("language:","language-")
;if(e.includes(".")){const n=e.split(".")
;return[`${t}${n.shift()}`,...n.map(((e,t)=>`${e}${"_".repeat(t+1)}`))].join(" ")
}return`${t}${e}`})(e.scope,{prefix:this.classPrefix});this.span(t)}
closeNode(e){s(e)&&(this.buffer+="</span>")}value(){return this.buffer}span(e){
this.buffer+=`<span class="${e}">`}}const o=(e={})=>{const t={children:[]}
;return Object.assign(t,e),t};class a{constructor(){
this.rootNode=o(),this.stack=[this.rootNode]}get top(){
return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(e){
this.top.children.push(e)}openNode(e){const t=o({scope:e})
;this.add(t),this.stack.push(t)}closeNode(){
if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){
for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}
walk(e){return this.constructor._walk(e,this.rootNode)}static _walk(e,t){
return"string"==typeof t?e.addText(t):t.children&&(e.openNode(t),
t.children.forEach((t=>this._walk(e,t))),e.closeNode(t)),e}static _collapse(e){
"string"!=typeof e&&e.children&&(e.children.every((e=>"string"==typeof e))?e.children=[e.children.join("")]:e.children.forEach((e=>{
a._collapse(e)})))}}class c extends a{constructor(e){super(),this.options=e}
addText(e){""!==e&&this.add(e)}startScope(e){this.openNode(e)}endScope(){
this.closeNode()}__addSublanguage(e,t){const n=e.root
;t&&(n.scope="language:"+t),this.add(n)}toHTML(){
return new r(this,this.options).value()}finalize(){
return this.closeAllNodes(),!0}}function l(e){
return e?"string"==typeof e?e:e.source:null}function g(e){return h("(?=",e,")")}
function u(e){return h("(?:",e,")*")}function d(e){return h("(?:",e,")?")}
function h(...e){return e.map((e=>l(e))).join("")}function f(...e){const t=(e=>{
const t=e[e.length-1]
;return"object"==typeof t&&t.constructor===Object?(e.splice(e.length-1,1),t):{}
})(e);return"("+(t.capture?"":"?:")+e.map((e=>l(e))).join("|")+")"}
function p(e){return RegExp(e.toString()+"|").exec("").length-1}
const b=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./
;function m(e,{joinWith:t}){let n=0;return e.map((e=>{n+=1;const t=n
;let i=l(e),s="";for(;i.length>0;){const e=b.exec(i);if(!e){s+=i;break}
s+=i.substring(0,e.index),
i=i.substring(e.index+e[0].length),"\\"===e[0][0]&&e[1]?s+="\\"+(Number(e[1])+t):(s+=e[0],
"("===e[0]&&n++)}return s})).map((e=>`(${e})`)).join(t)}
const E="[a-zA-Z]\\w*",x="[a-zA-Z_]\\w*",_="\\b\\d+(\\.\\d+)?",y="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",w="\\b(0b[01]+)",O={
begin:"\\\\[\\s\\S]",relevance:0},k={scope:"string",begin:"'",end:"'",
illegal:"\\n",contains:[O]},v={scope:"string",begin:'"',end:'"',illegal:"\\n",
contains:[O]},N=(e,t,n={})=>{const s=i({scope:"comment",begin:e,end:t,
contains:[]},n);s.contains.push({scope:"doctag",
begin:"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",
end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0})
;const r=f("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/)
;return s.contains.push({begin:h(/[ ]+/,"(",r,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),s
},S=N("//","$"),M=N("/\\*","\\*/"),R=N("#","$");var A=Object.freeze({
__proto__:null,APOS_STRING_MODE:k,BACKSLASH_ESCAPE:O,BINARY_NUMBER_MODE:{
scope:"number",begin:w,relevance:0},BINARY_NUMBER_RE:w,COMMENT:N,
C_BLOCK_COMMENT_MODE:M,C_LINE_COMMENT_MODE:S,C_NUMBER_MODE:{scope:"number",
begin:y,relevance:0},C_NUMBER_RE:y,END_SAME_AS_BEGIN:e=>Object.assign(e,{
"on:begin":(e,t)=>{t.data._beginMatch=e[1]},"on:end":(e,t)=>{
t.data._beginMatch!==e[1]&&t.ignoreMatch()}}),HASH_COMMENT_MODE:R,IDENT_RE:E,
MATCH_NOTHING_RE:/\b\B/,METHOD_GUARD:{begin:"\\.\\s*"+x,relevance:0},
NUMBER_MODE:{scope:"number",begin:_,relevance:0},NUMBER_RE:_,
PHRASAL_WORDS_MODE:{
begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/
},QUOTE_STRING_MODE:v,REGEXP_MODE:{scope:"regexp",begin:/\/(?=[^/\n]*\/)/,
end:/\/[gimuy]*/,contains:[O,{begin:/\[/,end:/\]/,relevance:0,contains:[O]}]},
RE_STARTERS_RE:"!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",
SHEBANG:(e={})=>{const t=/^#![ ]*\//
;return e.binary&&(e.begin=h(t,/.*\b/,e.binary,/\b.*/)),i({scope:"meta",begin:t,
end:/$/,relevance:0,"on:begin":(e,t)=>{0!==e.index&&t.ignoreMatch()}},e)},
TITLE_MODE:{scope:"title",begin:E,relevance:0},UNDERSCORE_IDENT_RE:x,
UNDERSCORE_TITLE_MODE:{scope:"title",begin:x,relevance:0}});function j(e,t){
"."===e.input[e.index-1]&&t.ignoreMatch()}function I(e,t){
void 0!==e.className&&(e.scope=e.className,delete e.className)}function T(e,t){
t&&e.beginKeywords&&(e.begin="\\b("+e.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",
e.__beforeBegin=j,e.keywords=e.keywords||e.beginKeywords,delete e.beginKeywords,
void 0===e.relevance&&(e.relevance=0))}function L(e,t){
Array.isArray(e.illegal)&&(e.illegal=f(...e.illegal))}function B(e,t){
if(e.match){
if(e.begin||e.end)throw Error("begin & end are not supported with match")
;e.begin=e.match,delete e.match}}function P(e,t){
void 0===e.relevance&&(e.relevance=1)}const D=(e,t)=>{if(!e.beforeMatch)return
;if(e.starts)throw Error("beforeMatch cannot be used with starts")
;const n=Object.assign({},e);Object.keys(e).forEach((t=>{delete e[t]
})),e.keywords=n.keywords,e.begin=h(n.beforeMatch,g(n.begin)),e.starts={
relevance:0,contains:[Object.assign(n,{endsParent:!0})]
},e.relevance=0,delete n.beforeMatch
},H=["of","and","for","in","not","or","if","then","parent","list","value"]
;function C(e,t,n="keyword"){const i=Object.create(null)
;return"string"==typeof e?s(n,e.split(" ")):Array.isArray(e)?s(n,e):Object.keys(e).forEach((n=>{
Object.assign(i,C(e[n],t,n))})),i;function s(e,n){
t&&(n=n.map((e=>e.toLowerCase()))),n.forEach((t=>{const n=t.split("|")
;i[n[0]]=[e,$(n[0],n[1])]}))}}function $(e,t){
return t?Number(t):(e=>H.includes(e.toLowerCase()))(e)?0:1}const U={},z=e=>{
console.error(e)},W=(e,...t)=>{console.log("WARN: "+e,...t)},X=(e,t)=>{
U[`${e}/${t}`]||(console.log(`Deprecated as of ${e}. ${t}`),U[`${e}/${t}`]=!0)
},G=Error();function K(e,t,{key:n}){let i=0;const s=e[n],r={},o={}
;for(let e=1;e<=t.length;e++)o[e+i]=s[e],r[e+i]=!0,i+=p(t[e-1])
;e[n]=o,e[n]._emit=r,e[n]._multi=!0}function F(e){(e=>{
e.scope&&"object"==typeof e.scope&&null!==e.scope&&(e.beginScope=e.scope,
delete e.scope)})(e),"string"==typeof e.beginScope&&(e.beginScope={
_wrap:e.beginScope}),"string"==typeof e.endScope&&(e.endScope={_wrap:e.endScope
}),(e=>{if(Array.isArray(e.begin)){
if(e.skip||e.excludeBegin||e.returnBegin)throw z("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),
G
;if("object"!=typeof e.beginScope||null===e.beginScope)throw z("beginScope must be object"),
G;K(e,e.begin,{key:"beginScope"}),e.begin=m(e.begin,{joinWith:""})}})(e),(e=>{
if(Array.isArray(e.end)){
if(e.skip||e.excludeEnd||e.returnEnd)throw z("skip, excludeEnd, returnEnd not compatible with endScope: {}"),
G
;if("object"!=typeof e.endScope||null===e.endScope)throw z("endScope must be object"),
G;K(e,e.end,{key:"endScope"}),e.end=m(e.end,{joinWith:""})}})(e)}function Z(e){
function t(t,n){
return RegExp(l(t),"m"+(e.case_insensitive?"i":"")+(e.unicodeRegex?"u":"")+(n?"g":""))
}class n{constructor(){
this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}
addRule(e,t){
t.position=this.position++,this.matchIndexes[this.matchAt]=t,this.regexes.push([t,e]),
this.matchAt+=p(e)+1}compile(){0===this.regexes.length&&(this.exec=()=>null)
;const e=this.regexes.map((e=>e[1]));this.matcherRe=t(m(e,{joinWith:"|"
}),!0),this.lastIndex=0}exec(e){this.matcherRe.lastIndex=this.lastIndex
;const t=this.matcherRe.exec(e);if(!t)return null
;const n=t.findIndex(((e,t)=>t>0&&void 0!==e)),i=this.matchIndexes[n]
;return t.splice(0,n),Object.assign(t,i)}}class s{constructor(){
this.rules=[],this.multiRegexes=[],
this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(e){
if(this.multiRegexes[e])return this.multiRegexes[e];const t=new n
;return this.rules.slice(e).forEach((([e,n])=>t.addRule(e,n))),
t.compile(),this.multiRegexes[e]=t,t}resumingScanAtSamePosition(){
return 0!==this.regexIndex}considerAll(){this.regexIndex=0}addRule(e,t){
this.rules.push([e,t]),"begin"===t.type&&this.count++}exec(e){
const t=this.getMatcher(this.regexIndex);t.lastIndex=this.lastIndex
;let n=t.exec(e)
;if(this.resumingScanAtSamePosition())if(n&&n.index===this.lastIndex);else{
const t=this.getMatcher(0);t.lastIndex=this.lastIndex+1,n=t.exec(e)}
return n&&(this.regexIndex+=n.position+1,
this.regexIndex===this.count&&this.considerAll()),n}}
if(e.compilerExtensions||(e.compilerExtensions=[]),
e.contains&&e.contains.includes("self"))throw Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.")
;return e.classNameAliases=i(e.classNameAliases||{}),function n(r,o){const a=r
;if(r.isCompiled)return a
;[I,B,F,D].forEach((e=>e(r,o))),e.compilerExtensions.forEach((e=>e(r,o))),
r.__beforeBegin=null,[T,L,P].forEach((e=>e(r,o))),r.isCompiled=!0;let c=null
;return"object"==typeof r.keywords&&r.keywords.$pattern&&(r.keywords=Object.assign({},r.keywords),
c=r.keywords.$pattern,
delete r.keywords.$pattern),c=c||/\w+/,r.keywords&&(r.keywords=C(r.keywords,e.case_insensitive)),
a.keywordPatternRe=t(c,!0),
o&&(r.begin||(r.begin=/\B|\b/),a.beginRe=t(a.begin),r.end||r.endsWithParent||(r.end=/\B|\b/),
r.end&&(a.endRe=t(a.end)),
a.terminatorEnd=l(a.end)||"",r.endsWithParent&&o.terminatorEnd&&(a.terminatorEnd+=(r.end?"|":"")+o.terminatorEnd)),
r.illegal&&(a.illegalRe=t(r.illegal)),
r.contains||(r.contains=[]),r.contains=[].concat(...r.contains.map((e=>(e=>(e.variants&&!e.cachedVariants&&(e.cachedVariants=e.variants.map((t=>i(e,{
variants:null},t)))),e.cachedVariants?e.cachedVariants:V(e)?i(e,{
starts:e.starts?i(e.starts):null
}):Object.isFrozen(e)?i(e):e))("self"===e?r:e)))),r.contains.forEach((e=>{n(e,a)
})),r.starts&&n(r.starts,o),a.matcher=(e=>{const t=new s
;return e.contains.forEach((e=>t.addRule(e.begin,{rule:e,type:"begin"
}))),e.terminatorEnd&&t.addRule(e.terminatorEnd,{type:"end"
}),e.illegal&&t.addRule(e.illegal,{type:"illegal"}),t})(a),a}(e)}function V(e){
return!!e&&(e.endsWithParent||V(e.starts))}class q extends Error{
constructor(e,t){super(e),this.name="HTMLInjectionError",this.html=t}}
const J=n,Y=i,Q=Symbol("nomatch"),ee=n=>{
const i=Object.create(null),s=Object.create(null),r=[];let o=!0
;const a="Could not find the language '{}', did you forget to load/include a language module?",l={
disableAutodetect:!0,name:"Plain text",contains:[]};let p={
ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,
languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",
cssSelector:"pre code",languages:null,__emitter:c};function b(e){
return p.noHighlightRe.test(e)}function m(e,t,n){let i="",s=""
;"object"==typeof t?(i=e,
n=t.ignoreIllegals,s=t.language):(X("10.7.0","highlight(lang, code, ...args) has been deprecated."),
X("10.7.0","Please use highlight(code, options) instead.\nhttps://github.com/highlightjs/highlight.js/issues/2277"),
s=e,i=t),void 0===n&&(n=!0);const r={code:i,language:s};N("before:highlight",r)
;const o=r.result?r.result:E(r.language,r.code,n)
;return o.code=r.code,N("after:highlight",o),o}function E(e,n,s,r){
const c=Object.create(null);function l(){if(!N.keywords)return void M.addText(R)
;let e=0;N.keywordPatternRe.lastIndex=0;let t=N.keywordPatternRe.exec(R),n=""
;for(;t;){n+=R.substring(e,t.index)
;const s=w.case_insensitive?t[0].toLowerCase():t[0],r=(i=s,N.keywords[i]);if(r){
const[e,i]=r
;if(M.addText(n),n="",c[s]=(c[s]||0)+1,c[s]<=7&&(A+=i),e.startsWith("_"))n+=t[0];else{
const n=w.classNameAliases[e]||e;u(t[0],n)}}else n+=t[0]
;e=N.keywordPatternRe.lastIndex,t=N.keywordPatternRe.exec(R)}var i
;n+=R.substring(e),M.addText(n)}function g(){null!=N.subLanguage?(()=>{
if(""===R)return;let e=null;if("string"==typeof N.subLanguage){
if(!i[N.subLanguage])return void M.addText(R)
;e=E(N.subLanguage,R,!0,S[N.subLanguage]),S[N.subLanguage]=e._top
}else e=x(R,N.subLanguage.length?N.subLanguage:null)
;N.relevance>0&&(A+=e.relevance),M.__addSublanguage(e._emitter,e.language)
})():l(),R=""}function u(e,t){
""!==e&&(M.startScope(t),M.addText(e),M.endScope())}function d(e,t){let n=1
;const i=t.length-1;for(;n<=i;){if(!e._emit[n]){n++;continue}
const i=w.classNameAliases[e[n]]||e[n],s=t[n];i?u(s,i):(R=s,l(),R=""),n++}}
function h(e,t){
return e.scope&&"string"==typeof e.scope&&M.openNode(w.classNameAliases[e.scope]||e.scope),
e.beginScope&&(e.beginScope._wrap?(u(R,w.classNameAliases[e.beginScope._wrap]||e.beginScope._wrap),
R=""):e.beginScope._multi&&(d(e.beginScope,t),R="")),N=Object.create(e,{parent:{
value:N}}),N}function f(e,n,i){let s=((e,t)=>{const n=e&&e.exec(t)
;return n&&0===n.index})(e.endRe,i);if(s){if(e["on:end"]){const i=new t(e)
;e["on:end"](n,i),i.isMatchIgnored&&(s=!1)}if(s){
for(;e.endsParent&&e.parent;)e=e.parent;return e}}
if(e.endsWithParent)return f(e.parent,n,i)}function b(e){
return 0===N.matcher.regexIndex?(R+=e[0],1):(T=!0,0)}function m(e){
const t=e[0],i=n.substring(e.index),s=f(N,e,i);if(!s)return Q;const r=N
;N.endScope&&N.endScope._wrap?(g(),
u(t,N.endScope._wrap)):N.endScope&&N.endScope._multi?(g(),
d(N.endScope,e)):r.skip?R+=t:(r.returnEnd||r.excludeEnd||(R+=t),
g(),r.excludeEnd&&(R=t));do{
N.scope&&M.closeNode(),N.skip||N.subLanguage||(A+=N.relevance),N=N.parent
}while(N!==s.parent);return s.starts&&h(s.starts,e),r.returnEnd?0:t.length}
let _={};function y(i,r){const a=r&&r[0];if(R+=i,null==a)return g(),0
;if("begin"===_.type&&"end"===r.type&&_.index===r.index&&""===a){
if(R+=n.slice(r.index,r.index+1),!o){const t=Error(`0 width match regex (${e})`)
;throw t.languageName=e,t.badRule=_.rule,t}return 1}
if(_=r,"begin"===r.type)return(e=>{
const n=e[0],i=e.rule,s=new t(i),r=[i.__beforeBegin,i["on:begin"]]
;for(const t of r)if(t&&(t(e,s),s.isMatchIgnored))return b(n)
;return i.skip?R+=n:(i.excludeBegin&&(R+=n),
g(),i.returnBegin||i.excludeBegin||(R=n)),h(i,e),i.returnBegin?0:n.length})(r)
;if("illegal"===r.type&&!s){
const e=Error('Illegal lexeme "'+a+'" for mode "'+(N.scope||"<unnamed>")+'"')
;throw e.mode=N,e}if("end"===r.type){const e=m(r);if(e!==Q)return e}
if("illegal"===r.type&&""===a)return R+="\n",1
;if(I>1e5&&I>3*r.index)throw Error("potential infinite loop, way more iterations than matches")
;return R+=a,a.length}const w=O(e)
;if(!w)throw z(a.replace("{}",e)),Error('Unknown language: "'+e+'"')
;const k=Z(w);let v="",N=r||k;const S={},M=new p.__emitter(p);(()=>{const e=[]
;for(let t=N;t!==w;t=t.parent)t.scope&&e.unshift(t.scope)
;e.forEach((e=>M.openNode(e)))})();let R="",A=0,j=0,I=0,T=!1;try{
if(w.__emitTokens)w.__emitTokens(n,M);else{for(N.matcher.considerAll();;){
I++,T?T=!1:N.matcher.considerAll(),N.matcher.lastIndex=j
;const e=N.matcher.exec(n);if(!e)break;const t=y(n.substring(j,e.index),e)
;j=e.index+t}y(n.substring(j))}return M.finalize(),v=M.toHTML(),{language:e,
value:v,relevance:A,illegal:!1,_emitter:M,_top:N}}catch(t){
if(t.message&&t.message.includes("Illegal"))return{language:e,value:J(n),
illegal:!0,relevance:0,_illegalBy:{message:t.message,index:j,
context:n.slice(j-100,j+100),mode:t.mode,resultSoFar:v},_emitter:M};if(o)return{
language:e,value:J(n),illegal:!1,relevance:0,errorRaised:t,_emitter:M,_top:N}
;throw t}}function x(e,t){t=t||p.languages||Object.keys(i);const n=(e=>{
const t={value:J(e),illegal:!1,relevance:0,_top:l,_emitter:new p.__emitter(p)}
;return t._emitter.addText(e),t})(e),s=t.filter(O).filter(v).map((t=>E(t,e,!1)))
;s.unshift(n);const r=s.sort(((e,t)=>{
if(e.relevance!==t.relevance)return t.relevance-e.relevance
;if(e.language&&t.language){if(O(e.language).supersetOf===t.language)return 1
;if(O(t.language).supersetOf===e.language)return-1}return 0})),[o,a]=r,c=o
;return c.secondBest=a,c}function _(e){let t=null;const n=(e=>{
let t=e.className+" ";t+=e.parentNode?e.parentNode.className:""
;const n=p.languageDetectRe.exec(t);if(n){const t=O(n[1])
;return t||(W(a.replace("{}",n[1])),
W("Falling back to no-highlight mode for this block.",e)),t?n[1]:"no-highlight"}
return t.split(/\s+/).find((e=>b(e)||O(e)))})(e);if(b(n))return
;if(N("before:highlightElement",{el:e,language:n
}),e.dataset.highlighted)return void console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",e)
;if(e.children.length>0&&(p.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),
console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),
console.warn("The element with unescaped HTML:"),
console.warn(e)),p.throwUnescapedHTML))throw new q("One of your code blocks includes unescaped HTML.",e.innerHTML)
;t=e;const i=t.textContent,r=n?m(i,{language:n,ignoreIllegals:!0}):x(i)
;e.innerHTML=r.value,e.dataset.highlighted="yes",((e,t,n)=>{const i=t&&s[t]||n
;e.classList.add("hljs"),e.classList.add("language-"+i)
})(e,n,r.language),e.result={language:r.language,re:r.relevance,
relevance:r.relevance},r.secondBest&&(e.secondBest={
language:r.secondBest.language,relevance:r.secondBest.relevance
}),N("after:highlightElement",{el:e,result:r,text:i})}let y=!1;function w(){
if("loading"===document.readyState)return y||window.addEventListener("DOMContentLoaded",(()=>{
w()}),!1),void(y=!0);document.querySelectorAll(p.cssSelector).forEach(_)}
function O(e){return e=(e||"").toLowerCase(),i[e]||i[s[e]]}
function k(e,{languageName:t}){"string"==typeof e&&(e=[e]),e.forEach((e=>{
s[e.toLowerCase()]=t}))}function v(e){const t=O(e)
;return t&&!t.disableAutodetect}function N(e,t){const n=e;r.forEach((e=>{
e[n]&&e[n](t)}))}Object.assign(n,{highlight:m,highlightAuto:x,highlightAll:w,
highlightElement:_,
highlightBlock:e=>(X("10.7.0","highlightBlock will be removed entirely in v12.0"),
X("10.7.0","Please use highlightElement now."),_(e)),configure:e=>{p=Y(p,e)},
initHighlighting:()=>{
w(),X("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")},
initHighlightingOnLoad:()=>{
w(),X("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")
},registerLanguage:(e,t)=>{let s=null;try{s=t(n)}catch(t){
if(z("Language definition for '{}' could not be registered.".replace("{}",e)),
!o)throw t;z(t),s=l}
s.name||(s.name=e),i[e]=s,s.rawDefinition=t.bind(null,n),s.aliases&&k(s.aliases,{
languageName:e})},unregisterLanguage:e=>{delete i[e]
;for(const t of Object.keys(s))s[t]===e&&delete s[t]},
listLanguages:()=>Object.keys(i),getLanguage:O,registerAliases:k,
autoDetection:v,inherit:Y,addPlugin:e=>{(e=>{
e["before:highlightBlock"]&&!e["before:highlightElement"]&&(e["before:highlightElement"]=t=>{
e["before:highlightBlock"](Object.assign({block:t.el},t))
}),e["after:highlightBlock"]&&!e["after:highlightElement"]&&(e["after:highlightElement"]=t=>{
e["after:highlightBlock"](Object.assign({block:t.el},t))})})(e),r.push(e)},
removePlugin:e=>{const t=r.indexOf(e);-1!==t&&r.splice(t,1)}}),n.debugMode=()=>{
o=!1},n.safeMode=()=>{o=!0},n.versionString="11.11.1",n.regex={concat:h,
lookahead:g,either:f,optional:d,anyNumberOfTimes:u}
;for(const t in A)"object"==typeof A[t]&&e(A[t]);return Object.assign(n,A),n
},te=ee({});te.newInstance=()=>ee({});export{te as default};

View File

@@ -0,0 +1,417 @@
/*! `bash` grammar compiled for Highlight.js 11.11.1 */
var hljsGrammar = (function () {
'use strict';
/*
Language: Bash
Author: vah <vahtenberg@gmail.com>
Contributrors: Benjamin Pannell <contact@sierrasoftworks.com>
Website: https://www.gnu.org/software/bash/
Category: common, scripting
*/
/** @type LanguageFn */
function bash(hljs) {
const regex = hljs.regex;
const VAR = {};
const BRACED_VAR = {
begin: /\$\{/,
end: /\}/,
contains: [
"self",
{
begin: /:-/,
contains: [ VAR ]
} // default values
]
};
Object.assign(VAR, {
className: 'variable',
variants: [
{ begin: regex.concat(/\$[\w\d#@][\w\d_]*/,
// negative look-ahead tries to avoid matching patterns that are not
// Perl at all like $ident$, @ident@, etc.
`(?![\\w\\d])(?![$])`) },
BRACED_VAR
]
});
const SUBST = {
className: 'subst',
begin: /\$\(/,
end: /\)/,
contains: [ hljs.BACKSLASH_ESCAPE ]
};
const COMMENT = hljs.inherit(
hljs.COMMENT(),
{
match: [
/(^|\s)/,
/#.*$/
],
scope: {
2: 'comment'
}
}
);
const HERE_DOC = {
begin: /<<-?\s*(?=\w+)/,
starts: { contains: [
hljs.END_SAME_AS_BEGIN({
begin: /(\w+)/,
end: /(\w+)/,
className: 'string'
})
] }
};
const QUOTE_STRING = {
className: 'string',
begin: /"/,
end: /"/,
contains: [
hljs.BACKSLASH_ESCAPE,
VAR,
SUBST
]
};
SUBST.contains.push(QUOTE_STRING);
const ESCAPED_QUOTE = {
match: /\\"/
};
const APOS_STRING = {
className: 'string',
begin: /'/,
end: /'/
};
const ESCAPED_APOS = {
match: /\\'/
};
const ARITHMETIC = {
begin: /\$?\(\(/,
end: /\)\)/,
contains: [
{
begin: /\d+#[0-9a-f]+/,
className: "number"
},
hljs.NUMBER_MODE,
VAR
]
};
const SH_LIKE_SHELLS = [
"fish",
"bash",
"zsh",
"sh",
"csh",
"ksh",
"tcsh",
"dash",
"scsh",
];
const KNOWN_SHEBANG = hljs.SHEBANG({
binary: `(${SH_LIKE_SHELLS.join("|")})`,
relevance: 10
});
const FUNCTION = {
className: 'function',
begin: /\w[\w\d_]*\s*\(\s*\)\s*\{/,
returnBegin: true,
contains: [ hljs.inherit(hljs.TITLE_MODE, { begin: /\w[\w\d_]*/ }) ],
relevance: 0
};
const KEYWORDS = [
"if",
"then",
"else",
"elif",
"fi",
"time",
"for",
"while",
"until",
"in",
"do",
"done",
"case",
"esac",
"coproc",
"function",
"select"
];
const LITERALS = [
"true",
"false"
];
// to consume paths to prevent keyword matches inside them
const PATH_MODE = { match: /(\/[a-z._-]+)+/ };
// http://www.gnu.org/software/bash/manual/html_node/Shell-Builtin-Commands.html
const SHELL_BUILT_INS = [
"break",
"cd",
"continue",
"eval",
"exec",
"exit",
"export",
"getopts",
"hash",
"pwd",
"readonly",
"return",
"shift",
"test",
"times",
"trap",
"umask",
"unset"
];
const BASH_BUILT_INS = [
"alias",
"bind",
"builtin",
"caller",
"command",
"declare",
"echo",
"enable",
"help",
"let",
"local",
"logout",
"mapfile",
"printf",
"read",
"readarray",
"source",
"sudo",
"type",
"typeset",
"ulimit",
"unalias"
];
const ZSH_BUILT_INS = [
"autoload",
"bg",
"bindkey",
"bye",
"cap",
"chdir",
"clone",
"comparguments",
"compcall",
"compctl",
"compdescribe",
"compfiles",
"compgroups",
"compquote",
"comptags",
"comptry",
"compvalues",
"dirs",
"disable",
"disown",
"echotc",
"echoti",
"emulate",
"fc",
"fg",
"float",
"functions",
"getcap",
"getln",
"history",
"integer",
"jobs",
"kill",
"limit",
"log",
"noglob",
"popd",
"print",
"pushd",
"pushln",
"rehash",
"sched",
"setcap",
"setopt",
"stat",
"suspend",
"ttyctl",
"unfunction",
"unhash",
"unlimit",
"unsetopt",
"vared",
"wait",
"whence",
"where",
"which",
"zcompile",
"zformat",
"zftp",
"zle",
"zmodload",
"zparseopts",
"zprof",
"zpty",
"zregexparse",
"zsocket",
"zstyle",
"ztcp"
];
const GNU_CORE_UTILS = [
"chcon",
"chgrp",
"chown",
"chmod",
"cp",
"dd",
"df",
"dir",
"dircolors",
"ln",
"ls",
"mkdir",
"mkfifo",
"mknod",
"mktemp",
"mv",
"realpath",
"rm",
"rmdir",
"shred",
"sync",
"touch",
"truncate",
"vdir",
"b2sum",
"base32",
"base64",
"cat",
"cksum",
"comm",
"csplit",
"cut",
"expand",
"fmt",
"fold",
"head",
"join",
"md5sum",
"nl",
"numfmt",
"od",
"paste",
"ptx",
"pr",
"sha1sum",
"sha224sum",
"sha256sum",
"sha384sum",
"sha512sum",
"shuf",
"sort",
"split",
"sum",
"tac",
"tail",
"tr",
"tsort",
"unexpand",
"uniq",
"wc",
"arch",
"basename",
"chroot",
"date",
"dirname",
"du",
"echo",
"env",
"expr",
"factor",
// "false", // keyword literal already
"groups",
"hostid",
"id",
"link",
"logname",
"nice",
"nohup",
"nproc",
"pathchk",
"pinky",
"printenv",
"printf",
"pwd",
"readlink",
"runcon",
"seq",
"sleep",
"stat",
"stdbuf",
"stty",
"tee",
"test",
"timeout",
// "true", // keyword literal already
"tty",
"uname",
"unlink",
"uptime",
"users",
"who",
"whoami",
"yes"
];
return {
name: 'Bash',
aliases: [
'sh',
'zsh'
],
keywords: {
$pattern: /\b[a-z][a-z0-9._-]+\b/,
keyword: KEYWORDS,
literal: LITERALS,
built_in: [
...SHELL_BUILT_INS,
...BASH_BUILT_INS,
// Shell modifiers
"set",
"shopt",
...ZSH_BUILT_INS,
...GNU_CORE_UTILS
]
},
contains: [
KNOWN_SHEBANG, // to catch known shells and boost relevancy
hljs.SHEBANG(), // to catch unknown shells but still highlight the shebang
FUNCTION,
ARITHMETIC,
COMMENT,
HERE_DOC,
PATH_MODE,
QUOTE_STRING,
ESCAPED_QUOTE,
APOS_STRING,
ESCAPED_APOS,
VAR
]
};
}
return bash;
})();
;
export default hljsGrammar;

View File

@@ -0,0 +1,21 @@
/*! `bash` grammar compiled for Highlight.js 11.11.1 */
var hljsGrammar=(()=>{"use strict";return e=>{const s=e.regex,t={},a={
begin:/\$\{/,end:/\}/,contains:["self",{begin:/:-/,contains:[t]}]}
;Object.assign(t,{className:"variable",variants:[{
begin:s.concat(/\$[\w\d#@][\w\d_]*/,"(?![\\w\\d])(?![$])")},a]});const n={
className:"subst",begin:/\$\(/,end:/\)/,contains:[e.BACKSLASH_ESCAPE]
},c=e.inherit(e.COMMENT(),{match:[/(^|\s)/,/#.*$/],scope:{2:"comment"}}),i={
begin:/<<-?\s*(?=\w+)/,starts:{contains:[e.END_SAME_AS_BEGIN({begin:/(\w+)/,
end:/(\w+)/,className:"string"})]}},o={className:"string",begin:/"/,end:/"/,
contains:[e.BACKSLASH_ESCAPE,t,n]};n.contains.push(o);const r={begin:/\$?\(\(/,
end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:"number"},e.NUMBER_MODE,t]
},l=e.SHEBANG({binary:"(fish|bash|zsh|sh|csh|ksh|tcsh|dash|scsh)",relevance:10
}),m={className:"function",begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0,
contains:[e.inherit(e.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0};return{
name:"Bash",aliases:["sh","zsh"],keywords:{$pattern:/\b[a-z][a-z0-9._-]+\b/,
keyword:["if","then","else","elif","fi","time","for","while","until","in","do","done","case","esac","coproc","function","select"],
literal:["true","false"],
built_in:["break","cd","continue","eval","exec","exit","export","getopts","hash","pwd","readonly","return","shift","test","times","trap","umask","unset","alias","bind","builtin","caller","command","declare","echo","enable","help","let","local","logout","mapfile","printf","read","readarray","source","sudo","type","typeset","ulimit","unalias","set","shopt","autoload","bg","bindkey","bye","cap","chdir","clone","comparguments","compcall","compctl","compdescribe","compfiles","compgroups","compquote","comptags","comptry","compvalues","dirs","disable","disown","echotc","echoti","emulate","fc","fg","float","functions","getcap","getln","history","integer","jobs","kill","limit","log","noglob","popd","print","pushd","pushln","rehash","sched","setcap","setopt","stat","suspend","ttyctl","unfunction","unhash","unlimit","unsetopt","vared","wait","whence","where","which","zcompile","zformat","zftp","zle","zmodload","zparseopts","zprof","zpty","zregexparse","zsocket","zstyle","ztcp","chcon","chgrp","chown","chmod","cp","dd","df","dir","dircolors","ln","ls","mkdir","mkfifo","mknod","mktemp","mv","realpath","rm","rmdir","shred","sync","touch","truncate","vdir","b2sum","base32","base64","cat","cksum","comm","csplit","cut","expand","fmt","fold","head","join","md5sum","nl","numfmt","od","paste","ptx","pr","sha1sum","sha224sum","sha256sum","sha384sum","sha512sum","shuf","sort","split","sum","tac","tail","tr","tsort","unexpand","uniq","wc","arch","basename","chroot","date","dirname","du","echo","env","expr","factor","groups","hostid","id","link","logname","nice","nohup","nproc","pathchk","pinky","printenv","printf","pwd","readlink","runcon","seq","sleep","stat","stdbuf","stty","tee","test","timeout","tty","uname","unlink","uptime","users","who","whoami","yes"]
},contains:[l,e.SHEBANG(),m,r,c,i,{match:/(\/[a-z._-]+)+/},o,{match:/\\"/},{
className:"string",begin:/'/,end:/'/},{match:/\\'/},t]}}})()
;export default hljsGrammar;

View File

@@ -0,0 +1,341 @@
/*! `c` grammar compiled for Highlight.js 11.11.1 */
var hljsGrammar = (function () {
'use strict';
/*
Language: C
Category: common, system
Website: https://en.wikipedia.org/wiki/C_(programming_language)
*/
/** @type LanguageFn */
function c(hljs) {
const regex = hljs.regex;
// added for historic reasons because `hljs.C_LINE_COMMENT_MODE` does
// not include such support nor can we be sure all the grammars depending
// on it would desire this behavior
const C_LINE_COMMENT_MODE = hljs.COMMENT('//', '$', { contains: [ { begin: /\\\n/ } ] });
const DECLTYPE_AUTO_RE = 'decltype\\(auto\\)';
const NAMESPACE_RE = '[a-zA-Z_]\\w*::';
const TEMPLATE_ARGUMENT_RE = '<[^<>]+>';
const FUNCTION_TYPE_RE = '('
+ DECLTYPE_AUTO_RE + '|'
+ regex.optional(NAMESPACE_RE)
+ '[a-zA-Z_]\\w*' + regex.optional(TEMPLATE_ARGUMENT_RE)
+ ')';
const TYPES = {
className: 'type',
variants: [
{ begin: '\\b[a-z\\d_]*_t\\b' },
{ match: /\batomic_[a-z]{3,6}\b/ }
]
};
// https://en.cppreference.com/w/cpp/language/escape
// \\ \x \xFF \u2837 \u00323747 \374
const CHARACTER_ESCAPES = '\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)';
const STRINGS = {
className: 'string',
variants: [
{
begin: '(u8?|U|L)?"',
end: '"',
illegal: '\\n',
contains: [ hljs.BACKSLASH_ESCAPE ]
},
{
begin: '(u8?|U|L)?\'(' + CHARACTER_ESCAPES + "|.)",
end: '\'',
illegal: '.'
},
hljs.END_SAME_AS_BEGIN({
begin: /(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,
end: /\)([^()\\ ]{0,16})"/
})
]
};
const NUMBERS = {
className: 'number',
variants: [
{ match: /\b(0b[01']+)/ },
{ match: /(-?)\b([\d']+(\.[\d']*)?|\.[\d']+)((ll|LL|l|L)(u|U)?|(u|U)(ll|LL|l|L)?|f|F|b|B)/ },
{ match: /(-?)\b(0[xX][a-fA-F0-9]+(?:'[a-fA-F0-9]+)*(?:\.[a-fA-F0-9]*(?:'[a-fA-F0-9]*)*)?(?:[pP][-+]?[0-9]+)?(l|L)?(u|U)?)/ },
{ match: /(-?)\b\d+(?:'\d+)*(?:\.\d*(?:'\d*)*)?(?:[eE][-+]?\d+)?/ }
],
relevance: 0
};
const PREPROCESSOR = {
className: 'meta',
begin: /#\s*[a-z]+\b/,
end: /$/,
keywords: { keyword:
'if else elif endif define undef warning error line '
+ 'pragma _Pragma ifdef ifndef elifdef elifndef include' },
contains: [
{
begin: /\\\n/,
relevance: 0
},
hljs.inherit(STRINGS, { className: 'string' }),
{
className: 'string',
begin: /<.*?>/
},
C_LINE_COMMENT_MODE,
hljs.C_BLOCK_COMMENT_MODE
]
};
const TITLE_MODE = {
className: 'title',
begin: regex.optional(NAMESPACE_RE) + hljs.IDENT_RE,
relevance: 0
};
const FUNCTION_TITLE = regex.optional(NAMESPACE_RE) + hljs.IDENT_RE + '\\s*\\(';
const C_KEYWORDS = [
"asm",
"auto",
"break",
"case",
"continue",
"default",
"do",
"else",
"enum",
"extern",
"for",
"fortran",
"goto",
"if",
"inline",
"register",
"restrict",
"return",
"sizeof",
"typeof",
"typeof_unqual",
"struct",
"switch",
"typedef",
"union",
"volatile",
"while",
"_Alignas",
"_Alignof",
"_Atomic",
"_Generic",
"_Noreturn",
"_Static_assert",
"_Thread_local",
// aliases
"alignas",
"alignof",
"noreturn",
"static_assert",
"thread_local",
// not a C keyword but is, for all intents and purposes, treated exactly like one.
"_Pragma"
];
const C_TYPES = [
"float",
"double",
"signed",
"unsigned",
"int",
"short",
"long",
"char",
"void",
"_Bool",
"_BitInt",
"_Complex",
"_Imaginary",
"_Decimal32",
"_Decimal64",
"_Decimal96",
"_Decimal128",
"_Decimal64x",
"_Decimal128x",
"_Float16",
"_Float32",
"_Float64",
"_Float128",
"_Float32x",
"_Float64x",
"_Float128x",
// modifiers
"const",
"static",
"constexpr",
// aliases
"complex",
"bool",
"imaginary"
];
const KEYWORDS = {
keyword: C_KEYWORDS,
type: C_TYPES,
literal: 'true false NULL',
// TODO: apply hinting work similar to what was done in cpp.js
built_in: 'std string wstring cin cout cerr clog stdin stdout stderr stringstream istringstream ostringstream '
+ 'auto_ptr deque list queue stack vector map set pair bitset multiset multimap unordered_set '
+ 'unordered_map unordered_multiset unordered_multimap priority_queue make_pair array shared_ptr abort terminate abs acos '
+ 'asin atan2 atan calloc ceil cosh cos exit exp fabs floor fmod fprintf fputs free frexp '
+ 'fscanf future isalnum isalpha iscntrl isdigit isgraph islower isprint ispunct isspace isupper '
+ 'isxdigit tolower toupper labs ldexp log10 log malloc realloc memchr memcmp memcpy memset modf pow '
+ 'printf putchar puts scanf sinh sin snprintf sprintf sqrt sscanf strcat strchr strcmp '
+ 'strcpy strcspn strlen strncat strncmp strncpy strpbrk strrchr strspn strstr tanh tan '
+ 'vfprintf vprintf vsprintf endl initializer_list unique_ptr',
};
const EXPRESSION_CONTAINS = [
PREPROCESSOR,
TYPES,
C_LINE_COMMENT_MODE,
hljs.C_BLOCK_COMMENT_MODE,
NUMBERS,
STRINGS
];
const EXPRESSION_CONTEXT = {
// This mode covers expression context where we can't expect a function
// definition and shouldn't highlight anything that looks like one:
// `return some()`, `else if()`, `(x*sum(1, 2))`
variants: [
{
begin: /=/,
end: /;/
},
{
begin: /\(/,
end: /\)/
},
{
beginKeywords: 'new throw return else',
end: /;/
}
],
keywords: KEYWORDS,
contains: EXPRESSION_CONTAINS.concat([
{
begin: /\(/,
end: /\)/,
keywords: KEYWORDS,
contains: EXPRESSION_CONTAINS.concat([ 'self' ]),
relevance: 0
}
]),
relevance: 0
};
const FUNCTION_DECLARATION = {
begin: '(' + FUNCTION_TYPE_RE + '[\\*&\\s]+)+' + FUNCTION_TITLE,
returnBegin: true,
end: /[{;=]/,
excludeEnd: true,
keywords: KEYWORDS,
illegal: /[^\w\s\*&:<>.]/,
contains: [
{ // to prevent it from being confused as the function title
begin: DECLTYPE_AUTO_RE,
keywords: KEYWORDS,
relevance: 0
},
{
begin: FUNCTION_TITLE,
returnBegin: true,
contains: [ hljs.inherit(TITLE_MODE, { className: "title.function" }) ],
relevance: 0
},
// allow for multiple declarations, e.g.:
// extern void f(int), g(char);
{
relevance: 0,
match: /,/
},
{
className: 'params',
begin: /\(/,
end: /\)/,
keywords: KEYWORDS,
relevance: 0,
contains: [
C_LINE_COMMENT_MODE,
hljs.C_BLOCK_COMMENT_MODE,
STRINGS,
NUMBERS,
TYPES,
// Count matching parentheses.
{
begin: /\(/,
end: /\)/,
keywords: KEYWORDS,
relevance: 0,
contains: [
'self',
C_LINE_COMMENT_MODE,
hljs.C_BLOCK_COMMENT_MODE,
STRINGS,
NUMBERS,
TYPES
]
}
]
},
TYPES,
C_LINE_COMMENT_MODE,
hljs.C_BLOCK_COMMENT_MODE,
PREPROCESSOR
]
};
return {
name: "C",
aliases: [ 'h' ],
keywords: KEYWORDS,
// Until differentiations are added between `c` and `cpp`, `c` will
// not be auto-detected to avoid auto-detect conflicts between C and C++
disableAutodetect: true,
illegal: '</',
contains: [].concat(
EXPRESSION_CONTEXT,
FUNCTION_DECLARATION,
EXPRESSION_CONTAINS,
[
PREPROCESSOR,
{
begin: hljs.IDENT_RE + '::',
keywords: KEYWORDS
},
{
className: 'class',
beginKeywords: 'enum class struct union',
end: /[{;:<>=]/,
contains: [
{ beginKeywords: "final class struct" },
hljs.TITLE_MODE
]
}
]),
exports: {
preprocessor: PREPROCESSOR,
strings: STRINGS,
keywords: KEYWORDS
}
};
}
return c;
})();
;
export default hljsGrammar;

View File

@@ -0,0 +1,41 @@
/*! `c` grammar compiled for Highlight.js 11.11.1 */
var hljsGrammar=(()=>{"use strict";return e=>{
const t=e.regex,a=e.COMMENT("//","$",{contains:[{begin:/\\\n/}]
}),n="decltype\\(auto\\)",s="[a-zA-Z_]\\w*::",r="("+n+"|"+t.optional(s)+"[a-zA-Z_]\\w*"+t.optional("<[^<>]+>")+")",i={
className:"type",variants:[{begin:"\\b[a-z\\d_]*_t\\b"},{
match:/\batomic_[a-z]{3,6}\b/}]},l={className:"string",variants:[{
begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[e.BACKSLASH_ESCAPE]},{
begin:"(u8?|U|L)?'(\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)|.)",
end:"'",illegal:"."},e.END_SAME_AS_BEGIN({
begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},o={
className:"number",variants:[{match:/\b(0b[01']+)/},{
match:/(-?)\b([\d']+(\.[\d']*)?|\.[\d']+)((ll|LL|l|L)(u|U)?|(u|U)(ll|LL|l|L)?|f|F|b|B)/
},{
match:/(-?)\b(0[xX][a-fA-F0-9]+(?:'[a-fA-F0-9]+)*(?:\.[a-fA-F0-9]*(?:'[a-fA-F0-9]*)*)?(?:[pP][-+]?[0-9]+)?(l|L)?(u|U)?)/
},{match:/(-?)\b\d+(?:'\d+)*(?:\.\d*(?:'\d*)*)?(?:[eE][-+]?\d+)?/}],relevance:0
},c={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{
keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef elifdef elifndef include"
},contains:[{begin:/\\\n/,relevance:0},e.inherit(l,{className:"string"}),{
className:"string",begin:/<.*?>/},a,e.C_BLOCK_COMMENT_MODE]},d={
className:"title",begin:t.optional(s)+e.IDENT_RE,relevance:0
},m=t.optional(s)+e.IDENT_RE+"\\s*\\(",_={
keyword:["asm","auto","break","case","continue","default","do","else","enum","extern","for","fortran","goto","if","inline","register","restrict","return","sizeof","typeof","typeof_unqual","struct","switch","typedef","union","volatile","while","_Alignas","_Alignof","_Atomic","_Generic","_Noreturn","_Static_assert","_Thread_local","alignas","alignof","noreturn","static_assert","thread_local","_Pragma"],
type:["float","double","signed","unsigned","int","short","long","char","void","_Bool","_BitInt","_Complex","_Imaginary","_Decimal32","_Decimal64","_Decimal96","_Decimal128","_Decimal64x","_Decimal128x","_Float16","_Float32","_Float64","_Float128","_Float32x","_Float64x","_Float128x","const","static","constexpr","complex","bool","imaginary"],
literal:"true false NULL",
built_in:"std string wstring cin cout cerr clog stdin stdout stderr stringstream istringstream ostringstream auto_ptr deque list queue stack vector map set pair bitset multiset multimap unordered_set unordered_map unordered_multiset unordered_multimap priority_queue make_pair array shared_ptr abort terminate abs acos asin atan2 atan calloc ceil cosh cos exit exp fabs floor fmod fprintf fputs free frexp fscanf future isalnum isalpha iscntrl isdigit isgraph islower isprint ispunct isspace isupper isxdigit tolower toupper labs ldexp log10 log malloc realloc memchr memcmp memcpy memset modf pow printf putchar puts scanf sinh sin snprintf sprintf sqrt sscanf strcat strchr strcmp strcpy strcspn strlen strncat strncmp strncpy strpbrk strrchr strspn strstr tanh tan vfprintf vprintf vsprintf endl initializer_list unique_ptr"
},u=[c,i,a,e.C_BLOCK_COMMENT_MODE,o,l],p={variants:[{begin:/=/,end:/;/},{
begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],
keywords:_,contains:u.concat([{begin:/\(/,end:/\)/,keywords:_,
contains:u.concat(["self"]),relevance:0}]),relevance:0},f={
begin:"("+r+"[\\*&\\s]+)+"+m,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,
keywords:_,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:n,keywords:_,relevance:0},{
begin:m,returnBegin:!0,contains:[e.inherit(d,{className:"title.function"})],
relevance:0},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,
keywords:_,relevance:0,contains:[a,e.C_BLOCK_COMMENT_MODE,l,o,i,{begin:/\(/,
end:/\)/,keywords:_,relevance:0,contains:["self",a,e.C_BLOCK_COMMENT_MODE,l,o,i]
}]},i,a,e.C_BLOCK_COMMENT_MODE,c]};return{name:"C",aliases:["h"],keywords:_,
disableAutodetect:!0,illegal:"</",contains:[].concat(p,f,u,[c,{
begin:e.IDENT_RE+"::",keywords:_},{className:"class",
beginKeywords:"enum class struct union",end:/[{;:<>=]/,contains:[{
beginKeywords:"final class struct"},e.TITLE_MODE]}]),exports:{preprocessor:c,
strings:l,keywords:_}}}})();export default hljsGrammar;

View File

@@ -0,0 +1,957 @@
/*! `css` grammar compiled for Highlight.js 11.11.1 */
var hljsGrammar = (function () {
'use strict';
const MODES = (hljs) => {
return {
IMPORTANT: {
scope: 'meta',
begin: '!important'
},
BLOCK_COMMENT: hljs.C_BLOCK_COMMENT_MODE,
HEXCOLOR: {
scope: 'number',
begin: /#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/
},
FUNCTION_DISPATCH: {
className: "built_in",
begin: /[\w-]+(?=\()/
},
ATTRIBUTE_SELECTOR_MODE: {
scope: 'selector-attr',
begin: /\[/,
end: /\]/,
illegal: '$',
contains: [
hljs.APOS_STRING_MODE,
hljs.QUOTE_STRING_MODE
]
},
CSS_NUMBER_MODE: {
scope: 'number',
begin: hljs.NUMBER_RE + '(' +
'%|em|ex|ch|rem' +
'|vw|vh|vmin|vmax' +
'|cm|mm|in|pt|pc|px' +
'|deg|grad|rad|turn' +
'|s|ms' +
'|Hz|kHz' +
'|dpi|dpcm|dppx' +
')?',
relevance: 0
},
CSS_VARIABLE: {
className: "attr",
begin: /--[A-Za-z_][A-Za-z0-9_-]*/
}
};
};
const HTML_TAGS = [
'a',
'abbr',
'address',
'article',
'aside',
'audio',
'b',
'blockquote',
'body',
'button',
'canvas',
'caption',
'cite',
'code',
'dd',
'del',
'details',
'dfn',
'div',
'dl',
'dt',
'em',
'fieldset',
'figcaption',
'figure',
'footer',
'form',
'h1',
'h2',
'h3',
'h4',
'h5',
'h6',
'header',
'hgroup',
'html',
'i',
'iframe',
'img',
'input',
'ins',
'kbd',
'label',
'legend',
'li',
'main',
'mark',
'menu',
'nav',
'object',
'ol',
'optgroup',
'option',
'p',
'picture',
'q',
'quote',
'samp',
'section',
'select',
'source',
'span',
'strong',
'summary',
'sup',
'table',
'tbody',
'td',
'textarea',
'tfoot',
'th',
'thead',
'time',
'tr',
'ul',
'var',
'video'
];
const SVG_TAGS = [
'defs',
'g',
'marker',
'mask',
'pattern',
'svg',
'switch',
'symbol',
'feBlend',
'feColorMatrix',
'feComponentTransfer',
'feComposite',
'feConvolveMatrix',
'feDiffuseLighting',
'feDisplacementMap',
'feFlood',
'feGaussianBlur',
'feImage',
'feMerge',
'feMorphology',
'feOffset',
'feSpecularLighting',
'feTile',
'feTurbulence',
'linearGradient',
'radialGradient',
'stop',
'circle',
'ellipse',
'image',
'line',
'path',
'polygon',
'polyline',
'rect',
'text',
'use',
'textPath',
'tspan',
'foreignObject',
'clipPath'
];
const TAGS = [
...HTML_TAGS,
...SVG_TAGS,
];
// Sorting, then reversing makes sure longer attributes/elements like
// `font-weight` are matched fully instead of getting false positives on say `font`
const MEDIA_FEATURES = [
'any-hover',
'any-pointer',
'aspect-ratio',
'color',
'color-gamut',
'color-index',
'device-aspect-ratio',
'device-height',
'device-width',
'display-mode',
'forced-colors',
'grid',
'height',
'hover',
'inverted-colors',
'monochrome',
'orientation',
'overflow-block',
'overflow-inline',
'pointer',
'prefers-color-scheme',
'prefers-contrast',
'prefers-reduced-motion',
'prefers-reduced-transparency',
'resolution',
'scan',
'scripting',
'update',
'width',
// TODO: find a better solution?
'min-width',
'max-width',
'min-height',
'max-height'
].sort().reverse();
// https://developer.mozilla.org/en-US/docs/Web/CSS/Pseudo-classes
const PSEUDO_CLASSES = [
'active',
'any-link',
'blank',
'checked',
'current',
'default',
'defined',
'dir', // dir()
'disabled',
'drop',
'empty',
'enabled',
'first',
'first-child',
'first-of-type',
'fullscreen',
'future',
'focus',
'focus-visible',
'focus-within',
'has', // has()
'host', // host or host()
'host-context', // host-context()
'hover',
'indeterminate',
'in-range',
'invalid',
'is', // is()
'lang', // lang()
'last-child',
'last-of-type',
'left',
'link',
'local-link',
'not', // not()
'nth-child', // nth-child()
'nth-col', // nth-col()
'nth-last-child', // nth-last-child()
'nth-last-col', // nth-last-col()
'nth-last-of-type', //nth-last-of-type()
'nth-of-type', //nth-of-type()
'only-child',
'only-of-type',
'optional',
'out-of-range',
'past',
'placeholder-shown',
'read-only',
'read-write',
'required',
'right',
'root',
'scope',
'target',
'target-within',
'user-invalid',
'valid',
'visited',
'where' // where()
].sort().reverse();
// https://developer.mozilla.org/en-US/docs/Web/CSS/Pseudo-elements
const PSEUDO_ELEMENTS = [
'after',
'backdrop',
'before',
'cue',
'cue-region',
'first-letter',
'first-line',
'grammar-error',
'marker',
'part',
'placeholder',
'selection',
'slotted',
'spelling-error'
].sort().reverse();
const ATTRIBUTES = [
'accent-color',
'align-content',
'align-items',
'align-self',
'alignment-baseline',
'all',
'anchor-name',
'animation',
'animation-composition',
'animation-delay',
'animation-direction',
'animation-duration',
'animation-fill-mode',
'animation-iteration-count',
'animation-name',
'animation-play-state',
'animation-range',
'animation-range-end',
'animation-range-start',
'animation-timeline',
'animation-timing-function',
'appearance',
'aspect-ratio',
'backdrop-filter',
'backface-visibility',
'background',
'background-attachment',
'background-blend-mode',
'background-clip',
'background-color',
'background-image',
'background-origin',
'background-position',
'background-position-x',
'background-position-y',
'background-repeat',
'background-size',
'baseline-shift',
'block-size',
'border',
'border-block',
'border-block-color',
'border-block-end',
'border-block-end-color',
'border-block-end-style',
'border-block-end-width',
'border-block-start',
'border-block-start-color',
'border-block-start-style',
'border-block-start-width',
'border-block-style',
'border-block-width',
'border-bottom',
'border-bottom-color',
'border-bottom-left-radius',
'border-bottom-right-radius',
'border-bottom-style',
'border-bottom-width',
'border-collapse',
'border-color',
'border-end-end-radius',
'border-end-start-radius',
'border-image',
'border-image-outset',
'border-image-repeat',
'border-image-slice',
'border-image-source',
'border-image-width',
'border-inline',
'border-inline-color',
'border-inline-end',
'border-inline-end-color',
'border-inline-end-style',
'border-inline-end-width',
'border-inline-start',
'border-inline-start-color',
'border-inline-start-style',
'border-inline-start-width',
'border-inline-style',
'border-inline-width',
'border-left',
'border-left-color',
'border-left-style',
'border-left-width',
'border-radius',
'border-right',
'border-right-color',
'border-right-style',
'border-right-width',
'border-spacing',
'border-start-end-radius',
'border-start-start-radius',
'border-style',
'border-top',
'border-top-color',
'border-top-left-radius',
'border-top-right-radius',
'border-top-style',
'border-top-width',
'border-width',
'bottom',
'box-align',
'box-decoration-break',
'box-direction',
'box-flex',
'box-flex-group',
'box-lines',
'box-ordinal-group',
'box-orient',
'box-pack',
'box-shadow',
'box-sizing',
'break-after',
'break-before',
'break-inside',
'caption-side',
'caret-color',
'clear',
'clip',
'clip-path',
'clip-rule',
'color',
'color-interpolation',
'color-interpolation-filters',
'color-profile',
'color-rendering',
'color-scheme',
'column-count',
'column-fill',
'column-gap',
'column-rule',
'column-rule-color',
'column-rule-style',
'column-rule-width',
'column-span',
'column-width',
'columns',
'contain',
'contain-intrinsic-block-size',
'contain-intrinsic-height',
'contain-intrinsic-inline-size',
'contain-intrinsic-size',
'contain-intrinsic-width',
'container',
'container-name',
'container-type',
'content',
'content-visibility',
'counter-increment',
'counter-reset',
'counter-set',
'cue',
'cue-after',
'cue-before',
'cursor',
'cx',
'cy',
'direction',
'display',
'dominant-baseline',
'empty-cells',
'enable-background',
'field-sizing',
'fill',
'fill-opacity',
'fill-rule',
'filter',
'flex',
'flex-basis',
'flex-direction',
'flex-flow',
'flex-grow',
'flex-shrink',
'flex-wrap',
'float',
'flood-color',
'flood-opacity',
'flow',
'font',
'font-display',
'font-family',
'font-feature-settings',
'font-kerning',
'font-language-override',
'font-optical-sizing',
'font-palette',
'font-size',
'font-size-adjust',
'font-smooth',
'font-smoothing',
'font-stretch',
'font-style',
'font-synthesis',
'font-synthesis-position',
'font-synthesis-small-caps',
'font-synthesis-style',
'font-synthesis-weight',
'font-variant',
'font-variant-alternates',
'font-variant-caps',
'font-variant-east-asian',
'font-variant-emoji',
'font-variant-ligatures',
'font-variant-numeric',
'font-variant-position',
'font-variation-settings',
'font-weight',
'forced-color-adjust',
'gap',
'glyph-orientation-horizontal',
'glyph-orientation-vertical',
'grid',
'grid-area',
'grid-auto-columns',
'grid-auto-flow',
'grid-auto-rows',
'grid-column',
'grid-column-end',
'grid-column-start',
'grid-gap',
'grid-row',
'grid-row-end',
'grid-row-start',
'grid-template',
'grid-template-areas',
'grid-template-columns',
'grid-template-rows',
'hanging-punctuation',
'height',
'hyphenate-character',
'hyphenate-limit-chars',
'hyphens',
'icon',
'image-orientation',
'image-rendering',
'image-resolution',
'ime-mode',
'initial-letter',
'initial-letter-align',
'inline-size',
'inset',
'inset-area',
'inset-block',
'inset-block-end',
'inset-block-start',
'inset-inline',
'inset-inline-end',
'inset-inline-start',
'isolation',
'justify-content',
'justify-items',
'justify-self',
'kerning',
'left',
'letter-spacing',
'lighting-color',
'line-break',
'line-height',
'line-height-step',
'list-style',
'list-style-image',
'list-style-position',
'list-style-type',
'margin',
'margin-block',
'margin-block-end',
'margin-block-start',
'margin-bottom',
'margin-inline',
'margin-inline-end',
'margin-inline-start',
'margin-left',
'margin-right',
'margin-top',
'margin-trim',
'marker',
'marker-end',
'marker-mid',
'marker-start',
'marks',
'mask',
'mask-border',
'mask-border-mode',
'mask-border-outset',
'mask-border-repeat',
'mask-border-slice',
'mask-border-source',
'mask-border-width',
'mask-clip',
'mask-composite',
'mask-image',
'mask-mode',
'mask-origin',
'mask-position',
'mask-repeat',
'mask-size',
'mask-type',
'masonry-auto-flow',
'math-depth',
'math-shift',
'math-style',
'max-block-size',
'max-height',
'max-inline-size',
'max-width',
'min-block-size',
'min-height',
'min-inline-size',
'min-width',
'mix-blend-mode',
'nav-down',
'nav-index',
'nav-left',
'nav-right',
'nav-up',
'none',
'normal',
'object-fit',
'object-position',
'offset',
'offset-anchor',
'offset-distance',
'offset-path',
'offset-position',
'offset-rotate',
'opacity',
'order',
'orphans',
'outline',
'outline-color',
'outline-offset',
'outline-style',
'outline-width',
'overflow',
'overflow-anchor',
'overflow-block',
'overflow-clip-margin',
'overflow-inline',
'overflow-wrap',
'overflow-x',
'overflow-y',
'overlay',
'overscroll-behavior',
'overscroll-behavior-block',
'overscroll-behavior-inline',
'overscroll-behavior-x',
'overscroll-behavior-y',
'padding',
'padding-block',
'padding-block-end',
'padding-block-start',
'padding-bottom',
'padding-inline',
'padding-inline-end',
'padding-inline-start',
'padding-left',
'padding-right',
'padding-top',
'page',
'page-break-after',
'page-break-before',
'page-break-inside',
'paint-order',
'pause',
'pause-after',
'pause-before',
'perspective',
'perspective-origin',
'place-content',
'place-items',
'place-self',
'pointer-events',
'position',
'position-anchor',
'position-visibility',
'print-color-adjust',
'quotes',
'r',
'resize',
'rest',
'rest-after',
'rest-before',
'right',
'rotate',
'row-gap',
'ruby-align',
'ruby-position',
'scale',
'scroll-behavior',
'scroll-margin',
'scroll-margin-block',
'scroll-margin-block-end',
'scroll-margin-block-start',
'scroll-margin-bottom',
'scroll-margin-inline',
'scroll-margin-inline-end',
'scroll-margin-inline-start',
'scroll-margin-left',
'scroll-margin-right',
'scroll-margin-top',
'scroll-padding',
'scroll-padding-block',
'scroll-padding-block-end',
'scroll-padding-block-start',
'scroll-padding-bottom',
'scroll-padding-inline',
'scroll-padding-inline-end',
'scroll-padding-inline-start',
'scroll-padding-left',
'scroll-padding-right',
'scroll-padding-top',
'scroll-snap-align',
'scroll-snap-stop',
'scroll-snap-type',
'scroll-timeline',
'scroll-timeline-axis',
'scroll-timeline-name',
'scrollbar-color',
'scrollbar-gutter',
'scrollbar-width',
'shape-image-threshold',
'shape-margin',
'shape-outside',
'shape-rendering',
'speak',
'speak-as',
'src', // @font-face
'stop-color',
'stop-opacity',
'stroke',
'stroke-dasharray',
'stroke-dashoffset',
'stroke-linecap',
'stroke-linejoin',
'stroke-miterlimit',
'stroke-opacity',
'stroke-width',
'tab-size',
'table-layout',
'text-align',
'text-align-all',
'text-align-last',
'text-anchor',
'text-combine-upright',
'text-decoration',
'text-decoration-color',
'text-decoration-line',
'text-decoration-skip',
'text-decoration-skip-ink',
'text-decoration-style',
'text-decoration-thickness',
'text-emphasis',
'text-emphasis-color',
'text-emphasis-position',
'text-emphasis-style',
'text-indent',
'text-justify',
'text-orientation',
'text-overflow',
'text-rendering',
'text-shadow',
'text-size-adjust',
'text-transform',
'text-underline-offset',
'text-underline-position',
'text-wrap',
'text-wrap-mode',
'text-wrap-style',
'timeline-scope',
'top',
'touch-action',
'transform',
'transform-box',
'transform-origin',
'transform-style',
'transition',
'transition-behavior',
'transition-delay',
'transition-duration',
'transition-property',
'transition-timing-function',
'translate',
'unicode-bidi',
'user-modify',
'user-select',
'vector-effect',
'vertical-align',
'view-timeline',
'view-timeline-axis',
'view-timeline-inset',
'view-timeline-name',
'view-transition-name',
'visibility',
'voice-balance',
'voice-duration',
'voice-family',
'voice-pitch',
'voice-range',
'voice-rate',
'voice-stress',
'voice-volume',
'white-space',
'white-space-collapse',
'widows',
'width',
'will-change',
'word-break',
'word-spacing',
'word-wrap',
'writing-mode',
'x',
'y',
'z-index',
'zoom'
].sort().reverse();
/*
Language: CSS
Category: common, css, web
Website: https://developer.mozilla.org/en-US/docs/Web/CSS
*/
/** @type LanguageFn */
function css(hljs) {
const regex = hljs.regex;
const modes = MODES(hljs);
const VENDOR_PREFIX = { begin: /-(webkit|moz|ms|o)-(?=[a-z])/ };
const AT_MODIFIERS = "and or not only";
const AT_PROPERTY_RE = /@-?\w[\w]*(-\w+)*/; // @-webkit-keyframes
const IDENT_RE = '[a-zA-Z-][a-zA-Z0-9_-]*';
const STRINGS = [
hljs.APOS_STRING_MODE,
hljs.QUOTE_STRING_MODE
];
return {
name: 'CSS',
case_insensitive: true,
illegal: /[=|'\$]/,
keywords: { keyframePosition: "from to" },
classNameAliases: {
// for visual continuity with `tag {}` and because we
// don't have a great class for this?
keyframePosition: "selector-tag" },
contains: [
modes.BLOCK_COMMENT,
VENDOR_PREFIX,
// to recognize keyframe 40% etc which are outside the scope of our
// attribute value mode
modes.CSS_NUMBER_MODE,
{
className: 'selector-id',
begin: /#[A-Za-z0-9_-]+/,
relevance: 0
},
{
className: 'selector-class',
begin: '\\.' + IDENT_RE,
relevance: 0
},
modes.ATTRIBUTE_SELECTOR_MODE,
{
className: 'selector-pseudo',
variants: [
{ begin: ':(' + PSEUDO_CLASSES.join('|') + ')' },
{ begin: ':(:)?(' + PSEUDO_ELEMENTS.join('|') + ')' }
]
},
// we may actually need this (12/2020)
// { // pseudo-selector params
// begin: /\(/,
// end: /\)/,
// contains: [ hljs.CSS_NUMBER_MODE ]
// },
modes.CSS_VARIABLE,
{
className: 'attribute',
begin: '\\b(' + ATTRIBUTES.join('|') + ')\\b'
},
// attribute values
{
begin: /:/,
end: /[;}{]/,
contains: [
modes.BLOCK_COMMENT,
modes.HEXCOLOR,
modes.IMPORTANT,
modes.CSS_NUMBER_MODE,
...STRINGS,
// needed to highlight these as strings and to avoid issues with
// illegal characters that might be inside urls that would tigger the
// languages illegal stack
{
begin: /(url|data-uri)\(/,
end: /\)/,
relevance: 0, // from keywords
keywords: { built_in: "url data-uri" },
contains: [
...STRINGS,
{
className: "string",
// any character other than `)` as in `url()` will be the start
// of a string, which ends with `)` (from the parent mode)
begin: /[^)]/,
endsWithParent: true,
excludeEnd: true
}
]
},
modes.FUNCTION_DISPATCH
]
},
{
begin: regex.lookahead(/@/),
end: '[{;]',
relevance: 0,
illegal: /:/, // break on Less variables @var: ...
contains: [
{
className: 'keyword',
begin: AT_PROPERTY_RE
},
{
begin: /\s/,
endsWithParent: true,
excludeEnd: true,
relevance: 0,
keywords: {
$pattern: /[a-z-]+/,
keyword: AT_MODIFIERS,
attribute: MEDIA_FEATURES.join(" ")
},
contains: [
{
begin: /[a-z-]+(?=:)/,
className: "attribute"
},
...STRINGS,
modes.CSS_NUMBER_MODE
]
}
]
},
{
className: 'selector-tag',
begin: '\\b(' + TAGS.join('|') + ')\\b'
}
]
};
}
return css;
})();
;
export default hljsGrammar;

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,83 @@
/*! `django` grammar compiled for Highlight.js 11.11.1 */
var hljsGrammar = (function () {
'use strict';
/*
Language: Django
Description: Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design.
Requires: xml.js
Author: Ivan Sagalaev <maniac@softwaremaniacs.org>
Contributors: Ilya Baryshev <baryshev@gmail.com>
Website: https://www.djangoproject.com
Category: template
*/
/** @type LanguageFn */
function django(hljs) {
const FILTER = {
begin: /\|[A-Za-z]+:?/,
keywords: { name:
'truncatewords removetags linebreaksbr yesno get_digit timesince random striptags '
+ 'filesizeformat escape linebreaks length_is ljust rjust cut urlize fix_ampersands '
+ 'title floatformat capfirst pprint divisibleby add make_list unordered_list urlencode '
+ 'timeuntil urlizetrunc wordcount stringformat linenumbers slice date dictsort '
+ 'dictsortreversed default_if_none pluralize lower join center default '
+ 'truncatewords_html upper length phone2numeric wordwrap time addslashes slugify first '
+ 'escapejs force_escape iriencode last safe safeseq truncatechars localize unlocalize '
+ 'localtime utc timezone' },
contains: [
hljs.QUOTE_STRING_MODE,
hljs.APOS_STRING_MODE
]
};
return {
name: 'Django',
aliases: [ 'jinja' ],
case_insensitive: true,
subLanguage: 'xml',
contains: [
hljs.COMMENT(/\{%\s*comment\s*%\}/, /\{%\s*endcomment\s*%\}/),
hljs.COMMENT(/\{#/, /#\}/),
{
className: 'template-tag',
begin: /\{%/,
end: /%\}/,
contains: [
{
className: 'name',
begin: /\w+/,
keywords: { name:
'comment endcomment load templatetag ifchanged endifchanged if endif firstof for '
+ 'endfor ifnotequal endifnotequal widthratio extends include spaceless '
+ 'endspaceless regroup ifequal endifequal ssi now with cycle url filter '
+ 'endfilter debug block endblock else autoescape endautoescape csrf_token empty elif '
+ 'endwith static trans blocktrans endblocktrans get_static_prefix get_media_prefix '
+ 'plural get_current_language language get_available_languages '
+ 'get_current_language_bidi get_language_info get_language_info_list localize '
+ 'endlocalize localtime endlocaltime timezone endtimezone get_current_timezone '
+ 'verbatim' },
starts: {
endsWithParent: true,
keywords: 'in by as',
contains: [ FILTER ],
relevance: 0
}
}
]
},
{
className: 'template-variable',
begin: /\{\{/,
end: /\}\}/,
contains: [ FILTER ]
}
]
};
}
return django;
})();
;
export default hljsGrammar;

View File

@@ -0,0 +1,13 @@
/*! `django` grammar compiled for Highlight.js 11.11.1 */
var hljsGrammar=(()=>{"use strict";return e=>{const a={begin:/\|[A-Za-z]+:?/,
keywords:{
name:"truncatewords removetags linebreaksbr yesno get_digit timesince random striptags filesizeformat escape linebreaks length_is ljust rjust cut urlize fix_ampersands title floatformat capfirst pprint divisibleby add make_list unordered_list urlencode timeuntil urlizetrunc wordcount stringformat linenumbers slice date dictsort dictsortreversed default_if_none pluralize lower join center default truncatewords_html upper length phone2numeric wordwrap time addslashes slugify first escapejs force_escape iriencode last safe safeseq truncatechars localize unlocalize localtime utc timezone"
},contains:[e.QUOTE_STRING_MODE,e.APOS_STRING_MODE]};return{name:"Django",
aliases:["jinja"],case_insensitive:!0,subLanguage:"xml",
contains:[e.COMMENT(/\{%\s*comment\s*%\}/,/\{%\s*endcomment\s*%\}/),e.COMMENT(/\{#/,/#\}/),{
className:"template-tag",begin:/\{%/,end:/%\}/,contains:[{className:"name",
begin:/\w+/,keywords:{
name:"comment endcomment load templatetag ifchanged endifchanged if endif firstof for endfor ifnotequal endifnotequal widthratio extends include spaceless endspaceless regroup ifequal endifequal ssi now with cycle url filter endfilter debug block endblock else autoescape endautoescape csrf_token empty elif endwith static trans blocktrans endblocktrans get_static_prefix get_media_prefix plural get_current_language language get_available_languages get_current_language_bidi get_language_info get_language_info_list localize endlocalize localtime endlocaltime timezone endtimezone get_current_timezone verbatim"
},starts:{endsWithParent:!0,keywords:"in by as",contains:[a],relevance:0}}]},{
className:"template-variable",begin:/\{\{/,end:/\}\}/,contains:[a]}]}}})()
;export default hljsGrammar;

View File

@@ -0,0 +1,52 @@
/*! `dockerfile` grammar compiled for Highlight.js 11.11.1 */
var hljsGrammar = (function () {
'use strict';
/*
Language: Dockerfile
Requires: bash.js
Author: Alexis Hénaut <alexis@henaut.net>
Description: language definition for Dockerfile files
Website: https://docs.docker.com/engine/reference/builder/
Category: config
*/
/** @type LanguageFn */
function dockerfile(hljs) {
const KEYWORDS = [
"from",
"maintainer",
"expose",
"env",
"arg",
"user",
"onbuild",
"stopsignal"
];
return {
name: 'Dockerfile',
aliases: [ 'docker' ],
case_insensitive: true,
keywords: KEYWORDS,
contains: [
hljs.HASH_COMMENT_MODE,
hljs.APOS_STRING_MODE,
hljs.QUOTE_STRING_MODE,
hljs.NUMBER_MODE,
{
beginKeywords: 'run cmd entrypoint volume add copy workdir label healthcheck shell',
starts: {
end: /[^\\]$/,
subLanguage: 'bash'
}
}
],
illegal: '</'
};
}
return dockerfile;
})();
;
export default hljsGrammar;

View File

@@ -0,0 +1,8 @@
/*! `dockerfile` grammar compiled for Highlight.js 11.11.1 */
var hljsGrammar=(()=>{"use strict";return e=>({name:"Dockerfile",
aliases:["docker"],case_insensitive:!0,
keywords:["from","maintainer","expose","env","arg","user","onbuild","stopsignal"],
contains:[e.HASH_COMMENT_MODE,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,e.NUMBER_MODE,{
beginKeywords:"run cmd entrypoint volume add copy workdir label healthcheck shell",
starts:{end:/[^\\]$/,subLanguage:"bash"}}],illegal:"</"})})()
;export default hljsGrammar;

View File

@@ -0,0 +1,164 @@
/*! `go` grammar compiled for Highlight.js 11.11.1 */
var hljsGrammar = (function () {
'use strict';
/*
Language: Go
Author: Stephan Kountso aka StepLg <steplg@gmail.com>
Contributors: Evgeny Stepanischev <imbolk@gmail.com>
Description: Google go language (golang). For info about language
Website: http://golang.org/
Category: common, system
*/
function go(hljs) {
const LITERALS = [
"true",
"false",
"iota",
"nil"
];
const BUILT_INS = [
"append",
"cap",
"close",
"complex",
"copy",
"imag",
"len",
"make",
"new",
"panic",
"print",
"println",
"real",
"recover",
"delete"
];
const TYPES = [
"bool",
"byte",
"complex64",
"complex128",
"error",
"float32",
"float64",
"int8",
"int16",
"int32",
"int64",
"string",
"uint8",
"uint16",
"uint32",
"uint64",
"int",
"uint",
"uintptr",
"rune"
];
const KWS = [
"break",
"case",
"chan",
"const",
"continue",
"default",
"defer",
"else",
"fallthrough",
"for",
"func",
"go",
"goto",
"if",
"import",
"interface",
"map",
"package",
"range",
"return",
"select",
"struct",
"switch",
"type",
"var",
];
const KEYWORDS = {
keyword: KWS,
type: TYPES,
literal: LITERALS,
built_in: BUILT_INS
};
return {
name: 'Go',
aliases: [ 'golang' ],
keywords: KEYWORDS,
illegal: '</',
contains: [
hljs.C_LINE_COMMENT_MODE,
hljs.C_BLOCK_COMMENT_MODE,
{
className: 'string',
variants: [
hljs.QUOTE_STRING_MODE,
hljs.APOS_STRING_MODE,
{
begin: '`',
end: '`'
}
]
},
{
className: 'number',
variants: [
{
match: /-?\b0[xX]\.[a-fA-F0-9](_?[a-fA-F0-9])*[pP][+-]?\d(_?\d)*i?/, // hex without a present digit before . (making a digit afterwards required)
relevance: 0
},
{
match: /-?\b0[xX](_?[a-fA-F0-9])+((\.([a-fA-F0-9](_?[a-fA-F0-9])*)?)?[pP][+-]?\d(_?\d)*)?i?/, // hex with a present digit before . (making a digit afterwards optional)
relevance: 0
},
{
match: /-?\b0[oO](_?[0-7])*i?/, // leading 0o octal
relevance: 0
},
{
match: /-?\.\d(_?\d)*([eE][+-]?\d(_?\d)*)?i?/, // decimal without a present digit before . (making a digit afterwards required)
relevance: 0
},
{
match: /-?\b\d(_?\d)*(\.(\d(_?\d)*)?)?([eE][+-]?\d(_?\d)*)?i?/, // decimal with a present digit before . (making a digit afterwards optional)
relevance: 0
}
]
},
{ begin: /:=/ // relevance booster
},
{
className: 'function',
beginKeywords: 'func',
end: '\\s*(\\{|$)',
excludeEnd: true,
contains: [
hljs.TITLE_MODE,
{
className: 'params',
begin: /\(/,
end: /\)/,
endsParent: true,
keywords: KEYWORDS,
illegal: /["']/
}
]
}
]
};
}
return go;
})();
;
export default hljsGrammar;

View File

@@ -0,0 +1,19 @@
/*! `go` grammar compiled for Highlight.js 11.11.1 */
var hljsGrammar=(()=>{"use strict";return e=>{const a={
keyword:["break","case","chan","const","continue","default","defer","else","fallthrough","for","func","go","goto","if","import","interface","map","package","range","return","select","struct","switch","type","var"],
type:["bool","byte","complex64","complex128","error","float32","float64","int8","int16","int32","int64","string","uint8","uint16","uint32","uint64","int","uint","uintptr","rune"],
literal:["true","false","iota","nil"],
built_in:["append","cap","close","complex","copy","imag","len","make","new","panic","print","println","real","recover","delete"]
};return{name:"Go",aliases:["golang"],keywords:a,illegal:"</",
contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,{className:"string",
variants:[e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,{begin:"`",end:"`"}]},{
className:"number",variants:[{
match:/-?\b0[xX]\.[a-fA-F0-9](_?[a-fA-F0-9])*[pP][+-]?\d(_?\d)*i?/,relevance:0
},{
match:/-?\b0[xX](_?[a-fA-F0-9])+((\.([a-fA-F0-9](_?[a-fA-F0-9])*)?)?[pP][+-]?\d(_?\d)*)?i?/,
relevance:0},{match:/-?\b0[oO](_?[0-7])*i?/,relevance:0},{
match:/-?\.\d(_?\d)*([eE][+-]?\d(_?\d)*)?i?/,relevance:0},{
match:/-?\b\d(_?\d)*(\.(\d(_?\d)*)?)?([eE][+-]?\d(_?\d)*)?i?/,relevance:0}]},{
begin:/:=/},{className:"function",beginKeywords:"func",end:"\\s*(\\{|$)",
excludeEnd:!0,contains:[e.TITLE_MODE,{className:"params",begin:/\(/,end:/\)/,
endsParent:!0,keywords:a,illegal:/["']/}]}]}}})();export default hljsGrammar;

View File

@@ -0,0 +1,105 @@
/*! `http` grammar compiled for Highlight.js 11.11.1 */
var hljsGrammar = (function () {
'use strict';
/*
Language: HTTP
Description: HTTP request and response headers with automatic body highlighting
Author: Ivan Sagalaev <maniac@softwaremaniacs.org>
Category: protocols, web
Website: https://developer.mozilla.org/en-US/docs/Web/HTTP/Overview
*/
function http(hljs) {
const regex = hljs.regex;
const VERSION = 'HTTP/([32]|1\\.[01])';
const HEADER_NAME = /[A-Za-z][A-Za-z0-9-]*/;
const HEADER = {
className: 'attribute',
begin: regex.concat('^', HEADER_NAME, '(?=\\:\\s)'),
starts: { contains: [
{
className: "punctuation",
begin: /: /,
relevance: 0,
starts: {
end: '$',
relevance: 0
}
}
] }
};
const HEADERS_AND_BODY = [
HEADER,
{
begin: '\\n\\n',
starts: {
subLanguage: [],
endsWithParent: true
}
}
];
return {
name: 'HTTP',
aliases: [ 'https' ],
illegal: /\S/,
contains: [
// response
{
begin: '^(?=' + VERSION + " \\d{3})",
end: /$/,
contains: [
{
className: "meta",
begin: VERSION
},
{
className: 'number',
begin: '\\b\\d{3}\\b'
}
],
starts: {
end: /\b\B/,
illegal: /\S/,
contains: HEADERS_AND_BODY
}
},
// request
{
begin: '(?=^[A-Z]+ (.*?) ' + VERSION + '$)',
end: /$/,
contains: [
{
className: 'string',
begin: ' ',
end: ' ',
excludeBegin: true,
excludeEnd: true
},
{
className: "meta",
begin: VERSION
},
{
className: 'keyword',
begin: '[A-Z]+'
}
],
starts: {
end: /\b\B/,
illegal: /\S/,
contains: HEADERS_AND_BODY
}
},
// to allow headers to work even without a preamble
hljs.inherit(HEADER, { relevance: 0 })
]
};
}
return http;
})();
;
export default hljsGrammar;

View File

@@ -0,0 +1,14 @@
/*! `http` grammar compiled for Highlight.js 11.11.1 */
var hljsGrammar=(()=>{"use strict";return e=>{const a="HTTP/([32]|1\\.[01])",n={
className:"attribute",
begin:e.regex.concat("^",/[A-Za-z][A-Za-z0-9-]*/,"(?=\\:\\s)"),starts:{
contains:[{className:"punctuation",begin:/: /,relevance:0,starts:{end:"$",
relevance:0}}]}},s=[n,{begin:"\\n\\n",starts:{subLanguage:[],endsWithParent:!0}
}];return{name:"HTTP",aliases:["https"],illegal:/\S/,contains:[{
begin:"^(?="+a+" \\d{3})",end:/$/,contains:[{className:"meta",begin:a},{
className:"number",begin:"\\b\\d{3}\\b"}],starts:{end:/\b\B/,illegal:/\S/,
contains:s}},{begin:"(?=^[A-Z]+ (.*?) "+a+"$)",end:/$/,contains:[{
className:"string",begin:" ",end:" ",excludeBegin:!0,excludeEnd:!0},{
className:"meta",begin:a},{className:"keyword",begin:"[A-Z]+"}],starts:{
end:/\b\B/,illegal:/\S/,contains:s}},e.inherit(n,{relevance:0})]}}})()
;export default hljsGrammar;

View File

@@ -0,0 +1,129 @@
/*! `ini` grammar compiled for Highlight.js 11.11.1 */
var hljsGrammar = (function () {
'use strict';
/*
Language: TOML, also INI
Description: TOML aims to be a minimal configuration file format that's easy to read due to obvious semantics.
Contributors: Guillaume Gomez <guillaume1.gomez@gmail.com>
Category: common, config
Website: https://github.com/toml-lang/toml
*/
function ini(hljs) {
const regex = hljs.regex;
const NUMBERS = {
className: 'number',
relevance: 0,
variants: [
{ begin: /([+-]+)?[\d]+_[\d_]+/ },
{ begin: hljs.NUMBER_RE }
]
};
const COMMENTS = hljs.COMMENT();
COMMENTS.variants = [
{
begin: /;/,
end: /$/
},
{
begin: /#/,
end: /$/
}
];
const VARIABLES = {
className: 'variable',
variants: [
{ begin: /\$[\w\d"][\w\d_]*/ },
{ begin: /\$\{(.*?)\}/ }
]
};
const LITERALS = {
className: 'literal',
begin: /\bon|off|true|false|yes|no\b/
};
const STRINGS = {
className: "string",
contains: [ hljs.BACKSLASH_ESCAPE ],
variants: [
{
begin: "'''",
end: "'''",
relevance: 10
},
{
begin: '"""',
end: '"""',
relevance: 10
},
{
begin: '"',
end: '"'
},
{
begin: "'",
end: "'"
}
]
};
const ARRAY = {
begin: /\[/,
end: /\]/,
contains: [
COMMENTS,
LITERALS,
VARIABLES,
STRINGS,
NUMBERS,
'self'
],
relevance: 0
};
const BARE_KEY = /[A-Za-z0-9_-]+/;
const QUOTED_KEY_DOUBLE_QUOTE = /"(\\"|[^"])*"/;
const QUOTED_KEY_SINGLE_QUOTE = /'[^']*'/;
const ANY_KEY = regex.either(
BARE_KEY, QUOTED_KEY_DOUBLE_QUOTE, QUOTED_KEY_SINGLE_QUOTE
);
const DOTTED_KEY = regex.concat(
ANY_KEY, '(\\s*\\.\\s*', ANY_KEY, ')*',
regex.lookahead(/\s*=\s*[^#\s]/)
);
return {
name: 'TOML, also INI',
aliases: [ 'toml' ],
case_insensitive: true,
illegal: /\S/,
contains: [
COMMENTS,
{
className: 'section',
begin: /\[+/,
end: /\]+/
},
{
begin: DOTTED_KEY,
className: 'attr',
starts: {
end: /$/,
contains: [
COMMENTS,
ARRAY,
LITERALS,
VARIABLES,
STRINGS,
NUMBERS
]
}
}
]
};
}
return ini;
})();
;
export default hljsGrammar;

View File

@@ -0,0 +1,16 @@
/*! `ini` grammar compiled for Highlight.js 11.11.1 */
var hljsGrammar=(()=>{"use strict";return e=>{const n=e.regex,a={
className:"number",relevance:0,variants:[{begin:/([+-]+)?[\d]+_[\d_]+/},{
begin:e.NUMBER_RE}]},s=e.COMMENT();s.variants=[{begin:/;/,end:/$/},{begin:/#/,
end:/$/}];const i={className:"variable",variants:[{begin:/\$[\w\d"][\w\d_]*/},{
begin:/\$\{(.*?)\}/}]},r={className:"literal",
begin:/\bon|off|true|false|yes|no\b/},t={className:"string",
contains:[e.BACKSLASH_ESCAPE],variants:[{begin:"'''",end:"'''",relevance:10},{
begin:'"""',end:'"""',relevance:10},{begin:'"',end:'"'},{begin:"'",end:"'"}]
},l={begin:/\[/,end:/\]/,contains:[s,r,i,t,a,"self"],relevance:0
},c=n.either(/[A-Za-z0-9_-]+/,/"(\\"|[^"])*"/,/'[^']*'/);return{
name:"TOML, also INI",aliases:["toml"],case_insensitive:!0,illegal:/\S/,
contains:[s,{className:"section",begin:/\[+/,end:/\]+/},{
begin:n.concat(c,"(\\s*\\.\\s*",c,")*",n.lookahead(/\s*=\s*[^#\s]/)),
className:"attr",starts:{end:/$/,contains:[s,l,r,i,t,a]}}]}}})()
;export default hljsGrammar;

View File

@@ -0,0 +1,777 @@
/*! `javascript` grammar compiled for Highlight.js 11.11.1 */
var hljsGrammar = (function () {
'use strict';
const IDENT_RE = '[A-Za-z$_][0-9A-Za-z$_]*';
const KEYWORDS = [
"as", // for exports
"in",
"of",
"if",
"for",
"while",
"finally",
"var",
"new",
"function",
"do",
"return",
"void",
"else",
"break",
"catch",
"instanceof",
"with",
"throw",
"case",
"default",
"try",
"switch",
"continue",
"typeof",
"delete",
"let",
"yield",
"const",
"class",
// JS handles these with a special rule
// "get",
// "set",
"debugger",
"async",
"await",
"static",
"import",
"from",
"export",
"extends",
// It's reached stage 3, which is "recommended for implementation":
"using"
];
const LITERALS = [
"true",
"false",
"null",
"undefined",
"NaN",
"Infinity"
];
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects
const TYPES = [
// Fundamental objects
"Object",
"Function",
"Boolean",
"Symbol",
// numbers and dates
"Math",
"Date",
"Number",
"BigInt",
// text
"String",
"RegExp",
// Indexed collections
"Array",
"Float32Array",
"Float64Array",
"Int8Array",
"Uint8Array",
"Uint8ClampedArray",
"Int16Array",
"Int32Array",
"Uint16Array",
"Uint32Array",
"BigInt64Array",
"BigUint64Array",
// Keyed collections
"Set",
"Map",
"WeakSet",
"WeakMap",
// Structured data
"ArrayBuffer",
"SharedArrayBuffer",
"Atomics",
"DataView",
"JSON",
// Control abstraction objects
"Promise",
"Generator",
"GeneratorFunction",
"AsyncFunction",
// Reflection
"Reflect",
"Proxy",
// Internationalization
"Intl",
// WebAssembly
"WebAssembly"
];
const ERROR_TYPES = [
"Error",
"EvalError",
"InternalError",
"RangeError",
"ReferenceError",
"SyntaxError",
"TypeError",
"URIError"
];
const BUILT_IN_GLOBALS = [
"setInterval",
"setTimeout",
"clearInterval",
"clearTimeout",
"require",
"exports",
"eval",
"isFinite",
"isNaN",
"parseFloat",
"parseInt",
"decodeURI",
"decodeURIComponent",
"encodeURI",
"encodeURIComponent",
"escape",
"unescape"
];
const BUILT_IN_VARIABLES = [
"arguments",
"this",
"super",
"console",
"window",
"document",
"localStorage",
"sessionStorage",
"module",
"global" // Node.js
];
const BUILT_INS = [].concat(
BUILT_IN_GLOBALS,
TYPES,
ERROR_TYPES
);
/*
Language: JavaScript
Description: JavaScript (JS) is a lightweight, interpreted, or just-in-time compiled programming language with first-class functions.
Category: common, scripting, web
Website: https://developer.mozilla.org/en-US/docs/Web/JavaScript
*/
/** @type LanguageFn */
function javascript(hljs) {
const regex = hljs.regex;
/**
* Takes a string like "<Booger" and checks to see
* if we can find a matching "</Booger" later in the
* content.
* @param {RegExpMatchArray} match
* @param {{after:number}} param1
*/
const hasClosingTag = (match, { after }) => {
const tag = "</" + match[0].slice(1);
const pos = match.input.indexOf(tag, after);
return pos !== -1;
};
const IDENT_RE$1 = IDENT_RE;
const FRAGMENT = {
begin: '<>',
end: '</>'
};
// to avoid some special cases inside isTrulyOpeningTag
const XML_SELF_CLOSING = /<[A-Za-z0-9\\._:-]+\s*\/>/;
const XML_TAG = {
begin: /<[A-Za-z0-9\\._:-]+/,
end: /\/[A-Za-z0-9\\._:-]+>|\/>/,
/**
* @param {RegExpMatchArray} match
* @param {CallbackResponse} response
*/
isTrulyOpeningTag: (match, response) => {
const afterMatchIndex = match[0].length + match.index;
const nextChar = match.input[afterMatchIndex];
if (
// HTML should not include another raw `<` inside a tag
// nested type?
// `<Array<Array<number>>`, etc.
nextChar === "<" ||
// the , gives away that this is not HTML
// `<T, A extends keyof T, V>`
nextChar === ","
) {
response.ignoreMatch();
return;
}
// `<something>`
// Quite possibly a tag, lets look for a matching closing tag...
if (nextChar === ">") {
// if we cannot find a matching closing tag, then we
// will ignore it
if (!hasClosingTag(match, { after: afterMatchIndex })) {
response.ignoreMatch();
}
}
// `<blah />` (self-closing)
// handled by simpleSelfClosing rule
let m;
const afterMatch = match.input.substring(afterMatchIndex);
// some more template typing stuff
// <T = any>(key?: string) => Modify<
if ((m = afterMatch.match(/^\s*=/))) {
response.ignoreMatch();
return;
}
// `<From extends string>`
// technically this could be HTML, but it smells like a type
// NOTE: This is ugh, but added specifically for https://github.com/highlightjs/highlight.js/issues/3276
if ((m = afterMatch.match(/^\s+extends\s+/))) {
if (m.index === 0) {
response.ignoreMatch();
// eslint-disable-next-line no-useless-return
return;
}
}
}
};
const KEYWORDS$1 = {
$pattern: IDENT_RE,
keyword: KEYWORDS,
literal: LITERALS,
built_in: BUILT_INS,
"variable.language": BUILT_IN_VARIABLES
};
// https://tc39.es/ecma262/#sec-literals-numeric-literals
const decimalDigits = '[0-9](_?[0-9])*';
const frac = `\\.(${decimalDigits})`;
// DecimalIntegerLiteral, including Annex B NonOctalDecimalIntegerLiteral
// https://tc39.es/ecma262/#sec-additional-syntax-numeric-literals
const decimalInteger = `0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*`;
const NUMBER = {
className: 'number',
variants: [
// DecimalLiteral
{ begin: `(\\b(${decimalInteger})((${frac})|\\.)?|(${frac}))` +
`[eE][+-]?(${decimalDigits})\\b` },
{ begin: `\\b(${decimalInteger})\\b((${frac})\\b|\\.)?|(${frac})\\b` },
// DecimalBigIntegerLiteral
{ begin: `\\b(0|[1-9](_?[0-9])*)n\\b` },
// NonDecimalIntegerLiteral
{ begin: "\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b" },
{ begin: "\\b0[bB][0-1](_?[0-1])*n?\\b" },
{ begin: "\\b0[oO][0-7](_?[0-7])*n?\\b" },
// LegacyOctalIntegerLiteral (does not include underscore separators)
// https://tc39.es/ecma262/#sec-additional-syntax-numeric-literals
{ begin: "\\b0[0-7]+n?\\b" },
],
relevance: 0
};
const SUBST = {
className: 'subst',
begin: '\\$\\{',
end: '\\}',
keywords: KEYWORDS$1,
contains: [] // defined later
};
const HTML_TEMPLATE = {
begin: '\.?html`',
end: '',
starts: {
end: '`',
returnEnd: false,
contains: [
hljs.BACKSLASH_ESCAPE,
SUBST
],
subLanguage: 'xml'
}
};
const CSS_TEMPLATE = {
begin: '\.?css`',
end: '',
starts: {
end: '`',
returnEnd: false,
contains: [
hljs.BACKSLASH_ESCAPE,
SUBST
],
subLanguage: 'css'
}
};
const GRAPHQL_TEMPLATE = {
begin: '\.?gql`',
end: '',
starts: {
end: '`',
returnEnd: false,
contains: [
hljs.BACKSLASH_ESCAPE,
SUBST
],
subLanguage: 'graphql'
}
};
const TEMPLATE_STRING = {
className: 'string',
begin: '`',
end: '`',
contains: [
hljs.BACKSLASH_ESCAPE,
SUBST
]
};
const JSDOC_COMMENT = hljs.COMMENT(
/\/\*\*(?!\/)/,
'\\*/',
{
relevance: 0,
contains: [
{
begin: '(?=@[A-Za-z]+)',
relevance: 0,
contains: [
{
className: 'doctag',
begin: '@[A-Za-z]+'
},
{
className: 'type',
begin: '\\{',
end: '\\}',
excludeEnd: true,
excludeBegin: true,
relevance: 0
},
{
className: 'variable',
begin: IDENT_RE$1 + '(?=\\s*(-)|$)',
endsParent: true,
relevance: 0
},
// eat spaces (not newlines) so we can find
// types or variables
{
begin: /(?=[^\n])\s/,
relevance: 0
}
]
}
]
}
);
const COMMENT = {
className: "comment",
variants: [
JSDOC_COMMENT,
hljs.C_BLOCK_COMMENT_MODE,
hljs.C_LINE_COMMENT_MODE
]
};
const SUBST_INTERNALS = [
hljs.APOS_STRING_MODE,
hljs.QUOTE_STRING_MODE,
HTML_TEMPLATE,
CSS_TEMPLATE,
GRAPHQL_TEMPLATE,
TEMPLATE_STRING,
// Skip numbers when they are part of a variable name
{ match: /\$\d+/ },
NUMBER,
// This is intentional:
// See https://github.com/highlightjs/highlight.js/issues/3288
// hljs.REGEXP_MODE
];
SUBST.contains = SUBST_INTERNALS
.concat({
// we need to pair up {} inside our subst to prevent
// it from ending too early by matching another }
begin: /\{/,
end: /\}/,
keywords: KEYWORDS$1,
contains: [
"self"
].concat(SUBST_INTERNALS)
});
const SUBST_AND_COMMENTS = [].concat(COMMENT, SUBST.contains);
const PARAMS_CONTAINS = SUBST_AND_COMMENTS.concat([
// eat recursive parens in sub expressions
{
begin: /(\s*)\(/,
end: /\)/,
keywords: KEYWORDS$1,
contains: ["self"].concat(SUBST_AND_COMMENTS)
}
]);
const PARAMS = {
className: 'params',
// convert this to negative lookbehind in v12
begin: /(\s*)\(/, // to match the parms with
end: /\)/,
excludeBegin: true,
excludeEnd: true,
keywords: KEYWORDS$1,
contains: PARAMS_CONTAINS
};
// ES6 classes
const CLASS_OR_EXTENDS = {
variants: [
// class Car extends vehicle
{
match: [
/class/,
/\s+/,
IDENT_RE$1,
/\s+/,
/extends/,
/\s+/,
regex.concat(IDENT_RE$1, "(", regex.concat(/\./, IDENT_RE$1), ")*")
],
scope: {
1: "keyword",
3: "title.class",
5: "keyword",
7: "title.class.inherited"
}
},
// class Car
{
match: [
/class/,
/\s+/,
IDENT_RE$1
],
scope: {
1: "keyword",
3: "title.class"
}
},
]
};
const CLASS_REFERENCE = {
relevance: 0,
match:
regex.either(
// Hard coded exceptions
/\bJSON/,
// Float32Array, OutT
/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,
// CSSFactory, CSSFactoryT
/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,
// FPs, FPsT
/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/,
// P
// single letters are not highlighted
// BLAH
// this will be flagged as a UPPER_CASE_CONSTANT instead
),
className: "title.class",
keywords: {
_: [
// se we still get relevance credit for JS library classes
...TYPES,
...ERROR_TYPES
]
}
};
const USE_STRICT = {
label: "use_strict",
className: 'meta',
relevance: 10,
begin: /^\s*['"]use (strict|asm)['"]/
};
const FUNCTION_DEFINITION = {
variants: [
{
match: [
/function/,
/\s+/,
IDENT_RE$1,
/(?=\s*\()/
]
},
// anonymous function
{
match: [
/function/,
/\s*(?=\()/
]
}
],
className: {
1: "keyword",
3: "title.function"
},
label: "func.def",
contains: [ PARAMS ],
illegal: /%/
};
const UPPER_CASE_CONSTANT = {
relevance: 0,
match: /\b[A-Z][A-Z_0-9]+\b/,
className: "variable.constant"
};
function noneOf(list) {
return regex.concat("(?!", list.join("|"), ")");
}
const FUNCTION_CALL = {
match: regex.concat(
/\b/,
noneOf([
...BUILT_IN_GLOBALS,
"super",
"import"
].map(x => `${x}\\s*\\(`)),
IDENT_RE$1, regex.lookahead(/\s*\(/)),
className: "title.function",
relevance: 0
};
const PROPERTY_ACCESS = {
begin: regex.concat(/\./, regex.lookahead(
regex.concat(IDENT_RE$1, /(?![0-9A-Za-z$_(])/)
)),
end: IDENT_RE$1,
excludeBegin: true,
keywords: "prototype",
className: "property",
relevance: 0
};
const GETTER_OR_SETTER = {
match: [
/get|set/,
/\s+/,
IDENT_RE$1,
/(?=\()/
],
className: {
1: "keyword",
3: "title.function"
},
contains: [
{ // eat to avoid empty params
begin: /\(\)/
},
PARAMS
]
};
const FUNC_LEAD_IN_RE = '(\\(' +
'[^()]*(\\(' +
'[^()]*(\\(' +
'[^()]*' +
'\\)[^()]*)*' +
'\\)[^()]*)*' +
'\\)|' + hljs.UNDERSCORE_IDENT_RE + ')\\s*=>';
const FUNCTION_VARIABLE = {
match: [
/const|var|let/, /\s+/,
IDENT_RE$1, /\s*/,
/=\s*/,
/(async\s*)?/, // async is optional
regex.lookahead(FUNC_LEAD_IN_RE)
],
keywords: "async",
className: {
1: "keyword",
3: "title.function"
},
contains: [
PARAMS
]
};
return {
name: 'JavaScript',
aliases: ['js', 'jsx', 'mjs', 'cjs'],
keywords: KEYWORDS$1,
// this will be extended by TypeScript
exports: { PARAMS_CONTAINS, CLASS_REFERENCE },
illegal: /#(?![$_A-z])/,
contains: [
hljs.SHEBANG({
label: "shebang",
binary: "node",
relevance: 5
}),
USE_STRICT,
hljs.APOS_STRING_MODE,
hljs.QUOTE_STRING_MODE,
HTML_TEMPLATE,
CSS_TEMPLATE,
GRAPHQL_TEMPLATE,
TEMPLATE_STRING,
COMMENT,
// Skip numbers when they are part of a variable name
{ match: /\$\d+/ },
NUMBER,
CLASS_REFERENCE,
{
scope: 'attr',
match: IDENT_RE$1 + regex.lookahead(':'),
relevance: 0
},
FUNCTION_VARIABLE,
{ // "value" container
begin: '(' + hljs.RE_STARTERS_RE + '|\\b(case|return|throw)\\b)\\s*',
keywords: 'return throw case',
relevance: 0,
contains: [
COMMENT,
hljs.REGEXP_MODE,
{
className: 'function',
// we have to count the parens to make sure we actually have the
// correct bounding ( ) before the =>. There could be any number of
// sub-expressions inside also surrounded by parens.
begin: FUNC_LEAD_IN_RE,
returnBegin: true,
end: '\\s*=>',
contains: [
{
className: 'params',
variants: [
{
begin: hljs.UNDERSCORE_IDENT_RE,
relevance: 0
},
{
className: null,
begin: /\(\s*\)/,
skip: true
},
{
begin: /(\s*)\(/,
end: /\)/,
excludeBegin: true,
excludeEnd: true,
keywords: KEYWORDS$1,
contains: PARAMS_CONTAINS
}
]
}
]
},
{ // could be a comma delimited list of params to a function call
begin: /,/,
relevance: 0
},
{
match: /\s+/,
relevance: 0
},
{ // JSX
variants: [
{ begin: FRAGMENT.begin, end: FRAGMENT.end },
{ match: XML_SELF_CLOSING },
{
begin: XML_TAG.begin,
// we carefully check the opening tag to see if it truly
// is a tag and not a false positive
'on:begin': XML_TAG.isTrulyOpeningTag,
end: XML_TAG.end
}
],
subLanguage: 'xml',
contains: [
{
begin: XML_TAG.begin,
end: XML_TAG.end,
skip: true,
contains: ['self']
}
]
}
],
},
FUNCTION_DEFINITION,
{
// prevent this from getting swallowed up by function
// since they appear "function like"
beginKeywords: "while if switch catch for"
},
{
// we have to count the parens to make sure we actually have the correct
// bounding ( ). There could be any number of sub-expressions inside
// also surrounded by parens.
begin: '\\b(?!function)' + hljs.UNDERSCORE_IDENT_RE +
'\\(' + // first parens
'[^()]*(\\(' +
'[^()]*(\\(' +
'[^()]*' +
'\\)[^()]*)*' +
'\\)[^()]*)*' +
'\\)\\s*\\{', // end parens
returnBegin:true,
label: "func.def",
contains: [
PARAMS,
hljs.inherit(hljs.TITLE_MODE, { begin: IDENT_RE$1, className: "title.function" })
]
},
// catch ... so it won't trigger the property rule below
{
match: /\.\.\./,
relevance: 0
},
PROPERTY_ACCESS,
// hack: prevents detection of keywords in some circumstances
// .keyword()
// $keyword = x
{
match: '\\$' + IDENT_RE$1,
relevance: 0
},
{
match: [ /\bconstructor(?=\s*\()/ ],
className: { 1: "title.function" },
contains: [ PARAMS ]
},
FUNCTION_CALL,
UPPER_CASE_CONSTANT,
CLASS_OR_EXTENDS,
GETTER_OR_SETTER,
{
match: /\$[(.]/ // relevance booster for a pattern common to JS libs: `$(something)` and `$.something`
}
]
};
}
return javascript;
})();
;
export default hljsGrammar;

View File

@@ -0,0 +1,81 @@
/*! `javascript` grammar compiled for Highlight.js 11.11.1 */
var hljsGrammar=(()=>{"use strict"
;const e="[A-Za-z$_][0-9A-Za-z$_]*",n=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],a=["true","false","null","undefined","NaN","Infinity"],t=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],s=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],r=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],c=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],i=[].concat(r,t,s)
;return o=>{const l=o.regex,d=e,b={begin:/<[A-Za-z0-9\\._:-]+/,
end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(e,n)=>{
const a=e[0].length+e.index,t=e.input[a]
;if("<"===t||","===t)return void n.ignoreMatch();let s
;">"===t&&(((e,{after:n})=>{const a="</"+e[0].slice(1)
;return-1!==e.input.indexOf(a,n)})(e,{after:a})||n.ignoreMatch())
;const r=e.input.substring(a)
;((s=r.match(/^\s*=/))||(s=r.match(/^\s+extends\s+/))&&0===s.index)&&n.ignoreMatch()
}},g={$pattern:e,keyword:n,literal:a,built_in:i,"variable.language":c
},u="[0-9](_?[0-9])*",m=`\\.(${u})`,E="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",A={
className:"number",variants:[{
begin:`(\\b(${E})((${m})|\\.)?|(${m}))[eE][+-]?(${u})\\b`},{
begin:`\\b(${E})\\b((${m})\\b|\\.)?|(${m})\\b`},{
begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{
begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{
begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{
begin:"\\b0[0-7]+n?\\b"}],relevance:0},y={className:"subst",begin:"\\$\\{",
end:"\\}",keywords:g,contains:[]},h={begin:".?html`",end:"",starts:{end:"`",
returnEnd:!1,contains:[o.BACKSLASH_ESCAPE,y],subLanguage:"xml"}},_={
begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,
contains:[o.BACKSLASH_ESCAPE,y],subLanguage:"css"}},N={begin:".?gql`",end:"",
starts:{end:"`",returnEnd:!1,contains:[o.BACKSLASH_ESCAPE,y],
subLanguage:"graphql"}},f={className:"string",begin:"`",end:"`",
contains:[o.BACKSLASH_ESCAPE,y]},p={className:"comment",
variants:[o.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{
begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",
begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,
excludeBegin:!0,relevance:0},{className:"variable",begin:d+"(?=\\s*(-)|$)",
endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]
}),o.C_BLOCK_COMMENT_MODE,o.C_LINE_COMMENT_MODE]
},v=[o.APOS_STRING_MODE,o.QUOTE_STRING_MODE,h,_,N,f,{match:/\$\d+/},A]
;y.contains=v.concat({begin:/\{/,end:/\}/,keywords:g,contains:["self"].concat(v)
});const S=[].concat(p,y.contains),w=S.concat([{begin:/(\s*)\(/,end:/\)/,
keywords:g,contains:["self"].concat(S)}]),R={className:"params",begin:/(\s*)\(/,
end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:g,contains:w},O={variants:[{
match:[/class/,/\s+/,d,/\s+/,/extends/,/\s+/,l.concat(d,"(",l.concat(/\./,d),")*")],
scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{
match:[/class/,/\s+/,d],scope:{1:"keyword",3:"title.class"}}]},k={relevance:0,
match:l.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),
className:"title.class",keywords:{_:[...t,...s]}},I={variants:[{
match:[/function/,/\s+/,d,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],
className:{1:"keyword",3:"title.function"},label:"func.def",contains:[R],
illegal:/%/},x={
match:l.concat(/\b/,(T=[...r,"super","import"].map((e=>e+"\\s*\\(")),
l.concat("(?!",T.join("|"),")")),d,l.lookahead(/\s*\(/)),
className:"title.function",relevance:0};var T;const C={
begin:l.concat(/\./,l.lookahead(l.concat(d,/(?![0-9A-Za-z$_(])/))),end:d,
excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},M={
match:[/get|set/,/\s+/,d,/(?=\()/],className:{1:"keyword",3:"title.function"},
contains:[{begin:/\(\)/},R]
},B="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+o.UNDERSCORE_IDENT_RE+")\\s*=>",$={
match:[/const|var|let/,/\s+/,d,/\s*/,/=\s*/,/(async\s*)?/,l.lookahead(B)],
keywords:"async",className:{1:"keyword",3:"title.function"},contains:[R]}
;return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:g,exports:{
PARAMS_CONTAINS:w,CLASS_REFERENCE:k},illegal:/#(?![$_A-z])/,
contains:[o.SHEBANG({label:"shebang",binary:"node",relevance:5}),{
label:"use_strict",className:"meta",relevance:10,
begin:/^\s*['"]use (strict|asm)['"]/
},o.APOS_STRING_MODE,o.QUOTE_STRING_MODE,h,_,N,f,p,{match:/\$\d+/},A,k,{
scope:"attr",match:d+l.lookahead(":"),relevance:0},$,{
begin:"("+o.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",
keywords:"return throw case",relevance:0,contains:[p,o.REGEXP_MODE,{
className:"function",begin:B,returnBegin:!0,end:"\\s*=>",contains:[{
className:"params",variants:[{begin:o.UNDERSCORE_IDENT_RE,relevance:0},{
className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,
excludeBegin:!0,excludeEnd:!0,keywords:g,contains:w}]}]},{begin:/,/,relevance:0
},{match:/\s+/,relevance:0},{variants:[{begin:"<>",end:"</>"},{
match:/<[A-Za-z0-9\\._:-]+\s*\/>/},{begin:b.begin,
"on:begin":b.isTrulyOpeningTag,end:b.end}],subLanguage:"xml",contains:[{
begin:b.begin,end:b.end,skip:!0,contains:["self"]}]}]},I,{
beginKeywords:"while if switch catch for"},{
begin:"\\b(?!function)"+o.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",
returnBegin:!0,label:"func.def",contains:[R,o.inherit(o.TITLE_MODE,{begin:d,
className:"title.function"})]},{match:/\.\.\./,relevance:0},C,{match:"\\$"+d,
relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},
contains:[R]},x,{relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,
className:"variable.constant"},O,M,{match:/\$[(.]/}]}}})()
;export default hljsGrammar;

View File

@@ -0,0 +1,62 @@
/*! `json` grammar compiled for Highlight.js 11.11.1 */
var hljsGrammar = (function () {
'use strict';
/*
Language: JSON
Description: JSON (JavaScript Object Notation) is a lightweight data-interchange format.
Author: Ivan Sagalaev <maniac@softwaremaniacs.org>
Website: http://www.json.org
Category: common, protocols, web
*/
function json(hljs) {
const ATTRIBUTE = {
className: 'attr',
begin: /"(\\.|[^\\"\r\n])*"(?=\s*:)/,
relevance: 1.01
};
const PUNCTUATION = {
match: /[{}[\],:]/,
className: "punctuation",
relevance: 0
};
const LITERALS = [
"true",
"false",
"null"
];
// NOTE: normally we would rely on `keywords` for this but using a mode here allows us
// - to use the very tight `illegal: \S` rule later to flag any other character
// - as illegal indicating that despite looking like JSON we do not truly have
// - JSON and thus improve false-positively greatly since JSON will try and claim
// - all sorts of JSON looking stuff
const LITERALS_MODE = {
scope: "literal",
beginKeywords: LITERALS.join(" "),
};
return {
name: 'JSON',
aliases: ['jsonc'],
keywords:{
literal: LITERALS,
},
contains: [
ATTRIBUTE,
PUNCTUATION,
hljs.QUOTE_STRING_MODE,
LITERALS_MODE,
hljs.C_NUMBER_MODE,
hljs.C_LINE_COMMENT_MODE,
hljs.C_BLOCK_COMMENT_MODE
],
illegal: '\\S'
};
}
return json;
})();
;
export default hljsGrammar;

View File

@@ -0,0 +1,8 @@
/*! `json` grammar compiled for Highlight.js 11.11.1 */
var hljsGrammar=(()=>{"use strict";return e=>{
const a=["true","false","null"],r={scope:"literal",beginKeywords:a.join(" ")}
;return{name:"JSON",aliases:["jsonc"],keywords:{literal:a},contains:[{
className:"attr",begin:/"(\\.|[^\\"\r\n])*"(?=\s*:)/,relevance:1.01},{
match:/[{}[\],:]/,className:"punctuation",relevance:0
},e.QUOTE_STRING_MODE,r,e.C_NUMBER_MODE,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE],
illegal:"\\S"}}})();export default hljsGrammar;

View File

@@ -0,0 +1,89 @@
/*! `lua` grammar compiled for Highlight.js 11.11.1 */
var hljsGrammar = (function () {
'use strict';
/*
Language: Lua
Description: Lua is a powerful, efficient, lightweight, embeddable scripting language.
Author: Andrew Fedorov <dmmdrs@mail.ru>
Category: common, gaming, scripting
Website: https://www.lua.org
*/
function lua(hljs) {
const OPENING_LONG_BRACKET = '\\[=*\\[';
const CLOSING_LONG_BRACKET = '\\]=*\\]';
const LONG_BRACKETS = {
begin: OPENING_LONG_BRACKET,
end: CLOSING_LONG_BRACKET,
contains: [ 'self' ]
};
const COMMENTS = [
hljs.COMMENT('--(?!' + OPENING_LONG_BRACKET + ')', '$'),
hljs.COMMENT(
'--' + OPENING_LONG_BRACKET,
CLOSING_LONG_BRACKET,
{
contains: [ LONG_BRACKETS ],
relevance: 10
}
)
];
return {
name: 'Lua',
aliases: ['pluto'],
keywords: {
$pattern: hljs.UNDERSCORE_IDENT_RE,
literal: "true false nil",
keyword: "and break do else elseif end for goto if in local not or repeat return then until while",
built_in:
// Metatags and globals:
'_G _ENV _VERSION __index __newindex __mode __call __metatable __tostring __len '
+ '__gc __add __sub __mul __div __mod __pow __concat __unm __eq __lt __le assert '
// Standard methods and properties:
+ 'collectgarbage dofile error getfenv getmetatable ipairs load loadfile loadstring '
+ 'module next pairs pcall print rawequal rawget rawset require select setfenv '
+ 'setmetatable tonumber tostring type unpack xpcall arg self '
// Library methods and properties (one line per library):
+ 'coroutine resume yield status wrap create running debug getupvalue '
+ 'debug sethook getmetatable gethook setmetatable setlocal traceback setfenv getinfo setupvalue getlocal getregistry getfenv '
+ 'io lines write close flush open output type read stderr stdin input stdout popen tmpfile '
+ 'math log max acos huge ldexp pi cos tanh pow deg tan cosh sinh random randomseed frexp ceil floor rad abs sqrt modf asin min mod fmod log10 atan2 exp sin atan '
+ 'os exit setlocale date getenv difftime remove time clock tmpname rename execute package preload loadlib loaded loaders cpath config path seeall '
+ 'string sub upper len gfind rep find match char dump gmatch reverse byte format gsub lower '
+ 'table setn insert getn foreachi maxn foreach concat sort remove'
},
contains: COMMENTS.concat([
{
className: 'function',
beginKeywords: 'function',
end: '\\)',
contains: [
hljs.inherit(hljs.TITLE_MODE, { begin: '([_a-zA-Z]\\w*\\.)*([_a-zA-Z]\\w*:)?[_a-zA-Z]\\w*' }),
{
className: 'params',
begin: '\\(',
endsWithParent: true,
contains: COMMENTS
}
].concat(COMMENTS)
},
hljs.C_NUMBER_MODE,
hljs.APOS_STRING_MODE,
hljs.QUOTE_STRING_MODE,
{
className: 'string',
begin: OPENING_LONG_BRACKET,
end: CLOSING_LONG_BRACKET,
contains: [ LONG_BRACKETS ],
relevance: 5
}
])
};
}
return lua;
})();
;
export default hljsGrammar;

View File

@@ -0,0 +1,14 @@
/*! `lua` grammar compiled for Highlight.js 11.11.1 */
var hljsGrammar=(()=>{"use strict";return e=>{
const t="\\[=*\\[",a="\\]=*\\]",n={begin:t,end:a,contains:["self"]
},r=[e.COMMENT("--(?!"+t+")","$"),e.COMMENT("--"+t,a,{contains:[n],relevance:10
})];return{name:"Lua",aliases:["pluto"],keywords:{
$pattern:e.UNDERSCORE_IDENT_RE,literal:"true false nil",
keyword:"and break do else elseif end for goto if in local not or repeat return then until while",
built_in:"_G _ENV _VERSION __index __newindex __mode __call __metatable __tostring __len __gc __add __sub __mul __div __mod __pow __concat __unm __eq __lt __le assert collectgarbage dofile error getfenv getmetatable ipairs load loadfile loadstring module next pairs pcall print rawequal rawget rawset require select setfenv setmetatable tonumber tostring type unpack xpcall arg self coroutine resume yield status wrap create running debug getupvalue debug sethook getmetatable gethook setmetatable setlocal traceback setfenv getinfo setupvalue getlocal getregistry getfenv io lines write close flush open output type read stderr stdin input stdout popen tmpfile math log max acos huge ldexp pi cos tanh pow deg tan cosh sinh random randomseed frexp ceil floor rad abs sqrt modf asin min mod fmod log10 atan2 exp sin atan os exit setlocale date getenv difftime remove time clock tmpname rename execute package preload loadlib loaded loaders cpath config path seeall string sub upper len gfind rep find match char dump gmatch reverse byte format gsub lower table setn insert getn foreachi maxn foreach concat sort remove"
},contains:r.concat([{className:"function",beginKeywords:"function",end:"\\)",
contains:[e.inherit(e.TITLE_MODE,{
begin:"([_a-zA-Z]\\w*\\.)*([_a-zA-Z]\\w*:)?[_a-zA-Z]\\w*"}),{className:"params",
begin:"\\(",endsWithParent:!0,contains:r}].concat(r)
},e.C_NUMBER_MODE,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,{className:"string",
begin:t,end:a,contains:[n],relevance:5}])}}})();export default hljsGrammar;

View File

@@ -0,0 +1,256 @@
/*! `markdown` grammar compiled for Highlight.js 11.11.1 */
var hljsGrammar = (function () {
'use strict';
/*
Language: Markdown
Requires: xml.js
Author: John Crepezzi <john.crepezzi@gmail.com>
Website: https://daringfireball.net/projects/markdown/
Category: common, markup
*/
function markdown(hljs) {
const regex = hljs.regex;
const INLINE_HTML = {
begin: /<\/?[A-Za-z_]/,
end: '>',
subLanguage: 'xml',
relevance: 0
};
const HORIZONTAL_RULE = {
begin: '^[-\\*]{3,}',
end: '$'
};
const CODE = {
className: 'code',
variants: [
// TODO: fix to allow these to work with sublanguage also
{ begin: '(`{3,})[^`](.|\\n)*?\\1`*[ ]*' },
{ begin: '(~{3,})[^~](.|\\n)*?\\1~*[ ]*' },
// needed to allow markdown as a sublanguage to work
{
begin: '```',
end: '```+[ ]*$'
},
{
begin: '~~~',
end: '~~~+[ ]*$'
},
{ begin: '`.+?`' },
{
begin: '(?=^( {4}|\\t))',
// use contains to gobble up multiple lines to allow the block to be whatever size
// but only have a single open/close tag vs one per line
contains: [
{
begin: '^( {4}|\\t)',
end: '(\\n)$'
}
],
relevance: 0
}
]
};
const LIST = {
className: 'bullet',
begin: '^[ \t]*([*+-]|(\\d+\\.))(?=\\s+)',
end: '\\s+',
excludeEnd: true
};
const LINK_REFERENCE = {
begin: /^\[[^\n]+\]:/,
returnBegin: true,
contains: [
{
className: 'symbol',
begin: /\[/,
end: /\]/,
excludeBegin: true,
excludeEnd: true
},
{
className: 'link',
begin: /:\s*/,
end: /$/,
excludeBegin: true
}
]
};
const URL_SCHEME = /[A-Za-z][A-Za-z0-9+.-]*/;
const LINK = {
variants: [
// too much like nested array access in so many languages
// to have any real relevance
{
begin: /\[.+?\]\[.*?\]/,
relevance: 0
},
// popular internet URLs
{
begin: /\[.+?\]\(((data|javascript|mailto):|(?:http|ftp)s?:\/\/).*?\)/,
relevance: 2
},
{
begin: regex.concat(/\[.+?\]\(/, URL_SCHEME, /:\/\/.*?\)/),
relevance: 2
},
// relative urls
{
begin: /\[.+?\]\([./?&#].*?\)/,
relevance: 1
},
// whatever else, lower relevance (might not be a link at all)
{
begin: /\[.*?\]\(.*?\)/,
relevance: 0
}
],
returnBegin: true,
contains: [
{
// empty strings for alt or link text
match: /\[(?=\])/ },
{
className: 'string',
relevance: 0,
begin: '\\[',
end: '\\]',
excludeBegin: true,
returnEnd: true
},
{
className: 'link',
relevance: 0,
begin: '\\]\\(',
end: '\\)',
excludeBegin: true,
excludeEnd: true
},
{
className: 'symbol',
relevance: 0,
begin: '\\]\\[',
end: '\\]',
excludeBegin: true,
excludeEnd: true
}
]
};
const BOLD = {
className: 'strong',
contains: [], // defined later
variants: [
{
begin: /_{2}(?!\s)/,
end: /_{2}/
},
{
begin: /\*{2}(?!\s)/,
end: /\*{2}/
}
]
};
const ITALIC = {
className: 'emphasis',
contains: [], // defined later
variants: [
{
begin: /\*(?![*\s])/,
end: /\*/
},
{
begin: /_(?![_\s])/,
end: /_/,
relevance: 0
}
]
};
// 3 level deep nesting is not allowed because it would create confusion
// in cases like `***testing***` because where we don't know if the last
// `***` is starting a new bold/italic or finishing the last one
const BOLD_WITHOUT_ITALIC = hljs.inherit(BOLD, { contains: [] });
const ITALIC_WITHOUT_BOLD = hljs.inherit(ITALIC, { contains: [] });
BOLD.contains.push(ITALIC_WITHOUT_BOLD);
ITALIC.contains.push(BOLD_WITHOUT_ITALIC);
let CONTAINABLE = [
INLINE_HTML,
LINK
];
[
BOLD,
ITALIC,
BOLD_WITHOUT_ITALIC,
ITALIC_WITHOUT_BOLD
].forEach(m => {
m.contains = m.contains.concat(CONTAINABLE);
});
CONTAINABLE = CONTAINABLE.concat(BOLD, ITALIC);
const HEADER = {
className: 'section',
variants: [
{
begin: '^#{1,6}',
end: '$',
contains: CONTAINABLE
},
{
begin: '(?=^.+?\\n[=-]{2,}$)',
contains: [
{ begin: '^[=-]*$' },
{
begin: '^',
end: "\\n",
contains: CONTAINABLE
}
]
}
]
};
const BLOCKQUOTE = {
className: 'quote',
begin: '^>\\s+',
contains: CONTAINABLE,
end: '$'
};
const ENTITY = {
//https://spec.commonmark.org/0.31.2/#entity-references
scope: 'literal',
match: /&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/
};
return {
name: 'Markdown',
aliases: [
'md',
'mkdown',
'mkd'
],
contains: [
HEADER,
INLINE_HTML,
LIST,
BOLD,
ITALIC,
BLOCKQUOTE,
CODE,
HORIZONTAL_RULE,
LINK,
LINK_REFERENCE,
ENTITY
]
};
}
return markdown;
})();
;
export default hljsGrammar;

View File

@@ -0,0 +1,32 @@
/*! `markdown` grammar compiled for Highlight.js 11.11.1 */
var hljsGrammar=(()=>{"use strict";return e=>{const n={begin:/<\/?[A-Za-z_]/,
end:">",subLanguage:"xml",relevance:0},a={variants:[{begin:/\[.+?\]\[.*?\]/,
relevance:0},{
begin:/\[.+?\]\(((data|javascript|mailto):|(?:http|ftp)s?:\/\/).*?\)/,
relevance:2},{
begin:e.regex.concat(/\[.+?\]\(/,/[A-Za-z][A-Za-z0-9+.-]*/,/:\/\/.*?\)/),
relevance:2},{begin:/\[.+?\]\([./?&#].*?\)/,relevance:1},{
begin:/\[.*?\]\(.*?\)/,relevance:0}],returnBegin:!0,contains:[{match:/\[(?=\])/
},{className:"string",relevance:0,begin:"\\[",end:"\\]",excludeBegin:!0,
returnEnd:!0},{className:"link",relevance:0,begin:"\\]\\(",end:"\\)",
excludeBegin:!0,excludeEnd:!0},{className:"symbol",relevance:0,begin:"\\]\\[",
end:"\\]",excludeBegin:!0,excludeEnd:!0}]},i={className:"strong",contains:[],
variants:[{begin:/_{2}(?!\s)/,end:/_{2}/},{begin:/\*{2}(?!\s)/,end:/\*{2}/}]
},s={className:"emphasis",contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/},{
begin:/_(?![_\s])/,end:/_/,relevance:0}]},c=e.inherit(i,{contains:[]
}),t=e.inherit(s,{contains:[]});i.contains.push(t),s.contains.push(c)
;let l=[n,a];return[i,s,c,t].forEach((e=>{e.contains=e.contains.concat(l)
})),l=l.concat(i,s),{name:"Markdown",aliases:["md","mkdown","mkd"],contains:[{
className:"section",variants:[{begin:"^#{1,6}",end:"$",contains:l},{
begin:"(?=^.+?\\n[=-]{2,}$)",contains:[{begin:"^[=-]*$"},{begin:"^",end:"\\n",
contains:l}]}]},n,{className:"bullet",begin:"^[ \t]*([*+-]|(\\d+\\.))(?=\\s+)",
end:"\\s+",excludeEnd:!0},i,s,{className:"quote",begin:"^>\\s+",contains:l,
end:"$"},{className:"code",variants:[{begin:"(`{3,})[^`](.|\\n)*?\\1`*[ ]*"},{
begin:"(~{3,})[^~](.|\\n)*?\\1~*[ ]*"},{begin:"```",end:"```+[ ]*$"},{
begin:"~~~",end:"~~~+[ ]*$"},{begin:"`.+?`"},{begin:"(?=^( {4}|\\t))",
contains:[{begin:"^( {4}|\\t)",end:"(\\n)$"}],relevance:0}]},{
begin:"^[-\\*]{3,}",end:"$"},a,{begin:/^\[[^\n]+\]:/,returnBegin:!0,contains:[{
className:"symbol",begin:/\[/,end:/\]/,excludeBegin:!0,excludeEnd:!0},{
className:"link",begin:/:\s*/,end:/$/,excludeBegin:!0}]},{scope:"literal",
match:/&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/}]}}})()
;export default hljsGrammar;

View File

@@ -0,0 +1,512 @@
/*! `perl` grammar compiled for Highlight.js 11.11.1 */
var hljsGrammar = (function () {
'use strict';
/*
Language: Perl
Author: Peter Leonov <gojpeg@yandex.ru>
Website: https://www.perl.org
Category: common
*/
/** @type LanguageFn */
function perl(hljs) {
const regex = hljs.regex;
const KEYWORDS = [
'abs',
'accept',
'alarm',
'and',
'atan2',
'bind',
'binmode',
'bless',
'break',
'caller',
'chdir',
'chmod',
'chomp',
'chop',
'chown',
'chr',
'chroot',
'class',
'close',
'closedir',
'connect',
'continue',
'cos',
'crypt',
'dbmclose',
'dbmopen',
'defined',
'delete',
'die',
'do',
'dump',
'each',
'else',
'elsif',
'endgrent',
'endhostent',
'endnetent',
'endprotoent',
'endpwent',
'endservent',
'eof',
'eval',
'exec',
'exists',
'exit',
'exp',
'fcntl',
'field',
'fileno',
'flock',
'for',
'foreach',
'fork',
'format',
'formline',
'getc',
'getgrent',
'getgrgid',
'getgrnam',
'gethostbyaddr',
'gethostbyname',
'gethostent',
'getlogin',
'getnetbyaddr',
'getnetbyname',
'getnetent',
'getpeername',
'getpgrp',
'getpriority',
'getprotobyname',
'getprotobynumber',
'getprotoent',
'getpwent',
'getpwnam',
'getpwuid',
'getservbyname',
'getservbyport',
'getservent',
'getsockname',
'getsockopt',
'given',
'glob',
'gmtime',
'goto',
'grep',
'gt',
'hex',
'if',
'index',
'int',
'ioctl',
'join',
'keys',
'kill',
'last',
'lc',
'lcfirst',
'length',
'link',
'listen',
'local',
'localtime',
'log',
'lstat',
'lt',
'ma',
'map',
'method',
'mkdir',
'msgctl',
'msgget',
'msgrcv',
'msgsnd',
'my',
'ne',
'next',
'no',
'not',
'oct',
'open',
'opendir',
'or',
'ord',
'our',
'pack',
'package',
'pipe',
'pop',
'pos',
'print',
'printf',
'prototype',
'push',
'q|0',
'qq',
'quotemeta',
'qw',
'qx',
'rand',
'read',
'readdir',
'readline',
'readlink',
'readpipe',
'recv',
'redo',
'ref',
'rename',
'require',
'reset',
'return',
'reverse',
'rewinddir',
'rindex',
'rmdir',
'say',
'scalar',
'seek',
'seekdir',
'select',
'semctl',
'semget',
'semop',
'send',
'setgrent',
'sethostent',
'setnetent',
'setpgrp',
'setpriority',
'setprotoent',
'setpwent',
'setservent',
'setsockopt',
'shift',
'shmctl',
'shmget',
'shmread',
'shmwrite',
'shutdown',
'sin',
'sleep',
'socket',
'socketpair',
'sort',
'splice',
'split',
'sprintf',
'sqrt',
'srand',
'stat',
'state',
'study',
'sub',
'substr',
'symlink',
'syscall',
'sysopen',
'sysread',
'sysseek',
'system',
'syswrite',
'tell',
'telldir',
'tie',
'tied',
'time',
'times',
'tr',
'truncate',
'uc',
'ucfirst',
'umask',
'undef',
'unless',
'unlink',
'unpack',
'unshift',
'untie',
'until',
'use',
'utime',
'values',
'vec',
'wait',
'waitpid',
'wantarray',
'warn',
'when',
'while',
'write',
'x|0',
'xor',
'y|0'
];
// https://perldoc.perl.org/perlre#Modifiers
const REGEX_MODIFIERS = /[dualxmsipngr]{0,12}/; // aa and xx are valid, making max length 12
const PERL_KEYWORDS = {
$pattern: /[\w.]+/,
keyword: KEYWORDS.join(" ")
};
const SUBST = {
className: 'subst',
begin: '[$@]\\{',
end: '\\}',
keywords: PERL_KEYWORDS
};
const METHOD = {
begin: /->\{/,
end: /\}/
// contains defined later
};
const ATTR = {
scope: 'attr',
match: /\s+:\s*\w+(\s*\(.*?\))?/,
};
const VAR = {
scope: 'variable',
variants: [
{ begin: /\$\d/ },
{ begin: regex.concat(
/[$%@](?!")(\^\w\b|#\w+(::\w+)*|\{\w+\}|\w+(::\w*)*)/,
// negative look-ahead tries to avoid matching patterns that are not
// Perl at all like $ident$, @ident@, etc.
`(?![A-Za-z])(?![@$%])`
)
},
{
// Only $= is a special Perl variable and one can't declare @= or %=.
begin: /[$%@](?!")[^\s\w{=]|\$=/,
relevance: 0
}
],
contains: [ ATTR ],
};
const NUMBER = {
className: 'number',
variants: [
// decimal numbers:
// include the case where a number starts with a dot (eg. .9), and
// the leading 0? avoids mixing the first and second match on 0.x cases
{ match: /0?\.[0-9][0-9_]+\b/ },
// include the special versioned number (eg. v5.38)
{ match: /\bv?(0|[1-9][0-9_]*(\.[0-9_]+)?|[1-9][0-9_]*)\b/ },
// non-decimal numbers:
{ match: /\b0[0-7][0-7_]*\b/ },
{ match: /\b0x[0-9a-fA-F][0-9a-fA-F_]*\b/ },
{ match: /\b0b[0-1][0-1_]*\b/ },
],
relevance: 0
};
const STRING_CONTAINS = [
hljs.BACKSLASH_ESCAPE,
SUBST,
VAR
];
const REGEX_DELIMS = [
/!/,
/\//,
/\|/,
/\?/,
/'/,
/"/, // valid but infrequent and weird
/#/ // valid but infrequent and weird
];
/**
* @param {string|RegExp} prefix
* @param {string|RegExp} open
* @param {string|RegExp} close
*/
const PAIRED_DOUBLE_RE = (prefix, open, close = '\\1') => {
const middle = (close === '\\1')
? close
: regex.concat(close, open);
return regex.concat(
regex.concat("(?:", prefix, ")"),
open,
/(?:\\.|[^\\\/])*?/,
middle,
/(?:\\.|[^\\\/])*?/,
close,
REGEX_MODIFIERS
);
};
/**
* @param {string|RegExp} prefix
* @param {string|RegExp} open
* @param {string|RegExp} close
*/
const PAIRED_RE = (prefix, open, close) => {
return regex.concat(
regex.concat("(?:", prefix, ")"),
open,
/(?:\\.|[^\\\/])*?/,
close,
REGEX_MODIFIERS
);
};
const PERL_DEFAULT_CONTAINS = [
VAR,
hljs.HASH_COMMENT_MODE,
hljs.COMMENT(
/^=\w/,
/=cut/,
{ endsWithParent: true }
),
METHOD,
{
className: 'string',
contains: STRING_CONTAINS,
variants: [
{
begin: 'q[qwxr]?\\s*\\(',
end: '\\)',
relevance: 5
},
{
begin: 'q[qwxr]?\\s*\\[',
end: '\\]',
relevance: 5
},
{
begin: 'q[qwxr]?\\s*\\{',
end: '\\}',
relevance: 5
},
{
begin: 'q[qwxr]?\\s*\\|',
end: '\\|',
relevance: 5
},
{
begin: 'q[qwxr]?\\s*<',
end: '>',
relevance: 5
},
{
begin: 'qw\\s+q',
end: 'q',
relevance: 5
},
{
begin: '\'',
end: '\'',
contains: [ hljs.BACKSLASH_ESCAPE ]
},
{
begin: '"',
end: '"'
},
{
begin: '`',
end: '`',
contains: [ hljs.BACKSLASH_ESCAPE ]
},
{
begin: /\{\w+\}/,
relevance: 0
},
{
begin: '-?\\w+\\s*=>',
relevance: 0
}
]
},
NUMBER,
{ // regexp container
begin: '(\\/\\/|' + hljs.RE_STARTERS_RE + '|\\b(split|return|print|reverse|grep)\\b)\\s*',
keywords: 'split return print reverse grep',
relevance: 0,
contains: [
hljs.HASH_COMMENT_MODE,
{
className: 'regexp',
variants: [
// allow matching common delimiters
{ begin: PAIRED_DOUBLE_RE("s|tr|y", regex.either(...REGEX_DELIMS, { capture: true })) },
// and then paired delmis
{ begin: PAIRED_DOUBLE_RE("s|tr|y", "\\(", "\\)") },
{ begin: PAIRED_DOUBLE_RE("s|tr|y", "\\[", "\\]") },
{ begin: PAIRED_DOUBLE_RE("s|tr|y", "\\{", "\\}") }
],
relevance: 2
},
{
className: 'regexp',
variants: [
{
// could be a comment in many languages so do not count
// as relevant
begin: /(m|qr)\/\//,
relevance: 0
},
// prefix is optional with /regex/
{ begin: PAIRED_RE("(?:m|qr)?", /\//, /\//) },
// allow matching common delimiters
{ begin: PAIRED_RE("m|qr", regex.either(...REGEX_DELIMS, { capture: true }), /\1/) },
// allow common paired delmins
{ begin: PAIRED_RE("m|qr", /\(/, /\)/) },
{ begin: PAIRED_RE("m|qr", /\[/, /\]/) },
{ begin: PAIRED_RE("m|qr", /\{/, /\}/) }
]
}
]
},
{
className: 'function',
beginKeywords: 'sub method',
end: '(\\s*\\(.*?\\))?[;{]',
excludeEnd: true,
relevance: 5,
contains: [ hljs.TITLE_MODE, ATTR ]
},
{
className: 'class',
beginKeywords: 'class',
end: '[;{]',
excludeEnd: true,
relevance: 5,
contains: [ hljs.TITLE_MODE, ATTR, NUMBER ]
},
{
begin: '-\\w\\b',
relevance: 0
},
{
begin: "^__DATA__$",
end: "^__END__$",
subLanguage: 'mojolicious',
contains: [
{
begin: "^@@.*",
end: "$",
className: "comment"
}
]
}
];
SUBST.contains = PERL_DEFAULT_CONTAINS;
METHOD.contains = PERL_DEFAULT_CONTAINS;
return {
name: 'Perl',
aliases: [
'pl',
'pm'
],
keywords: PERL_KEYWORDS,
contains: PERL_DEFAULT_CONTAINS
};
}
return perl;
})();
;
export default hljsGrammar;

View File

@@ -0,0 +1,40 @@
/*! `perl` grammar compiled for Highlight.js 11.11.1 */
var hljsGrammar=(()=>{"use strict";return e=>{
const n=e.regex,t=/[dualxmsipngr]{0,12}/,s={$pattern:/[\w.]+/,
keyword:"abs accept alarm and atan2 bind binmode bless break caller chdir chmod chomp chop chown chr chroot class close closedir connect continue cos crypt dbmclose dbmopen defined delete die do dump each else elsif endgrent endhostent endnetent endprotoent endpwent endservent eof eval exec exists exit exp fcntl field fileno flock for foreach fork format formline getc getgrent getgrgid getgrnam gethostbyaddr gethostbyname gethostent getlogin getnetbyaddr getnetbyname getnetent getpeername getpgrp getpriority getprotobyname getprotobynumber getprotoent getpwent getpwnam getpwuid getservbyname getservbyport getservent getsockname getsockopt given glob gmtime goto grep gt hex if index int ioctl join keys kill last lc lcfirst length link listen local localtime log lstat lt ma map method mkdir msgctl msgget msgrcv msgsnd my ne next no not oct open opendir or ord our pack package pipe pop pos print printf prototype push q|0 qq quotemeta qw qx rand read readdir readline readlink readpipe recv redo ref rename require reset return reverse rewinddir rindex rmdir say scalar seek seekdir select semctl semget semop send setgrent sethostent setnetent setpgrp setpriority setprotoent setpwent setservent setsockopt shift shmctl shmget shmread shmwrite shutdown sin sleep socket socketpair sort splice split sprintf sqrt srand stat state study sub substr symlink syscall sysopen sysread sysseek system syswrite tell telldir tie tied time times tr truncate uc ucfirst umask undef unless unlink unpack unshift untie until use utime values vec wait waitpid wantarray warn when while write x|0 xor y|0"
},r={className:"subst",begin:"[$@]\\{",end:"\\}",keywords:s},a={begin:/->\{/,
end:/\}/},i={scope:"attr",match:/\s+:\s*\w+(\s*\(.*?\))?/},c={scope:"variable",
variants:[{begin:/\$\d/},{
begin:n.concat(/[$%@](?!")(\^\w\b|#\w+(::\w+)*|\{\w+\}|\w+(::\w*)*)/,"(?![A-Za-z])(?![@$%])")
},{begin:/[$%@](?!")[^\s\w{=]|\$=/,relevance:0}],contains:[i]},o={
className:"number",variants:[{match:/0?\.[0-9][0-9_]+\b/},{
match:/\bv?(0|[1-9][0-9_]*(\.[0-9_]+)?|[1-9][0-9_]*)\b/},{
match:/\b0[0-7][0-7_]*\b/},{match:/\b0x[0-9a-fA-F][0-9a-fA-F_]*\b/},{
match:/\b0b[0-1][0-1_]*\b/}],relevance:0
},l=[e.BACKSLASH_ESCAPE,r,c],g=[/!/,/\//,/\|/,/\?/,/'/,/"/,/#/],d=(e,s,r="\\1")=>{
const a="\\1"===r?r:n.concat(r,s)
;return n.concat(n.concat("(?:",e,")"),s,/(?:\\.|[^\\\/])*?/,a,/(?:\\.|[^\\\/])*?/,r,t)
},m=(e,s,r)=>n.concat(n.concat("(?:",e,")"),s,/(?:\\.|[^\\\/])*?/,r,t),p=[c,e.HASH_COMMENT_MODE,e.COMMENT(/^=\w/,/=cut/,{
endsWithParent:!0}),a,{className:"string",contains:l,variants:[{
begin:"q[qwxr]?\\s*\\(",end:"\\)",relevance:5},{begin:"q[qwxr]?\\s*\\[",
end:"\\]",relevance:5},{begin:"q[qwxr]?\\s*\\{",end:"\\}",relevance:5},{
begin:"q[qwxr]?\\s*\\|",end:"\\|",relevance:5},{begin:"q[qwxr]?\\s*<",end:">",
relevance:5},{begin:"qw\\s+q",end:"q",relevance:5},{begin:"'",end:"'",
contains:[e.BACKSLASH_ESCAPE]},{begin:'"',end:'"'},{begin:"`",end:"`",
contains:[e.BACKSLASH_ESCAPE]},{begin:/\{\w+\}/,relevance:0},{
begin:"-?\\w+\\s*=>",relevance:0}]},o,{
begin:"(\\/\\/|"+e.RE_STARTERS_RE+"|\\b(split|return|print|reverse|grep)\\b)\\s*",
keywords:"split return print reverse grep",relevance:0,
contains:[e.HASH_COMMENT_MODE,{className:"regexp",variants:[{
begin:d("s|tr|y",n.either(...g,{capture:!0}))},{begin:d("s|tr|y","\\(","\\)")},{
begin:d("s|tr|y","\\[","\\]")},{begin:d("s|tr|y","\\{","\\}")}],relevance:2},{
className:"regexp",variants:[{begin:/(m|qr)\/\//,relevance:0},{
begin:m("(?:m|qr)?",/\//,/\//)},{begin:m("m|qr",n.either(...g,{capture:!0
}),/\1/)},{begin:m("m|qr",/\(/,/\)/)},{begin:m("m|qr",/\[/,/\]/)},{
begin:m("m|qr",/\{/,/\}/)}]}]},{className:"function",beginKeywords:"sub method",
end:"(\\s*\\(.*?\\))?[;{]",excludeEnd:!0,relevance:5,contains:[e.TITLE_MODE,i]
},{className:"class",beginKeywords:"class",end:"[;{]",excludeEnd:!0,relevance:5,
contains:[e.TITLE_MODE,i,o]},{begin:"-\\w\\b",relevance:0},{begin:"^__DATA__$",
end:"^__END__$",subLanguage:"mojolicious",contains:[{begin:"^@@.*",end:"$",
className:"comment"}]}];return r.contains=p,a.contains=p,{name:"Perl",
aliases:["pl","pm"],keywords:s,contains:p}}})();export default hljsGrammar;

View File

@@ -0,0 +1,633 @@
/*! `php` grammar compiled for Highlight.js 11.11.1 */
var hljsGrammar = (function () {
'use strict';
/*
Language: PHP
Author: Victor Karamzin <Victor.Karamzin@enterra-inc.com>
Contributors: Evgeny Stepanischev <imbolk@gmail.com>, Ivan Sagalaev <maniac@softwaremaniacs.org>
Website: https://www.php.net
Category: common
*/
/**
* @param {HLJSApi} hljs
* @returns {LanguageDetail}
* */
function php(hljs) {
const regex = hljs.regex;
// negative look-ahead tries to avoid matching patterns that are not
// Perl at all like $ident$, @ident@, etc.
const NOT_PERL_ETC = /(?![A-Za-z0-9])(?![$])/;
const IDENT_RE = regex.concat(
/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/,
NOT_PERL_ETC);
// Will not detect camelCase classes
const PASCAL_CASE_CLASS_NAME_RE = regex.concat(
/(\\?[A-Z][a-z0-9_\x7f-\xff]+|\\?[A-Z]+(?=[A-Z][a-z0-9_\x7f-\xff])){1,}/,
NOT_PERL_ETC);
const UPCASE_NAME_RE = regex.concat(
/[A-Z]+/,
NOT_PERL_ETC);
const VARIABLE = {
scope: 'variable',
match: '\\$+' + IDENT_RE,
};
const PREPROCESSOR = {
scope: "meta",
variants: [
{ begin: /<\?php/, relevance: 10 }, // boost for obvious PHP
{ begin: /<\?=/ },
// less relevant per PSR-1 which says not to use short-tags
{ begin: /<\?/, relevance: 0.1 },
{ begin: /\?>/ } // end php tag
]
};
const SUBST = {
scope: 'subst',
variants: [
{ begin: /\$\w+/ },
{
begin: /\{\$/,
end: /\}/
}
]
};
const SINGLE_QUOTED = hljs.inherit(hljs.APOS_STRING_MODE, { illegal: null, });
const DOUBLE_QUOTED = hljs.inherit(hljs.QUOTE_STRING_MODE, {
illegal: null,
contains: hljs.QUOTE_STRING_MODE.contains.concat(SUBST),
});
const HEREDOC = {
begin: /<<<[ \t]*(?:(\w+)|"(\w+)")\n/,
end: /[ \t]*(\w+)\b/,
contains: hljs.QUOTE_STRING_MODE.contains.concat(SUBST),
'on:begin': (m, resp) => { resp.data._beginMatch = m[1] || m[2]; },
'on:end': (m, resp) => { if (resp.data._beginMatch !== m[1]) resp.ignoreMatch(); },
};
const NOWDOC = hljs.END_SAME_AS_BEGIN({
begin: /<<<[ \t]*'(\w+)'\n/,
end: /[ \t]*(\w+)\b/,
});
// list of valid whitespaces because non-breaking space might be part of a IDENT_RE
const WHITESPACE = '[ \t\n]';
const STRING = {
scope: 'string',
variants: [
DOUBLE_QUOTED,
SINGLE_QUOTED,
HEREDOC,
NOWDOC
]
};
const NUMBER = {
scope: 'number',
variants: [
{ begin: `\\b0[bB][01]+(?:_[01]+)*\\b` }, // Binary w/ underscore support
{ begin: `\\b0[oO][0-7]+(?:_[0-7]+)*\\b` }, // Octals w/ underscore support
{ begin: `\\b0[xX][\\da-fA-F]+(?:_[\\da-fA-F]+)*\\b` }, // Hex w/ underscore support
// Decimals w/ underscore support, with optional fragments and scientific exponent (e) suffix.
{ begin: `(?:\\b\\d+(?:_\\d+)*(\\.(?:\\d+(?:_\\d+)*))?|\\B\\.\\d+)(?:[eE][+-]?\\d+)?` }
],
relevance: 0
};
const LITERALS = [
"false",
"null",
"true"
];
const KWS = [
// Magic constants:
// <https://www.php.net/manual/en/language.constants.predefined.php>
"__CLASS__",
"__DIR__",
"__FILE__",
"__FUNCTION__",
"__COMPILER_HALT_OFFSET__",
"__LINE__",
"__METHOD__",
"__NAMESPACE__",
"__TRAIT__",
// Function that look like language construct or language construct that look like function:
// List of keywords that may not require parenthesis
"die",
"echo",
"exit",
"include",
"include_once",
"print",
"require",
"require_once",
// These are not language construct (function) but operate on the currently-executing function and can access the current symbol table
// 'compact extract func_get_arg func_get_args func_num_args get_called_class get_parent_class ' +
// Other keywords:
// <https://www.php.net/manual/en/reserved.php>
// <https://www.php.net/manual/en/language.types.type-juggling.php>
"array",
"abstract",
"and",
"as",
"binary",
"bool",
"boolean",
"break",
"callable",
"case",
"catch",
"class",
"clone",
"const",
"continue",
"declare",
"default",
"do",
"double",
"else",
"elseif",
"empty",
"enddeclare",
"endfor",
"endforeach",
"endif",
"endswitch",
"endwhile",
"enum",
"eval",
"extends",
"final",
"finally",
"float",
"for",
"foreach",
"from",
"global",
"goto",
"if",
"implements",
"instanceof",
"insteadof",
"int",
"integer",
"interface",
"isset",
"iterable",
"list",
"match|0",
"mixed",
"new",
"never",
"object",
"or",
"private",
"protected",
"public",
"readonly",
"real",
"return",
"string",
"switch",
"throw",
"trait",
"try",
"unset",
"use",
"var",
"void",
"while",
"xor",
"yield"
];
const BUILT_INS = [
// Standard PHP library:
// <https://www.php.net/manual/en/book.spl.php>
"Error|0",
"AppendIterator",
"ArgumentCountError",
"ArithmeticError",
"ArrayIterator",
"ArrayObject",
"AssertionError",
"BadFunctionCallException",
"BadMethodCallException",
"CachingIterator",
"CallbackFilterIterator",
"CompileError",
"Countable",
"DirectoryIterator",
"DivisionByZeroError",
"DomainException",
"EmptyIterator",
"ErrorException",
"Exception",
"FilesystemIterator",
"FilterIterator",
"GlobIterator",
"InfiniteIterator",
"InvalidArgumentException",
"IteratorIterator",
"LengthException",
"LimitIterator",
"LogicException",
"MultipleIterator",
"NoRewindIterator",
"OutOfBoundsException",
"OutOfRangeException",
"OuterIterator",
"OverflowException",
"ParentIterator",
"ParseError",
"RangeException",
"RecursiveArrayIterator",
"RecursiveCachingIterator",
"RecursiveCallbackFilterIterator",
"RecursiveDirectoryIterator",
"RecursiveFilterIterator",
"RecursiveIterator",
"RecursiveIteratorIterator",
"RecursiveRegexIterator",
"RecursiveTreeIterator",
"RegexIterator",
"RuntimeException",
"SeekableIterator",
"SplDoublyLinkedList",
"SplFileInfo",
"SplFileObject",
"SplFixedArray",
"SplHeap",
"SplMaxHeap",
"SplMinHeap",
"SplObjectStorage",
"SplObserver",
"SplPriorityQueue",
"SplQueue",
"SplStack",
"SplSubject",
"SplTempFileObject",
"TypeError",
"UnderflowException",
"UnexpectedValueException",
"UnhandledMatchError",
// Reserved interfaces:
// <https://www.php.net/manual/en/reserved.interfaces.php>
"ArrayAccess",
"BackedEnum",
"Closure",
"Fiber",
"Generator",
"Iterator",
"IteratorAggregate",
"Serializable",
"Stringable",
"Throwable",
"Traversable",
"UnitEnum",
"WeakReference",
"WeakMap",
// Reserved classes:
// <https://www.php.net/manual/en/reserved.classes.php>
"Directory",
"__PHP_Incomplete_Class",
"parent",
"php_user_filter",
"self",
"static",
"stdClass"
];
/** Dual-case keywords
*
* ["then","FILE"] =>
* ["then", "THEN", "FILE", "file"]
*
* @param {string[]} items */
const dualCase = (items) => {
/** @type string[] */
const result = [];
items.forEach(item => {
result.push(item);
if (item.toLowerCase() === item) {
result.push(item.toUpperCase());
} else {
result.push(item.toLowerCase());
}
});
return result;
};
const KEYWORDS = {
keyword: KWS,
literal: dualCase(LITERALS),
built_in: BUILT_INS,
};
/**
* @param {string[]} items */
const normalizeKeywords = (items) => {
return items.map(item => {
return item.replace(/\|\d+$/, "");
});
};
const CONSTRUCTOR_CALL = { variants: [
{
match: [
/new/,
regex.concat(WHITESPACE, "+"),
// to prevent built ins from being confused as the class constructor call
regex.concat("(?!", normalizeKeywords(BUILT_INS).join("\\b|"), "\\b)"),
PASCAL_CASE_CLASS_NAME_RE,
],
scope: {
1: "keyword",
4: "title.class",
},
}
] };
const CONSTANT_REFERENCE = regex.concat(IDENT_RE, "\\b(?!\\()");
const LEFT_AND_RIGHT_SIDE_OF_DOUBLE_COLON = { variants: [
{
match: [
regex.concat(
/::/,
regex.lookahead(/(?!class\b)/)
),
CONSTANT_REFERENCE,
],
scope: { 2: "variable.constant", },
},
{
match: [
/::/,
/class/,
],
scope: { 2: "variable.language", },
},
{
match: [
PASCAL_CASE_CLASS_NAME_RE,
regex.concat(
/::/,
regex.lookahead(/(?!class\b)/)
),
CONSTANT_REFERENCE,
],
scope: {
1: "title.class",
3: "variable.constant",
},
},
{
match: [
PASCAL_CASE_CLASS_NAME_RE,
regex.concat(
"::",
regex.lookahead(/(?!class\b)/)
),
],
scope: { 1: "title.class", },
},
{
match: [
PASCAL_CASE_CLASS_NAME_RE,
/::/,
/class/,
],
scope: {
1: "title.class",
3: "variable.language",
},
}
] };
const NAMED_ARGUMENT = {
scope: 'attr',
match: regex.concat(IDENT_RE, regex.lookahead(':'), regex.lookahead(/(?!::)/)),
};
const PARAMS_MODE = {
relevance: 0,
begin: /\(/,
end: /\)/,
keywords: KEYWORDS,
contains: [
NAMED_ARGUMENT,
VARIABLE,
LEFT_AND_RIGHT_SIDE_OF_DOUBLE_COLON,
hljs.C_BLOCK_COMMENT_MODE,
STRING,
NUMBER,
CONSTRUCTOR_CALL,
],
};
const FUNCTION_INVOKE = {
relevance: 0,
match: [
/\b/,
// to prevent keywords from being confused as the function title
regex.concat("(?!fn\\b|function\\b|", normalizeKeywords(KWS).join("\\b|"), "|", normalizeKeywords(BUILT_INS).join("\\b|"), "\\b)"),
IDENT_RE,
regex.concat(WHITESPACE, "*"),
regex.lookahead(/(?=\()/)
],
scope: { 3: "title.function.invoke", },
contains: [ PARAMS_MODE ]
};
PARAMS_MODE.contains.push(FUNCTION_INVOKE);
const ATTRIBUTE_CONTAINS = [
NAMED_ARGUMENT,
LEFT_AND_RIGHT_SIDE_OF_DOUBLE_COLON,
hljs.C_BLOCK_COMMENT_MODE,
STRING,
NUMBER,
CONSTRUCTOR_CALL,
];
const ATTRIBUTES = {
begin: regex.concat(/#\[\s*\\?/,
regex.either(
PASCAL_CASE_CLASS_NAME_RE,
UPCASE_NAME_RE
)
),
beginScope: "meta",
end: /]/,
endScope: "meta",
keywords: {
literal: LITERALS,
keyword: [
'new',
'array',
]
},
contains: [
{
begin: /\[/,
end: /]/,
keywords: {
literal: LITERALS,
keyword: [
'new',
'array',
]
},
contains: [
'self',
...ATTRIBUTE_CONTAINS,
]
},
...ATTRIBUTE_CONTAINS,
{
scope: 'meta',
variants: [
{ match: PASCAL_CASE_CLASS_NAME_RE },
{ match: UPCASE_NAME_RE }
]
}
]
};
return {
case_insensitive: false,
keywords: KEYWORDS,
contains: [
ATTRIBUTES,
hljs.HASH_COMMENT_MODE,
hljs.COMMENT('//', '$'),
hljs.COMMENT(
'/\\*',
'\\*/',
{ contains: [
{
scope: 'doctag',
match: '@[A-Za-z]+'
}
] }
),
{
match: /__halt_compiler\(\);/,
keywords: '__halt_compiler',
starts: {
scope: "comment",
end: hljs.MATCH_NOTHING_RE,
contains: [
{
match: /\?>/,
scope: "meta",
endsParent: true
}
]
}
},
PREPROCESSOR,
{
scope: 'variable.language',
match: /\$this\b/
},
VARIABLE,
FUNCTION_INVOKE,
LEFT_AND_RIGHT_SIDE_OF_DOUBLE_COLON,
{
match: [
/const/,
/\s/,
IDENT_RE,
],
scope: {
1: "keyword",
3: "variable.constant",
},
},
CONSTRUCTOR_CALL,
{
scope: 'function',
relevance: 0,
beginKeywords: 'fn function',
end: /[;{]/,
excludeEnd: true,
illegal: '[$%\\[]',
contains: [
{ beginKeywords: 'use', },
hljs.UNDERSCORE_TITLE_MODE,
{
begin: '=>', // No markup, just a relevance booster
endsParent: true
},
{
scope: 'params',
begin: '\\(',
end: '\\)',
excludeBegin: true,
excludeEnd: true,
keywords: KEYWORDS,
contains: [
'self',
ATTRIBUTES,
VARIABLE,
LEFT_AND_RIGHT_SIDE_OF_DOUBLE_COLON,
hljs.C_BLOCK_COMMENT_MODE,
STRING,
NUMBER
]
},
]
},
{
scope: 'class',
variants: [
{
beginKeywords: "enum",
illegal: /[($"]/
},
{
beginKeywords: "class interface trait",
illegal: /[:($"]/
}
],
relevance: 0,
end: /\{/,
excludeEnd: true,
contains: [
{ beginKeywords: 'extends implements' },
hljs.UNDERSCORE_TITLE_MODE
]
},
// both use and namespace still use "old style" rules (vs multi-match)
// because the namespace name can include `\` and we still want each
// element to be treated as its own *individual* title
{
beginKeywords: 'namespace',
relevance: 0,
end: ';',
illegal: /[.']/,
contains: [ hljs.inherit(hljs.UNDERSCORE_TITLE_MODE, { scope: "title.class" }) ]
},
{
beginKeywords: 'use',
relevance: 0,
end: ';',
contains: [
// TODO: title.function vs title.class
{
match: /\b(as|const|function)\b/,
scope: "keyword"
},
// TODO: could be title.class or title.function
hljs.UNDERSCORE_TITLE_MODE
]
},
STRING,
NUMBER,
]
};
}
return php;
})();
;
export default hljsGrammar;

View File

@@ -0,0 +1,59 @@
/*! `php` grammar compiled for Highlight.js 11.11.1 */
var hljsGrammar=(()=>{"use strict";return e=>{
const t=e.regex,a=/(?![A-Za-z0-9])(?![$])/,r=t.concat(/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/,a),n=t.concat(/(\\?[A-Z][a-z0-9_\x7f-\xff]+|\\?[A-Z]+(?=[A-Z][a-z0-9_\x7f-\xff])){1,}/,a),o=t.concat(/[A-Z]+/,a),c={
scope:"variable",match:"\\$+"+r},i={scope:"subst",variants:[{begin:/\$\w+/},{
begin:/\{\$/,end:/\}/}]},s=e.inherit(e.APOS_STRING_MODE,{illegal:null
}),l="[ \t\n]",d={scope:"string",variants:[e.inherit(e.QUOTE_STRING_MODE,{
illegal:null,contains:e.QUOTE_STRING_MODE.contains.concat(i)}),s,{
begin:/<<<[ \t]*(?:(\w+)|"(\w+)")\n/,end:/[ \t]*(\w+)\b/,
contains:e.QUOTE_STRING_MODE.contains.concat(i),"on:begin":(e,t)=>{
t.data._beginMatch=e[1]||e[2]},"on:end":(e,t)=>{
t.data._beginMatch!==e[1]&&t.ignoreMatch()}},e.END_SAME_AS_BEGIN({
begin:/<<<[ \t]*'(\w+)'\n/,end:/[ \t]*(\w+)\b/})]},_={scope:"number",variants:[{
begin:"\\b0[bB][01]+(?:_[01]+)*\\b"},{begin:"\\b0[oO][0-7]+(?:_[0-7]+)*\\b"},{
begin:"\\b0[xX][\\da-fA-F]+(?:_[\\da-fA-F]+)*\\b"},{
begin:"(?:\\b\\d+(?:_\\d+)*(\\.(?:\\d+(?:_\\d+)*))?|\\B\\.\\d+)(?:[eE][+-]?\\d+)?"
}],relevance:0
},p=["false","null","true"],b=["__CLASS__","__DIR__","__FILE__","__FUNCTION__","__COMPILER_HALT_OFFSET__","__LINE__","__METHOD__","__NAMESPACE__","__TRAIT__","die","echo","exit","include","include_once","print","require","require_once","array","abstract","and","as","binary","bool","boolean","break","callable","case","catch","class","clone","const","continue","declare","default","do","double","else","elseif","empty","enddeclare","endfor","endforeach","endif","endswitch","endwhile","enum","eval","extends","final","finally","float","for","foreach","from","global","goto","if","implements","instanceof","insteadof","int","integer","interface","isset","iterable","list","match|0","mixed","new","never","object","or","private","protected","public","readonly","real","return","string","switch","throw","trait","try","unset","use","var","void","while","xor","yield"],E=["Error|0","AppendIterator","ArgumentCountError","ArithmeticError","ArrayIterator","ArrayObject","AssertionError","BadFunctionCallException","BadMethodCallException","CachingIterator","CallbackFilterIterator","CompileError","Countable","DirectoryIterator","DivisionByZeroError","DomainException","EmptyIterator","ErrorException","Exception","FilesystemIterator","FilterIterator","GlobIterator","InfiniteIterator","InvalidArgumentException","IteratorIterator","LengthException","LimitIterator","LogicException","MultipleIterator","NoRewindIterator","OutOfBoundsException","OutOfRangeException","OuterIterator","OverflowException","ParentIterator","ParseError","RangeException","RecursiveArrayIterator","RecursiveCachingIterator","RecursiveCallbackFilterIterator","RecursiveDirectoryIterator","RecursiveFilterIterator","RecursiveIterator","RecursiveIteratorIterator","RecursiveRegexIterator","RecursiveTreeIterator","RegexIterator","RuntimeException","SeekableIterator","SplDoublyLinkedList","SplFileInfo","SplFileObject","SplFixedArray","SplHeap","SplMaxHeap","SplMinHeap","SplObjectStorage","SplObserver","SplPriorityQueue","SplQueue","SplStack","SplSubject","SplTempFileObject","TypeError","UnderflowException","UnexpectedValueException","UnhandledMatchError","ArrayAccess","BackedEnum","Closure","Fiber","Generator","Iterator","IteratorAggregate","Serializable","Stringable","Throwable","Traversable","UnitEnum","WeakReference","WeakMap","Directory","__PHP_Incomplete_Class","parent","php_user_filter","self","static","stdClass"],u={
keyword:b,literal:(e=>{const t=[];return e.forEach((e=>{
t.push(e),e.toLowerCase()===e?t.push(e.toUpperCase()):t.push(e.toLowerCase())
})),t})(p),built_in:E},g=e=>e.map((e=>e.replace(/\|\d+$/,""))),h={variants:[{
match:[/new/,t.concat(l,"+"),t.concat("(?!",g(E).join("\\b|"),"\\b)"),n],scope:{
1:"keyword",4:"title.class"}}]},m=t.concat(r,"\\b(?!\\()"),f={variants:[{
match:[t.concat(/::/,t.lookahead(/(?!class\b)/)),m],scope:{2:"variable.constant"
}},{match:[/::/,/class/],scope:{2:"variable.language"}},{
match:[n,t.concat(/::/,t.lookahead(/(?!class\b)/)),m],scope:{1:"title.class",
3:"variable.constant"}},{match:[n,t.concat("::",t.lookahead(/(?!class\b)/))],
scope:{1:"title.class"}},{match:[n,/::/,/class/],scope:{1:"title.class",
3:"variable.language"}}]},I={scope:"attr",
match:t.concat(r,t.lookahead(":"),t.lookahead(/(?!::)/))},v={relevance:0,
begin:/\(/,end:/\)/,keywords:u,contains:[I,c,f,e.C_BLOCK_COMMENT_MODE,d,_,h]
},O={relevance:0,
match:[/\b/,t.concat("(?!fn\\b|function\\b|",g(b).join("\\b|"),"|",g(E).join("\\b|"),"\\b)"),r,t.concat(l,"*"),t.lookahead(/(?=\()/)],
scope:{3:"title.function.invoke"},contains:[v]};v.contains.push(O)
;const y=[I,f,e.C_BLOCK_COMMENT_MODE,d,_,h],w={
begin:t.concat(/#\[\s*\\?/,t.either(n,o)),beginScope:"meta",end:/]/,
endScope:"meta",keywords:{literal:p,keyword:["new","array"]},contains:[{
begin:/\[/,end:/]/,keywords:{literal:p,keyword:["new","array"]},
contains:["self",...y]},...y,{scope:"meta",variants:[{match:n},{match:o}]}]}
;return{case_insensitive:!1,keywords:u,
contains:[w,e.HASH_COMMENT_MODE,e.COMMENT("//","$"),e.COMMENT("/\\*","\\*/",{
contains:[{scope:"doctag",match:"@[A-Za-z]+"}]}),{match:/__halt_compiler\(\);/,
keywords:"__halt_compiler",starts:{scope:"comment",end:e.MATCH_NOTHING_RE,
contains:[{match:/\?>/,scope:"meta",endsParent:!0}]}},{scope:"meta",variants:[{
begin:/<\?php/,relevance:10},{begin:/<\?=/},{begin:/<\?/,relevance:.1},{
begin:/\?>/}]},{scope:"variable.language",match:/\$this\b/},c,O,f,{
match:[/const/,/\s/,r],scope:{1:"keyword",3:"variable.constant"}},h,{
scope:"function",relevance:0,beginKeywords:"fn function",end:/[;{]/,
excludeEnd:!0,illegal:"[$%\\[]",contains:[{beginKeywords:"use"
},e.UNDERSCORE_TITLE_MODE,{begin:"=>",endsParent:!0},{scope:"params",
begin:"\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0,keywords:u,
contains:["self",w,c,f,e.C_BLOCK_COMMENT_MODE,d,_]}]},{scope:"class",variants:[{
beginKeywords:"enum",illegal:/[($"]/},{beginKeywords:"class interface trait",
illegal:/[:($"]/}],relevance:0,end:/\{/,excludeEnd:!0,contains:[{
beginKeywords:"extends implements"},e.UNDERSCORE_TITLE_MODE]},{
beginKeywords:"namespace",relevance:0,end:";",illegal:/[.']/,
contains:[e.inherit(e.UNDERSCORE_TITLE_MODE,{scope:"title.class"})]},{
beginKeywords:"use",relevance:0,end:";",contains:[{
match:/\b(as|const|function)\b/,scope:"keyword"},e.UNDERSCORE_TITLE_MODE]},d,_]}
}})();export default hljsGrammar;

View File

@@ -0,0 +1,27 @@
/*! `plaintext` grammar compiled for Highlight.js 11.11.1 */
var hljsGrammar = (function () {
'use strict';
/*
Language: Plain text
Author: Egor Rogov (e.rogov@postgrespro.ru)
Description: Plain text without any highlighting.
Category: common
*/
function plaintext(hljs) {
return {
name: 'Plain text',
aliases: [
'text',
'txt'
],
disableAutodetect: true
};
}
return plaintext;
})();
;
export default hljsGrammar;

View File

@@ -0,0 +1,3 @@
/*! `plaintext` grammar compiled for Highlight.js 11.11.1 */
var hljsGrammar=(()=>{"use strict";return t=>({name:"Plain text",
aliases:["text","txt"],disableAutodetect:!0})})();export default hljsGrammar;

View File

@@ -0,0 +1,444 @@
/*! `python` grammar compiled for Highlight.js 11.11.1 */
var hljsGrammar = (function () {
'use strict';
/*
Language: Python
Description: Python is an interpreted, object-oriented, high-level programming language with dynamic semantics.
Website: https://www.python.org
Category: common
*/
function python(hljs) {
const regex = hljs.regex;
const IDENT_RE = /[\p{XID_Start}_]\p{XID_Continue}*/u;
const RESERVED_WORDS = [
'and',
'as',
'assert',
'async',
'await',
'break',
'case',
'class',
'continue',
'def',
'del',
'elif',
'else',
'except',
'finally',
'for',
'from',
'global',
'if',
'import',
'in',
'is',
'lambda',
'match',
'nonlocal|10',
'not',
'or',
'pass',
'raise',
'return',
'try',
'while',
'with',
'yield'
];
const BUILT_INS = [
'__import__',
'abs',
'all',
'any',
'ascii',
'bin',
'bool',
'breakpoint',
'bytearray',
'bytes',
'callable',
'chr',
'classmethod',
'compile',
'complex',
'delattr',
'dict',
'dir',
'divmod',
'enumerate',
'eval',
'exec',
'filter',
'float',
'format',
'frozenset',
'getattr',
'globals',
'hasattr',
'hash',
'help',
'hex',
'id',
'input',
'int',
'isinstance',
'issubclass',
'iter',
'len',
'list',
'locals',
'map',
'max',
'memoryview',
'min',
'next',
'object',
'oct',
'open',
'ord',
'pow',
'print',
'property',
'range',
'repr',
'reversed',
'round',
'set',
'setattr',
'slice',
'sorted',
'staticmethod',
'str',
'sum',
'super',
'tuple',
'type',
'vars',
'zip'
];
const LITERALS = [
'__debug__',
'Ellipsis',
'False',
'None',
'NotImplemented',
'True'
];
// https://docs.python.org/3/library/typing.html
// TODO: Could these be supplemented by a CamelCase matcher in certain
// contexts, leaving these remaining only for relevance hinting?
const TYPES = [
"Any",
"Callable",
"Coroutine",
"Dict",
"List",
"Literal",
"Generic",
"Optional",
"Sequence",
"Set",
"Tuple",
"Type",
"Union"
];
const KEYWORDS = {
$pattern: /[A-Za-z]\w+|__\w+__/,
keyword: RESERVED_WORDS,
built_in: BUILT_INS,
literal: LITERALS,
type: TYPES
};
const PROMPT = {
className: 'meta',
begin: /^(>>>|\.\.\.) /
};
const SUBST = {
className: 'subst',
begin: /\{/,
end: /\}/,
keywords: KEYWORDS,
illegal: /#/
};
const LITERAL_BRACKET = {
begin: /\{\{/,
relevance: 0
};
const STRING = {
className: 'string',
contains: [ hljs.BACKSLASH_ESCAPE ],
variants: [
{
begin: /([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,
end: /'''/,
contains: [
hljs.BACKSLASH_ESCAPE,
PROMPT
],
relevance: 10
},
{
begin: /([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,
end: /"""/,
contains: [
hljs.BACKSLASH_ESCAPE,
PROMPT
],
relevance: 10
},
{
begin: /([fF][rR]|[rR][fF]|[fF])'''/,
end: /'''/,
contains: [
hljs.BACKSLASH_ESCAPE,
PROMPT,
LITERAL_BRACKET,
SUBST
]
},
{
begin: /([fF][rR]|[rR][fF]|[fF])"""/,
end: /"""/,
contains: [
hljs.BACKSLASH_ESCAPE,
PROMPT,
LITERAL_BRACKET,
SUBST
]
},
{
begin: /([uU]|[rR])'/,
end: /'/,
relevance: 10
},
{
begin: /([uU]|[rR])"/,
end: /"/,
relevance: 10
},
{
begin: /([bB]|[bB][rR]|[rR][bB])'/,
end: /'/
},
{
begin: /([bB]|[bB][rR]|[rR][bB])"/,
end: /"/
},
{
begin: /([fF][rR]|[rR][fF]|[fF])'/,
end: /'/,
contains: [
hljs.BACKSLASH_ESCAPE,
LITERAL_BRACKET,
SUBST
]
},
{
begin: /([fF][rR]|[rR][fF]|[fF])"/,
end: /"/,
contains: [
hljs.BACKSLASH_ESCAPE,
LITERAL_BRACKET,
SUBST
]
},
hljs.APOS_STRING_MODE,
hljs.QUOTE_STRING_MODE
]
};
// https://docs.python.org/3.9/reference/lexical_analysis.html#numeric-literals
const digitpart = '[0-9](_?[0-9])*';
const pointfloat = `(\\b(${digitpart}))?\\.(${digitpart})|\\b(${digitpart})\\.`;
// Whitespace after a number (or any lexical token) is needed only if its absence
// would change the tokenization
// https://docs.python.org/3.9/reference/lexical_analysis.html#whitespace-between-tokens
// We deviate slightly, requiring a word boundary or a keyword
// to avoid accidentally recognizing *prefixes* (e.g., `0` in `0x41` or `08` or `0__1`)
const lookahead = `\\b|${RESERVED_WORDS.join('|')}`;
const NUMBER = {
className: 'number',
relevance: 0,
variants: [
// exponentfloat, pointfloat
// https://docs.python.org/3.9/reference/lexical_analysis.html#floating-point-literals
// optionally imaginary
// https://docs.python.org/3.9/reference/lexical_analysis.html#imaginary-literals
// Note: no leading \b because floats can start with a decimal point
// and we don't want to mishandle e.g. `fn(.5)`,
// no trailing \b for pointfloat because it can end with a decimal point
// and we don't want to mishandle e.g. `0..hex()`; this should be safe
// because both MUST contain a decimal point and so cannot be confused with
// the interior part of an identifier
{
begin: `(\\b(${digitpart})|(${pointfloat}))[eE][+-]?(${digitpart})[jJ]?(?=${lookahead})`
},
{
begin: `(${pointfloat})[jJ]?`
},
// decinteger, bininteger, octinteger, hexinteger
// https://docs.python.org/3.9/reference/lexical_analysis.html#integer-literals
// optionally "long" in Python 2
// https://docs.python.org/2.7/reference/lexical_analysis.html#integer-and-long-integer-literals
// decinteger is optionally imaginary
// https://docs.python.org/3.9/reference/lexical_analysis.html#imaginary-literals
{
begin: `\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${lookahead})`
},
{
begin: `\\b0[bB](_?[01])+[lL]?(?=${lookahead})`
},
{
begin: `\\b0[oO](_?[0-7])+[lL]?(?=${lookahead})`
},
{
begin: `\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${lookahead})`
},
// imagnumber (digitpart-based)
// https://docs.python.org/3.9/reference/lexical_analysis.html#imaginary-literals
{
begin: `\\b(${digitpart})[jJ](?=${lookahead})`
}
]
};
const COMMENT_TYPE = {
className: "comment",
begin: regex.lookahead(/# type:/),
end: /$/,
keywords: KEYWORDS,
contains: [
{ // prevent keywords from coloring `type`
begin: /# type:/
},
// comment within a datatype comment includes no keywords
{
begin: /#/,
end: /\b\B/,
endsWithParent: true
}
]
};
const PARAMS = {
className: 'params',
variants: [
// Exclude params in functions without params
{
className: "",
begin: /\(\s*\)/,
skip: true
},
{
begin: /\(/,
end: /\)/,
excludeBegin: true,
excludeEnd: true,
keywords: KEYWORDS,
contains: [
'self',
PROMPT,
NUMBER,
STRING,
hljs.HASH_COMMENT_MODE
]
}
]
};
SUBST.contains = [
STRING,
NUMBER,
PROMPT
];
return {
name: 'Python',
aliases: [
'py',
'gyp',
'ipython'
],
unicodeRegex: true,
keywords: KEYWORDS,
illegal: /(<\/|\?)|=>/,
contains: [
PROMPT,
NUMBER,
{
// very common convention
scope: 'variable.language',
match: /\bself\b/
},
{
// eat "if" prior to string so that it won't accidentally be
// labeled as an f-string
beginKeywords: "if",
relevance: 0
},
{ match: /\bor\b/, scope: "keyword" },
STRING,
COMMENT_TYPE,
hljs.HASH_COMMENT_MODE,
{
match: [
/\bdef/, /\s+/,
IDENT_RE,
],
scope: {
1: "keyword",
3: "title.function"
},
contains: [ PARAMS ]
},
{
variants: [
{
match: [
/\bclass/, /\s+/,
IDENT_RE, /\s*/,
/\(\s*/, IDENT_RE,/\s*\)/
],
},
{
match: [
/\bclass/, /\s+/,
IDENT_RE
],
}
],
scope: {
1: "keyword",
3: "title.class",
6: "title.class.inherited",
}
},
{
className: 'meta',
begin: /^[\t ]*@/,
end: /(?=#)|$/,
contains: [
NUMBER,
PARAMS,
STRING
]
}
]
};
}
return python;
})();
;
export default hljsGrammar;

View File

@@ -0,0 +1,42 @@
/*! `python` grammar compiled for Highlight.js 11.11.1 */
var hljsGrammar=(()=>{"use strict";return e=>{
const n=e.regex,a=/[\p{XID_Start}_]\p{XID_Continue}*/u,s=["and","as","assert","async","await","break","case","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","match","nonlocal|10","not","or","pass","raise","return","try","while","with","yield"],t={
$pattern:/[A-Za-z]\w+|__\w+__/,keyword:s,
built_in:["__import__","abs","all","any","ascii","bin","bool","breakpoint","bytearray","bytes","callable","chr","classmethod","compile","complex","delattr","dict","dir","divmod","enumerate","eval","exec","filter","float","format","frozenset","getattr","globals","hasattr","hash","help","hex","id","input","int","isinstance","issubclass","iter","len","list","locals","map","max","memoryview","min","next","object","oct","open","ord","pow","print","property","range","repr","reversed","round","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","vars","zip"],
literal:["__debug__","Ellipsis","False","None","NotImplemented","True"],
type:["Any","Callable","Coroutine","Dict","List","Literal","Generic","Optional","Sequence","Set","Tuple","Type","Union"]
},i={className:"meta",begin:/^(>>>|\.\.\.) /},r={className:"subst",begin:/\{/,
end:/\}/,keywords:t,illegal:/#/},l={begin:/\{\{/,relevance:0},o={
className:"string",contains:[e.BACKSLASH_ESCAPE],variants:[{
begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,
contains:[e.BACKSLASH_ESCAPE,i],relevance:10},{
begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,
contains:[e.BACKSLASH_ESCAPE,i],relevance:10},{
begin:/([fF][rR]|[rR][fF]|[fF])'''/,end:/'''/,
contains:[e.BACKSLASH_ESCAPE,i,l,r]},{begin:/([fF][rR]|[rR][fF]|[fF])"""/,
end:/"""/,contains:[e.BACKSLASH_ESCAPE,i,l,r]},{begin:/([uU]|[rR])'/,end:/'/,
relevance:10},{begin:/([uU]|[rR])"/,end:/"/,relevance:10},{
begin:/([bB]|[bB][rR]|[rR][bB])'/,end:/'/},{begin:/([bB]|[bB][rR]|[rR][bB])"/,
end:/"/},{begin:/([fF][rR]|[rR][fF]|[fF])'/,end:/'/,
contains:[e.BACKSLASH_ESCAPE,l,r]},{begin:/([fF][rR]|[rR][fF]|[fF])"/,end:/"/,
contains:[e.BACKSLASH_ESCAPE,l,r]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]
},b="[0-9](_?[0-9])*",c=`(\\b(${b}))?\\.(${b})|\\b(${b})\\.`,d="\\b|"+s.join("|"),m={
className:"number",relevance:0,variants:[{
begin:`(\\b(${b})|(${c}))[eE][+-]?(${b})[jJ]?(?=${d})`},{begin:`(${c})[jJ]?`},{
begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${d})`},{
begin:`\\b0[bB](_?[01])+[lL]?(?=${d})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${d})`
},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${d})`},{begin:`\\b(${b})[jJ](?=${d})`
}]},g={className:"comment",begin:n.lookahead(/# type:/),end:/$/,keywords:t,
contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},p={
className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,
end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:t,
contains:["self",i,m,o,e.HASH_COMMENT_MODE]}]};return r.contains=[o,m,i],{
name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:t,
illegal:/(<\/|\?)|=>/,contains:[i,m,{scope:"variable.language",match:/\bself\b/
},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"
},o,g,e.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,a],scope:{1:"keyword",
3:"title.function"},contains:[p]},{variants:[{
match:[/\bclass/,/\s+/,a,/\s*/,/\(\s*/,a,/\s*\)/]},{match:[/\bclass/,/\s+/,a]}],
scope:{1:"keyword",3:"title.class",6:"title.class.inherited"}},{
className:"meta",begin:/^[\t ]*@/,end:/(?=#)|$/,contains:[m,p,o]}]}}})()
;export default hljsGrammar;

View File

@@ -0,0 +1,41 @@
/*! `shell` grammar compiled for Highlight.js 11.11.1 */
var hljsGrammar = (function () {
'use strict';
/*
Language: Shell Session
Requires: bash.js
Author: TSUYUSATO Kitsune <make.just.on@gmail.com>
Category: common
Audit: 2020
*/
/** @type LanguageFn */
function shell(hljs) {
return {
name: 'Shell Session',
aliases: [
'console',
'shellsession'
],
contains: [
{
className: 'meta.prompt',
// We cannot add \s (spaces) in the regular expression otherwise it will be too broad and produce unexpected result.
// For instance, in the following example, it would match "echo /path/to/home >" as a prompt:
// echo /path/to/home > t.exe
begin: /^\s{0,3}[/~\w\d[\]()@-]*[>%$#][ ]?/,
starts: {
end: /[^\\](?=\s*$)/,
subLanguage: 'bash'
}
}
]
};
}
return shell;
})();
;
export default hljsGrammar;

View File

@@ -0,0 +1,5 @@
/*! `shell` grammar compiled for Highlight.js 11.11.1 */
var hljsGrammar=(()=>{"use strict";return s=>({name:"Shell Session",
aliases:["console","shellsession"],contains:[{className:"meta.prompt",
begin:/^\s{0,3}[/~\w\d[\]()@-]*[>%$#][ ]?/,starts:{end:/[^\\](?=\s*$)/,
subLanguage:"bash"}}]})})();export default hljsGrammar;

View File

@@ -0,0 +1,701 @@
/*! `sql` grammar compiled for Highlight.js 11.11.1 */
var hljsGrammar = (function () {
'use strict';
/*
Language: SQL
Website: https://en.wikipedia.org/wiki/SQL
Category: common, database
*/
/*
Goals:
SQL is intended to highlight basic/common SQL keywords and expressions
- If pretty much every single SQL server includes supports, then it's a canidate.
- It is NOT intended to include tons of vendor specific keywords (Oracle, MySQL,
PostgreSQL) although the list of data types is purposely a bit more expansive.
- For more specific SQL grammars please see:
- PostgreSQL and PL/pgSQL - core
- T-SQL - https://github.com/highlightjs/highlightjs-tsql
- sql_more (core)
*/
function sql(hljs) {
const regex = hljs.regex;
const COMMENT_MODE = hljs.COMMENT('--', '$');
const STRING = {
scope: 'string',
variants: [
{
begin: /'/,
end: /'/,
contains: [ { match: /''/ } ]
}
]
};
const QUOTED_IDENTIFIER = {
begin: /"/,
end: /"/,
contains: [ { match: /""/ } ]
};
const LITERALS = [
"true",
"false",
// Not sure it's correct to call NULL literal, and clauses like IS [NOT] NULL look strange that way.
// "null",
"unknown"
];
const MULTI_WORD_TYPES = [
"double precision",
"large object",
"with timezone",
"without timezone"
];
const TYPES = [
'bigint',
'binary',
'blob',
'boolean',
'char',
'character',
'clob',
'date',
'dec',
'decfloat',
'decimal',
'float',
'int',
'integer',
'interval',
'nchar',
'nclob',
'national',
'numeric',
'real',
'row',
'smallint',
'time',
'timestamp',
'varchar',
'varying', // modifier (character varying)
'varbinary'
];
const NON_RESERVED_WORDS = [
"add",
"asc",
"collation",
"desc",
"final",
"first",
"last",
"view"
];
// https://jakewheat.github.io/sql-overview/sql-2016-foundation-grammar.html#reserved-word
const RESERVED_WORDS = [
"abs",
"acos",
"all",
"allocate",
"alter",
"and",
"any",
"are",
"array",
"array_agg",
"array_max_cardinality",
"as",
"asensitive",
"asin",
"asymmetric",
"at",
"atan",
"atomic",
"authorization",
"avg",
"begin",
"begin_frame",
"begin_partition",
"between",
"bigint",
"binary",
"blob",
"boolean",
"both",
"by",
"call",
"called",
"cardinality",
"cascaded",
"case",
"cast",
"ceil",
"ceiling",
"char",
"char_length",
"character",
"character_length",
"check",
"classifier",
"clob",
"close",
"coalesce",
"collate",
"collect",
"column",
"commit",
"condition",
"connect",
"constraint",
"contains",
"convert",
"copy",
"corr",
"corresponding",
"cos",
"cosh",
"count",
"covar_pop",
"covar_samp",
"create",
"cross",
"cube",
"cume_dist",
"current",
"current_catalog",
"current_date",
"current_default_transform_group",
"current_path",
"current_role",
"current_row",
"current_schema",
"current_time",
"current_timestamp",
"current_path",
"current_role",
"current_transform_group_for_type",
"current_user",
"cursor",
"cycle",
"date",
"day",
"deallocate",
"dec",
"decimal",
"decfloat",
"declare",
"default",
"define",
"delete",
"dense_rank",
"deref",
"describe",
"deterministic",
"disconnect",
"distinct",
"double",
"drop",
"dynamic",
"each",
"element",
"else",
"empty",
"end",
"end_frame",
"end_partition",
"end-exec",
"equals",
"escape",
"every",
"except",
"exec",
"execute",
"exists",
"exp",
"external",
"extract",
"false",
"fetch",
"filter",
"first_value",
"float",
"floor",
"for",
"foreign",
"frame_row",
"free",
"from",
"full",
"function",
"fusion",
"get",
"global",
"grant",
"group",
"grouping",
"groups",
"having",
"hold",
"hour",
"identity",
"in",
"indicator",
"initial",
"inner",
"inout",
"insensitive",
"insert",
"int",
"integer",
"intersect",
"intersection",
"interval",
"into",
"is",
"join",
"json_array",
"json_arrayagg",
"json_exists",
"json_object",
"json_objectagg",
"json_query",
"json_table",
"json_table_primitive",
"json_value",
"lag",
"language",
"large",
"last_value",
"lateral",
"lead",
"leading",
"left",
"like",
"like_regex",
"listagg",
"ln",
"local",
"localtime",
"localtimestamp",
"log",
"log10",
"lower",
"match",
"match_number",
"match_recognize",
"matches",
"max",
"member",
"merge",
"method",
"min",
"minute",
"mod",
"modifies",
"module",
"month",
"multiset",
"national",
"natural",
"nchar",
"nclob",
"new",
"no",
"none",
"normalize",
"not",
"nth_value",
"ntile",
"null",
"nullif",
"numeric",
"octet_length",
"occurrences_regex",
"of",
"offset",
"old",
"omit",
"on",
"one",
"only",
"open",
"or",
"order",
"out",
"outer",
"over",
"overlaps",
"overlay",
"parameter",
"partition",
"pattern",
"per",
"percent",
"percent_rank",
"percentile_cont",
"percentile_disc",
"period",
"portion",
"position",
"position_regex",
"power",
"precedes",
"precision",
"prepare",
"primary",
"procedure",
"ptf",
"range",
"rank",
"reads",
"real",
"recursive",
"ref",
"references",
"referencing",
"regr_avgx",
"regr_avgy",
"regr_count",
"regr_intercept",
"regr_r2",
"regr_slope",
"regr_sxx",
"regr_sxy",
"regr_syy",
"release",
"result",
"return",
"returns",
"revoke",
"right",
"rollback",
"rollup",
"row",
"row_number",
"rows",
"running",
"savepoint",
"scope",
"scroll",
"search",
"second",
"seek",
"select",
"sensitive",
"session_user",
"set",
"show",
"similar",
"sin",
"sinh",
"skip",
"smallint",
"some",
"specific",
"specifictype",
"sql",
"sqlexception",
"sqlstate",
"sqlwarning",
"sqrt",
"start",
"static",
"stddev_pop",
"stddev_samp",
"submultiset",
"subset",
"substring",
"substring_regex",
"succeeds",
"sum",
"symmetric",
"system",
"system_time",
"system_user",
"table",
"tablesample",
"tan",
"tanh",
"then",
"time",
"timestamp",
"timezone_hour",
"timezone_minute",
"to",
"trailing",
"translate",
"translate_regex",
"translation",
"treat",
"trigger",
"trim",
"trim_array",
"true",
"truncate",
"uescape",
"union",
"unique",
"unknown",
"unnest",
"update",
"upper",
"user",
"using",
"value",
"values",
"value_of",
"var_pop",
"var_samp",
"varbinary",
"varchar",
"varying",
"versioning",
"when",
"whenever",
"where",
"width_bucket",
"window",
"with",
"within",
"without",
"year",
];
// these are reserved words we have identified to be functions
// and should only be highlighted in a dispatch-like context
// ie, array_agg(...), etc.
const RESERVED_FUNCTIONS = [
"abs",
"acos",
"array_agg",
"asin",
"atan",
"avg",
"cast",
"ceil",
"ceiling",
"coalesce",
"corr",
"cos",
"cosh",
"count",
"covar_pop",
"covar_samp",
"cume_dist",
"dense_rank",
"deref",
"element",
"exp",
"extract",
"first_value",
"floor",
"json_array",
"json_arrayagg",
"json_exists",
"json_object",
"json_objectagg",
"json_query",
"json_table",
"json_table_primitive",
"json_value",
"lag",
"last_value",
"lead",
"listagg",
"ln",
"log",
"log10",
"lower",
"max",
"min",
"mod",
"nth_value",
"ntile",
"nullif",
"percent_rank",
"percentile_cont",
"percentile_disc",
"position",
"position_regex",
"power",
"rank",
"regr_avgx",
"regr_avgy",
"regr_count",
"regr_intercept",
"regr_r2",
"regr_slope",
"regr_sxx",
"regr_sxy",
"regr_syy",
"row_number",
"sin",
"sinh",
"sqrt",
"stddev_pop",
"stddev_samp",
"substring",
"substring_regex",
"sum",
"tan",
"tanh",
"translate",
"translate_regex",
"treat",
"trim",
"trim_array",
"unnest",
"upper",
"value_of",
"var_pop",
"var_samp",
"width_bucket",
];
// these functions can
const POSSIBLE_WITHOUT_PARENS = [
"current_catalog",
"current_date",
"current_default_transform_group",
"current_path",
"current_role",
"current_schema",
"current_transform_group_for_type",
"current_user",
"session_user",
"system_time",
"system_user",
"current_time",
"localtime",
"current_timestamp",
"localtimestamp"
];
// those exist to boost relevance making these very
// "SQL like" keyword combos worth +1 extra relevance
const COMBOS = [
"create table",
"insert into",
"primary key",
"foreign key",
"not null",
"alter table",
"add constraint",
"grouping sets",
"on overflow",
"character set",
"respect nulls",
"ignore nulls",
"nulls first",
"nulls last",
"depth first",
"breadth first"
];
const FUNCTIONS = RESERVED_FUNCTIONS;
const KEYWORDS = [
...RESERVED_WORDS,
...NON_RESERVED_WORDS
].filter((keyword) => {
return !RESERVED_FUNCTIONS.includes(keyword);
});
const VARIABLE = {
scope: "variable",
match: /@[a-z0-9][a-z0-9_]*/,
};
const OPERATOR = {
scope: "operator",
match: /[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,
relevance: 0,
};
const FUNCTION_CALL = {
match: regex.concat(/\b/, regex.either(...FUNCTIONS), /\s*\(/),
relevance: 0,
keywords: { built_in: FUNCTIONS }
};
// turns a multi-word keyword combo into a regex that doesn't
// care about extra whitespace etc.
// input: "START QUERY"
// output: /\bSTART\s+QUERY\b/
function kws_to_regex(list) {
return regex.concat(
/\b/,
regex.either(...list.map((kw) => {
return kw.replace(/\s+/, "\\s+")
})),
/\b/
)
}
const MULTI_WORD_KEYWORDS = {
scope: "keyword",
match: kws_to_regex(COMBOS),
relevance: 0,
};
// keywords with less than 3 letters are reduced in relevancy
function reduceRelevancy(list, {
exceptions, when
} = {}) {
const qualifyFn = when;
exceptions = exceptions || [];
return list.map((item) => {
if (item.match(/\|\d+$/) || exceptions.includes(item)) {
return item;
} else if (qualifyFn(item)) {
return `${item}|0`;
} else {
return item;
}
});
}
return {
name: 'SQL',
case_insensitive: true,
// does not include {} or HTML tags `</`
illegal: /[{}]|<\//,
keywords: {
$pattern: /\b[\w\.]+/,
keyword:
reduceRelevancy(KEYWORDS, { when: (x) => x.length < 3 }),
literal: LITERALS,
type: TYPES,
built_in: POSSIBLE_WITHOUT_PARENS
},
contains: [
{
scope: "type",
match: kws_to_regex(MULTI_WORD_TYPES)
},
MULTI_WORD_KEYWORDS,
FUNCTION_CALL,
VARIABLE,
STRING,
QUOTED_IDENTIFIER,
hljs.C_NUMBER_MODE,
hljs.C_BLOCK_COMMENT_MODE,
COMMENT_MODE,
OPERATOR
]
};
}
return sql;
})();
;
export default hljsGrammar;

View File

@@ -0,0 +1,21 @@
/*! `sql` grammar compiled for Highlight.js 11.11.1 */
var hljsGrammar=(()=>{"use strict";return e=>{
const r=e.regex,t=e.COMMENT("--","$"),a=["abs","acos","array_agg","asin","atan","avg","cast","ceil","ceiling","coalesce","corr","cos","cosh","count","covar_pop","covar_samp","cume_dist","dense_rank","deref","element","exp","extract","first_value","floor","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","last_value","lead","listagg","ln","log","log10","lower","max","min","mod","nth_value","ntile","nullif","percent_rank","percentile_cont","percentile_disc","position","position_regex","power","rank","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","row_number","sin","sinh","sqrt","stddev_pop","stddev_samp","substring","substring_regex","sum","tan","tanh","translate","translate_regex","treat","trim","trim_array","unnest","upper","value_of","var_pop","var_samp","width_bucket"],n=a,s=["abs","acos","all","allocate","alter","and","any","are","array","array_agg","array_max_cardinality","as","asensitive","asin","asymmetric","at","atan","atomic","authorization","avg","begin","begin_frame","begin_partition","between","bigint","binary","blob","boolean","both","by","call","called","cardinality","cascaded","case","cast","ceil","ceiling","char","char_length","character","character_length","check","classifier","clob","close","coalesce","collate","collect","column","commit","condition","connect","constraint","contains","convert","copy","corr","corresponding","cos","cosh","count","covar_pop","covar_samp","create","cross","cube","cume_dist","current","current_catalog","current_date","current_default_transform_group","current_path","current_role","current_row","current_schema","current_time","current_timestamp","current_path","current_role","current_transform_group_for_type","current_user","cursor","cycle","date","day","deallocate","dec","decimal","decfloat","declare","default","define","delete","dense_rank","deref","describe","deterministic","disconnect","distinct","double","drop","dynamic","each","element","else","empty","end","end_frame","end_partition","end-exec","equals","escape","every","except","exec","execute","exists","exp","external","extract","false","fetch","filter","first_value","float","floor","for","foreign","frame_row","free","from","full","function","fusion","get","global","grant","group","grouping","groups","having","hold","hour","identity","in","indicator","initial","inner","inout","insensitive","insert","int","integer","intersect","intersection","interval","into","is","join","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","language","large","last_value","lateral","lead","leading","left","like","like_regex","listagg","ln","local","localtime","localtimestamp","log","log10","lower","match","match_number","match_recognize","matches","max","member","merge","method","min","minute","mod","modifies","module","month","multiset","national","natural","nchar","nclob","new","no","none","normalize","not","nth_value","ntile","null","nullif","numeric","octet_length","occurrences_regex","of","offset","old","omit","on","one","only","open","or","order","out","outer","over","overlaps","overlay","parameter","partition","pattern","per","percent","percent_rank","percentile_cont","percentile_disc","period","portion","position","position_regex","power","precedes","precision","prepare","primary","procedure","ptf","range","rank","reads","real","recursive","ref","references","referencing","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","release","result","return","returns","revoke","right","rollback","rollup","row","row_number","rows","running","savepoint","scope","scroll","search","second","seek","select","sensitive","session_user","set","show","similar","sin","sinh","skip","smallint","some","specific","specifictype","sql","sqlexception","sqlstate","sqlwarning","sqrt","start","static","stddev_pop","stddev_samp","submultiset","subset","substring","substring_regex","succeeds","sum","symmetric","system","system_time","system_user","table","tablesample","tan","tanh","then","time","timestamp","timezone_hour","timezone_minute","to","trailing","translate","translate_regex","translation","treat","trigger","trim","trim_array","true","truncate","uescape","union","unique","unknown","unnest","update","upper","user","using","value","values","value_of","var_pop","var_samp","varbinary","varchar","varying","versioning","when","whenever","where","width_bucket","window","with","within","without","year","add","asc","collation","desc","final","first","last","view"].filter((e=>!a.includes(e))),i={
match:r.concat(/\b/,r.either(...n),/\s*\(/),relevance:0,keywords:{built_in:n}}
;function o(e){
return r.concat(/\b/,r.either(...e.map((e=>e.replace(/\s+/,"\\s+")))),/\b/)}
const c={scope:"keyword",
match:o(["create table","insert into","primary key","foreign key","not null","alter table","add constraint","grouping sets","on overflow","character set","respect nulls","ignore nulls","nulls first","nulls last","depth first","breadth first"]),
relevance:0};return{name:"SQL",case_insensitive:!0,illegal:/[{}]|<\//,keywords:{
$pattern:/\b[\w\.]+/,keyword:((e,{exceptions:r,when:t}={})=>{const a=t
;return r=r||[],e.map((e=>e.match(/\|\d+$/)||r.includes(e)?e:a(e)?e+"|0":e))
})(s,{when:e=>e.length<3}),literal:["true","false","unknown"],
type:["bigint","binary","blob","boolean","char","character","clob","date","dec","decfloat","decimal","float","int","integer","interval","nchar","nclob","national","numeric","real","row","smallint","time","timestamp","varchar","varying","varbinary"],
built_in:["current_catalog","current_date","current_default_transform_group","current_path","current_role","current_schema","current_transform_group_for_type","current_user","session_user","system_time","system_user","current_time","localtime","current_timestamp","localtimestamp"]
},contains:[{scope:"type",
match:o(["double precision","large object","with timezone","without timezone"])
},c,i,{scope:"variable",match:/@[a-z0-9][a-z0-9_]*/},{scope:"string",variants:[{
begin:/'/,end:/'/,contains:[{match:/''/}]}]},{begin:/"/,end:/"/,contains:[{
match:/""/}]},e.C_NUMBER_MODE,e.C_BLOCK_COMMENT_MODE,t,{scope:"operator",
match:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0}]}}})()
;export default hljsGrammar;

View File

@@ -0,0 +1,921 @@
/*! `typescript` grammar compiled for Highlight.js 11.11.1 */
var hljsGrammar = (function () {
'use strict';
const IDENT_RE = '[A-Za-z$_][0-9A-Za-z$_]*';
const KEYWORDS = [
"as", // for exports
"in",
"of",
"if",
"for",
"while",
"finally",
"var",
"new",
"function",
"do",
"return",
"void",
"else",
"break",
"catch",
"instanceof",
"with",
"throw",
"case",
"default",
"try",
"switch",
"continue",
"typeof",
"delete",
"let",
"yield",
"const",
"class",
// JS handles these with a special rule
// "get",
// "set",
"debugger",
"async",
"await",
"static",
"import",
"from",
"export",
"extends",
// It's reached stage 3, which is "recommended for implementation":
"using"
];
const LITERALS = [
"true",
"false",
"null",
"undefined",
"NaN",
"Infinity"
];
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects
const TYPES = [
// Fundamental objects
"Object",
"Function",
"Boolean",
"Symbol",
// numbers and dates
"Math",
"Date",
"Number",
"BigInt",
// text
"String",
"RegExp",
// Indexed collections
"Array",
"Float32Array",
"Float64Array",
"Int8Array",
"Uint8Array",
"Uint8ClampedArray",
"Int16Array",
"Int32Array",
"Uint16Array",
"Uint32Array",
"BigInt64Array",
"BigUint64Array",
// Keyed collections
"Set",
"Map",
"WeakSet",
"WeakMap",
// Structured data
"ArrayBuffer",
"SharedArrayBuffer",
"Atomics",
"DataView",
"JSON",
// Control abstraction objects
"Promise",
"Generator",
"GeneratorFunction",
"AsyncFunction",
// Reflection
"Reflect",
"Proxy",
// Internationalization
"Intl",
// WebAssembly
"WebAssembly"
];
const ERROR_TYPES = [
"Error",
"EvalError",
"InternalError",
"RangeError",
"ReferenceError",
"SyntaxError",
"TypeError",
"URIError"
];
const BUILT_IN_GLOBALS = [
"setInterval",
"setTimeout",
"clearInterval",
"clearTimeout",
"require",
"exports",
"eval",
"isFinite",
"isNaN",
"parseFloat",
"parseInt",
"decodeURI",
"decodeURIComponent",
"encodeURI",
"encodeURIComponent",
"escape",
"unescape"
];
const BUILT_IN_VARIABLES = [
"arguments",
"this",
"super",
"console",
"window",
"document",
"localStorage",
"sessionStorage",
"module",
"global" // Node.js
];
const BUILT_INS = [].concat(
BUILT_IN_GLOBALS,
TYPES,
ERROR_TYPES
);
/*
Language: JavaScript
Description: JavaScript (JS) is a lightweight, interpreted, or just-in-time compiled programming language with first-class functions.
Category: common, scripting, web
Website: https://developer.mozilla.org/en-US/docs/Web/JavaScript
*/
/** @type LanguageFn */
function javascript(hljs) {
const regex = hljs.regex;
/**
* Takes a string like "<Booger" and checks to see
* if we can find a matching "</Booger" later in the
* content.
* @param {RegExpMatchArray} match
* @param {{after:number}} param1
*/
const hasClosingTag = (match, { after }) => {
const tag = "</" + match[0].slice(1);
const pos = match.input.indexOf(tag, after);
return pos !== -1;
};
const IDENT_RE$1 = IDENT_RE;
const FRAGMENT = {
begin: '<>',
end: '</>'
};
// to avoid some special cases inside isTrulyOpeningTag
const XML_SELF_CLOSING = /<[A-Za-z0-9\\._:-]+\s*\/>/;
const XML_TAG = {
begin: /<[A-Za-z0-9\\._:-]+/,
end: /\/[A-Za-z0-9\\._:-]+>|\/>/,
/**
* @param {RegExpMatchArray} match
* @param {CallbackResponse} response
*/
isTrulyOpeningTag: (match, response) => {
const afterMatchIndex = match[0].length + match.index;
const nextChar = match.input[afterMatchIndex];
if (
// HTML should not include another raw `<` inside a tag
// nested type?
// `<Array<Array<number>>`, etc.
nextChar === "<" ||
// the , gives away that this is not HTML
// `<T, A extends keyof T, V>`
nextChar === ","
) {
response.ignoreMatch();
return;
}
// `<something>`
// Quite possibly a tag, lets look for a matching closing tag...
if (nextChar === ">") {
// if we cannot find a matching closing tag, then we
// will ignore it
if (!hasClosingTag(match, { after: afterMatchIndex })) {
response.ignoreMatch();
}
}
// `<blah />` (self-closing)
// handled by simpleSelfClosing rule
let m;
const afterMatch = match.input.substring(afterMatchIndex);
// some more template typing stuff
// <T = any>(key?: string) => Modify<
if ((m = afterMatch.match(/^\s*=/))) {
response.ignoreMatch();
return;
}
// `<From extends string>`
// technically this could be HTML, but it smells like a type
// NOTE: This is ugh, but added specifically for https://github.com/highlightjs/highlight.js/issues/3276
if ((m = afterMatch.match(/^\s+extends\s+/))) {
if (m.index === 0) {
response.ignoreMatch();
// eslint-disable-next-line no-useless-return
return;
}
}
}
};
const KEYWORDS$1 = {
$pattern: IDENT_RE,
keyword: KEYWORDS,
literal: LITERALS,
built_in: BUILT_INS,
"variable.language": BUILT_IN_VARIABLES
};
// https://tc39.es/ecma262/#sec-literals-numeric-literals
const decimalDigits = '[0-9](_?[0-9])*';
const frac = `\\.(${decimalDigits})`;
// DecimalIntegerLiteral, including Annex B NonOctalDecimalIntegerLiteral
// https://tc39.es/ecma262/#sec-additional-syntax-numeric-literals
const decimalInteger = `0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*`;
const NUMBER = {
className: 'number',
variants: [
// DecimalLiteral
{ begin: `(\\b(${decimalInteger})((${frac})|\\.)?|(${frac}))` +
`[eE][+-]?(${decimalDigits})\\b` },
{ begin: `\\b(${decimalInteger})\\b((${frac})\\b|\\.)?|(${frac})\\b` },
// DecimalBigIntegerLiteral
{ begin: `\\b(0|[1-9](_?[0-9])*)n\\b` },
// NonDecimalIntegerLiteral
{ begin: "\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b" },
{ begin: "\\b0[bB][0-1](_?[0-1])*n?\\b" },
{ begin: "\\b0[oO][0-7](_?[0-7])*n?\\b" },
// LegacyOctalIntegerLiteral (does not include underscore separators)
// https://tc39.es/ecma262/#sec-additional-syntax-numeric-literals
{ begin: "\\b0[0-7]+n?\\b" },
],
relevance: 0
};
const SUBST = {
className: 'subst',
begin: '\\$\\{',
end: '\\}',
keywords: KEYWORDS$1,
contains: [] // defined later
};
const HTML_TEMPLATE = {
begin: '\.?html`',
end: '',
starts: {
end: '`',
returnEnd: false,
contains: [
hljs.BACKSLASH_ESCAPE,
SUBST
],
subLanguage: 'xml'
}
};
const CSS_TEMPLATE = {
begin: '\.?css`',
end: '',
starts: {
end: '`',
returnEnd: false,
contains: [
hljs.BACKSLASH_ESCAPE,
SUBST
],
subLanguage: 'css'
}
};
const GRAPHQL_TEMPLATE = {
begin: '\.?gql`',
end: '',
starts: {
end: '`',
returnEnd: false,
contains: [
hljs.BACKSLASH_ESCAPE,
SUBST
],
subLanguage: 'graphql'
}
};
const TEMPLATE_STRING = {
className: 'string',
begin: '`',
end: '`',
contains: [
hljs.BACKSLASH_ESCAPE,
SUBST
]
};
const JSDOC_COMMENT = hljs.COMMENT(
/\/\*\*(?!\/)/,
'\\*/',
{
relevance: 0,
contains: [
{
begin: '(?=@[A-Za-z]+)',
relevance: 0,
contains: [
{
className: 'doctag',
begin: '@[A-Za-z]+'
},
{
className: 'type',
begin: '\\{',
end: '\\}',
excludeEnd: true,
excludeBegin: true,
relevance: 0
},
{
className: 'variable',
begin: IDENT_RE$1 + '(?=\\s*(-)|$)',
endsParent: true,
relevance: 0
},
// eat spaces (not newlines) so we can find
// types or variables
{
begin: /(?=[^\n])\s/,
relevance: 0
}
]
}
]
}
);
const COMMENT = {
className: "comment",
variants: [
JSDOC_COMMENT,
hljs.C_BLOCK_COMMENT_MODE,
hljs.C_LINE_COMMENT_MODE
]
};
const SUBST_INTERNALS = [
hljs.APOS_STRING_MODE,
hljs.QUOTE_STRING_MODE,
HTML_TEMPLATE,
CSS_TEMPLATE,
GRAPHQL_TEMPLATE,
TEMPLATE_STRING,
// Skip numbers when they are part of a variable name
{ match: /\$\d+/ },
NUMBER,
// This is intentional:
// See https://github.com/highlightjs/highlight.js/issues/3288
// hljs.REGEXP_MODE
];
SUBST.contains = SUBST_INTERNALS
.concat({
// we need to pair up {} inside our subst to prevent
// it from ending too early by matching another }
begin: /\{/,
end: /\}/,
keywords: KEYWORDS$1,
contains: [
"self"
].concat(SUBST_INTERNALS)
});
const SUBST_AND_COMMENTS = [].concat(COMMENT, SUBST.contains);
const PARAMS_CONTAINS = SUBST_AND_COMMENTS.concat([
// eat recursive parens in sub expressions
{
begin: /(\s*)\(/,
end: /\)/,
keywords: KEYWORDS$1,
contains: ["self"].concat(SUBST_AND_COMMENTS)
}
]);
const PARAMS = {
className: 'params',
// convert this to negative lookbehind in v12
begin: /(\s*)\(/, // to match the parms with
end: /\)/,
excludeBegin: true,
excludeEnd: true,
keywords: KEYWORDS$1,
contains: PARAMS_CONTAINS
};
// ES6 classes
const CLASS_OR_EXTENDS = {
variants: [
// class Car extends vehicle
{
match: [
/class/,
/\s+/,
IDENT_RE$1,
/\s+/,
/extends/,
/\s+/,
regex.concat(IDENT_RE$1, "(", regex.concat(/\./, IDENT_RE$1), ")*")
],
scope: {
1: "keyword",
3: "title.class",
5: "keyword",
7: "title.class.inherited"
}
},
// class Car
{
match: [
/class/,
/\s+/,
IDENT_RE$1
],
scope: {
1: "keyword",
3: "title.class"
}
},
]
};
const CLASS_REFERENCE = {
relevance: 0,
match:
regex.either(
// Hard coded exceptions
/\bJSON/,
// Float32Array, OutT
/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,
// CSSFactory, CSSFactoryT
/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,
// FPs, FPsT
/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/,
// P
// single letters are not highlighted
// BLAH
// this will be flagged as a UPPER_CASE_CONSTANT instead
),
className: "title.class",
keywords: {
_: [
// se we still get relevance credit for JS library classes
...TYPES,
...ERROR_TYPES
]
}
};
const USE_STRICT = {
label: "use_strict",
className: 'meta',
relevance: 10,
begin: /^\s*['"]use (strict|asm)['"]/
};
const FUNCTION_DEFINITION = {
variants: [
{
match: [
/function/,
/\s+/,
IDENT_RE$1,
/(?=\s*\()/
]
},
// anonymous function
{
match: [
/function/,
/\s*(?=\()/
]
}
],
className: {
1: "keyword",
3: "title.function"
},
label: "func.def",
contains: [ PARAMS ],
illegal: /%/
};
const UPPER_CASE_CONSTANT = {
relevance: 0,
match: /\b[A-Z][A-Z_0-9]+\b/,
className: "variable.constant"
};
function noneOf(list) {
return regex.concat("(?!", list.join("|"), ")");
}
const FUNCTION_CALL = {
match: regex.concat(
/\b/,
noneOf([
...BUILT_IN_GLOBALS,
"super",
"import"
].map(x => `${x}\\s*\\(`)),
IDENT_RE$1, regex.lookahead(/\s*\(/)),
className: "title.function",
relevance: 0
};
const PROPERTY_ACCESS = {
begin: regex.concat(/\./, regex.lookahead(
regex.concat(IDENT_RE$1, /(?![0-9A-Za-z$_(])/)
)),
end: IDENT_RE$1,
excludeBegin: true,
keywords: "prototype",
className: "property",
relevance: 0
};
const GETTER_OR_SETTER = {
match: [
/get|set/,
/\s+/,
IDENT_RE$1,
/(?=\()/
],
className: {
1: "keyword",
3: "title.function"
},
contains: [
{ // eat to avoid empty params
begin: /\(\)/
},
PARAMS
]
};
const FUNC_LEAD_IN_RE = '(\\(' +
'[^()]*(\\(' +
'[^()]*(\\(' +
'[^()]*' +
'\\)[^()]*)*' +
'\\)[^()]*)*' +
'\\)|' + hljs.UNDERSCORE_IDENT_RE + ')\\s*=>';
const FUNCTION_VARIABLE = {
match: [
/const|var|let/, /\s+/,
IDENT_RE$1, /\s*/,
/=\s*/,
/(async\s*)?/, // async is optional
regex.lookahead(FUNC_LEAD_IN_RE)
],
keywords: "async",
className: {
1: "keyword",
3: "title.function"
},
contains: [
PARAMS
]
};
return {
name: 'JavaScript',
aliases: ['js', 'jsx', 'mjs', 'cjs'],
keywords: KEYWORDS$1,
// this will be extended by TypeScript
exports: { PARAMS_CONTAINS, CLASS_REFERENCE },
illegal: /#(?![$_A-z])/,
contains: [
hljs.SHEBANG({
label: "shebang",
binary: "node",
relevance: 5
}),
USE_STRICT,
hljs.APOS_STRING_MODE,
hljs.QUOTE_STRING_MODE,
HTML_TEMPLATE,
CSS_TEMPLATE,
GRAPHQL_TEMPLATE,
TEMPLATE_STRING,
COMMENT,
// Skip numbers when they are part of a variable name
{ match: /\$\d+/ },
NUMBER,
CLASS_REFERENCE,
{
scope: 'attr',
match: IDENT_RE$1 + regex.lookahead(':'),
relevance: 0
},
FUNCTION_VARIABLE,
{ // "value" container
begin: '(' + hljs.RE_STARTERS_RE + '|\\b(case|return|throw)\\b)\\s*',
keywords: 'return throw case',
relevance: 0,
contains: [
COMMENT,
hljs.REGEXP_MODE,
{
className: 'function',
// we have to count the parens to make sure we actually have the
// correct bounding ( ) before the =>. There could be any number of
// sub-expressions inside also surrounded by parens.
begin: FUNC_LEAD_IN_RE,
returnBegin: true,
end: '\\s*=>',
contains: [
{
className: 'params',
variants: [
{
begin: hljs.UNDERSCORE_IDENT_RE,
relevance: 0
},
{
className: null,
begin: /\(\s*\)/,
skip: true
},
{
begin: /(\s*)\(/,
end: /\)/,
excludeBegin: true,
excludeEnd: true,
keywords: KEYWORDS$1,
contains: PARAMS_CONTAINS
}
]
}
]
},
{ // could be a comma delimited list of params to a function call
begin: /,/,
relevance: 0
},
{
match: /\s+/,
relevance: 0
},
{ // JSX
variants: [
{ begin: FRAGMENT.begin, end: FRAGMENT.end },
{ match: XML_SELF_CLOSING },
{
begin: XML_TAG.begin,
// we carefully check the opening tag to see if it truly
// is a tag and not a false positive
'on:begin': XML_TAG.isTrulyOpeningTag,
end: XML_TAG.end
}
],
subLanguage: 'xml',
contains: [
{
begin: XML_TAG.begin,
end: XML_TAG.end,
skip: true,
contains: ['self']
}
]
}
],
},
FUNCTION_DEFINITION,
{
// prevent this from getting swallowed up by function
// since they appear "function like"
beginKeywords: "while if switch catch for"
},
{
// we have to count the parens to make sure we actually have the correct
// bounding ( ). There could be any number of sub-expressions inside
// also surrounded by parens.
begin: '\\b(?!function)' + hljs.UNDERSCORE_IDENT_RE +
'\\(' + // first parens
'[^()]*(\\(' +
'[^()]*(\\(' +
'[^()]*' +
'\\)[^()]*)*' +
'\\)[^()]*)*' +
'\\)\\s*\\{', // end parens
returnBegin:true,
label: "func.def",
contains: [
PARAMS,
hljs.inherit(hljs.TITLE_MODE, { begin: IDENT_RE$1, className: "title.function" })
]
},
// catch ... so it won't trigger the property rule below
{
match: /\.\.\./,
relevance: 0
},
PROPERTY_ACCESS,
// hack: prevents detection of keywords in some circumstances
// .keyword()
// $keyword = x
{
match: '\\$' + IDENT_RE$1,
relevance: 0
},
{
match: [ /\bconstructor(?=\s*\()/ ],
className: { 1: "title.function" },
contains: [ PARAMS ]
},
FUNCTION_CALL,
UPPER_CASE_CONSTANT,
CLASS_OR_EXTENDS,
GETTER_OR_SETTER,
{
match: /\$[(.]/ // relevance booster for a pattern common to JS libs: `$(something)` and `$.something`
}
]
};
}
/*
Language: TypeScript
Author: Panu Horsmalahti <panu.horsmalahti@iki.fi>
Contributors: Ike Ku <dempfi@yahoo.com>
Description: TypeScript is a strict superset of JavaScript
Website: https://www.typescriptlang.org
Category: common, scripting
*/
/** @type LanguageFn */
function typescript(hljs) {
const regex = hljs.regex;
const tsLanguage = javascript(hljs);
const IDENT_RE$1 = IDENT_RE;
const TYPES = [
"any",
"void",
"number",
"boolean",
"string",
"object",
"never",
"symbol",
"bigint",
"unknown"
];
const NAMESPACE = {
begin: [
/namespace/,
/\s+/,
hljs.IDENT_RE
],
beginScope: {
1: "keyword",
3: "title.class"
}
};
const INTERFACE = {
beginKeywords: 'interface',
end: /\{/,
excludeEnd: true,
keywords: {
keyword: 'interface extends',
built_in: TYPES
},
contains: [ tsLanguage.exports.CLASS_REFERENCE ]
};
const USE_STRICT = {
className: 'meta',
relevance: 10,
begin: /^\s*['"]use strict['"]/
};
const TS_SPECIFIC_KEYWORDS = [
"type",
// "namespace",
"interface",
"public",
"private",
"protected",
"implements",
"declare",
"abstract",
"readonly",
"enum",
"override",
"satisfies"
];
/*
namespace is a TS keyword but it's fine to use it as a variable name too.
const message = 'foo';
const namespace = 'bar';
*/
const KEYWORDS$1 = {
$pattern: IDENT_RE,
keyword: KEYWORDS.concat(TS_SPECIFIC_KEYWORDS),
literal: LITERALS,
built_in: BUILT_INS.concat(TYPES),
"variable.language": BUILT_IN_VARIABLES
};
const DECORATOR = {
className: 'meta',
begin: '@' + IDENT_RE$1,
};
const swapMode = (mode, label, replacement) => {
const indx = mode.contains.findIndex(m => m.label === label);
if (indx === -1) { throw new Error("can not find mode to replace"); }
mode.contains.splice(indx, 1, replacement);
};
// this should update anywhere keywords is used since
// it will be the same actual JS object
Object.assign(tsLanguage.keywords, KEYWORDS$1);
tsLanguage.exports.PARAMS_CONTAINS.push(DECORATOR);
// highlight the function params
const ATTRIBUTE_HIGHLIGHT = tsLanguage.contains.find(c => c.scope === "attr");
// take default attr rule and extend it to support optionals
const OPTIONAL_KEY_OR_ARGUMENT = Object.assign({},
ATTRIBUTE_HIGHLIGHT,
{ match: regex.concat(IDENT_RE$1, regex.lookahead(/\s*\?:/)) }
);
tsLanguage.exports.PARAMS_CONTAINS.push([
tsLanguage.exports.CLASS_REFERENCE, // class reference for highlighting the params types
ATTRIBUTE_HIGHLIGHT, // highlight the params key
OPTIONAL_KEY_OR_ARGUMENT, // Added for optional property assignment highlighting
]);
// Add the optional property assignment highlighting for objects or classes
tsLanguage.contains = tsLanguage.contains.concat([
DECORATOR,
NAMESPACE,
INTERFACE,
OPTIONAL_KEY_OR_ARGUMENT, // Added for optional property assignment highlighting
]);
// TS gets a simpler shebang rule than JS
swapMode(tsLanguage, "shebang", hljs.SHEBANG());
// JS use strict rule purposely excludes `asm` which makes no sense
swapMode(tsLanguage, "use_strict", USE_STRICT);
const functionDeclaration = tsLanguage.contains.find(m => m.label === "func.def");
functionDeclaration.relevance = 0; // () => {} is more typical in TypeScript
Object.assign(tsLanguage, {
name: 'TypeScript',
aliases: [
'ts',
'tsx',
'mts',
'cts'
]
});
return tsLanguage;
}
return typescript;
})();
;
export default hljsGrammar;

View File

@@ -0,0 +1,99 @@
/*! `typescript` grammar compiled for Highlight.js 11.11.1 */
var hljsGrammar=(()=>{"use strict"
;const e="[A-Za-z$_][0-9A-Za-z$_]*",n=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],a=["true","false","null","undefined","NaN","Infinity"],t=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],s=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],r=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],c=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],i=[].concat(r,t,s)
;function o(o){const l=o.regex,d=e,b={begin:/<[A-Za-z0-9\\._:-]+/,
end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(e,n)=>{
const a=e[0].length+e.index,t=e.input[a]
;if("<"===t||","===t)return void n.ignoreMatch();let s
;">"===t&&(((e,{after:n})=>{const a="</"+e[0].slice(1)
;return-1!==e.input.indexOf(a,n)})(e,{after:a})||n.ignoreMatch())
;const r=e.input.substring(a)
;((s=r.match(/^\s*=/))||(s=r.match(/^\s+extends\s+/))&&0===s.index)&&n.ignoreMatch()
}},g={$pattern:e,keyword:n,literal:a,built_in:i,"variable.language":c
},u="[0-9](_?[0-9])*",m=`\\.(${u})`,E="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",A={
className:"number",variants:[{
begin:`(\\b(${E})((${m})|\\.)?|(${m}))[eE][+-]?(${u})\\b`},{
begin:`\\b(${E})\\b((${m})\\b|\\.)?|(${m})\\b`},{
begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{
begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{
begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{
begin:"\\b0[0-7]+n?\\b"}],relevance:0},y={className:"subst",begin:"\\$\\{",
end:"\\}",keywords:g,contains:[]},p={begin:".?html`",end:"",starts:{end:"`",
returnEnd:!1,contains:[o.BACKSLASH_ESCAPE,y],subLanguage:"xml"}},f={
begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,
contains:[o.BACKSLASH_ESCAPE,y],subLanguage:"css"}},N={begin:".?gql`",end:"",
starts:{end:"`",returnEnd:!1,contains:[o.BACKSLASH_ESCAPE,y],
subLanguage:"graphql"}},h={className:"string",begin:"`",end:"`",
contains:[o.BACKSLASH_ESCAPE,y]},_={className:"comment",
variants:[o.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{
begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",
begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,
excludeBegin:!0,relevance:0},{className:"variable",begin:d+"(?=\\s*(-)|$)",
endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]
}),o.C_BLOCK_COMMENT_MODE,o.C_LINE_COMMENT_MODE]
},S=[o.APOS_STRING_MODE,o.QUOTE_STRING_MODE,p,f,N,h,{match:/\$\d+/},A]
;y.contains=S.concat({begin:/\{/,end:/\}/,keywords:g,contains:["self"].concat(S)
});const v=[].concat(_,y.contains),w=v.concat([{begin:/(\s*)\(/,end:/\)/,
keywords:g,contains:["self"].concat(v)}]),R={className:"params",begin:/(\s*)\(/,
end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:g,contains:w},x={variants:[{
match:[/class/,/\s+/,d,/\s+/,/extends/,/\s+/,l.concat(d,"(",l.concat(/\./,d),")*")],
scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{
match:[/class/,/\s+/,d],scope:{1:"keyword",3:"title.class"}}]},k={relevance:0,
match:l.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),
className:"title.class",keywords:{_:[...t,...s]}},O={variants:[{
match:[/function/,/\s+/,d,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],
className:{1:"keyword",3:"title.function"},label:"func.def",contains:[R],
illegal:/%/},I={
match:l.concat(/\b/,(C=[...r,"super","import"].map((e=>e+"\\s*\\(")),
l.concat("(?!",C.join("|"),")")),d,l.lookahead(/\s*\(/)),
className:"title.function",relevance:0};var C;const T={
begin:l.concat(/\./,l.lookahead(l.concat(d,/(?![0-9A-Za-z$_(])/))),end:d,
excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},M={
match:[/get|set/,/\s+/,d,/(?=\()/],className:{1:"keyword",3:"title.function"},
contains:[{begin:/\(\)/},R]
},B="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+o.UNDERSCORE_IDENT_RE+")\\s*=>",$={
match:[/const|var|let/,/\s+/,d,/\s*/,/=\s*/,/(async\s*)?/,l.lookahead(B)],
keywords:"async",className:{1:"keyword",3:"title.function"},contains:[R]}
;return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:g,exports:{
PARAMS_CONTAINS:w,CLASS_REFERENCE:k},illegal:/#(?![$_A-z])/,
contains:[o.SHEBANG({label:"shebang",binary:"node",relevance:5}),{
label:"use_strict",className:"meta",relevance:10,
begin:/^\s*['"]use (strict|asm)['"]/
},o.APOS_STRING_MODE,o.QUOTE_STRING_MODE,p,f,N,h,_,{match:/\$\d+/},A,k,{
scope:"attr",match:d+l.lookahead(":"),relevance:0},$,{
begin:"("+o.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",
keywords:"return throw case",relevance:0,contains:[_,o.REGEXP_MODE,{
className:"function",begin:B,returnBegin:!0,end:"\\s*=>",contains:[{
className:"params",variants:[{begin:o.UNDERSCORE_IDENT_RE,relevance:0},{
className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,
excludeBegin:!0,excludeEnd:!0,keywords:g,contains:w}]}]},{begin:/,/,relevance:0
},{match:/\s+/,relevance:0},{variants:[{begin:"<>",end:"</>"},{
match:/<[A-Za-z0-9\\._:-]+\s*\/>/},{begin:b.begin,
"on:begin":b.isTrulyOpeningTag,end:b.end}],subLanguage:"xml",contains:[{
begin:b.begin,end:b.end,skip:!0,contains:["self"]}]}]},O,{
beginKeywords:"while if switch catch for"},{
begin:"\\b(?!function)"+o.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",
returnBegin:!0,label:"func.def",contains:[R,o.inherit(o.TITLE_MODE,{begin:d,
className:"title.function"})]},{match:/\.\.\./,relevance:0},T,{match:"\\$"+d,
relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},
contains:[R]},I,{relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,
className:"variable.constant"},x,M,{match:/\$[(.]/}]}}return t=>{
const s=t.regex,r=o(t),l=e,d=["any","void","number","boolean","string","object","never","symbol","bigint","unknown"],b={
begin:[/namespace/,/\s+/,t.IDENT_RE],beginScope:{1:"keyword",3:"title.class"}
},g={beginKeywords:"interface",end:/\{/,excludeEnd:!0,keywords:{
keyword:"interface extends",built_in:d},contains:[r.exports.CLASS_REFERENCE]
},u={$pattern:e,
keyword:n.concat(["type","interface","public","private","protected","implements","declare","abstract","readonly","enum","override","satisfies"]),
literal:a,built_in:i.concat(d),"variable.language":c},m={className:"meta",
begin:"@"+l},E=(e,n,a)=>{const t=e.contains.findIndex((e=>e.label===n))
;if(-1===t)throw Error("can not find mode to replace");e.contains.splice(t,1,a)}
;Object.assign(r.keywords,u),r.exports.PARAMS_CONTAINS.push(m)
;const A=r.contains.find((e=>"attr"===e.scope)),y=Object.assign({},A,{
match:s.concat(l,s.lookahead(/\s*\?:/))})
;return r.exports.PARAMS_CONTAINS.push([r.exports.CLASS_REFERENCE,A,y]),
r.contains=r.contains.concat([m,b,g,y]),
E(r,"shebang",t.SHEBANG()),E(r,"use_strict",{className:"meta",relevance:10,
begin:/^\s*['"]use strict['"]/
}),r.contains.find((e=>"func.def"===e.label)).relevance=0,Object.assign(r,{
name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),r}})()
;export default hljsGrammar;

View File

@@ -0,0 +1,228 @@
/*! `vbscript` grammar compiled for Highlight.js 11.11.1 */
var hljsGrammar = (function () {
'use strict';
/*
Language: VBScript
Description: VBScript ("Microsoft Visual Basic Scripting Edition") is an Active Scripting language developed by Microsoft that is modeled on Visual Basic.
Author: Nikita Ledyaev <lenikita@yandex.ru>
Contributors: Michal Gabrukiewicz <mgabru@gmail.com>
Website: https://en.wikipedia.org/wiki/VBScript
Category: scripting
*/
/** @type LanguageFn */
function vbscript(hljs) {
const regex = hljs.regex;
const BUILT_IN_FUNCTIONS = [
"lcase",
"month",
"vartype",
"instrrev",
"ubound",
"setlocale",
"getobject",
"rgb",
"getref",
"string",
"weekdayname",
"rnd",
"dateadd",
"monthname",
"now",
"day",
"minute",
"isarray",
"cbool",
"round",
"formatcurrency",
"conversions",
"csng",
"timevalue",
"second",
"year",
"space",
"abs",
"clng",
"timeserial",
"fixs",
"len",
"asc",
"isempty",
"maths",
"dateserial",
"atn",
"timer",
"isobject",
"filter",
"weekday",
"datevalue",
"ccur",
"isdate",
"instr",
"datediff",
"formatdatetime",
"replace",
"isnull",
"right",
"sgn",
"array",
"snumeric",
"log",
"cdbl",
"hex",
"chr",
"lbound",
"msgbox",
"ucase",
"getlocale",
"cos",
"cdate",
"cbyte",
"rtrim",
"join",
"hour",
"oct",
"typename",
"trim",
"strcomp",
"int",
"createobject",
"loadpicture",
"tan",
"formatnumber",
"mid",
"split",
"cint",
"sin",
"datepart",
"ltrim",
"sqr",
"time",
"derived",
"eval",
"date",
"formatpercent",
"exp",
"inputbox",
"left",
"ascw",
"chrw",
"regexp",
"cstr",
"err"
];
const BUILT_IN_OBJECTS = [
"server",
"response",
"request",
// take no arguments so can be called without ()
"scriptengine",
"scriptenginebuildversion",
"scriptengineminorversion",
"scriptenginemajorversion"
];
const BUILT_IN_CALL = {
begin: regex.concat(regex.either(...BUILT_IN_FUNCTIONS), "\\s*\\("),
// relevance 0 because this is acting as a beginKeywords really
relevance: 0,
keywords: { built_in: BUILT_IN_FUNCTIONS }
};
const LITERALS = [
"true",
"false",
"null",
"nothing",
"empty"
];
const KEYWORDS = [
"call",
"class",
"const",
"dim",
"do",
"loop",
"erase",
"execute",
"executeglobal",
"exit",
"for",
"each",
"next",
"function",
"if",
"then",
"else",
"on",
"error",
"option",
"explicit",
"new",
"private",
"property",
"let",
"get",
"public",
"randomize",
"redim",
"rem",
"select",
"case",
"set",
"stop",
"sub",
"while",
"wend",
"with",
"end",
"to",
"elseif",
"is",
"or",
"xor",
"and",
"not",
"class_initialize",
"class_terminate",
"default",
"preserve",
"in",
"me",
"byval",
"byref",
"step",
"resume",
"goto"
];
return {
name: 'VBScript',
aliases: [ 'vbs' ],
case_insensitive: true,
keywords: {
keyword: KEYWORDS,
built_in: BUILT_IN_OBJECTS,
literal: LITERALS
},
illegal: '//',
contains: [
BUILT_IN_CALL,
hljs.inherit(hljs.QUOTE_STRING_MODE, { contains: [ { begin: '""' } ] }),
hljs.COMMENT(
/'/,
/$/,
{ relevance: 0 }
),
hljs.C_NUMBER_MODE
]
};
}
return vbscript;
})();
;
export default hljsGrammar;

View File

@@ -0,0 +1,10 @@
/*! `vbscript` grammar compiled for Highlight.js 11.11.1 */
var hljsGrammar=(()=>{"use strict";return e=>{
const t=e.regex,r=["lcase","month","vartype","instrrev","ubound","setlocale","getobject","rgb","getref","string","weekdayname","rnd","dateadd","monthname","now","day","minute","isarray","cbool","round","formatcurrency","conversions","csng","timevalue","second","year","space","abs","clng","timeserial","fixs","len","asc","isempty","maths","dateserial","atn","timer","isobject","filter","weekday","datevalue","ccur","isdate","instr","datediff","formatdatetime","replace","isnull","right","sgn","array","snumeric","log","cdbl","hex","chr","lbound","msgbox","ucase","getlocale","cos","cdate","cbyte","rtrim","join","hour","oct","typename","trim","strcomp","int","createobject","loadpicture","tan","formatnumber","mid","split","cint","sin","datepart","ltrim","sqr","time","derived","eval","date","formatpercent","exp","inputbox","left","ascw","chrw","regexp","cstr","err"]
;return{name:"VBScript",aliases:["vbs"],case_insensitive:!0,keywords:{
keyword:["call","class","const","dim","do","loop","erase","execute","executeglobal","exit","for","each","next","function","if","then","else","on","error","option","explicit","new","private","property","let","get","public","randomize","redim","rem","select","case","set","stop","sub","while","wend","with","end","to","elseif","is","or","xor","and","not","class_initialize","class_terminate","default","preserve","in","me","byval","byref","step","resume","goto"],
built_in:["server","response","request","scriptengine","scriptenginebuildversion","scriptengineminorversion","scriptenginemajorversion"],
literal:["true","false","null","nothing","empty"]},illegal:"//",contains:[{
begin:t.concat(t.either(...r),"\\s*\\("),relevance:0,keywords:{built_in:r}
},e.inherit(e.QUOTE_STRING_MODE,{contains:[{begin:'""'}]}),e.COMMENT(/'/,/$/,{
relevance:0}),e.C_NUMBER_MODE]}}})();export default hljsGrammar;

View File

@@ -0,0 +1,249 @@
/*! `xml` grammar compiled for Highlight.js 11.11.1 */
var hljsGrammar = (function () {
'use strict';
/*
Language: HTML, XML
Website: https://www.w3.org/XML/
Category: common, web
Audit: 2020
*/
/** @type LanguageFn */
function xml(hljs) {
const regex = hljs.regex;
// XML names can have the following additional letters: https://www.w3.org/TR/xml/#NT-NameChar
// OTHER_NAME_CHARS = /[:\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]/;
// Element names start with NAME_START_CHAR followed by optional other Unicode letters, ASCII digits, hyphens, underscores, and periods
// const TAG_NAME_RE = regex.concat(/[A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/, regex.optional(/[A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*:/), /[A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*/);;
// const XML_IDENT_RE = /[A-Z_a-z:\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]+/;
// const TAG_NAME_RE = regex.concat(/[A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/, regex.optional(/[A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*:/), /[A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*/);
// however, to cater for performance and more Unicode support rely simply on the Unicode letter class
const TAG_NAME_RE = regex.concat(/[\p{L}_]/u, regex.optional(/[\p{L}0-9_.-]*:/u), /[\p{L}0-9_.-]*/u);
const XML_IDENT_RE = /[\p{L}0-9._:-]+/u;
const XML_ENTITIES = {
className: 'symbol',
begin: /&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/
};
const XML_META_KEYWORDS = {
begin: /\s/,
contains: [
{
className: 'keyword',
begin: /#?[a-z_][a-z1-9_-]+/,
illegal: /\n/
}
]
};
const XML_META_PAR_KEYWORDS = hljs.inherit(XML_META_KEYWORDS, {
begin: /\(/,
end: /\)/
});
const APOS_META_STRING_MODE = hljs.inherit(hljs.APOS_STRING_MODE, { className: 'string' });
const QUOTE_META_STRING_MODE = hljs.inherit(hljs.QUOTE_STRING_MODE, { className: 'string' });
const TAG_INTERNALS = {
endsWithParent: true,
illegal: /</,
relevance: 0,
contains: [
{
className: 'attr',
begin: XML_IDENT_RE,
relevance: 0
},
{
begin: /=\s*/,
relevance: 0,
contains: [
{
className: 'string',
endsParent: true,
variants: [
{
begin: /"/,
end: /"/,
contains: [ XML_ENTITIES ]
},
{
begin: /'/,
end: /'/,
contains: [ XML_ENTITIES ]
},
{ begin: /[^\s"'=<>`]+/ }
]
}
]
}
]
};
return {
name: 'HTML, XML',
aliases: [
'html',
'xhtml',
'rss',
'atom',
'xjb',
'xsd',
'xsl',
'plist',
'wsf',
'svg'
],
case_insensitive: true,
unicodeRegex: true,
contains: [
{
className: 'meta',
begin: /<![a-z]/,
end: />/,
relevance: 10,
contains: [
XML_META_KEYWORDS,
QUOTE_META_STRING_MODE,
APOS_META_STRING_MODE,
XML_META_PAR_KEYWORDS,
{
begin: /\[/,
end: /\]/,
contains: [
{
className: 'meta',
begin: /<![a-z]/,
end: />/,
contains: [
XML_META_KEYWORDS,
XML_META_PAR_KEYWORDS,
QUOTE_META_STRING_MODE,
APOS_META_STRING_MODE
]
}
]
}
]
},
hljs.COMMENT(
/<!--/,
/-->/,
{ relevance: 10 }
),
{
begin: /<!\[CDATA\[/,
end: /\]\]>/,
relevance: 10
},
XML_ENTITIES,
// xml processing instructions
{
className: 'meta',
end: /\?>/,
variants: [
{
begin: /<\?xml/,
relevance: 10,
contains: [
QUOTE_META_STRING_MODE
]
},
{
begin: /<\?[a-z][a-z0-9]+/,
}
]
},
{
className: 'tag',
/*
The lookahead pattern (?=...) ensures that 'begin' only matches
'<style' as a single word, followed by a whitespace or an
ending bracket.
*/
begin: /<style(?=\s|>)/,
end: />/,
keywords: { name: 'style' },
contains: [ TAG_INTERNALS ],
starts: {
end: /<\/style>/,
returnEnd: true,
subLanguage: [
'css',
'xml'
]
}
},
{
className: 'tag',
// See the comment in the <style tag about the lookahead pattern
begin: /<script(?=\s|>)/,
end: />/,
keywords: { name: 'script' },
contains: [ TAG_INTERNALS ],
starts: {
end: /<\/script>/,
returnEnd: true,
subLanguage: [
'javascript',
'handlebars',
'xml'
]
}
},
// we need this for now for jSX
{
className: 'tag',
begin: /<>|<\/>/
},
// open tag
{
className: 'tag',
begin: regex.concat(
/</,
regex.lookahead(regex.concat(
TAG_NAME_RE,
// <tag/>
// <tag>
// <tag ...
regex.either(/\/>/, />/, /\s/)
))
),
end: /\/?>/,
contains: [
{
className: 'name',
begin: TAG_NAME_RE,
relevance: 0,
starts: TAG_INTERNALS
}
]
},
// close tag
{
className: 'tag',
begin: regex.concat(
/<\//,
regex.lookahead(regex.concat(
TAG_NAME_RE, />/
))
),
contains: [
{
className: 'name',
begin: TAG_NAME_RE,
relevance: 0
},
{
begin: />/,
relevance: 0,
endsParent: true
}
]
}
]
};
}
return xml;
})();
;
export default hljsGrammar;

View File

@@ -0,0 +1,29 @@
/*! `xml` grammar compiled for Highlight.js 11.11.1 */
var hljsGrammar=(()=>{"use strict";return e=>{
const a=e.regex,n=a.concat(/[\p{L}_]/u,a.optional(/[\p{L}0-9_.-]*:/u),/[\p{L}0-9_.-]*/u),s={
className:"symbol",begin:/&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/},t={begin:/\s/,
contains:[{className:"keyword",begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}]
},i=e.inherit(t,{begin:/\(/,end:/\)/}),c=e.inherit(e.APOS_STRING_MODE,{
className:"string"}),l=e.inherit(e.QUOTE_STRING_MODE,{className:"string"}),r={
endsWithParent:!0,illegal:/</,relevance:0,contains:[{className:"attr",
begin:/[\p{L}0-9._:-]+/u,relevance:0},{begin:/=\s*/,relevance:0,contains:[{
className:"string",endsParent:!0,variants:[{begin:/"/,end:/"/,contains:[s]},{
begin:/'/,end:/'/,contains:[s]},{begin:/[^\s"'=<>`]+/}]}]}]};return{
name:"HTML, XML",
aliases:["html","xhtml","rss","atom","xjb","xsd","xsl","plist","wsf","svg"],
case_insensitive:!0,unicodeRegex:!0,contains:[{className:"meta",begin:/<![a-z]/,
end:/>/,relevance:10,contains:[t,l,c,i,{begin:/\[/,end:/\]/,contains:[{
className:"meta",begin:/<![a-z]/,end:/>/,contains:[t,i,l,c]}]}]
},e.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,
relevance:10},s,{className:"meta",end:/\?>/,variants:[{begin:/<\?xml/,
relevance:10,contains:[l]},{begin:/<\?[a-z][a-z0-9]+/}]},{className:"tag",
begin:/<style(?=\s|>)/,end:/>/,keywords:{name:"style"},contains:[r],starts:{
end:/<\/style>/,returnEnd:!0,subLanguage:["css","xml"]}},{className:"tag",
begin:/<script(?=\s|>)/,end:/>/,keywords:{name:"script"},contains:[r],starts:{
end:/<\/script>/,returnEnd:!0,subLanguage:["javascript","handlebars","xml"]}},{
className:"tag",begin:/<>|<\/>/},{className:"tag",
begin:a.concat(/</,a.lookahead(a.concat(n,a.either(/\/>/,/>/,/\s/)))),
end:/\/?>/,contains:[{className:"name",begin:n,relevance:0,starts:r}]},{
className:"tag",begin:a.concat(/<\//,a.lookahead(a.concat(n,/>/))),contains:[{
className:"name",begin:n,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}
})();export default hljsGrammar;

View File

@@ -0,0 +1,221 @@
/*! `yaml` grammar compiled for Highlight.js 11.11.1 */
var hljsGrammar = (function () {
'use strict';
/*
Language: YAML
Description: Yet Another Markdown Language
Author: Stefan Wienert <stwienert@gmail.com>
Contributors: Carl Baxter <carl@cbax.tech>
Requires: ruby.js
Website: https://yaml.org
Category: common, config
*/
function yaml(hljs) {
const LITERALS = 'true false yes no null';
// YAML spec allows non-reserved URI characters in tags.
const URI_CHARACTERS = '[\\w#;/?:@&=+$,.~*\'()[\\]]+';
// Define keys as starting with a word character
// ...containing word chars, spaces, colons, forward-slashes, hyphens and periods
// ...and ending with a colon followed immediately by a space, tab or newline.
// The YAML spec allows for much more than this, but this covers most use-cases.
const KEY = {
className: 'attr',
variants: [
// added brackets support and special char support
{ begin: /[\w*@][\w*@ :()\./-]*:(?=[ \t]|$)/ },
{ // double quoted keys - with brackets and special char support
begin: /"[\w*@][\w*@ :()\./-]*":(?=[ \t]|$)/ },
{ // single quoted keys - with brackets and special char support
begin: /'[\w*@][\w*@ :()\./-]*':(?=[ \t]|$)/ },
]
};
const TEMPLATE_VARIABLES = {
className: 'template-variable',
variants: [
{ // jinja templates Ansible
begin: /\{\{/,
end: /\}\}/
},
{ // Ruby i18n
begin: /%\{/,
end: /\}/
}
]
};
const SINGLE_QUOTE_STRING = {
className: 'string',
relevance: 0,
begin: /'/,
end: /'/,
contains: [
{
match: /''/,
scope: 'char.escape',
relevance: 0
}
]
};
const STRING = {
className: 'string',
relevance: 0,
variants: [
{
begin: /"/,
end: /"/
},
{ begin: /\S+/ }
],
contains: [
hljs.BACKSLASH_ESCAPE,
TEMPLATE_VARIABLES
]
};
// Strings inside of value containers (objects) can't contain braces,
// brackets, or commas
const CONTAINER_STRING = hljs.inherit(STRING, { variants: [
{
begin: /'/,
end: /'/,
contains: [
{
begin: /''/,
relevance: 0
}
]
},
{
begin: /"/,
end: /"/
},
{ begin: /[^\s,{}[\]]+/ }
] });
const DATE_RE = '[0-9]{4}(-[0-9][0-9]){0,2}';
const TIME_RE = '([Tt \\t][0-9][0-9]?(:[0-9][0-9]){2})?';
const FRACTION_RE = '(\\.[0-9]*)?';
const ZONE_RE = '([ \\t])*(Z|[-+][0-9][0-9]?(:[0-9][0-9])?)?';
const TIMESTAMP = {
className: 'number',
begin: '\\b' + DATE_RE + TIME_RE + FRACTION_RE + ZONE_RE + '\\b'
};
const VALUE_CONTAINER = {
end: ',',
endsWithParent: true,
excludeEnd: true,
keywords: LITERALS,
relevance: 0
};
const OBJECT = {
begin: /\{/,
end: /\}/,
contains: [ VALUE_CONTAINER ],
illegal: '\\n',
relevance: 0
};
const ARRAY = {
begin: '\\[',
end: '\\]',
contains: [ VALUE_CONTAINER ],
illegal: '\\n',
relevance: 0
};
const MODES = [
KEY,
{
className: 'meta',
begin: '^---\\s*$',
relevance: 10
},
{ // multi line string
// Blocks start with a | or > followed by a newline
//
// Indentation of subsequent lines must be the same to
// be considered part of the block
className: 'string',
begin: '[\\|>]([1-9]?[+-])?[ ]*\\n( +)[^ ][^\\n]*\\n(\\2[^\\n]+\\n?)*'
},
{ // Ruby/Rails erb
begin: '<%[%=-]?',
end: '[%-]?%>',
subLanguage: 'ruby',
excludeBegin: true,
excludeEnd: true,
relevance: 0
},
{ // named tags
className: 'type',
begin: '!\\w+!' + URI_CHARACTERS
},
// https://yaml.org/spec/1.2/spec.html#id2784064
{ // verbatim tags
className: 'type',
begin: '!<' + URI_CHARACTERS + ">"
},
{ // primary tags
className: 'type',
begin: '!' + URI_CHARACTERS
},
{ // secondary tags
className: 'type',
begin: '!!' + URI_CHARACTERS
},
{ // fragment id &ref
className: 'meta',
begin: '&' + hljs.UNDERSCORE_IDENT_RE + '$'
},
{ // fragment reference *ref
className: 'meta',
begin: '\\*' + hljs.UNDERSCORE_IDENT_RE + '$'
},
{ // array listing
className: 'bullet',
// TODO: remove |$ hack when we have proper look-ahead support
begin: '-(?=[ ]|$)',
relevance: 0
},
hljs.HASH_COMMENT_MODE,
{
beginKeywords: LITERALS,
keywords: { literal: LITERALS }
},
TIMESTAMP,
// numbers are any valid C-style number that
// sit isolated from other words
{
className: 'number',
begin: hljs.C_NUMBER_RE + '\\b',
relevance: 0
},
OBJECT,
ARRAY,
SINGLE_QUOTE_STRING,
STRING
];
const VALUE_MODES = [ ...MODES ];
VALUE_MODES.pop();
VALUE_MODES.push(CONTAINER_STRING);
VALUE_CONTAINER.contains = VALUE_MODES;
return {
name: 'YAML',
case_insensitive: true,
aliases: [ 'yml' ],
contains: MODES
};
}
return yaml;
})();
;
export default hljsGrammar;

View File

@@ -0,0 +1,28 @@
/*! `yaml` grammar compiled for Highlight.js 11.11.1 */
var hljsGrammar=(()=>{"use strict";return e=>{
const n="true false yes no null",a="[\\w#;/?:@&=+$,.~*'()[\\]]+",s={
className:"string",relevance:0,variants:[{begin:/"/,end:/"/},{begin:/\S+/}],
contains:[e.BACKSLASH_ESCAPE,{className:"template-variable",variants:[{
begin:/\{\{/,end:/\}\}/},{begin:/%\{/,end:/\}/}]}]},i=e.inherit(s,{variants:[{
begin:/'/,end:/'/,contains:[{begin:/''/,relevance:0}]},{begin:/"/,end:/"/},{
begin:/[^\s,{}[\]]+/}]}),l={end:",",endsWithParent:!0,excludeEnd:!0,keywords:n,
relevance:0},t={begin:/\{/,end:/\}/,contains:[l],illegal:"\\n",relevance:0},c={
begin:"\\[",end:"\\]",contains:[l],illegal:"\\n",relevance:0},r=[{
className:"attr",variants:[{begin:/[\w*@][\w*@ :()\./-]*:(?=[ \t]|$)/},{
begin:/"[\w*@][\w*@ :()\./-]*":(?=[ \t]|$)/},{
begin:/'[\w*@][\w*@ :()\./-]*':(?=[ \t]|$)/}]},{className:"meta",
begin:"^---\\s*$",relevance:10},{className:"string",
begin:"[\\|>]([1-9]?[+-])?[ ]*\\n( +)[^ ][^\\n]*\\n(\\2[^\\n]+\\n?)*"},{
begin:"<%[%=-]?",end:"[%-]?%>",subLanguage:"ruby",excludeBegin:!0,excludeEnd:!0,
relevance:0},{className:"type",begin:"!\\w+!"+a},{className:"type",
begin:"!<"+a+">"},{className:"type",begin:"!"+a},{className:"type",begin:"!!"+a
},{className:"meta",begin:"&"+e.UNDERSCORE_IDENT_RE+"$"},{className:"meta",
begin:"\\*"+e.UNDERSCORE_IDENT_RE+"$"},{className:"bullet",begin:"-(?=[ ]|$)",
relevance:0},e.HASH_COMMENT_MODE,{beginKeywords:n,keywords:{literal:n}},{
className:"number",
begin:"\\b[0-9]{4}(-[0-9][0-9]){0,2}([Tt \\t][0-9][0-9]?(:[0-9][0-9]){2})?(\\.[0-9]*)?([ \\t])*(Z|[-+][0-9][0-9]?(:[0-9][0-9])?)?\\b"
},{className:"number",begin:e.C_NUMBER_RE+"\\b",relevance:0},t,c,{
className:"string",relevance:0,begin:/'/,end:/'/,contains:[{match:/''/,
scope:"char.escape",relevance:0}]},s],b=[...r]
;return b.pop(),b.push(i),l.contains=b,{name:"YAML",case_insensitive:!0,
aliases:["yml"],contains:r}}})();export default hljsGrammar;

View File

@@ -0,0 +1 @@
{ "type": "module" }

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,419 @@
/*! `bash` grammar compiled for Highlight.js 11.11.1 */
(function(){
var hljsGrammar = (function () {
'use strict';
/*
Language: Bash
Author: vah <vahtenberg@gmail.com>
Contributrors: Benjamin Pannell <contact@sierrasoftworks.com>
Website: https://www.gnu.org/software/bash/
Category: common, scripting
*/
/** @type LanguageFn */
function bash(hljs) {
const regex = hljs.regex;
const VAR = {};
const BRACED_VAR = {
begin: /\$\{/,
end: /\}/,
contains: [
"self",
{
begin: /:-/,
contains: [ VAR ]
} // default values
]
};
Object.assign(VAR, {
className: 'variable',
variants: [
{ begin: regex.concat(/\$[\w\d#@][\w\d_]*/,
// negative look-ahead tries to avoid matching patterns that are not
// Perl at all like $ident$, @ident@, etc.
`(?![\\w\\d])(?![$])`) },
BRACED_VAR
]
});
const SUBST = {
className: 'subst',
begin: /\$\(/,
end: /\)/,
contains: [ hljs.BACKSLASH_ESCAPE ]
};
const COMMENT = hljs.inherit(
hljs.COMMENT(),
{
match: [
/(^|\s)/,
/#.*$/
],
scope: {
2: 'comment'
}
}
);
const HERE_DOC = {
begin: /<<-?\s*(?=\w+)/,
starts: { contains: [
hljs.END_SAME_AS_BEGIN({
begin: /(\w+)/,
end: /(\w+)/,
className: 'string'
})
] }
};
const QUOTE_STRING = {
className: 'string',
begin: /"/,
end: /"/,
contains: [
hljs.BACKSLASH_ESCAPE,
VAR,
SUBST
]
};
SUBST.contains.push(QUOTE_STRING);
const ESCAPED_QUOTE = {
match: /\\"/
};
const APOS_STRING = {
className: 'string',
begin: /'/,
end: /'/
};
const ESCAPED_APOS = {
match: /\\'/
};
const ARITHMETIC = {
begin: /\$?\(\(/,
end: /\)\)/,
contains: [
{
begin: /\d+#[0-9a-f]+/,
className: "number"
},
hljs.NUMBER_MODE,
VAR
]
};
const SH_LIKE_SHELLS = [
"fish",
"bash",
"zsh",
"sh",
"csh",
"ksh",
"tcsh",
"dash",
"scsh",
];
const KNOWN_SHEBANG = hljs.SHEBANG({
binary: `(${SH_LIKE_SHELLS.join("|")})`,
relevance: 10
});
const FUNCTION = {
className: 'function',
begin: /\w[\w\d_]*\s*\(\s*\)\s*\{/,
returnBegin: true,
contains: [ hljs.inherit(hljs.TITLE_MODE, { begin: /\w[\w\d_]*/ }) ],
relevance: 0
};
const KEYWORDS = [
"if",
"then",
"else",
"elif",
"fi",
"time",
"for",
"while",
"until",
"in",
"do",
"done",
"case",
"esac",
"coproc",
"function",
"select"
];
const LITERALS = [
"true",
"false"
];
// to consume paths to prevent keyword matches inside them
const PATH_MODE = { match: /(\/[a-z._-]+)+/ };
// http://www.gnu.org/software/bash/manual/html_node/Shell-Builtin-Commands.html
const SHELL_BUILT_INS = [
"break",
"cd",
"continue",
"eval",
"exec",
"exit",
"export",
"getopts",
"hash",
"pwd",
"readonly",
"return",
"shift",
"test",
"times",
"trap",
"umask",
"unset"
];
const BASH_BUILT_INS = [
"alias",
"bind",
"builtin",
"caller",
"command",
"declare",
"echo",
"enable",
"help",
"let",
"local",
"logout",
"mapfile",
"printf",
"read",
"readarray",
"source",
"sudo",
"type",
"typeset",
"ulimit",
"unalias"
];
const ZSH_BUILT_INS = [
"autoload",
"bg",
"bindkey",
"bye",
"cap",
"chdir",
"clone",
"comparguments",
"compcall",
"compctl",
"compdescribe",
"compfiles",
"compgroups",
"compquote",
"comptags",
"comptry",
"compvalues",
"dirs",
"disable",
"disown",
"echotc",
"echoti",
"emulate",
"fc",
"fg",
"float",
"functions",
"getcap",
"getln",
"history",
"integer",
"jobs",
"kill",
"limit",
"log",
"noglob",
"popd",
"print",
"pushd",
"pushln",
"rehash",
"sched",
"setcap",
"setopt",
"stat",
"suspend",
"ttyctl",
"unfunction",
"unhash",
"unlimit",
"unsetopt",
"vared",
"wait",
"whence",
"where",
"which",
"zcompile",
"zformat",
"zftp",
"zle",
"zmodload",
"zparseopts",
"zprof",
"zpty",
"zregexparse",
"zsocket",
"zstyle",
"ztcp"
];
const GNU_CORE_UTILS = [
"chcon",
"chgrp",
"chown",
"chmod",
"cp",
"dd",
"df",
"dir",
"dircolors",
"ln",
"ls",
"mkdir",
"mkfifo",
"mknod",
"mktemp",
"mv",
"realpath",
"rm",
"rmdir",
"shred",
"sync",
"touch",
"truncate",
"vdir",
"b2sum",
"base32",
"base64",
"cat",
"cksum",
"comm",
"csplit",
"cut",
"expand",
"fmt",
"fold",
"head",
"join",
"md5sum",
"nl",
"numfmt",
"od",
"paste",
"ptx",
"pr",
"sha1sum",
"sha224sum",
"sha256sum",
"sha384sum",
"sha512sum",
"shuf",
"sort",
"split",
"sum",
"tac",
"tail",
"tr",
"tsort",
"unexpand",
"uniq",
"wc",
"arch",
"basename",
"chroot",
"date",
"dirname",
"du",
"echo",
"env",
"expr",
"factor",
// "false", // keyword literal already
"groups",
"hostid",
"id",
"link",
"logname",
"nice",
"nohup",
"nproc",
"pathchk",
"pinky",
"printenv",
"printf",
"pwd",
"readlink",
"runcon",
"seq",
"sleep",
"stat",
"stdbuf",
"stty",
"tee",
"test",
"timeout",
// "true", // keyword literal already
"tty",
"uname",
"unlink",
"uptime",
"users",
"who",
"whoami",
"yes"
];
return {
name: 'Bash',
aliases: [
'sh',
'zsh'
],
keywords: {
$pattern: /\b[a-z][a-z0-9._-]+\b/,
keyword: KEYWORDS,
literal: LITERALS,
built_in: [
...SHELL_BUILT_INS,
...BASH_BUILT_INS,
// Shell modifiers
"set",
"shopt",
...ZSH_BUILT_INS,
...GNU_CORE_UTILS
]
},
contains: [
KNOWN_SHEBANG, // to catch known shells and boost relevancy
hljs.SHEBANG(), // to catch unknown shells but still highlight the shebang
FUNCTION,
ARITHMETIC,
COMMENT,
HERE_DOC,
PATH_MODE,
QUOTE_STRING,
ESCAPED_QUOTE,
APOS_STRING,
ESCAPED_APOS,
VAR
]
};
}
return bash;
})();
hljs.registerLanguage('bash', hljsGrammar);
})();

View File

@@ -0,0 +1,21 @@
/*! `bash` grammar compiled for Highlight.js 11.11.1 */
(()=>{var e=(()=>{"use strict";return e=>{const s=e.regex,t={},n={begin:/\$\{/,
end:/\}/,contains:["self",{begin:/:-/,contains:[t]}]};Object.assign(t,{
className:"variable",variants:[{
begin:s.concat(/\$[\w\d#@][\w\d_]*/,"(?![\\w\\d])(?![$])")},n]});const a={
className:"subst",begin:/\$\(/,end:/\)/,contains:[e.BACKSLASH_ESCAPE]
},i=e.inherit(e.COMMENT(),{match:[/(^|\s)/,/#.*$/],scope:{2:"comment"}}),c={
begin:/<<-?\s*(?=\w+)/,starts:{contains:[e.END_SAME_AS_BEGIN({begin:/(\w+)/,
end:/(\w+)/,className:"string"})]}},o={className:"string",begin:/"/,end:/"/,
contains:[e.BACKSLASH_ESCAPE,t,a]};a.contains.push(o);const r={begin:/\$?\(\(/,
end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:"number"},e.NUMBER_MODE,t]
},l=e.SHEBANG({binary:"(fish|bash|zsh|sh|csh|ksh|tcsh|dash|scsh)",relevance:10
}),m={className:"function",begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0,
contains:[e.inherit(e.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0};return{
name:"Bash",aliases:["sh","zsh"],keywords:{$pattern:/\b[a-z][a-z0-9._-]+\b/,
keyword:["if","then","else","elif","fi","time","for","while","until","in","do","done","case","esac","coproc","function","select"],
literal:["true","false"],
built_in:["break","cd","continue","eval","exec","exit","export","getopts","hash","pwd","readonly","return","shift","test","times","trap","umask","unset","alias","bind","builtin","caller","command","declare","echo","enable","help","let","local","logout","mapfile","printf","read","readarray","source","sudo","type","typeset","ulimit","unalias","set","shopt","autoload","bg","bindkey","bye","cap","chdir","clone","comparguments","compcall","compctl","compdescribe","compfiles","compgroups","compquote","comptags","comptry","compvalues","dirs","disable","disown","echotc","echoti","emulate","fc","fg","float","functions","getcap","getln","history","integer","jobs","kill","limit","log","noglob","popd","print","pushd","pushln","rehash","sched","setcap","setopt","stat","suspend","ttyctl","unfunction","unhash","unlimit","unsetopt","vared","wait","whence","where","which","zcompile","zformat","zftp","zle","zmodload","zparseopts","zprof","zpty","zregexparse","zsocket","zstyle","ztcp","chcon","chgrp","chown","chmod","cp","dd","df","dir","dircolors","ln","ls","mkdir","mkfifo","mknod","mktemp","mv","realpath","rm","rmdir","shred","sync","touch","truncate","vdir","b2sum","base32","base64","cat","cksum","comm","csplit","cut","expand","fmt","fold","head","join","md5sum","nl","numfmt","od","paste","ptx","pr","sha1sum","sha224sum","sha256sum","sha384sum","sha512sum","shuf","sort","split","sum","tac","tail","tr","tsort","unexpand","uniq","wc","arch","basename","chroot","date","dirname","du","echo","env","expr","factor","groups","hostid","id","link","logname","nice","nohup","nproc","pathchk","pinky","printenv","printf","pwd","readlink","runcon","seq","sleep","stat","stdbuf","stty","tee","test","timeout","tty","uname","unlink","uptime","users","who","whoami","yes"]
},contains:[l,e.SHEBANG(),m,r,i,c,{match:/(\/[a-z._-]+)+/},o,{match:/\\"/},{
className:"string",begin:/'/,end:/'/},{match:/\\'/},t]}}})()
;hljs.registerLanguage("bash",e)})();

View File

@@ -0,0 +1,343 @@
/*! `c` grammar compiled for Highlight.js 11.11.1 */
(function(){
var hljsGrammar = (function () {
'use strict';
/*
Language: C
Category: common, system
Website: https://en.wikipedia.org/wiki/C_(programming_language)
*/
/** @type LanguageFn */
function c(hljs) {
const regex = hljs.regex;
// added for historic reasons because `hljs.C_LINE_COMMENT_MODE` does
// not include such support nor can we be sure all the grammars depending
// on it would desire this behavior
const C_LINE_COMMENT_MODE = hljs.COMMENT('//', '$', { contains: [ { begin: /\\\n/ } ] });
const DECLTYPE_AUTO_RE = 'decltype\\(auto\\)';
const NAMESPACE_RE = '[a-zA-Z_]\\w*::';
const TEMPLATE_ARGUMENT_RE = '<[^<>]+>';
const FUNCTION_TYPE_RE = '('
+ DECLTYPE_AUTO_RE + '|'
+ regex.optional(NAMESPACE_RE)
+ '[a-zA-Z_]\\w*' + regex.optional(TEMPLATE_ARGUMENT_RE)
+ ')';
const TYPES = {
className: 'type',
variants: [
{ begin: '\\b[a-z\\d_]*_t\\b' },
{ match: /\batomic_[a-z]{3,6}\b/ }
]
};
// https://en.cppreference.com/w/cpp/language/escape
// \\ \x \xFF \u2837 \u00323747 \374
const CHARACTER_ESCAPES = '\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)';
const STRINGS = {
className: 'string',
variants: [
{
begin: '(u8?|U|L)?"',
end: '"',
illegal: '\\n',
contains: [ hljs.BACKSLASH_ESCAPE ]
},
{
begin: '(u8?|U|L)?\'(' + CHARACTER_ESCAPES + "|.)",
end: '\'',
illegal: '.'
},
hljs.END_SAME_AS_BEGIN({
begin: /(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,
end: /\)([^()\\ ]{0,16})"/
})
]
};
const NUMBERS = {
className: 'number',
variants: [
{ match: /\b(0b[01']+)/ },
{ match: /(-?)\b([\d']+(\.[\d']*)?|\.[\d']+)((ll|LL|l|L)(u|U)?|(u|U)(ll|LL|l|L)?|f|F|b|B)/ },
{ match: /(-?)\b(0[xX][a-fA-F0-9]+(?:'[a-fA-F0-9]+)*(?:\.[a-fA-F0-9]*(?:'[a-fA-F0-9]*)*)?(?:[pP][-+]?[0-9]+)?(l|L)?(u|U)?)/ },
{ match: /(-?)\b\d+(?:'\d+)*(?:\.\d*(?:'\d*)*)?(?:[eE][-+]?\d+)?/ }
],
relevance: 0
};
const PREPROCESSOR = {
className: 'meta',
begin: /#\s*[a-z]+\b/,
end: /$/,
keywords: { keyword:
'if else elif endif define undef warning error line '
+ 'pragma _Pragma ifdef ifndef elifdef elifndef include' },
contains: [
{
begin: /\\\n/,
relevance: 0
},
hljs.inherit(STRINGS, { className: 'string' }),
{
className: 'string',
begin: /<.*?>/
},
C_LINE_COMMENT_MODE,
hljs.C_BLOCK_COMMENT_MODE
]
};
const TITLE_MODE = {
className: 'title',
begin: regex.optional(NAMESPACE_RE) + hljs.IDENT_RE,
relevance: 0
};
const FUNCTION_TITLE = regex.optional(NAMESPACE_RE) + hljs.IDENT_RE + '\\s*\\(';
const C_KEYWORDS = [
"asm",
"auto",
"break",
"case",
"continue",
"default",
"do",
"else",
"enum",
"extern",
"for",
"fortran",
"goto",
"if",
"inline",
"register",
"restrict",
"return",
"sizeof",
"typeof",
"typeof_unqual",
"struct",
"switch",
"typedef",
"union",
"volatile",
"while",
"_Alignas",
"_Alignof",
"_Atomic",
"_Generic",
"_Noreturn",
"_Static_assert",
"_Thread_local",
// aliases
"alignas",
"alignof",
"noreturn",
"static_assert",
"thread_local",
// not a C keyword but is, for all intents and purposes, treated exactly like one.
"_Pragma"
];
const C_TYPES = [
"float",
"double",
"signed",
"unsigned",
"int",
"short",
"long",
"char",
"void",
"_Bool",
"_BitInt",
"_Complex",
"_Imaginary",
"_Decimal32",
"_Decimal64",
"_Decimal96",
"_Decimal128",
"_Decimal64x",
"_Decimal128x",
"_Float16",
"_Float32",
"_Float64",
"_Float128",
"_Float32x",
"_Float64x",
"_Float128x",
// modifiers
"const",
"static",
"constexpr",
// aliases
"complex",
"bool",
"imaginary"
];
const KEYWORDS = {
keyword: C_KEYWORDS,
type: C_TYPES,
literal: 'true false NULL',
// TODO: apply hinting work similar to what was done in cpp.js
built_in: 'std string wstring cin cout cerr clog stdin stdout stderr stringstream istringstream ostringstream '
+ 'auto_ptr deque list queue stack vector map set pair bitset multiset multimap unordered_set '
+ 'unordered_map unordered_multiset unordered_multimap priority_queue make_pair array shared_ptr abort terminate abs acos '
+ 'asin atan2 atan calloc ceil cosh cos exit exp fabs floor fmod fprintf fputs free frexp '
+ 'fscanf future isalnum isalpha iscntrl isdigit isgraph islower isprint ispunct isspace isupper '
+ 'isxdigit tolower toupper labs ldexp log10 log malloc realloc memchr memcmp memcpy memset modf pow '
+ 'printf putchar puts scanf sinh sin snprintf sprintf sqrt sscanf strcat strchr strcmp '
+ 'strcpy strcspn strlen strncat strncmp strncpy strpbrk strrchr strspn strstr tanh tan '
+ 'vfprintf vprintf vsprintf endl initializer_list unique_ptr',
};
const EXPRESSION_CONTAINS = [
PREPROCESSOR,
TYPES,
C_LINE_COMMENT_MODE,
hljs.C_BLOCK_COMMENT_MODE,
NUMBERS,
STRINGS
];
const EXPRESSION_CONTEXT = {
// This mode covers expression context where we can't expect a function
// definition and shouldn't highlight anything that looks like one:
// `return some()`, `else if()`, `(x*sum(1, 2))`
variants: [
{
begin: /=/,
end: /;/
},
{
begin: /\(/,
end: /\)/
},
{
beginKeywords: 'new throw return else',
end: /;/
}
],
keywords: KEYWORDS,
contains: EXPRESSION_CONTAINS.concat([
{
begin: /\(/,
end: /\)/,
keywords: KEYWORDS,
contains: EXPRESSION_CONTAINS.concat([ 'self' ]),
relevance: 0
}
]),
relevance: 0
};
const FUNCTION_DECLARATION = {
begin: '(' + FUNCTION_TYPE_RE + '[\\*&\\s]+)+' + FUNCTION_TITLE,
returnBegin: true,
end: /[{;=]/,
excludeEnd: true,
keywords: KEYWORDS,
illegal: /[^\w\s\*&:<>.]/,
contains: [
{ // to prevent it from being confused as the function title
begin: DECLTYPE_AUTO_RE,
keywords: KEYWORDS,
relevance: 0
},
{
begin: FUNCTION_TITLE,
returnBegin: true,
contains: [ hljs.inherit(TITLE_MODE, { className: "title.function" }) ],
relevance: 0
},
// allow for multiple declarations, e.g.:
// extern void f(int), g(char);
{
relevance: 0,
match: /,/
},
{
className: 'params',
begin: /\(/,
end: /\)/,
keywords: KEYWORDS,
relevance: 0,
contains: [
C_LINE_COMMENT_MODE,
hljs.C_BLOCK_COMMENT_MODE,
STRINGS,
NUMBERS,
TYPES,
// Count matching parentheses.
{
begin: /\(/,
end: /\)/,
keywords: KEYWORDS,
relevance: 0,
contains: [
'self',
C_LINE_COMMENT_MODE,
hljs.C_BLOCK_COMMENT_MODE,
STRINGS,
NUMBERS,
TYPES
]
}
]
},
TYPES,
C_LINE_COMMENT_MODE,
hljs.C_BLOCK_COMMENT_MODE,
PREPROCESSOR
]
};
return {
name: "C",
aliases: [ 'h' ],
keywords: KEYWORDS,
// Until differentiations are added between `c` and `cpp`, `c` will
// not be auto-detected to avoid auto-detect conflicts between C and C++
disableAutodetect: true,
illegal: '</',
contains: [].concat(
EXPRESSION_CONTEXT,
FUNCTION_DECLARATION,
EXPRESSION_CONTAINS,
[
PREPROCESSOR,
{
begin: hljs.IDENT_RE + '::',
keywords: KEYWORDS
},
{
className: 'class',
beginKeywords: 'enum class struct union',
end: /[{;:<>=]/,
contains: [
{ beginKeywords: "final class struct" },
hljs.TITLE_MODE
]
}
]),
exports: {
preprocessor: PREPROCESSOR,
strings: STRINGS,
keywords: KEYWORDS
}
};
}
return c;
})();
hljs.registerLanguage('c', hljsGrammar);
})();

View File

@@ -0,0 +1,41 @@
/*! `c` grammar compiled for Highlight.js 11.11.1 */
(()=>{var e=(()=>{"use strict";return e=>{const t=e.regex,n=e.COMMENT("//","$",{
contains:[{begin:/\\\n/}]
}),a="decltype\\(auto\\)",s="[a-zA-Z_]\\w*::",r="("+a+"|"+t.optional(s)+"[a-zA-Z_]\\w*"+t.optional("<[^<>]+>")+")",i={
className:"type",variants:[{begin:"\\b[a-z\\d_]*_t\\b"},{
match:/\batomic_[a-z]{3,6}\b/}]},l={className:"string",variants:[{
begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[e.BACKSLASH_ESCAPE]},{
begin:"(u8?|U|L)?'(\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)|.)",
end:"'",illegal:"."},e.END_SAME_AS_BEGIN({
begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},o={
className:"number",variants:[{match:/\b(0b[01']+)/},{
match:/(-?)\b([\d']+(\.[\d']*)?|\.[\d']+)((ll|LL|l|L)(u|U)?|(u|U)(ll|LL|l|L)?|f|F|b|B)/
},{
match:/(-?)\b(0[xX][a-fA-F0-9]+(?:'[a-fA-F0-9]+)*(?:\.[a-fA-F0-9]*(?:'[a-fA-F0-9]*)*)?(?:[pP][-+]?[0-9]+)?(l|L)?(u|U)?)/
},{match:/(-?)\b\d+(?:'\d+)*(?:\.\d*(?:'\d*)*)?(?:[eE][-+]?\d+)?/}],relevance:0
},c={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{
keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef elifdef elifndef include"
},contains:[{begin:/\\\n/,relevance:0},e.inherit(l,{className:"string"}),{
className:"string",begin:/<.*?>/},n,e.C_BLOCK_COMMENT_MODE]},d={
className:"title",begin:t.optional(s)+e.IDENT_RE,relevance:0
},_=t.optional(s)+e.IDENT_RE+"\\s*\\(",u={
keyword:["asm","auto","break","case","continue","default","do","else","enum","extern","for","fortran","goto","if","inline","register","restrict","return","sizeof","typeof","typeof_unqual","struct","switch","typedef","union","volatile","while","_Alignas","_Alignof","_Atomic","_Generic","_Noreturn","_Static_assert","_Thread_local","alignas","alignof","noreturn","static_assert","thread_local","_Pragma"],
type:["float","double","signed","unsigned","int","short","long","char","void","_Bool","_BitInt","_Complex","_Imaginary","_Decimal32","_Decimal64","_Decimal96","_Decimal128","_Decimal64x","_Decimal128x","_Float16","_Float32","_Float64","_Float128","_Float32x","_Float64x","_Float128x","const","static","constexpr","complex","bool","imaginary"],
literal:"true false NULL",
built_in:"std string wstring cin cout cerr clog stdin stdout stderr stringstream istringstream ostringstream auto_ptr deque list queue stack vector map set pair bitset multiset multimap unordered_set unordered_map unordered_multiset unordered_multimap priority_queue make_pair array shared_ptr abort terminate abs acos asin atan2 atan calloc ceil cosh cos exit exp fabs floor fmod fprintf fputs free frexp fscanf future isalnum isalpha iscntrl isdigit isgraph islower isprint ispunct isspace isupper isxdigit tolower toupper labs ldexp log10 log malloc realloc memchr memcmp memcpy memset modf pow printf putchar puts scanf sinh sin snprintf sprintf sqrt sscanf strcat strchr strcmp strcpy strcspn strlen strncat strncmp strncpy strpbrk strrchr strspn strstr tanh tan vfprintf vprintf vsprintf endl initializer_list unique_ptr"
},m=[c,i,n,e.C_BLOCK_COMMENT_MODE,o,l],g={variants:[{begin:/=/,end:/;/},{
begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],
keywords:u,contains:m.concat([{begin:/\(/,end:/\)/,keywords:u,
contains:m.concat(["self"]),relevance:0}]),relevance:0},p={
begin:"("+r+"[\\*&\\s]+)+"+_,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,
keywords:u,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:a,keywords:u,relevance:0},{
begin:_,returnBegin:!0,contains:[e.inherit(d,{className:"title.function"})],
relevance:0},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,
keywords:u,relevance:0,contains:[n,e.C_BLOCK_COMMENT_MODE,l,o,i,{begin:/\(/,
end:/\)/,keywords:u,relevance:0,contains:["self",n,e.C_BLOCK_COMMENT_MODE,l,o,i]
}]},i,n,e.C_BLOCK_COMMENT_MODE,c]};return{name:"C",aliases:["h"],keywords:u,
disableAutodetect:!0,illegal:"</",contains:[].concat(g,p,m,[c,{
begin:e.IDENT_RE+"::",keywords:u},{className:"class",
beginKeywords:"enum class struct union",end:/[{;:<>=]/,contains:[{
beginKeywords:"final class struct"},e.TITLE_MODE]}]),exports:{preprocessor:c,
strings:l,keywords:u}}}})();hljs.registerLanguage("c",e)})();

View File

@@ -0,0 +1,959 @@
/*! `css` grammar compiled for Highlight.js 11.11.1 */
(function(){
var hljsGrammar = (function () {
'use strict';
const MODES = (hljs) => {
return {
IMPORTANT: {
scope: 'meta',
begin: '!important'
},
BLOCK_COMMENT: hljs.C_BLOCK_COMMENT_MODE,
HEXCOLOR: {
scope: 'number',
begin: /#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/
},
FUNCTION_DISPATCH: {
className: "built_in",
begin: /[\w-]+(?=\()/
},
ATTRIBUTE_SELECTOR_MODE: {
scope: 'selector-attr',
begin: /\[/,
end: /\]/,
illegal: '$',
contains: [
hljs.APOS_STRING_MODE,
hljs.QUOTE_STRING_MODE
]
},
CSS_NUMBER_MODE: {
scope: 'number',
begin: hljs.NUMBER_RE + '(' +
'%|em|ex|ch|rem' +
'|vw|vh|vmin|vmax' +
'|cm|mm|in|pt|pc|px' +
'|deg|grad|rad|turn' +
'|s|ms' +
'|Hz|kHz' +
'|dpi|dpcm|dppx' +
')?',
relevance: 0
},
CSS_VARIABLE: {
className: "attr",
begin: /--[A-Za-z_][A-Za-z0-9_-]*/
}
};
};
const HTML_TAGS = [
'a',
'abbr',
'address',
'article',
'aside',
'audio',
'b',
'blockquote',
'body',
'button',
'canvas',
'caption',
'cite',
'code',
'dd',
'del',
'details',
'dfn',
'div',
'dl',
'dt',
'em',
'fieldset',
'figcaption',
'figure',
'footer',
'form',
'h1',
'h2',
'h3',
'h4',
'h5',
'h6',
'header',
'hgroup',
'html',
'i',
'iframe',
'img',
'input',
'ins',
'kbd',
'label',
'legend',
'li',
'main',
'mark',
'menu',
'nav',
'object',
'ol',
'optgroup',
'option',
'p',
'picture',
'q',
'quote',
'samp',
'section',
'select',
'source',
'span',
'strong',
'summary',
'sup',
'table',
'tbody',
'td',
'textarea',
'tfoot',
'th',
'thead',
'time',
'tr',
'ul',
'var',
'video'
];
const SVG_TAGS = [
'defs',
'g',
'marker',
'mask',
'pattern',
'svg',
'switch',
'symbol',
'feBlend',
'feColorMatrix',
'feComponentTransfer',
'feComposite',
'feConvolveMatrix',
'feDiffuseLighting',
'feDisplacementMap',
'feFlood',
'feGaussianBlur',
'feImage',
'feMerge',
'feMorphology',
'feOffset',
'feSpecularLighting',
'feTile',
'feTurbulence',
'linearGradient',
'radialGradient',
'stop',
'circle',
'ellipse',
'image',
'line',
'path',
'polygon',
'polyline',
'rect',
'text',
'use',
'textPath',
'tspan',
'foreignObject',
'clipPath'
];
const TAGS = [
...HTML_TAGS,
...SVG_TAGS,
];
// Sorting, then reversing makes sure longer attributes/elements like
// `font-weight` are matched fully instead of getting false positives on say `font`
const MEDIA_FEATURES = [
'any-hover',
'any-pointer',
'aspect-ratio',
'color',
'color-gamut',
'color-index',
'device-aspect-ratio',
'device-height',
'device-width',
'display-mode',
'forced-colors',
'grid',
'height',
'hover',
'inverted-colors',
'monochrome',
'orientation',
'overflow-block',
'overflow-inline',
'pointer',
'prefers-color-scheme',
'prefers-contrast',
'prefers-reduced-motion',
'prefers-reduced-transparency',
'resolution',
'scan',
'scripting',
'update',
'width',
// TODO: find a better solution?
'min-width',
'max-width',
'min-height',
'max-height'
].sort().reverse();
// https://developer.mozilla.org/en-US/docs/Web/CSS/Pseudo-classes
const PSEUDO_CLASSES = [
'active',
'any-link',
'blank',
'checked',
'current',
'default',
'defined',
'dir', // dir()
'disabled',
'drop',
'empty',
'enabled',
'first',
'first-child',
'first-of-type',
'fullscreen',
'future',
'focus',
'focus-visible',
'focus-within',
'has', // has()
'host', // host or host()
'host-context', // host-context()
'hover',
'indeterminate',
'in-range',
'invalid',
'is', // is()
'lang', // lang()
'last-child',
'last-of-type',
'left',
'link',
'local-link',
'not', // not()
'nth-child', // nth-child()
'nth-col', // nth-col()
'nth-last-child', // nth-last-child()
'nth-last-col', // nth-last-col()
'nth-last-of-type', //nth-last-of-type()
'nth-of-type', //nth-of-type()
'only-child',
'only-of-type',
'optional',
'out-of-range',
'past',
'placeholder-shown',
'read-only',
'read-write',
'required',
'right',
'root',
'scope',
'target',
'target-within',
'user-invalid',
'valid',
'visited',
'where' // where()
].sort().reverse();
// https://developer.mozilla.org/en-US/docs/Web/CSS/Pseudo-elements
const PSEUDO_ELEMENTS = [
'after',
'backdrop',
'before',
'cue',
'cue-region',
'first-letter',
'first-line',
'grammar-error',
'marker',
'part',
'placeholder',
'selection',
'slotted',
'spelling-error'
].sort().reverse();
const ATTRIBUTES = [
'accent-color',
'align-content',
'align-items',
'align-self',
'alignment-baseline',
'all',
'anchor-name',
'animation',
'animation-composition',
'animation-delay',
'animation-direction',
'animation-duration',
'animation-fill-mode',
'animation-iteration-count',
'animation-name',
'animation-play-state',
'animation-range',
'animation-range-end',
'animation-range-start',
'animation-timeline',
'animation-timing-function',
'appearance',
'aspect-ratio',
'backdrop-filter',
'backface-visibility',
'background',
'background-attachment',
'background-blend-mode',
'background-clip',
'background-color',
'background-image',
'background-origin',
'background-position',
'background-position-x',
'background-position-y',
'background-repeat',
'background-size',
'baseline-shift',
'block-size',
'border',
'border-block',
'border-block-color',
'border-block-end',
'border-block-end-color',
'border-block-end-style',
'border-block-end-width',
'border-block-start',
'border-block-start-color',
'border-block-start-style',
'border-block-start-width',
'border-block-style',
'border-block-width',
'border-bottom',
'border-bottom-color',
'border-bottom-left-radius',
'border-bottom-right-radius',
'border-bottom-style',
'border-bottom-width',
'border-collapse',
'border-color',
'border-end-end-radius',
'border-end-start-radius',
'border-image',
'border-image-outset',
'border-image-repeat',
'border-image-slice',
'border-image-source',
'border-image-width',
'border-inline',
'border-inline-color',
'border-inline-end',
'border-inline-end-color',
'border-inline-end-style',
'border-inline-end-width',
'border-inline-start',
'border-inline-start-color',
'border-inline-start-style',
'border-inline-start-width',
'border-inline-style',
'border-inline-width',
'border-left',
'border-left-color',
'border-left-style',
'border-left-width',
'border-radius',
'border-right',
'border-right-color',
'border-right-style',
'border-right-width',
'border-spacing',
'border-start-end-radius',
'border-start-start-radius',
'border-style',
'border-top',
'border-top-color',
'border-top-left-radius',
'border-top-right-radius',
'border-top-style',
'border-top-width',
'border-width',
'bottom',
'box-align',
'box-decoration-break',
'box-direction',
'box-flex',
'box-flex-group',
'box-lines',
'box-ordinal-group',
'box-orient',
'box-pack',
'box-shadow',
'box-sizing',
'break-after',
'break-before',
'break-inside',
'caption-side',
'caret-color',
'clear',
'clip',
'clip-path',
'clip-rule',
'color',
'color-interpolation',
'color-interpolation-filters',
'color-profile',
'color-rendering',
'color-scheme',
'column-count',
'column-fill',
'column-gap',
'column-rule',
'column-rule-color',
'column-rule-style',
'column-rule-width',
'column-span',
'column-width',
'columns',
'contain',
'contain-intrinsic-block-size',
'contain-intrinsic-height',
'contain-intrinsic-inline-size',
'contain-intrinsic-size',
'contain-intrinsic-width',
'container',
'container-name',
'container-type',
'content',
'content-visibility',
'counter-increment',
'counter-reset',
'counter-set',
'cue',
'cue-after',
'cue-before',
'cursor',
'cx',
'cy',
'direction',
'display',
'dominant-baseline',
'empty-cells',
'enable-background',
'field-sizing',
'fill',
'fill-opacity',
'fill-rule',
'filter',
'flex',
'flex-basis',
'flex-direction',
'flex-flow',
'flex-grow',
'flex-shrink',
'flex-wrap',
'float',
'flood-color',
'flood-opacity',
'flow',
'font',
'font-display',
'font-family',
'font-feature-settings',
'font-kerning',
'font-language-override',
'font-optical-sizing',
'font-palette',
'font-size',
'font-size-adjust',
'font-smooth',
'font-smoothing',
'font-stretch',
'font-style',
'font-synthesis',
'font-synthesis-position',
'font-synthesis-small-caps',
'font-synthesis-style',
'font-synthesis-weight',
'font-variant',
'font-variant-alternates',
'font-variant-caps',
'font-variant-east-asian',
'font-variant-emoji',
'font-variant-ligatures',
'font-variant-numeric',
'font-variant-position',
'font-variation-settings',
'font-weight',
'forced-color-adjust',
'gap',
'glyph-orientation-horizontal',
'glyph-orientation-vertical',
'grid',
'grid-area',
'grid-auto-columns',
'grid-auto-flow',
'grid-auto-rows',
'grid-column',
'grid-column-end',
'grid-column-start',
'grid-gap',
'grid-row',
'grid-row-end',
'grid-row-start',
'grid-template',
'grid-template-areas',
'grid-template-columns',
'grid-template-rows',
'hanging-punctuation',
'height',
'hyphenate-character',
'hyphenate-limit-chars',
'hyphens',
'icon',
'image-orientation',
'image-rendering',
'image-resolution',
'ime-mode',
'initial-letter',
'initial-letter-align',
'inline-size',
'inset',
'inset-area',
'inset-block',
'inset-block-end',
'inset-block-start',
'inset-inline',
'inset-inline-end',
'inset-inline-start',
'isolation',
'justify-content',
'justify-items',
'justify-self',
'kerning',
'left',
'letter-spacing',
'lighting-color',
'line-break',
'line-height',
'line-height-step',
'list-style',
'list-style-image',
'list-style-position',
'list-style-type',
'margin',
'margin-block',
'margin-block-end',
'margin-block-start',
'margin-bottom',
'margin-inline',
'margin-inline-end',
'margin-inline-start',
'margin-left',
'margin-right',
'margin-top',
'margin-trim',
'marker',
'marker-end',
'marker-mid',
'marker-start',
'marks',
'mask',
'mask-border',
'mask-border-mode',
'mask-border-outset',
'mask-border-repeat',
'mask-border-slice',
'mask-border-source',
'mask-border-width',
'mask-clip',
'mask-composite',
'mask-image',
'mask-mode',
'mask-origin',
'mask-position',
'mask-repeat',
'mask-size',
'mask-type',
'masonry-auto-flow',
'math-depth',
'math-shift',
'math-style',
'max-block-size',
'max-height',
'max-inline-size',
'max-width',
'min-block-size',
'min-height',
'min-inline-size',
'min-width',
'mix-blend-mode',
'nav-down',
'nav-index',
'nav-left',
'nav-right',
'nav-up',
'none',
'normal',
'object-fit',
'object-position',
'offset',
'offset-anchor',
'offset-distance',
'offset-path',
'offset-position',
'offset-rotate',
'opacity',
'order',
'orphans',
'outline',
'outline-color',
'outline-offset',
'outline-style',
'outline-width',
'overflow',
'overflow-anchor',
'overflow-block',
'overflow-clip-margin',
'overflow-inline',
'overflow-wrap',
'overflow-x',
'overflow-y',
'overlay',
'overscroll-behavior',
'overscroll-behavior-block',
'overscroll-behavior-inline',
'overscroll-behavior-x',
'overscroll-behavior-y',
'padding',
'padding-block',
'padding-block-end',
'padding-block-start',
'padding-bottom',
'padding-inline',
'padding-inline-end',
'padding-inline-start',
'padding-left',
'padding-right',
'padding-top',
'page',
'page-break-after',
'page-break-before',
'page-break-inside',
'paint-order',
'pause',
'pause-after',
'pause-before',
'perspective',
'perspective-origin',
'place-content',
'place-items',
'place-self',
'pointer-events',
'position',
'position-anchor',
'position-visibility',
'print-color-adjust',
'quotes',
'r',
'resize',
'rest',
'rest-after',
'rest-before',
'right',
'rotate',
'row-gap',
'ruby-align',
'ruby-position',
'scale',
'scroll-behavior',
'scroll-margin',
'scroll-margin-block',
'scroll-margin-block-end',
'scroll-margin-block-start',
'scroll-margin-bottom',
'scroll-margin-inline',
'scroll-margin-inline-end',
'scroll-margin-inline-start',
'scroll-margin-left',
'scroll-margin-right',
'scroll-margin-top',
'scroll-padding',
'scroll-padding-block',
'scroll-padding-block-end',
'scroll-padding-block-start',
'scroll-padding-bottom',
'scroll-padding-inline',
'scroll-padding-inline-end',
'scroll-padding-inline-start',
'scroll-padding-left',
'scroll-padding-right',
'scroll-padding-top',
'scroll-snap-align',
'scroll-snap-stop',
'scroll-snap-type',
'scroll-timeline',
'scroll-timeline-axis',
'scroll-timeline-name',
'scrollbar-color',
'scrollbar-gutter',
'scrollbar-width',
'shape-image-threshold',
'shape-margin',
'shape-outside',
'shape-rendering',
'speak',
'speak-as',
'src', // @font-face
'stop-color',
'stop-opacity',
'stroke',
'stroke-dasharray',
'stroke-dashoffset',
'stroke-linecap',
'stroke-linejoin',
'stroke-miterlimit',
'stroke-opacity',
'stroke-width',
'tab-size',
'table-layout',
'text-align',
'text-align-all',
'text-align-last',
'text-anchor',
'text-combine-upright',
'text-decoration',
'text-decoration-color',
'text-decoration-line',
'text-decoration-skip',
'text-decoration-skip-ink',
'text-decoration-style',
'text-decoration-thickness',
'text-emphasis',
'text-emphasis-color',
'text-emphasis-position',
'text-emphasis-style',
'text-indent',
'text-justify',
'text-orientation',
'text-overflow',
'text-rendering',
'text-shadow',
'text-size-adjust',
'text-transform',
'text-underline-offset',
'text-underline-position',
'text-wrap',
'text-wrap-mode',
'text-wrap-style',
'timeline-scope',
'top',
'touch-action',
'transform',
'transform-box',
'transform-origin',
'transform-style',
'transition',
'transition-behavior',
'transition-delay',
'transition-duration',
'transition-property',
'transition-timing-function',
'translate',
'unicode-bidi',
'user-modify',
'user-select',
'vector-effect',
'vertical-align',
'view-timeline',
'view-timeline-axis',
'view-timeline-inset',
'view-timeline-name',
'view-transition-name',
'visibility',
'voice-balance',
'voice-duration',
'voice-family',
'voice-pitch',
'voice-range',
'voice-rate',
'voice-stress',
'voice-volume',
'white-space',
'white-space-collapse',
'widows',
'width',
'will-change',
'word-break',
'word-spacing',
'word-wrap',
'writing-mode',
'x',
'y',
'z-index',
'zoom'
].sort().reverse();
/*
Language: CSS
Category: common, css, web
Website: https://developer.mozilla.org/en-US/docs/Web/CSS
*/
/** @type LanguageFn */
function css(hljs) {
const regex = hljs.regex;
const modes = MODES(hljs);
const VENDOR_PREFIX = { begin: /-(webkit|moz|ms|o)-(?=[a-z])/ };
const AT_MODIFIERS = "and or not only";
const AT_PROPERTY_RE = /@-?\w[\w]*(-\w+)*/; // @-webkit-keyframes
const IDENT_RE = '[a-zA-Z-][a-zA-Z0-9_-]*';
const STRINGS = [
hljs.APOS_STRING_MODE,
hljs.QUOTE_STRING_MODE
];
return {
name: 'CSS',
case_insensitive: true,
illegal: /[=|'\$]/,
keywords: { keyframePosition: "from to" },
classNameAliases: {
// for visual continuity with `tag {}` and because we
// don't have a great class for this?
keyframePosition: "selector-tag" },
contains: [
modes.BLOCK_COMMENT,
VENDOR_PREFIX,
// to recognize keyframe 40% etc which are outside the scope of our
// attribute value mode
modes.CSS_NUMBER_MODE,
{
className: 'selector-id',
begin: /#[A-Za-z0-9_-]+/,
relevance: 0
},
{
className: 'selector-class',
begin: '\\.' + IDENT_RE,
relevance: 0
},
modes.ATTRIBUTE_SELECTOR_MODE,
{
className: 'selector-pseudo',
variants: [
{ begin: ':(' + PSEUDO_CLASSES.join('|') + ')' },
{ begin: ':(:)?(' + PSEUDO_ELEMENTS.join('|') + ')' }
]
},
// we may actually need this (12/2020)
// { // pseudo-selector params
// begin: /\(/,
// end: /\)/,
// contains: [ hljs.CSS_NUMBER_MODE ]
// },
modes.CSS_VARIABLE,
{
className: 'attribute',
begin: '\\b(' + ATTRIBUTES.join('|') + ')\\b'
},
// attribute values
{
begin: /:/,
end: /[;}{]/,
contains: [
modes.BLOCK_COMMENT,
modes.HEXCOLOR,
modes.IMPORTANT,
modes.CSS_NUMBER_MODE,
...STRINGS,
// needed to highlight these as strings and to avoid issues with
// illegal characters that might be inside urls that would tigger the
// languages illegal stack
{
begin: /(url|data-uri)\(/,
end: /\)/,
relevance: 0, // from keywords
keywords: { built_in: "url data-uri" },
contains: [
...STRINGS,
{
className: "string",
// any character other than `)` as in `url()` will be the start
// of a string, which ends with `)` (from the parent mode)
begin: /[^)]/,
endsWithParent: true,
excludeEnd: true
}
]
},
modes.FUNCTION_DISPATCH
]
},
{
begin: regex.lookahead(/@/),
end: '[{;]',
relevance: 0,
illegal: /:/, // break on Less variables @var: ...
contains: [
{
className: 'keyword',
begin: AT_PROPERTY_RE
},
{
begin: /\s/,
endsWithParent: true,
excludeEnd: true,
relevance: 0,
keywords: {
$pattern: /[a-z-]+/,
keyword: AT_MODIFIERS,
attribute: MEDIA_FEATURES.join(" ")
},
contains: [
{
begin: /[a-z-]+(?=:)/,
className: "attribute"
},
...STRINGS,
modes.CSS_NUMBER_MODE
]
}
]
},
{
className: 'selector-tag',
begin: '\\b(' + TAGS.join('|') + ')\\b'
}
]
};
}
return css;
})();
hljs.registerLanguage('css', hljsGrammar);
})();

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,85 @@
/*! `django` grammar compiled for Highlight.js 11.11.1 */
(function(){
var hljsGrammar = (function () {
'use strict';
/*
Language: Django
Description: Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design.
Requires: xml.js
Author: Ivan Sagalaev <maniac@softwaremaniacs.org>
Contributors: Ilya Baryshev <baryshev@gmail.com>
Website: https://www.djangoproject.com
Category: template
*/
/** @type LanguageFn */
function django(hljs) {
const FILTER = {
begin: /\|[A-Za-z]+:?/,
keywords: { name:
'truncatewords removetags linebreaksbr yesno get_digit timesince random striptags '
+ 'filesizeformat escape linebreaks length_is ljust rjust cut urlize fix_ampersands '
+ 'title floatformat capfirst pprint divisibleby add make_list unordered_list urlencode '
+ 'timeuntil urlizetrunc wordcount stringformat linenumbers slice date dictsort '
+ 'dictsortreversed default_if_none pluralize lower join center default '
+ 'truncatewords_html upper length phone2numeric wordwrap time addslashes slugify first '
+ 'escapejs force_escape iriencode last safe safeseq truncatechars localize unlocalize '
+ 'localtime utc timezone' },
contains: [
hljs.QUOTE_STRING_MODE,
hljs.APOS_STRING_MODE
]
};
return {
name: 'Django',
aliases: [ 'jinja' ],
case_insensitive: true,
subLanguage: 'xml',
contains: [
hljs.COMMENT(/\{%\s*comment\s*%\}/, /\{%\s*endcomment\s*%\}/),
hljs.COMMENT(/\{#/, /#\}/),
{
className: 'template-tag',
begin: /\{%/,
end: /%\}/,
contains: [
{
className: 'name',
begin: /\w+/,
keywords: { name:
'comment endcomment load templatetag ifchanged endifchanged if endif firstof for '
+ 'endfor ifnotequal endifnotequal widthratio extends include spaceless '
+ 'endspaceless regroup ifequal endifequal ssi now with cycle url filter '
+ 'endfilter debug block endblock else autoescape endautoescape csrf_token empty elif '
+ 'endwith static trans blocktrans endblocktrans get_static_prefix get_media_prefix '
+ 'plural get_current_language language get_available_languages '
+ 'get_current_language_bidi get_language_info get_language_info_list localize '
+ 'endlocalize localtime endlocaltime timezone endtimezone get_current_timezone '
+ 'verbatim' },
starts: {
endsWithParent: true,
keywords: 'in by as',
contains: [ FILTER ],
relevance: 0
}
}
]
},
{
className: 'template-variable',
begin: /\{\{/,
end: /\}\}/,
contains: [ FILTER ]
}
]
};
}
return django;
})();
hljs.registerLanguage('django', hljsGrammar);
})();

View File

@@ -0,0 +1,13 @@
/*! `django` grammar compiled for Highlight.js 11.11.1 */
(()=>{var e=(()=>{"use strict";return e=>{const t={begin:/\|[A-Za-z]+:?/,
keywords:{
name:"truncatewords removetags linebreaksbr yesno get_digit timesince random striptags filesizeformat escape linebreaks length_is ljust rjust cut urlize fix_ampersands title floatformat capfirst pprint divisibleby add make_list unordered_list urlencode timeuntil urlizetrunc wordcount stringformat linenumbers slice date dictsort dictsortreversed default_if_none pluralize lower join center default truncatewords_html upper length phone2numeric wordwrap time addslashes slugify first escapejs force_escape iriencode last safe safeseq truncatechars localize unlocalize localtime utc timezone"
},contains:[e.QUOTE_STRING_MODE,e.APOS_STRING_MODE]};return{name:"Django",
aliases:["jinja"],case_insensitive:!0,subLanguage:"xml",
contains:[e.COMMENT(/\{%\s*comment\s*%\}/,/\{%\s*endcomment\s*%\}/),e.COMMENT(/\{#/,/#\}/),{
className:"template-tag",begin:/\{%/,end:/%\}/,contains:[{className:"name",
begin:/\w+/,keywords:{
name:"comment endcomment load templatetag ifchanged endifchanged if endif firstof for endfor ifnotequal endifnotequal widthratio extends include spaceless endspaceless regroup ifequal endifequal ssi now with cycle url filter endfilter debug block endblock else autoescape endautoescape csrf_token empty elif endwith static trans blocktrans endblocktrans get_static_prefix get_media_prefix plural get_current_language language get_available_languages get_current_language_bidi get_language_info get_language_info_list localize endlocalize localtime endlocaltime timezone endtimezone get_current_timezone verbatim"
},starts:{endsWithParent:!0,keywords:"in by as",contains:[t],relevance:0}}]},{
className:"template-variable",begin:/\{\{/,end:/\}\}/,contains:[t]}]}}})()
;hljs.registerLanguage("django",e)})();

View File

@@ -0,0 +1,54 @@
/*! `dockerfile` grammar compiled for Highlight.js 11.11.1 */
(function(){
var hljsGrammar = (function () {
'use strict';
/*
Language: Dockerfile
Requires: bash.js
Author: Alexis Hénaut <alexis@henaut.net>
Description: language definition for Dockerfile files
Website: https://docs.docker.com/engine/reference/builder/
Category: config
*/
/** @type LanguageFn */
function dockerfile(hljs) {
const KEYWORDS = [
"from",
"maintainer",
"expose",
"env",
"arg",
"user",
"onbuild",
"stopsignal"
];
return {
name: 'Dockerfile',
aliases: [ 'docker' ],
case_insensitive: true,
keywords: KEYWORDS,
contains: [
hljs.HASH_COMMENT_MODE,
hljs.APOS_STRING_MODE,
hljs.QUOTE_STRING_MODE,
hljs.NUMBER_MODE,
{
beginKeywords: 'run cmd entrypoint volume add copy workdir label healthcheck shell',
starts: {
end: /[^\\]$/,
subLanguage: 'bash'
}
}
],
illegal: '</'
};
}
return dockerfile;
})();
hljs.registerLanguage('dockerfile', hljsGrammar);
})();

View File

@@ -0,0 +1,8 @@
/*! `dockerfile` grammar compiled for Highlight.js 11.11.1 */
(()=>{var e=(()=>{"use strict";return e=>({name:"Dockerfile",aliases:["docker"],
case_insensitive:!0,
keywords:["from","maintainer","expose","env","arg","user","onbuild","stopsignal"],
contains:[e.HASH_COMMENT_MODE,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,e.NUMBER_MODE,{
beginKeywords:"run cmd entrypoint volume add copy workdir label healthcheck shell",
starts:{end:/[^\\]$/,subLanguage:"bash"}}],illegal:"</"})})()
;hljs.registerLanguage("dockerfile",e)})();

View File

@@ -0,0 +1,166 @@
/*! `go` grammar compiled for Highlight.js 11.11.1 */
(function(){
var hljsGrammar = (function () {
'use strict';
/*
Language: Go
Author: Stephan Kountso aka StepLg <steplg@gmail.com>
Contributors: Evgeny Stepanischev <imbolk@gmail.com>
Description: Google go language (golang). For info about language
Website: http://golang.org/
Category: common, system
*/
function go(hljs) {
const LITERALS = [
"true",
"false",
"iota",
"nil"
];
const BUILT_INS = [
"append",
"cap",
"close",
"complex",
"copy",
"imag",
"len",
"make",
"new",
"panic",
"print",
"println",
"real",
"recover",
"delete"
];
const TYPES = [
"bool",
"byte",
"complex64",
"complex128",
"error",
"float32",
"float64",
"int8",
"int16",
"int32",
"int64",
"string",
"uint8",
"uint16",
"uint32",
"uint64",
"int",
"uint",
"uintptr",
"rune"
];
const KWS = [
"break",
"case",
"chan",
"const",
"continue",
"default",
"defer",
"else",
"fallthrough",
"for",
"func",
"go",
"goto",
"if",
"import",
"interface",
"map",
"package",
"range",
"return",
"select",
"struct",
"switch",
"type",
"var",
];
const KEYWORDS = {
keyword: KWS,
type: TYPES,
literal: LITERALS,
built_in: BUILT_INS
};
return {
name: 'Go',
aliases: [ 'golang' ],
keywords: KEYWORDS,
illegal: '</',
contains: [
hljs.C_LINE_COMMENT_MODE,
hljs.C_BLOCK_COMMENT_MODE,
{
className: 'string',
variants: [
hljs.QUOTE_STRING_MODE,
hljs.APOS_STRING_MODE,
{
begin: '`',
end: '`'
}
]
},
{
className: 'number',
variants: [
{
match: /-?\b0[xX]\.[a-fA-F0-9](_?[a-fA-F0-9])*[pP][+-]?\d(_?\d)*i?/, // hex without a present digit before . (making a digit afterwards required)
relevance: 0
},
{
match: /-?\b0[xX](_?[a-fA-F0-9])+((\.([a-fA-F0-9](_?[a-fA-F0-9])*)?)?[pP][+-]?\d(_?\d)*)?i?/, // hex with a present digit before . (making a digit afterwards optional)
relevance: 0
},
{
match: /-?\b0[oO](_?[0-7])*i?/, // leading 0o octal
relevance: 0
},
{
match: /-?\.\d(_?\d)*([eE][+-]?\d(_?\d)*)?i?/, // decimal without a present digit before . (making a digit afterwards required)
relevance: 0
},
{
match: /-?\b\d(_?\d)*(\.(\d(_?\d)*)?)?([eE][+-]?\d(_?\d)*)?i?/, // decimal with a present digit before . (making a digit afterwards optional)
relevance: 0
}
]
},
{ begin: /:=/ // relevance booster
},
{
className: 'function',
beginKeywords: 'func',
end: '\\s*(\\{|$)',
excludeEnd: true,
contains: [
hljs.TITLE_MODE,
{
className: 'params',
begin: /\(/,
end: /\)/,
endsParent: true,
keywords: KEYWORDS,
illegal: /["']/
}
]
}
]
};
}
return go;
})();
hljs.registerLanguage('go', hljsGrammar);
})();

View File

@@ -0,0 +1,20 @@
/*! `go` grammar compiled for Highlight.js 11.11.1 */
(()=>{var e=(()=>{"use strict";return e=>{const a={
keyword:["break","case","chan","const","continue","default","defer","else","fallthrough","for","func","go","goto","if","import","interface","map","package","range","return","select","struct","switch","type","var"],
type:["bool","byte","complex64","complex128","error","float32","float64","int8","int16","int32","int64","string","uint8","uint16","uint32","uint64","int","uint","uintptr","rune"],
literal:["true","false","iota","nil"],
built_in:["append","cap","close","complex","copy","imag","len","make","new","panic","print","println","real","recover","delete"]
};return{name:"Go",aliases:["golang"],keywords:a,illegal:"</",
contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,{className:"string",
variants:[e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,{begin:"`",end:"`"}]},{
className:"number",variants:[{
match:/-?\b0[xX]\.[a-fA-F0-9](_?[a-fA-F0-9])*[pP][+-]?\d(_?\d)*i?/,relevance:0
},{
match:/-?\b0[xX](_?[a-fA-F0-9])+((\.([a-fA-F0-9](_?[a-fA-F0-9])*)?)?[pP][+-]?\d(_?\d)*)?i?/,
relevance:0},{match:/-?\b0[oO](_?[0-7])*i?/,relevance:0},{
match:/-?\.\d(_?\d)*([eE][+-]?\d(_?\d)*)?i?/,relevance:0},{
match:/-?\b\d(_?\d)*(\.(\d(_?\d)*)?)?([eE][+-]?\d(_?\d)*)?i?/,relevance:0}]},{
begin:/:=/},{className:"function",beginKeywords:"func",end:"\\s*(\\{|$)",
excludeEnd:!0,contains:[e.TITLE_MODE,{className:"params",begin:/\(/,end:/\)/,
endsParent:!0,keywords:a,illegal:/["']/}]}]}}})();hljs.registerLanguage("go",e)
})();

View File

@@ -0,0 +1,107 @@
/*! `http` grammar compiled for Highlight.js 11.11.1 */
(function(){
var hljsGrammar = (function () {
'use strict';
/*
Language: HTTP
Description: HTTP request and response headers with automatic body highlighting
Author: Ivan Sagalaev <maniac@softwaremaniacs.org>
Category: protocols, web
Website: https://developer.mozilla.org/en-US/docs/Web/HTTP/Overview
*/
function http(hljs) {
const regex = hljs.regex;
const VERSION = 'HTTP/([32]|1\\.[01])';
const HEADER_NAME = /[A-Za-z][A-Za-z0-9-]*/;
const HEADER = {
className: 'attribute',
begin: regex.concat('^', HEADER_NAME, '(?=\\:\\s)'),
starts: { contains: [
{
className: "punctuation",
begin: /: /,
relevance: 0,
starts: {
end: '$',
relevance: 0
}
}
] }
};
const HEADERS_AND_BODY = [
HEADER,
{
begin: '\\n\\n',
starts: {
subLanguage: [],
endsWithParent: true
}
}
];
return {
name: 'HTTP',
aliases: [ 'https' ],
illegal: /\S/,
contains: [
// response
{
begin: '^(?=' + VERSION + " \\d{3})",
end: /$/,
contains: [
{
className: "meta",
begin: VERSION
},
{
className: 'number',
begin: '\\b\\d{3}\\b'
}
],
starts: {
end: /\b\B/,
illegal: /\S/,
contains: HEADERS_AND_BODY
}
},
// request
{
begin: '(?=^[A-Z]+ (.*?) ' + VERSION + '$)',
end: /$/,
contains: [
{
className: 'string',
begin: ' ',
end: ' ',
excludeBegin: true,
excludeEnd: true
},
{
className: "meta",
begin: VERSION
},
{
className: 'keyword',
begin: '[A-Z]+'
}
],
starts: {
end: /\b\B/,
illegal: /\S/,
contains: HEADERS_AND_BODY
}
},
// to allow headers to work even without a preamble
hljs.inherit(HEADER, { relevance: 0 })
]
};
}
return http;
})();
hljs.registerLanguage('http', hljsGrammar);
})();

View File

@@ -0,0 +1,14 @@
/*! `http` grammar compiled for Highlight.js 11.11.1 */
(()=>{var e=(()=>{"use strict";return e=>{const n="HTTP/([32]|1\\.[01])",a={
className:"attribute",
begin:e.regex.concat("^",/[A-Za-z][A-Za-z0-9-]*/,"(?=\\:\\s)"),starts:{
contains:[{className:"punctuation",begin:/: /,relevance:0,starts:{end:"$",
relevance:0}}]}},s=[a,{begin:"\\n\\n",starts:{subLanguage:[],endsWithParent:!0}
}];return{name:"HTTP",aliases:["https"],illegal:/\S/,contains:[{
begin:"^(?="+n+" \\d{3})",end:/$/,contains:[{className:"meta",begin:n},{
className:"number",begin:"\\b\\d{3}\\b"}],starts:{end:/\b\B/,illegal:/\S/,
contains:s}},{begin:"(?=^[A-Z]+ (.*?) "+n+"$)",end:/$/,contains:[{
className:"string",begin:" ",end:" ",excludeBegin:!0,excludeEnd:!0},{
className:"meta",begin:n},{className:"keyword",begin:"[A-Z]+"}],starts:{
end:/\b\B/,illegal:/\S/,contains:s}},e.inherit(a,{relevance:0})]}}})()
;hljs.registerLanguage("http",e)})();

View File

@@ -0,0 +1,131 @@
/*! `ini` grammar compiled for Highlight.js 11.11.1 */
(function(){
var hljsGrammar = (function () {
'use strict';
/*
Language: TOML, also INI
Description: TOML aims to be a minimal configuration file format that's easy to read due to obvious semantics.
Contributors: Guillaume Gomez <guillaume1.gomez@gmail.com>
Category: common, config
Website: https://github.com/toml-lang/toml
*/
function ini(hljs) {
const regex = hljs.regex;
const NUMBERS = {
className: 'number',
relevance: 0,
variants: [
{ begin: /([+-]+)?[\d]+_[\d_]+/ },
{ begin: hljs.NUMBER_RE }
]
};
const COMMENTS = hljs.COMMENT();
COMMENTS.variants = [
{
begin: /;/,
end: /$/
},
{
begin: /#/,
end: /$/
}
];
const VARIABLES = {
className: 'variable',
variants: [
{ begin: /\$[\w\d"][\w\d_]*/ },
{ begin: /\$\{(.*?)\}/ }
]
};
const LITERALS = {
className: 'literal',
begin: /\bon|off|true|false|yes|no\b/
};
const STRINGS = {
className: "string",
contains: [ hljs.BACKSLASH_ESCAPE ],
variants: [
{
begin: "'''",
end: "'''",
relevance: 10
},
{
begin: '"""',
end: '"""',
relevance: 10
},
{
begin: '"',
end: '"'
},
{
begin: "'",
end: "'"
}
]
};
const ARRAY = {
begin: /\[/,
end: /\]/,
contains: [
COMMENTS,
LITERALS,
VARIABLES,
STRINGS,
NUMBERS,
'self'
],
relevance: 0
};
const BARE_KEY = /[A-Za-z0-9_-]+/;
const QUOTED_KEY_DOUBLE_QUOTE = /"(\\"|[^"])*"/;
const QUOTED_KEY_SINGLE_QUOTE = /'[^']*'/;
const ANY_KEY = regex.either(
BARE_KEY, QUOTED_KEY_DOUBLE_QUOTE, QUOTED_KEY_SINGLE_QUOTE
);
const DOTTED_KEY = regex.concat(
ANY_KEY, '(\\s*\\.\\s*', ANY_KEY, ')*',
regex.lookahead(/\s*=\s*[^#\s]/)
);
return {
name: 'TOML, also INI',
aliases: [ 'toml' ],
case_insensitive: true,
illegal: /\S/,
contains: [
COMMENTS,
{
className: 'section',
begin: /\[+/,
end: /\]+/
},
{
begin: DOTTED_KEY,
className: 'attr',
starts: {
end: /$/,
contains: [
COMMENTS,
ARRAY,
LITERALS,
VARIABLES,
STRINGS,
NUMBERS
]
}
}
]
};
}
return ini;
})();
hljs.registerLanguage('ini', hljsGrammar);
})();

View File

@@ -0,0 +1,15 @@
/*! `ini` grammar compiled for Highlight.js 11.11.1 */
(()=>{var e=(()=>{"use strict";return e=>{const n=e.regex,a={className:"number",
relevance:0,variants:[{begin:/([+-]+)?[\d]+_[\d_]+/},{begin:e.NUMBER_RE}]
},s=e.COMMENT();s.variants=[{begin:/;/,end:/$/},{begin:/#/,end:/$/}];const i={
className:"variable",variants:[{begin:/\$[\w\d"][\w\d_]*/},{begin:/\$\{(.*?)\}/
}]},t={className:"literal",begin:/\bon|off|true|false|yes|no\b/},r={
className:"string",contains:[e.BACKSLASH_ESCAPE],variants:[{begin:"'''",
end:"'''",relevance:10},{begin:'"""',end:'"""',relevance:10},{begin:'"',end:'"'
},{begin:"'",end:"'"}]},l={begin:/\[/,end:/\]/,contains:[s,t,i,r,a,"self"],
relevance:0},c=n.either(/[A-Za-z0-9_-]+/,/"(\\"|[^"])*"/,/'[^']*'/);return{
name:"TOML, also INI",aliases:["toml"],case_insensitive:!0,illegal:/\S/,
contains:[s,{className:"section",begin:/\[+/,end:/\]+/},{
begin:n.concat(c,"(\\s*\\.\\s*",c,")*",n.lookahead(/\s*=\s*[^#\s]/)),
className:"attr",starts:{end:/$/,contains:[s,l,t,i,r,a]}}]}}})()
;hljs.registerLanguage("ini",e)})();

View File

@@ -0,0 +1,779 @@
/*! `javascript` grammar compiled for Highlight.js 11.11.1 */
(function(){
var hljsGrammar = (function () {
'use strict';
const IDENT_RE = '[A-Za-z$_][0-9A-Za-z$_]*';
const KEYWORDS = [
"as", // for exports
"in",
"of",
"if",
"for",
"while",
"finally",
"var",
"new",
"function",
"do",
"return",
"void",
"else",
"break",
"catch",
"instanceof",
"with",
"throw",
"case",
"default",
"try",
"switch",
"continue",
"typeof",
"delete",
"let",
"yield",
"const",
"class",
// JS handles these with a special rule
// "get",
// "set",
"debugger",
"async",
"await",
"static",
"import",
"from",
"export",
"extends",
// It's reached stage 3, which is "recommended for implementation":
"using"
];
const LITERALS = [
"true",
"false",
"null",
"undefined",
"NaN",
"Infinity"
];
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects
const TYPES = [
// Fundamental objects
"Object",
"Function",
"Boolean",
"Symbol",
// numbers and dates
"Math",
"Date",
"Number",
"BigInt",
// text
"String",
"RegExp",
// Indexed collections
"Array",
"Float32Array",
"Float64Array",
"Int8Array",
"Uint8Array",
"Uint8ClampedArray",
"Int16Array",
"Int32Array",
"Uint16Array",
"Uint32Array",
"BigInt64Array",
"BigUint64Array",
// Keyed collections
"Set",
"Map",
"WeakSet",
"WeakMap",
// Structured data
"ArrayBuffer",
"SharedArrayBuffer",
"Atomics",
"DataView",
"JSON",
// Control abstraction objects
"Promise",
"Generator",
"GeneratorFunction",
"AsyncFunction",
// Reflection
"Reflect",
"Proxy",
// Internationalization
"Intl",
// WebAssembly
"WebAssembly"
];
const ERROR_TYPES = [
"Error",
"EvalError",
"InternalError",
"RangeError",
"ReferenceError",
"SyntaxError",
"TypeError",
"URIError"
];
const BUILT_IN_GLOBALS = [
"setInterval",
"setTimeout",
"clearInterval",
"clearTimeout",
"require",
"exports",
"eval",
"isFinite",
"isNaN",
"parseFloat",
"parseInt",
"decodeURI",
"decodeURIComponent",
"encodeURI",
"encodeURIComponent",
"escape",
"unescape"
];
const BUILT_IN_VARIABLES = [
"arguments",
"this",
"super",
"console",
"window",
"document",
"localStorage",
"sessionStorage",
"module",
"global" // Node.js
];
const BUILT_INS = [].concat(
BUILT_IN_GLOBALS,
TYPES,
ERROR_TYPES
);
/*
Language: JavaScript
Description: JavaScript (JS) is a lightweight, interpreted, or just-in-time compiled programming language with first-class functions.
Category: common, scripting, web
Website: https://developer.mozilla.org/en-US/docs/Web/JavaScript
*/
/** @type LanguageFn */
function javascript(hljs) {
const regex = hljs.regex;
/**
* Takes a string like "<Booger" and checks to see
* if we can find a matching "</Booger" later in the
* content.
* @param {RegExpMatchArray} match
* @param {{after:number}} param1
*/
const hasClosingTag = (match, { after }) => {
const tag = "</" + match[0].slice(1);
const pos = match.input.indexOf(tag, after);
return pos !== -1;
};
const IDENT_RE$1 = IDENT_RE;
const FRAGMENT = {
begin: '<>',
end: '</>'
};
// to avoid some special cases inside isTrulyOpeningTag
const XML_SELF_CLOSING = /<[A-Za-z0-9\\._:-]+\s*\/>/;
const XML_TAG = {
begin: /<[A-Za-z0-9\\._:-]+/,
end: /\/[A-Za-z0-9\\._:-]+>|\/>/,
/**
* @param {RegExpMatchArray} match
* @param {CallbackResponse} response
*/
isTrulyOpeningTag: (match, response) => {
const afterMatchIndex = match[0].length + match.index;
const nextChar = match.input[afterMatchIndex];
if (
// HTML should not include another raw `<` inside a tag
// nested type?
// `<Array<Array<number>>`, etc.
nextChar === "<" ||
// the , gives away that this is not HTML
// `<T, A extends keyof T, V>`
nextChar === ","
) {
response.ignoreMatch();
return;
}
// `<something>`
// Quite possibly a tag, lets look for a matching closing tag...
if (nextChar === ">") {
// if we cannot find a matching closing tag, then we
// will ignore it
if (!hasClosingTag(match, { after: afterMatchIndex })) {
response.ignoreMatch();
}
}
// `<blah />` (self-closing)
// handled by simpleSelfClosing rule
let m;
const afterMatch = match.input.substring(afterMatchIndex);
// some more template typing stuff
// <T = any>(key?: string) => Modify<
if ((m = afterMatch.match(/^\s*=/))) {
response.ignoreMatch();
return;
}
// `<From extends string>`
// technically this could be HTML, but it smells like a type
// NOTE: This is ugh, but added specifically for https://github.com/highlightjs/highlight.js/issues/3276
if ((m = afterMatch.match(/^\s+extends\s+/))) {
if (m.index === 0) {
response.ignoreMatch();
// eslint-disable-next-line no-useless-return
return;
}
}
}
};
const KEYWORDS$1 = {
$pattern: IDENT_RE,
keyword: KEYWORDS,
literal: LITERALS,
built_in: BUILT_INS,
"variable.language": BUILT_IN_VARIABLES
};
// https://tc39.es/ecma262/#sec-literals-numeric-literals
const decimalDigits = '[0-9](_?[0-9])*';
const frac = `\\.(${decimalDigits})`;
// DecimalIntegerLiteral, including Annex B NonOctalDecimalIntegerLiteral
// https://tc39.es/ecma262/#sec-additional-syntax-numeric-literals
const decimalInteger = `0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*`;
const NUMBER = {
className: 'number',
variants: [
// DecimalLiteral
{ begin: `(\\b(${decimalInteger})((${frac})|\\.)?|(${frac}))` +
`[eE][+-]?(${decimalDigits})\\b` },
{ begin: `\\b(${decimalInteger})\\b((${frac})\\b|\\.)?|(${frac})\\b` },
// DecimalBigIntegerLiteral
{ begin: `\\b(0|[1-9](_?[0-9])*)n\\b` },
// NonDecimalIntegerLiteral
{ begin: "\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b" },
{ begin: "\\b0[bB][0-1](_?[0-1])*n?\\b" },
{ begin: "\\b0[oO][0-7](_?[0-7])*n?\\b" },
// LegacyOctalIntegerLiteral (does not include underscore separators)
// https://tc39.es/ecma262/#sec-additional-syntax-numeric-literals
{ begin: "\\b0[0-7]+n?\\b" },
],
relevance: 0
};
const SUBST = {
className: 'subst',
begin: '\\$\\{',
end: '\\}',
keywords: KEYWORDS$1,
contains: [] // defined later
};
const HTML_TEMPLATE = {
begin: '\.?html`',
end: '',
starts: {
end: '`',
returnEnd: false,
contains: [
hljs.BACKSLASH_ESCAPE,
SUBST
],
subLanguage: 'xml'
}
};
const CSS_TEMPLATE = {
begin: '\.?css`',
end: '',
starts: {
end: '`',
returnEnd: false,
contains: [
hljs.BACKSLASH_ESCAPE,
SUBST
],
subLanguage: 'css'
}
};
const GRAPHQL_TEMPLATE = {
begin: '\.?gql`',
end: '',
starts: {
end: '`',
returnEnd: false,
contains: [
hljs.BACKSLASH_ESCAPE,
SUBST
],
subLanguage: 'graphql'
}
};
const TEMPLATE_STRING = {
className: 'string',
begin: '`',
end: '`',
contains: [
hljs.BACKSLASH_ESCAPE,
SUBST
]
};
const JSDOC_COMMENT = hljs.COMMENT(
/\/\*\*(?!\/)/,
'\\*/',
{
relevance: 0,
contains: [
{
begin: '(?=@[A-Za-z]+)',
relevance: 0,
contains: [
{
className: 'doctag',
begin: '@[A-Za-z]+'
},
{
className: 'type',
begin: '\\{',
end: '\\}',
excludeEnd: true,
excludeBegin: true,
relevance: 0
},
{
className: 'variable',
begin: IDENT_RE$1 + '(?=\\s*(-)|$)',
endsParent: true,
relevance: 0
},
// eat spaces (not newlines) so we can find
// types or variables
{
begin: /(?=[^\n])\s/,
relevance: 0
}
]
}
]
}
);
const COMMENT = {
className: "comment",
variants: [
JSDOC_COMMENT,
hljs.C_BLOCK_COMMENT_MODE,
hljs.C_LINE_COMMENT_MODE
]
};
const SUBST_INTERNALS = [
hljs.APOS_STRING_MODE,
hljs.QUOTE_STRING_MODE,
HTML_TEMPLATE,
CSS_TEMPLATE,
GRAPHQL_TEMPLATE,
TEMPLATE_STRING,
// Skip numbers when they are part of a variable name
{ match: /\$\d+/ },
NUMBER,
// This is intentional:
// See https://github.com/highlightjs/highlight.js/issues/3288
// hljs.REGEXP_MODE
];
SUBST.contains = SUBST_INTERNALS
.concat({
// we need to pair up {} inside our subst to prevent
// it from ending too early by matching another }
begin: /\{/,
end: /\}/,
keywords: KEYWORDS$1,
contains: [
"self"
].concat(SUBST_INTERNALS)
});
const SUBST_AND_COMMENTS = [].concat(COMMENT, SUBST.contains);
const PARAMS_CONTAINS = SUBST_AND_COMMENTS.concat([
// eat recursive parens in sub expressions
{
begin: /(\s*)\(/,
end: /\)/,
keywords: KEYWORDS$1,
contains: ["self"].concat(SUBST_AND_COMMENTS)
}
]);
const PARAMS = {
className: 'params',
// convert this to negative lookbehind in v12
begin: /(\s*)\(/, // to match the parms with
end: /\)/,
excludeBegin: true,
excludeEnd: true,
keywords: KEYWORDS$1,
contains: PARAMS_CONTAINS
};
// ES6 classes
const CLASS_OR_EXTENDS = {
variants: [
// class Car extends vehicle
{
match: [
/class/,
/\s+/,
IDENT_RE$1,
/\s+/,
/extends/,
/\s+/,
regex.concat(IDENT_RE$1, "(", regex.concat(/\./, IDENT_RE$1), ")*")
],
scope: {
1: "keyword",
3: "title.class",
5: "keyword",
7: "title.class.inherited"
}
},
// class Car
{
match: [
/class/,
/\s+/,
IDENT_RE$1
],
scope: {
1: "keyword",
3: "title.class"
}
},
]
};
const CLASS_REFERENCE = {
relevance: 0,
match:
regex.either(
// Hard coded exceptions
/\bJSON/,
// Float32Array, OutT
/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,
// CSSFactory, CSSFactoryT
/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,
// FPs, FPsT
/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/,
// P
// single letters are not highlighted
// BLAH
// this will be flagged as a UPPER_CASE_CONSTANT instead
),
className: "title.class",
keywords: {
_: [
// se we still get relevance credit for JS library classes
...TYPES,
...ERROR_TYPES
]
}
};
const USE_STRICT = {
label: "use_strict",
className: 'meta',
relevance: 10,
begin: /^\s*['"]use (strict|asm)['"]/
};
const FUNCTION_DEFINITION = {
variants: [
{
match: [
/function/,
/\s+/,
IDENT_RE$1,
/(?=\s*\()/
]
},
// anonymous function
{
match: [
/function/,
/\s*(?=\()/
]
}
],
className: {
1: "keyword",
3: "title.function"
},
label: "func.def",
contains: [ PARAMS ],
illegal: /%/
};
const UPPER_CASE_CONSTANT = {
relevance: 0,
match: /\b[A-Z][A-Z_0-9]+\b/,
className: "variable.constant"
};
function noneOf(list) {
return regex.concat("(?!", list.join("|"), ")");
}
const FUNCTION_CALL = {
match: regex.concat(
/\b/,
noneOf([
...BUILT_IN_GLOBALS,
"super",
"import"
].map(x => `${x}\\s*\\(`)),
IDENT_RE$1, regex.lookahead(/\s*\(/)),
className: "title.function",
relevance: 0
};
const PROPERTY_ACCESS = {
begin: regex.concat(/\./, regex.lookahead(
regex.concat(IDENT_RE$1, /(?![0-9A-Za-z$_(])/)
)),
end: IDENT_RE$1,
excludeBegin: true,
keywords: "prototype",
className: "property",
relevance: 0
};
const GETTER_OR_SETTER = {
match: [
/get|set/,
/\s+/,
IDENT_RE$1,
/(?=\()/
],
className: {
1: "keyword",
3: "title.function"
},
contains: [
{ // eat to avoid empty params
begin: /\(\)/
},
PARAMS
]
};
const FUNC_LEAD_IN_RE = '(\\(' +
'[^()]*(\\(' +
'[^()]*(\\(' +
'[^()]*' +
'\\)[^()]*)*' +
'\\)[^()]*)*' +
'\\)|' + hljs.UNDERSCORE_IDENT_RE + ')\\s*=>';
const FUNCTION_VARIABLE = {
match: [
/const|var|let/, /\s+/,
IDENT_RE$1, /\s*/,
/=\s*/,
/(async\s*)?/, // async is optional
regex.lookahead(FUNC_LEAD_IN_RE)
],
keywords: "async",
className: {
1: "keyword",
3: "title.function"
},
contains: [
PARAMS
]
};
return {
name: 'JavaScript',
aliases: ['js', 'jsx', 'mjs', 'cjs'],
keywords: KEYWORDS$1,
// this will be extended by TypeScript
exports: { PARAMS_CONTAINS, CLASS_REFERENCE },
illegal: /#(?![$_A-z])/,
contains: [
hljs.SHEBANG({
label: "shebang",
binary: "node",
relevance: 5
}),
USE_STRICT,
hljs.APOS_STRING_MODE,
hljs.QUOTE_STRING_MODE,
HTML_TEMPLATE,
CSS_TEMPLATE,
GRAPHQL_TEMPLATE,
TEMPLATE_STRING,
COMMENT,
// Skip numbers when they are part of a variable name
{ match: /\$\d+/ },
NUMBER,
CLASS_REFERENCE,
{
scope: 'attr',
match: IDENT_RE$1 + regex.lookahead(':'),
relevance: 0
},
FUNCTION_VARIABLE,
{ // "value" container
begin: '(' + hljs.RE_STARTERS_RE + '|\\b(case|return|throw)\\b)\\s*',
keywords: 'return throw case',
relevance: 0,
contains: [
COMMENT,
hljs.REGEXP_MODE,
{
className: 'function',
// we have to count the parens to make sure we actually have the
// correct bounding ( ) before the =>. There could be any number of
// sub-expressions inside also surrounded by parens.
begin: FUNC_LEAD_IN_RE,
returnBegin: true,
end: '\\s*=>',
contains: [
{
className: 'params',
variants: [
{
begin: hljs.UNDERSCORE_IDENT_RE,
relevance: 0
},
{
className: null,
begin: /\(\s*\)/,
skip: true
},
{
begin: /(\s*)\(/,
end: /\)/,
excludeBegin: true,
excludeEnd: true,
keywords: KEYWORDS$1,
contains: PARAMS_CONTAINS
}
]
}
]
},
{ // could be a comma delimited list of params to a function call
begin: /,/,
relevance: 0
},
{
match: /\s+/,
relevance: 0
},
{ // JSX
variants: [
{ begin: FRAGMENT.begin, end: FRAGMENT.end },
{ match: XML_SELF_CLOSING },
{
begin: XML_TAG.begin,
// we carefully check the opening tag to see if it truly
// is a tag and not a false positive
'on:begin': XML_TAG.isTrulyOpeningTag,
end: XML_TAG.end
}
],
subLanguage: 'xml',
contains: [
{
begin: XML_TAG.begin,
end: XML_TAG.end,
skip: true,
contains: ['self']
}
]
}
],
},
FUNCTION_DEFINITION,
{
// prevent this from getting swallowed up by function
// since they appear "function like"
beginKeywords: "while if switch catch for"
},
{
// we have to count the parens to make sure we actually have the correct
// bounding ( ). There could be any number of sub-expressions inside
// also surrounded by parens.
begin: '\\b(?!function)' + hljs.UNDERSCORE_IDENT_RE +
'\\(' + // first parens
'[^()]*(\\(' +
'[^()]*(\\(' +
'[^()]*' +
'\\)[^()]*)*' +
'\\)[^()]*)*' +
'\\)\\s*\\{', // end parens
returnBegin:true,
label: "func.def",
contains: [
PARAMS,
hljs.inherit(hljs.TITLE_MODE, { begin: IDENT_RE$1, className: "title.function" })
]
},
// catch ... so it won't trigger the property rule below
{
match: /\.\.\./,
relevance: 0
},
PROPERTY_ACCESS,
// hack: prevents detection of keywords in some circumstances
// .keyword()
// $keyword = x
{
match: '\\$' + IDENT_RE$1,
relevance: 0
},
{
match: [ /\bconstructor(?=\s*\()/ ],
className: { 1: "title.function" },
contains: [ PARAMS ]
},
FUNCTION_CALL,
UPPER_CASE_CONSTANT,
CLASS_OR_EXTENDS,
GETTER_OR_SETTER,
{
match: /\$[(.]/ // relevance booster for a pattern common to JS libs: `$(something)` and `$.something`
}
]
};
}
return javascript;
})();
hljs.registerLanguage('javascript', hljsGrammar);
})();

View File

@@ -0,0 +1,81 @@
/*! `javascript` grammar compiled for Highlight.js 11.11.1 */
(()=>{var e=(()=>{"use strict"
;const e="[A-Za-z$_][0-9A-Za-z$_]*",n=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],a=["true","false","null","undefined","NaN","Infinity"],t=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],s=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],r=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],c=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],i=[].concat(r,t,s)
;return o=>{const l=o.regex,d=e,b={begin:/<[A-Za-z0-9\\._:-]+/,
end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(e,n)=>{
const a=e[0].length+e.index,t=e.input[a]
;if("<"===t||","===t)return void n.ignoreMatch();let s
;">"===t&&(((e,{after:n})=>{const a="</"+e[0].slice(1)
;return-1!==e.input.indexOf(a,n)})(e,{after:a})||n.ignoreMatch())
;const r=e.input.substring(a)
;((s=r.match(/^\s*=/))||(s=r.match(/^\s+extends\s+/))&&0===s.index)&&n.ignoreMatch()
}},g={$pattern:e,keyword:n,literal:a,built_in:i,"variable.language":c
},u="[0-9](_?[0-9])*",m=`\\.(${u})`,E="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",A={
className:"number",variants:[{
begin:`(\\b(${E})((${m})|\\.)?|(${m}))[eE][+-]?(${u})\\b`},{
begin:`\\b(${E})\\b((${m})\\b|\\.)?|(${m})\\b`},{
begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{
begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{
begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{
begin:"\\b0[0-7]+n?\\b"}],relevance:0},y={className:"subst",begin:"\\$\\{",
end:"\\}",keywords:g,contains:[]},h={begin:".?html`",end:"",starts:{end:"`",
returnEnd:!1,contains:[o.BACKSLASH_ESCAPE,y],subLanguage:"xml"}},_={
begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,
contains:[o.BACKSLASH_ESCAPE,y],subLanguage:"css"}},N={begin:".?gql`",end:"",
starts:{end:"`",returnEnd:!1,contains:[o.BACKSLASH_ESCAPE,y],
subLanguage:"graphql"}},f={className:"string",begin:"`",end:"`",
contains:[o.BACKSLASH_ESCAPE,y]},p={className:"comment",
variants:[o.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{
begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",
begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,
excludeBegin:!0,relevance:0},{className:"variable",begin:d+"(?=\\s*(-)|$)",
endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]
}),o.C_BLOCK_COMMENT_MODE,o.C_LINE_COMMENT_MODE]
},v=[o.APOS_STRING_MODE,o.QUOTE_STRING_MODE,h,_,N,f,{match:/\$\d+/},A]
;y.contains=v.concat({begin:/\{/,end:/\}/,keywords:g,contains:["self"].concat(v)
});const S=[].concat(p,y.contains),w=S.concat([{begin:/(\s*)\(/,end:/\)/,
keywords:g,contains:["self"].concat(S)}]),R={className:"params",begin:/(\s*)\(/,
end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:g,contains:w},O={variants:[{
match:[/class/,/\s+/,d,/\s+/,/extends/,/\s+/,l.concat(d,"(",l.concat(/\./,d),")*")],
scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{
match:[/class/,/\s+/,d],scope:{1:"keyword",3:"title.class"}}]},k={relevance:0,
match:l.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),
className:"title.class",keywords:{_:[...t,...s]}},I={variants:[{
match:[/function/,/\s+/,d,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],
className:{1:"keyword",3:"title.function"},label:"func.def",contains:[R],
illegal:/%/},x={
match:l.concat(/\b/,(T=[...r,"super","import"].map((e=>e+"\\s*\\(")),
l.concat("(?!",T.join("|"),")")),d,l.lookahead(/\s*\(/)),
className:"title.function",relevance:0};var T;const C={
begin:l.concat(/\./,l.lookahead(l.concat(d,/(?![0-9A-Za-z$_(])/))),end:d,
excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},M={
match:[/get|set/,/\s+/,d,/(?=\()/],className:{1:"keyword",3:"title.function"},
contains:[{begin:/\(\)/},R]
},B="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+o.UNDERSCORE_IDENT_RE+")\\s*=>",$={
match:[/const|var|let/,/\s+/,d,/\s*/,/=\s*/,/(async\s*)?/,l.lookahead(B)],
keywords:"async",className:{1:"keyword",3:"title.function"},contains:[R]}
;return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:g,exports:{
PARAMS_CONTAINS:w,CLASS_REFERENCE:k},illegal:/#(?![$_A-z])/,
contains:[o.SHEBANG({label:"shebang",binary:"node",relevance:5}),{
label:"use_strict",className:"meta",relevance:10,
begin:/^\s*['"]use (strict|asm)['"]/
},o.APOS_STRING_MODE,o.QUOTE_STRING_MODE,h,_,N,f,p,{match:/\$\d+/},A,k,{
scope:"attr",match:d+l.lookahead(":"),relevance:0},$,{
begin:"("+o.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",
keywords:"return throw case",relevance:0,contains:[p,o.REGEXP_MODE,{
className:"function",begin:B,returnBegin:!0,end:"\\s*=>",contains:[{
className:"params",variants:[{begin:o.UNDERSCORE_IDENT_RE,relevance:0},{
className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,
excludeBegin:!0,excludeEnd:!0,keywords:g,contains:w}]}]},{begin:/,/,relevance:0
},{match:/\s+/,relevance:0},{variants:[{begin:"<>",end:"</>"},{
match:/<[A-Za-z0-9\\._:-]+\s*\/>/},{begin:b.begin,
"on:begin":b.isTrulyOpeningTag,end:b.end}],subLanguage:"xml",contains:[{
begin:b.begin,end:b.end,skip:!0,contains:["self"]}]}]},I,{
beginKeywords:"while if switch catch for"},{
begin:"\\b(?!function)"+o.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",
returnBegin:!0,label:"func.def",contains:[R,o.inherit(o.TITLE_MODE,{begin:d,
className:"title.function"})]},{match:/\.\.\./,relevance:0},C,{match:"\\$"+d,
relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},
contains:[R]},x,{relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,
className:"variable.constant"},O,M,{match:/\$[(.]/}]}}})()
;hljs.registerLanguage("javascript",e)})();

View File

@@ -0,0 +1,64 @@
/*! `json` grammar compiled for Highlight.js 11.11.1 */
(function(){
var hljsGrammar = (function () {
'use strict';
/*
Language: JSON
Description: JSON (JavaScript Object Notation) is a lightweight data-interchange format.
Author: Ivan Sagalaev <maniac@softwaremaniacs.org>
Website: http://www.json.org
Category: common, protocols, web
*/
function json(hljs) {
const ATTRIBUTE = {
className: 'attr',
begin: /"(\\.|[^\\"\r\n])*"(?=\s*:)/,
relevance: 1.01
};
const PUNCTUATION = {
match: /[{}[\],:]/,
className: "punctuation",
relevance: 0
};
const LITERALS = [
"true",
"false",
"null"
];
// NOTE: normally we would rely on `keywords` for this but using a mode here allows us
// - to use the very tight `illegal: \S` rule later to flag any other character
// - as illegal indicating that despite looking like JSON we do not truly have
// - JSON and thus improve false-positively greatly since JSON will try and claim
// - all sorts of JSON looking stuff
const LITERALS_MODE = {
scope: "literal",
beginKeywords: LITERALS.join(" "),
};
return {
name: 'JSON',
aliases: ['jsonc'],
keywords:{
literal: LITERALS,
},
contains: [
ATTRIBUTE,
PUNCTUATION,
hljs.QUOTE_STRING_MODE,
LITERALS_MODE,
hljs.C_NUMBER_MODE,
hljs.C_LINE_COMMENT_MODE,
hljs.C_BLOCK_COMMENT_MODE
],
illegal: '\\S'
};
}
return json;
})();
hljs.registerLanguage('json', hljsGrammar);
})();

View File

@@ -0,0 +1,8 @@
/*! `json` grammar compiled for Highlight.js 11.11.1 */
(()=>{var e=(()=>{"use strict";return e=>{const a=["true","false","null"],s={
scope:"literal",beginKeywords:a.join(" ")};return{name:"JSON",aliases:["jsonc"],
keywords:{literal:a},contains:[{className:"attr",
begin:/"(\\.|[^\\"\r\n])*"(?=\s*:)/,relevance:1.01},{match:/[{}[\],:]/,
className:"punctuation",relevance:0
},e.QUOTE_STRING_MODE,s,e.C_NUMBER_MODE,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE],
illegal:"\\S"}}})();hljs.registerLanguage("json",e)})();

View File

@@ -0,0 +1,91 @@
/*! `lua` grammar compiled for Highlight.js 11.11.1 */
(function(){
var hljsGrammar = (function () {
'use strict';
/*
Language: Lua
Description: Lua is a powerful, efficient, lightweight, embeddable scripting language.
Author: Andrew Fedorov <dmmdrs@mail.ru>
Category: common, gaming, scripting
Website: https://www.lua.org
*/
function lua(hljs) {
const OPENING_LONG_BRACKET = '\\[=*\\[';
const CLOSING_LONG_BRACKET = '\\]=*\\]';
const LONG_BRACKETS = {
begin: OPENING_LONG_BRACKET,
end: CLOSING_LONG_BRACKET,
contains: [ 'self' ]
};
const COMMENTS = [
hljs.COMMENT('--(?!' + OPENING_LONG_BRACKET + ')', '$'),
hljs.COMMENT(
'--' + OPENING_LONG_BRACKET,
CLOSING_LONG_BRACKET,
{
contains: [ LONG_BRACKETS ],
relevance: 10
}
)
];
return {
name: 'Lua',
aliases: ['pluto'],
keywords: {
$pattern: hljs.UNDERSCORE_IDENT_RE,
literal: "true false nil",
keyword: "and break do else elseif end for goto if in local not or repeat return then until while",
built_in:
// Metatags and globals:
'_G _ENV _VERSION __index __newindex __mode __call __metatable __tostring __len '
+ '__gc __add __sub __mul __div __mod __pow __concat __unm __eq __lt __le assert '
// Standard methods and properties:
+ 'collectgarbage dofile error getfenv getmetatable ipairs load loadfile loadstring '
+ 'module next pairs pcall print rawequal rawget rawset require select setfenv '
+ 'setmetatable tonumber tostring type unpack xpcall arg self '
// Library methods and properties (one line per library):
+ 'coroutine resume yield status wrap create running debug getupvalue '
+ 'debug sethook getmetatable gethook setmetatable setlocal traceback setfenv getinfo setupvalue getlocal getregistry getfenv '
+ 'io lines write close flush open output type read stderr stdin input stdout popen tmpfile '
+ 'math log max acos huge ldexp pi cos tanh pow deg tan cosh sinh random randomseed frexp ceil floor rad abs sqrt modf asin min mod fmod log10 atan2 exp sin atan '
+ 'os exit setlocale date getenv difftime remove time clock tmpname rename execute package preload loadlib loaded loaders cpath config path seeall '
+ 'string sub upper len gfind rep find match char dump gmatch reverse byte format gsub lower '
+ 'table setn insert getn foreachi maxn foreach concat sort remove'
},
contains: COMMENTS.concat([
{
className: 'function',
beginKeywords: 'function',
end: '\\)',
contains: [
hljs.inherit(hljs.TITLE_MODE, { begin: '([_a-zA-Z]\\w*\\.)*([_a-zA-Z]\\w*:)?[_a-zA-Z]\\w*' }),
{
className: 'params',
begin: '\\(',
endsWithParent: true,
contains: COMMENTS
}
].concat(COMMENTS)
},
hljs.C_NUMBER_MODE,
hljs.APOS_STRING_MODE,
hljs.QUOTE_STRING_MODE,
{
className: 'string',
begin: OPENING_LONG_BRACKET,
end: CLOSING_LONG_BRACKET,
contains: [ LONG_BRACKETS ],
relevance: 5
}
])
};
}
return lua;
})();
hljs.registerLanguage('lua', hljsGrammar);
})();

View File

@@ -0,0 +1,15 @@
/*! `lua` grammar compiled for Highlight.js 11.11.1 */
(()=>{var e=(()=>{"use strict";return e=>{const t="\\[=*\\[",a="\\]=*\\]",n={
begin:t,end:a,contains:["self"]
},o=[e.COMMENT("--(?!"+t+")","$"),e.COMMENT("--"+t,a,{contains:[n],relevance:10
})];return{name:"Lua",aliases:["pluto"],keywords:{
$pattern:e.UNDERSCORE_IDENT_RE,literal:"true false nil",
keyword:"and break do else elseif end for goto if in local not or repeat return then until while",
built_in:"_G _ENV _VERSION __index __newindex __mode __call __metatable __tostring __len __gc __add __sub __mul __div __mod __pow __concat __unm __eq __lt __le assert collectgarbage dofile error getfenv getmetatable ipairs load loadfile loadstring module next pairs pcall print rawequal rawget rawset require select setfenv setmetatable tonumber tostring type unpack xpcall arg self coroutine resume yield status wrap create running debug getupvalue debug sethook getmetatable gethook setmetatable setlocal traceback setfenv getinfo setupvalue getlocal getregistry getfenv io lines write close flush open output type read stderr stdin input stdout popen tmpfile math log max acos huge ldexp pi cos tanh pow deg tan cosh sinh random randomseed frexp ceil floor rad abs sqrt modf asin min mod fmod log10 atan2 exp sin atan os exit setlocale date getenv difftime remove time clock tmpname rename execute package preload loadlib loaded loaders cpath config path seeall string sub upper len gfind rep find match char dump gmatch reverse byte format gsub lower table setn insert getn foreachi maxn foreach concat sort remove"
},contains:o.concat([{className:"function",beginKeywords:"function",end:"\\)",
contains:[e.inherit(e.TITLE_MODE,{
begin:"([_a-zA-Z]\\w*\\.)*([_a-zA-Z]\\w*:)?[_a-zA-Z]\\w*"}),{className:"params",
begin:"\\(",endsWithParent:!0,contains:o}].concat(o)
},e.C_NUMBER_MODE,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,{className:"string",
begin:t,end:a,contains:[n],relevance:5}])}}})();hljs.registerLanguage("lua",e)
})();

View File

@@ -0,0 +1,258 @@
/*! `markdown` grammar compiled for Highlight.js 11.11.1 */
(function(){
var hljsGrammar = (function () {
'use strict';
/*
Language: Markdown
Requires: xml.js
Author: John Crepezzi <john.crepezzi@gmail.com>
Website: https://daringfireball.net/projects/markdown/
Category: common, markup
*/
function markdown(hljs) {
const regex = hljs.regex;
const INLINE_HTML = {
begin: /<\/?[A-Za-z_]/,
end: '>',
subLanguage: 'xml',
relevance: 0
};
const HORIZONTAL_RULE = {
begin: '^[-\\*]{3,}',
end: '$'
};
const CODE = {
className: 'code',
variants: [
// TODO: fix to allow these to work with sublanguage also
{ begin: '(`{3,})[^`](.|\\n)*?\\1`*[ ]*' },
{ begin: '(~{3,})[^~](.|\\n)*?\\1~*[ ]*' },
// needed to allow markdown as a sublanguage to work
{
begin: '```',
end: '```+[ ]*$'
},
{
begin: '~~~',
end: '~~~+[ ]*$'
},
{ begin: '`.+?`' },
{
begin: '(?=^( {4}|\\t))',
// use contains to gobble up multiple lines to allow the block to be whatever size
// but only have a single open/close tag vs one per line
contains: [
{
begin: '^( {4}|\\t)',
end: '(\\n)$'
}
],
relevance: 0
}
]
};
const LIST = {
className: 'bullet',
begin: '^[ \t]*([*+-]|(\\d+\\.))(?=\\s+)',
end: '\\s+',
excludeEnd: true
};
const LINK_REFERENCE = {
begin: /^\[[^\n]+\]:/,
returnBegin: true,
contains: [
{
className: 'symbol',
begin: /\[/,
end: /\]/,
excludeBegin: true,
excludeEnd: true
},
{
className: 'link',
begin: /:\s*/,
end: /$/,
excludeBegin: true
}
]
};
const URL_SCHEME = /[A-Za-z][A-Za-z0-9+.-]*/;
const LINK = {
variants: [
// too much like nested array access in so many languages
// to have any real relevance
{
begin: /\[.+?\]\[.*?\]/,
relevance: 0
},
// popular internet URLs
{
begin: /\[.+?\]\(((data|javascript|mailto):|(?:http|ftp)s?:\/\/).*?\)/,
relevance: 2
},
{
begin: regex.concat(/\[.+?\]\(/, URL_SCHEME, /:\/\/.*?\)/),
relevance: 2
},
// relative urls
{
begin: /\[.+?\]\([./?&#].*?\)/,
relevance: 1
},
// whatever else, lower relevance (might not be a link at all)
{
begin: /\[.*?\]\(.*?\)/,
relevance: 0
}
],
returnBegin: true,
contains: [
{
// empty strings for alt or link text
match: /\[(?=\])/ },
{
className: 'string',
relevance: 0,
begin: '\\[',
end: '\\]',
excludeBegin: true,
returnEnd: true
},
{
className: 'link',
relevance: 0,
begin: '\\]\\(',
end: '\\)',
excludeBegin: true,
excludeEnd: true
},
{
className: 'symbol',
relevance: 0,
begin: '\\]\\[',
end: '\\]',
excludeBegin: true,
excludeEnd: true
}
]
};
const BOLD = {
className: 'strong',
contains: [], // defined later
variants: [
{
begin: /_{2}(?!\s)/,
end: /_{2}/
},
{
begin: /\*{2}(?!\s)/,
end: /\*{2}/
}
]
};
const ITALIC = {
className: 'emphasis',
contains: [], // defined later
variants: [
{
begin: /\*(?![*\s])/,
end: /\*/
},
{
begin: /_(?![_\s])/,
end: /_/,
relevance: 0
}
]
};
// 3 level deep nesting is not allowed because it would create confusion
// in cases like `***testing***` because where we don't know if the last
// `***` is starting a new bold/italic or finishing the last one
const BOLD_WITHOUT_ITALIC = hljs.inherit(BOLD, { contains: [] });
const ITALIC_WITHOUT_BOLD = hljs.inherit(ITALIC, { contains: [] });
BOLD.contains.push(ITALIC_WITHOUT_BOLD);
ITALIC.contains.push(BOLD_WITHOUT_ITALIC);
let CONTAINABLE = [
INLINE_HTML,
LINK
];
[
BOLD,
ITALIC,
BOLD_WITHOUT_ITALIC,
ITALIC_WITHOUT_BOLD
].forEach(m => {
m.contains = m.contains.concat(CONTAINABLE);
});
CONTAINABLE = CONTAINABLE.concat(BOLD, ITALIC);
const HEADER = {
className: 'section',
variants: [
{
begin: '^#{1,6}',
end: '$',
contains: CONTAINABLE
},
{
begin: '(?=^.+?\\n[=-]{2,}$)',
contains: [
{ begin: '^[=-]*$' },
{
begin: '^',
end: "\\n",
contains: CONTAINABLE
}
]
}
]
};
const BLOCKQUOTE = {
className: 'quote',
begin: '^>\\s+',
contains: CONTAINABLE,
end: '$'
};
const ENTITY = {
//https://spec.commonmark.org/0.31.2/#entity-references
scope: 'literal',
match: /&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/
};
return {
name: 'Markdown',
aliases: [
'md',
'mkdown',
'mkd'
],
contains: [
HEADER,
INLINE_HTML,
LIST,
BOLD,
ITALIC,
BLOCKQUOTE,
CODE,
HORIZONTAL_RULE,
LINK,
LINK_REFERENCE,
ENTITY
]
};
}
return markdown;
})();
hljs.registerLanguage('markdown', hljsGrammar);
})();

View File

@@ -0,0 +1,32 @@
/*! `markdown` grammar compiled for Highlight.js 11.11.1 */
(()=>{var e=(()=>{"use strict";return e=>{const n={begin:/<\/?[A-Za-z_]/,
end:">",subLanguage:"xml",relevance:0},a={variants:[{begin:/\[.+?\]\[.*?\]/,
relevance:0},{
begin:/\[.+?\]\(((data|javascript|mailto):|(?:http|ftp)s?:\/\/).*?\)/,
relevance:2},{
begin:e.regex.concat(/\[.+?\]\(/,/[A-Za-z][A-Za-z0-9+.-]*/,/:\/\/.*?\)/),
relevance:2},{begin:/\[.+?\]\([./?&#].*?\)/,relevance:1},{
begin:/\[.*?\]\(.*?\)/,relevance:0}],returnBegin:!0,contains:[{match:/\[(?=\])/
},{className:"string",relevance:0,begin:"\\[",end:"\\]",excludeBegin:!0,
returnEnd:!0},{className:"link",relevance:0,begin:"\\]\\(",end:"\\)",
excludeBegin:!0,excludeEnd:!0},{className:"symbol",relevance:0,begin:"\\]\\[",
end:"\\]",excludeBegin:!0,excludeEnd:!0}]},i={className:"strong",contains:[],
variants:[{begin:/_{2}(?!\s)/,end:/_{2}/},{begin:/\*{2}(?!\s)/,end:/\*{2}/}]
},s={className:"emphasis",contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/},{
begin:/_(?![_\s])/,end:/_/,relevance:0}]},c=e.inherit(i,{contains:[]
}),t=e.inherit(s,{contains:[]});i.contains.push(t),s.contains.push(c)
;let g=[n,a];return[i,s,c,t].forEach((e=>{e.contains=e.contains.concat(g)
})),g=g.concat(i,s),{name:"Markdown",aliases:["md","mkdown","mkd"],contains:[{
className:"section",variants:[{begin:"^#{1,6}",end:"$",contains:g},{
begin:"(?=^.+?\\n[=-]{2,}$)",contains:[{begin:"^[=-]*$"},{begin:"^",end:"\\n",
contains:g}]}]},n,{className:"bullet",begin:"^[ \t]*([*+-]|(\\d+\\.))(?=\\s+)",
end:"\\s+",excludeEnd:!0},i,s,{className:"quote",begin:"^>\\s+",contains:g,
end:"$"},{className:"code",variants:[{begin:"(`{3,})[^`](.|\\n)*?\\1`*[ ]*"},{
begin:"(~{3,})[^~](.|\\n)*?\\1~*[ ]*"},{begin:"```",end:"```+[ ]*$"},{
begin:"~~~",end:"~~~+[ ]*$"},{begin:"`.+?`"},{begin:"(?=^( {4}|\\t))",
contains:[{begin:"^( {4}|\\t)",end:"(\\n)$"}],relevance:0}]},{
begin:"^[-\\*]{3,}",end:"$"},a,{begin:/^\[[^\n]+\]:/,returnBegin:!0,contains:[{
className:"symbol",begin:/\[/,end:/\]/,excludeBegin:!0,excludeEnd:!0},{
className:"link",begin:/:\s*/,end:/$/,excludeBegin:!0}]},{scope:"literal",
match:/&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/}]}}})()
;hljs.registerLanguage("markdown",e)})();

View File

@@ -0,0 +1,514 @@
/*! `perl` grammar compiled for Highlight.js 11.11.1 */
(function(){
var hljsGrammar = (function () {
'use strict';
/*
Language: Perl
Author: Peter Leonov <gojpeg@yandex.ru>
Website: https://www.perl.org
Category: common
*/
/** @type LanguageFn */
function perl(hljs) {
const regex = hljs.regex;
const KEYWORDS = [
'abs',
'accept',
'alarm',
'and',
'atan2',
'bind',
'binmode',
'bless',
'break',
'caller',
'chdir',
'chmod',
'chomp',
'chop',
'chown',
'chr',
'chroot',
'class',
'close',
'closedir',
'connect',
'continue',
'cos',
'crypt',
'dbmclose',
'dbmopen',
'defined',
'delete',
'die',
'do',
'dump',
'each',
'else',
'elsif',
'endgrent',
'endhostent',
'endnetent',
'endprotoent',
'endpwent',
'endservent',
'eof',
'eval',
'exec',
'exists',
'exit',
'exp',
'fcntl',
'field',
'fileno',
'flock',
'for',
'foreach',
'fork',
'format',
'formline',
'getc',
'getgrent',
'getgrgid',
'getgrnam',
'gethostbyaddr',
'gethostbyname',
'gethostent',
'getlogin',
'getnetbyaddr',
'getnetbyname',
'getnetent',
'getpeername',
'getpgrp',
'getpriority',
'getprotobyname',
'getprotobynumber',
'getprotoent',
'getpwent',
'getpwnam',
'getpwuid',
'getservbyname',
'getservbyport',
'getservent',
'getsockname',
'getsockopt',
'given',
'glob',
'gmtime',
'goto',
'grep',
'gt',
'hex',
'if',
'index',
'int',
'ioctl',
'join',
'keys',
'kill',
'last',
'lc',
'lcfirst',
'length',
'link',
'listen',
'local',
'localtime',
'log',
'lstat',
'lt',
'ma',
'map',
'method',
'mkdir',
'msgctl',
'msgget',
'msgrcv',
'msgsnd',
'my',
'ne',
'next',
'no',
'not',
'oct',
'open',
'opendir',
'or',
'ord',
'our',
'pack',
'package',
'pipe',
'pop',
'pos',
'print',
'printf',
'prototype',
'push',
'q|0',
'qq',
'quotemeta',
'qw',
'qx',
'rand',
'read',
'readdir',
'readline',
'readlink',
'readpipe',
'recv',
'redo',
'ref',
'rename',
'require',
'reset',
'return',
'reverse',
'rewinddir',
'rindex',
'rmdir',
'say',
'scalar',
'seek',
'seekdir',
'select',
'semctl',
'semget',
'semop',
'send',
'setgrent',
'sethostent',
'setnetent',
'setpgrp',
'setpriority',
'setprotoent',
'setpwent',
'setservent',
'setsockopt',
'shift',
'shmctl',
'shmget',
'shmread',
'shmwrite',
'shutdown',
'sin',
'sleep',
'socket',
'socketpair',
'sort',
'splice',
'split',
'sprintf',
'sqrt',
'srand',
'stat',
'state',
'study',
'sub',
'substr',
'symlink',
'syscall',
'sysopen',
'sysread',
'sysseek',
'system',
'syswrite',
'tell',
'telldir',
'tie',
'tied',
'time',
'times',
'tr',
'truncate',
'uc',
'ucfirst',
'umask',
'undef',
'unless',
'unlink',
'unpack',
'unshift',
'untie',
'until',
'use',
'utime',
'values',
'vec',
'wait',
'waitpid',
'wantarray',
'warn',
'when',
'while',
'write',
'x|0',
'xor',
'y|0'
];
// https://perldoc.perl.org/perlre#Modifiers
const REGEX_MODIFIERS = /[dualxmsipngr]{0,12}/; // aa and xx are valid, making max length 12
const PERL_KEYWORDS = {
$pattern: /[\w.]+/,
keyword: KEYWORDS.join(" ")
};
const SUBST = {
className: 'subst',
begin: '[$@]\\{',
end: '\\}',
keywords: PERL_KEYWORDS
};
const METHOD = {
begin: /->\{/,
end: /\}/
// contains defined later
};
const ATTR = {
scope: 'attr',
match: /\s+:\s*\w+(\s*\(.*?\))?/,
};
const VAR = {
scope: 'variable',
variants: [
{ begin: /\$\d/ },
{ begin: regex.concat(
/[$%@](?!")(\^\w\b|#\w+(::\w+)*|\{\w+\}|\w+(::\w*)*)/,
// negative look-ahead tries to avoid matching patterns that are not
// Perl at all like $ident$, @ident@, etc.
`(?![A-Za-z])(?![@$%])`
)
},
{
// Only $= is a special Perl variable and one can't declare @= or %=.
begin: /[$%@](?!")[^\s\w{=]|\$=/,
relevance: 0
}
],
contains: [ ATTR ],
};
const NUMBER = {
className: 'number',
variants: [
// decimal numbers:
// include the case where a number starts with a dot (eg. .9), and
// the leading 0? avoids mixing the first and second match on 0.x cases
{ match: /0?\.[0-9][0-9_]+\b/ },
// include the special versioned number (eg. v5.38)
{ match: /\bv?(0|[1-9][0-9_]*(\.[0-9_]+)?|[1-9][0-9_]*)\b/ },
// non-decimal numbers:
{ match: /\b0[0-7][0-7_]*\b/ },
{ match: /\b0x[0-9a-fA-F][0-9a-fA-F_]*\b/ },
{ match: /\b0b[0-1][0-1_]*\b/ },
],
relevance: 0
};
const STRING_CONTAINS = [
hljs.BACKSLASH_ESCAPE,
SUBST,
VAR
];
const REGEX_DELIMS = [
/!/,
/\//,
/\|/,
/\?/,
/'/,
/"/, // valid but infrequent and weird
/#/ // valid but infrequent and weird
];
/**
* @param {string|RegExp} prefix
* @param {string|RegExp} open
* @param {string|RegExp} close
*/
const PAIRED_DOUBLE_RE = (prefix, open, close = '\\1') => {
const middle = (close === '\\1')
? close
: regex.concat(close, open);
return regex.concat(
regex.concat("(?:", prefix, ")"),
open,
/(?:\\.|[^\\\/])*?/,
middle,
/(?:\\.|[^\\\/])*?/,
close,
REGEX_MODIFIERS
);
};
/**
* @param {string|RegExp} prefix
* @param {string|RegExp} open
* @param {string|RegExp} close
*/
const PAIRED_RE = (prefix, open, close) => {
return regex.concat(
regex.concat("(?:", prefix, ")"),
open,
/(?:\\.|[^\\\/])*?/,
close,
REGEX_MODIFIERS
);
};
const PERL_DEFAULT_CONTAINS = [
VAR,
hljs.HASH_COMMENT_MODE,
hljs.COMMENT(
/^=\w/,
/=cut/,
{ endsWithParent: true }
),
METHOD,
{
className: 'string',
contains: STRING_CONTAINS,
variants: [
{
begin: 'q[qwxr]?\\s*\\(',
end: '\\)',
relevance: 5
},
{
begin: 'q[qwxr]?\\s*\\[',
end: '\\]',
relevance: 5
},
{
begin: 'q[qwxr]?\\s*\\{',
end: '\\}',
relevance: 5
},
{
begin: 'q[qwxr]?\\s*\\|',
end: '\\|',
relevance: 5
},
{
begin: 'q[qwxr]?\\s*<',
end: '>',
relevance: 5
},
{
begin: 'qw\\s+q',
end: 'q',
relevance: 5
},
{
begin: '\'',
end: '\'',
contains: [ hljs.BACKSLASH_ESCAPE ]
},
{
begin: '"',
end: '"'
},
{
begin: '`',
end: '`',
contains: [ hljs.BACKSLASH_ESCAPE ]
},
{
begin: /\{\w+\}/,
relevance: 0
},
{
begin: '-?\\w+\\s*=>',
relevance: 0
}
]
},
NUMBER,
{ // regexp container
begin: '(\\/\\/|' + hljs.RE_STARTERS_RE + '|\\b(split|return|print|reverse|grep)\\b)\\s*',
keywords: 'split return print reverse grep',
relevance: 0,
contains: [
hljs.HASH_COMMENT_MODE,
{
className: 'regexp',
variants: [
// allow matching common delimiters
{ begin: PAIRED_DOUBLE_RE("s|tr|y", regex.either(...REGEX_DELIMS, { capture: true })) },
// and then paired delmis
{ begin: PAIRED_DOUBLE_RE("s|tr|y", "\\(", "\\)") },
{ begin: PAIRED_DOUBLE_RE("s|tr|y", "\\[", "\\]") },
{ begin: PAIRED_DOUBLE_RE("s|tr|y", "\\{", "\\}") }
],
relevance: 2
},
{
className: 'regexp',
variants: [
{
// could be a comment in many languages so do not count
// as relevant
begin: /(m|qr)\/\//,
relevance: 0
},
// prefix is optional with /regex/
{ begin: PAIRED_RE("(?:m|qr)?", /\//, /\//) },
// allow matching common delimiters
{ begin: PAIRED_RE("m|qr", regex.either(...REGEX_DELIMS, { capture: true }), /\1/) },
// allow common paired delmins
{ begin: PAIRED_RE("m|qr", /\(/, /\)/) },
{ begin: PAIRED_RE("m|qr", /\[/, /\]/) },
{ begin: PAIRED_RE("m|qr", /\{/, /\}/) }
]
}
]
},
{
className: 'function',
beginKeywords: 'sub method',
end: '(\\s*\\(.*?\\))?[;{]',
excludeEnd: true,
relevance: 5,
contains: [ hljs.TITLE_MODE, ATTR ]
},
{
className: 'class',
beginKeywords: 'class',
end: '[;{]',
excludeEnd: true,
relevance: 5,
contains: [ hljs.TITLE_MODE, ATTR, NUMBER ]
},
{
begin: '-\\w\\b',
relevance: 0
},
{
begin: "^__DATA__$",
end: "^__END__$",
subLanguage: 'mojolicious',
contains: [
{
begin: "^@@.*",
end: "$",
className: "comment"
}
]
}
];
SUBST.contains = PERL_DEFAULT_CONTAINS;
METHOD.contains = PERL_DEFAULT_CONTAINS;
return {
name: 'Perl',
aliases: [
'pl',
'pm'
],
keywords: PERL_KEYWORDS,
contains: PERL_DEFAULT_CONTAINS
};
}
return perl;
})();
hljs.registerLanguage('perl', hljsGrammar);
})();

View File

@@ -0,0 +1,41 @@
/*! `perl` grammar compiled for Highlight.js 11.11.1 */
(()=>{var e=(()=>{"use strict";return e=>{
const n=e.regex,t=/[dualxmsipngr]{0,12}/,s={$pattern:/[\w.]+/,
keyword:"abs accept alarm and atan2 bind binmode bless break caller chdir chmod chomp chop chown chr chroot class close closedir connect continue cos crypt dbmclose dbmopen defined delete die do dump each else elsif endgrent endhostent endnetent endprotoent endpwent endservent eof eval exec exists exit exp fcntl field fileno flock for foreach fork format formline getc getgrent getgrgid getgrnam gethostbyaddr gethostbyname gethostent getlogin getnetbyaddr getnetbyname getnetent getpeername getpgrp getpriority getprotobyname getprotobynumber getprotoent getpwent getpwnam getpwuid getservbyname getservbyport getservent getsockname getsockopt given glob gmtime goto grep gt hex if index int ioctl join keys kill last lc lcfirst length link listen local localtime log lstat lt ma map method mkdir msgctl msgget msgrcv msgsnd my ne next no not oct open opendir or ord our pack package pipe pop pos print printf prototype push q|0 qq quotemeta qw qx rand read readdir readline readlink readpipe recv redo ref rename require reset return reverse rewinddir rindex rmdir say scalar seek seekdir select semctl semget semop send setgrent sethostent setnetent setpgrp setpriority setprotoent setpwent setservent setsockopt shift shmctl shmget shmread shmwrite shutdown sin sleep socket socketpair sort splice split sprintf sqrt srand stat state study sub substr symlink syscall sysopen sysread sysseek system syswrite tell telldir tie tied time times tr truncate uc ucfirst umask undef unless unlink unpack unshift untie until use utime values vec wait waitpid wantarray warn when while write x|0 xor y|0"
},r={className:"subst",begin:"[$@]\\{",end:"\\}",keywords:s},a={begin:/->\{/,
end:/\}/},i={scope:"attr",match:/\s+:\s*\w+(\s*\(.*?\))?/},c={scope:"variable",
variants:[{begin:/\$\d/},{
begin:n.concat(/[$%@](?!")(\^\w\b|#\w+(::\w+)*|\{\w+\}|\w+(::\w*)*)/,"(?![A-Za-z])(?![@$%])")
},{begin:/[$%@](?!")[^\s\w{=]|\$=/,relevance:0}],contains:[i]},o={
className:"number",variants:[{match:/0?\.[0-9][0-9_]+\b/},{
match:/\bv?(0|[1-9][0-9_]*(\.[0-9_]+)?|[1-9][0-9_]*)\b/},{
match:/\b0[0-7][0-7_]*\b/},{match:/\b0x[0-9a-fA-F][0-9a-fA-F_]*\b/},{
match:/\b0b[0-1][0-1_]*\b/}],relevance:0
},l=[e.BACKSLASH_ESCAPE,r,c],g=[/!/,/\//,/\|/,/\?/,/'/,/"/,/#/],d=(e,s,r="\\1")=>{
const a="\\1"===r?r:n.concat(r,s)
;return n.concat(n.concat("(?:",e,")"),s,/(?:\\.|[^\\\/])*?/,a,/(?:\\.|[^\\\/])*?/,r,t)
},m=(e,s,r)=>n.concat(n.concat("(?:",e,")"),s,/(?:\\.|[^\\\/])*?/,r,t),p=[c,e.HASH_COMMENT_MODE,e.COMMENT(/^=\w/,/=cut/,{
endsWithParent:!0}),a,{className:"string",contains:l,variants:[{
begin:"q[qwxr]?\\s*\\(",end:"\\)",relevance:5},{begin:"q[qwxr]?\\s*\\[",
end:"\\]",relevance:5},{begin:"q[qwxr]?\\s*\\{",end:"\\}",relevance:5},{
begin:"q[qwxr]?\\s*\\|",end:"\\|",relevance:5},{begin:"q[qwxr]?\\s*<",end:">",
relevance:5},{begin:"qw\\s+q",end:"q",relevance:5},{begin:"'",end:"'",
contains:[e.BACKSLASH_ESCAPE]},{begin:'"',end:'"'},{begin:"`",end:"`",
contains:[e.BACKSLASH_ESCAPE]},{begin:/\{\w+\}/,relevance:0},{
begin:"-?\\w+\\s*=>",relevance:0}]},o,{
begin:"(\\/\\/|"+e.RE_STARTERS_RE+"|\\b(split|return|print|reverse|grep)\\b)\\s*",
keywords:"split return print reverse grep",relevance:0,
contains:[e.HASH_COMMENT_MODE,{className:"regexp",variants:[{
begin:d("s|tr|y",n.either(...g,{capture:!0}))},{begin:d("s|tr|y","\\(","\\)")},{
begin:d("s|tr|y","\\[","\\]")},{begin:d("s|tr|y","\\{","\\}")}],relevance:2},{
className:"regexp",variants:[{begin:/(m|qr)\/\//,relevance:0},{
begin:m("(?:m|qr)?",/\//,/\//)},{begin:m("m|qr",n.either(...g,{capture:!0
}),/\1/)},{begin:m("m|qr",/\(/,/\)/)},{begin:m("m|qr",/\[/,/\]/)},{
begin:m("m|qr",/\{/,/\}/)}]}]},{className:"function",beginKeywords:"sub method",
end:"(\\s*\\(.*?\\))?[;{]",excludeEnd:!0,relevance:5,contains:[e.TITLE_MODE,i]
},{className:"class",beginKeywords:"class",end:"[;{]",excludeEnd:!0,relevance:5,
contains:[e.TITLE_MODE,i,o]},{begin:"-\\w\\b",relevance:0},{begin:"^__DATA__$",
end:"^__END__$",subLanguage:"mojolicious",contains:[{begin:"^@@.*",end:"$",
className:"comment"}]}];return r.contains=p,a.contains=p,{name:"Perl",
aliases:["pl","pm"],keywords:s,contains:p}}})();hljs.registerLanguage("perl",e)
})();

View File

@@ -0,0 +1,635 @@
/*! `php` grammar compiled for Highlight.js 11.11.1 */
(function(){
var hljsGrammar = (function () {
'use strict';
/*
Language: PHP
Author: Victor Karamzin <Victor.Karamzin@enterra-inc.com>
Contributors: Evgeny Stepanischev <imbolk@gmail.com>, Ivan Sagalaev <maniac@softwaremaniacs.org>
Website: https://www.php.net
Category: common
*/
/**
* @param {HLJSApi} hljs
* @returns {LanguageDetail}
* */
function php(hljs) {
const regex = hljs.regex;
// negative look-ahead tries to avoid matching patterns that are not
// Perl at all like $ident$, @ident@, etc.
const NOT_PERL_ETC = /(?![A-Za-z0-9])(?![$])/;
const IDENT_RE = regex.concat(
/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/,
NOT_PERL_ETC);
// Will not detect camelCase classes
const PASCAL_CASE_CLASS_NAME_RE = regex.concat(
/(\\?[A-Z][a-z0-9_\x7f-\xff]+|\\?[A-Z]+(?=[A-Z][a-z0-9_\x7f-\xff])){1,}/,
NOT_PERL_ETC);
const UPCASE_NAME_RE = regex.concat(
/[A-Z]+/,
NOT_PERL_ETC);
const VARIABLE = {
scope: 'variable',
match: '\\$+' + IDENT_RE,
};
const PREPROCESSOR = {
scope: "meta",
variants: [
{ begin: /<\?php/, relevance: 10 }, // boost for obvious PHP
{ begin: /<\?=/ },
// less relevant per PSR-1 which says not to use short-tags
{ begin: /<\?/, relevance: 0.1 },
{ begin: /\?>/ } // end php tag
]
};
const SUBST = {
scope: 'subst',
variants: [
{ begin: /\$\w+/ },
{
begin: /\{\$/,
end: /\}/
}
]
};
const SINGLE_QUOTED = hljs.inherit(hljs.APOS_STRING_MODE, { illegal: null, });
const DOUBLE_QUOTED = hljs.inherit(hljs.QUOTE_STRING_MODE, {
illegal: null,
contains: hljs.QUOTE_STRING_MODE.contains.concat(SUBST),
});
const HEREDOC = {
begin: /<<<[ \t]*(?:(\w+)|"(\w+)")\n/,
end: /[ \t]*(\w+)\b/,
contains: hljs.QUOTE_STRING_MODE.contains.concat(SUBST),
'on:begin': (m, resp) => { resp.data._beginMatch = m[1] || m[2]; },
'on:end': (m, resp) => { if (resp.data._beginMatch !== m[1]) resp.ignoreMatch(); },
};
const NOWDOC = hljs.END_SAME_AS_BEGIN({
begin: /<<<[ \t]*'(\w+)'\n/,
end: /[ \t]*(\w+)\b/,
});
// list of valid whitespaces because non-breaking space might be part of a IDENT_RE
const WHITESPACE = '[ \t\n]';
const STRING = {
scope: 'string',
variants: [
DOUBLE_QUOTED,
SINGLE_QUOTED,
HEREDOC,
NOWDOC
]
};
const NUMBER = {
scope: 'number',
variants: [
{ begin: `\\b0[bB][01]+(?:_[01]+)*\\b` }, // Binary w/ underscore support
{ begin: `\\b0[oO][0-7]+(?:_[0-7]+)*\\b` }, // Octals w/ underscore support
{ begin: `\\b0[xX][\\da-fA-F]+(?:_[\\da-fA-F]+)*\\b` }, // Hex w/ underscore support
// Decimals w/ underscore support, with optional fragments and scientific exponent (e) suffix.
{ begin: `(?:\\b\\d+(?:_\\d+)*(\\.(?:\\d+(?:_\\d+)*))?|\\B\\.\\d+)(?:[eE][+-]?\\d+)?` }
],
relevance: 0
};
const LITERALS = [
"false",
"null",
"true"
];
const KWS = [
// Magic constants:
// <https://www.php.net/manual/en/language.constants.predefined.php>
"__CLASS__",
"__DIR__",
"__FILE__",
"__FUNCTION__",
"__COMPILER_HALT_OFFSET__",
"__LINE__",
"__METHOD__",
"__NAMESPACE__",
"__TRAIT__",
// Function that look like language construct or language construct that look like function:
// List of keywords that may not require parenthesis
"die",
"echo",
"exit",
"include",
"include_once",
"print",
"require",
"require_once",
// These are not language construct (function) but operate on the currently-executing function and can access the current symbol table
// 'compact extract func_get_arg func_get_args func_num_args get_called_class get_parent_class ' +
// Other keywords:
// <https://www.php.net/manual/en/reserved.php>
// <https://www.php.net/manual/en/language.types.type-juggling.php>
"array",
"abstract",
"and",
"as",
"binary",
"bool",
"boolean",
"break",
"callable",
"case",
"catch",
"class",
"clone",
"const",
"continue",
"declare",
"default",
"do",
"double",
"else",
"elseif",
"empty",
"enddeclare",
"endfor",
"endforeach",
"endif",
"endswitch",
"endwhile",
"enum",
"eval",
"extends",
"final",
"finally",
"float",
"for",
"foreach",
"from",
"global",
"goto",
"if",
"implements",
"instanceof",
"insteadof",
"int",
"integer",
"interface",
"isset",
"iterable",
"list",
"match|0",
"mixed",
"new",
"never",
"object",
"or",
"private",
"protected",
"public",
"readonly",
"real",
"return",
"string",
"switch",
"throw",
"trait",
"try",
"unset",
"use",
"var",
"void",
"while",
"xor",
"yield"
];
const BUILT_INS = [
// Standard PHP library:
// <https://www.php.net/manual/en/book.spl.php>
"Error|0",
"AppendIterator",
"ArgumentCountError",
"ArithmeticError",
"ArrayIterator",
"ArrayObject",
"AssertionError",
"BadFunctionCallException",
"BadMethodCallException",
"CachingIterator",
"CallbackFilterIterator",
"CompileError",
"Countable",
"DirectoryIterator",
"DivisionByZeroError",
"DomainException",
"EmptyIterator",
"ErrorException",
"Exception",
"FilesystemIterator",
"FilterIterator",
"GlobIterator",
"InfiniteIterator",
"InvalidArgumentException",
"IteratorIterator",
"LengthException",
"LimitIterator",
"LogicException",
"MultipleIterator",
"NoRewindIterator",
"OutOfBoundsException",
"OutOfRangeException",
"OuterIterator",
"OverflowException",
"ParentIterator",
"ParseError",
"RangeException",
"RecursiveArrayIterator",
"RecursiveCachingIterator",
"RecursiveCallbackFilterIterator",
"RecursiveDirectoryIterator",
"RecursiveFilterIterator",
"RecursiveIterator",
"RecursiveIteratorIterator",
"RecursiveRegexIterator",
"RecursiveTreeIterator",
"RegexIterator",
"RuntimeException",
"SeekableIterator",
"SplDoublyLinkedList",
"SplFileInfo",
"SplFileObject",
"SplFixedArray",
"SplHeap",
"SplMaxHeap",
"SplMinHeap",
"SplObjectStorage",
"SplObserver",
"SplPriorityQueue",
"SplQueue",
"SplStack",
"SplSubject",
"SplTempFileObject",
"TypeError",
"UnderflowException",
"UnexpectedValueException",
"UnhandledMatchError",
// Reserved interfaces:
// <https://www.php.net/manual/en/reserved.interfaces.php>
"ArrayAccess",
"BackedEnum",
"Closure",
"Fiber",
"Generator",
"Iterator",
"IteratorAggregate",
"Serializable",
"Stringable",
"Throwable",
"Traversable",
"UnitEnum",
"WeakReference",
"WeakMap",
// Reserved classes:
// <https://www.php.net/manual/en/reserved.classes.php>
"Directory",
"__PHP_Incomplete_Class",
"parent",
"php_user_filter",
"self",
"static",
"stdClass"
];
/** Dual-case keywords
*
* ["then","FILE"] =>
* ["then", "THEN", "FILE", "file"]
*
* @param {string[]} items */
const dualCase = (items) => {
/** @type string[] */
const result = [];
items.forEach(item => {
result.push(item);
if (item.toLowerCase() === item) {
result.push(item.toUpperCase());
} else {
result.push(item.toLowerCase());
}
});
return result;
};
const KEYWORDS = {
keyword: KWS,
literal: dualCase(LITERALS),
built_in: BUILT_INS,
};
/**
* @param {string[]} items */
const normalizeKeywords = (items) => {
return items.map(item => {
return item.replace(/\|\d+$/, "");
});
};
const CONSTRUCTOR_CALL = { variants: [
{
match: [
/new/,
regex.concat(WHITESPACE, "+"),
// to prevent built ins from being confused as the class constructor call
regex.concat("(?!", normalizeKeywords(BUILT_INS).join("\\b|"), "\\b)"),
PASCAL_CASE_CLASS_NAME_RE,
],
scope: {
1: "keyword",
4: "title.class",
},
}
] };
const CONSTANT_REFERENCE = regex.concat(IDENT_RE, "\\b(?!\\()");
const LEFT_AND_RIGHT_SIDE_OF_DOUBLE_COLON = { variants: [
{
match: [
regex.concat(
/::/,
regex.lookahead(/(?!class\b)/)
),
CONSTANT_REFERENCE,
],
scope: { 2: "variable.constant", },
},
{
match: [
/::/,
/class/,
],
scope: { 2: "variable.language", },
},
{
match: [
PASCAL_CASE_CLASS_NAME_RE,
regex.concat(
/::/,
regex.lookahead(/(?!class\b)/)
),
CONSTANT_REFERENCE,
],
scope: {
1: "title.class",
3: "variable.constant",
},
},
{
match: [
PASCAL_CASE_CLASS_NAME_RE,
regex.concat(
"::",
regex.lookahead(/(?!class\b)/)
),
],
scope: { 1: "title.class", },
},
{
match: [
PASCAL_CASE_CLASS_NAME_RE,
/::/,
/class/,
],
scope: {
1: "title.class",
3: "variable.language",
},
}
] };
const NAMED_ARGUMENT = {
scope: 'attr',
match: regex.concat(IDENT_RE, regex.lookahead(':'), regex.lookahead(/(?!::)/)),
};
const PARAMS_MODE = {
relevance: 0,
begin: /\(/,
end: /\)/,
keywords: KEYWORDS,
contains: [
NAMED_ARGUMENT,
VARIABLE,
LEFT_AND_RIGHT_SIDE_OF_DOUBLE_COLON,
hljs.C_BLOCK_COMMENT_MODE,
STRING,
NUMBER,
CONSTRUCTOR_CALL,
],
};
const FUNCTION_INVOKE = {
relevance: 0,
match: [
/\b/,
// to prevent keywords from being confused as the function title
regex.concat("(?!fn\\b|function\\b|", normalizeKeywords(KWS).join("\\b|"), "|", normalizeKeywords(BUILT_INS).join("\\b|"), "\\b)"),
IDENT_RE,
regex.concat(WHITESPACE, "*"),
regex.lookahead(/(?=\()/)
],
scope: { 3: "title.function.invoke", },
contains: [ PARAMS_MODE ]
};
PARAMS_MODE.contains.push(FUNCTION_INVOKE);
const ATTRIBUTE_CONTAINS = [
NAMED_ARGUMENT,
LEFT_AND_RIGHT_SIDE_OF_DOUBLE_COLON,
hljs.C_BLOCK_COMMENT_MODE,
STRING,
NUMBER,
CONSTRUCTOR_CALL,
];
const ATTRIBUTES = {
begin: regex.concat(/#\[\s*\\?/,
regex.either(
PASCAL_CASE_CLASS_NAME_RE,
UPCASE_NAME_RE
)
),
beginScope: "meta",
end: /]/,
endScope: "meta",
keywords: {
literal: LITERALS,
keyword: [
'new',
'array',
]
},
contains: [
{
begin: /\[/,
end: /]/,
keywords: {
literal: LITERALS,
keyword: [
'new',
'array',
]
},
contains: [
'self',
...ATTRIBUTE_CONTAINS,
]
},
...ATTRIBUTE_CONTAINS,
{
scope: 'meta',
variants: [
{ match: PASCAL_CASE_CLASS_NAME_RE },
{ match: UPCASE_NAME_RE }
]
}
]
};
return {
case_insensitive: false,
keywords: KEYWORDS,
contains: [
ATTRIBUTES,
hljs.HASH_COMMENT_MODE,
hljs.COMMENT('//', '$'),
hljs.COMMENT(
'/\\*',
'\\*/',
{ contains: [
{
scope: 'doctag',
match: '@[A-Za-z]+'
}
] }
),
{
match: /__halt_compiler\(\);/,
keywords: '__halt_compiler',
starts: {
scope: "comment",
end: hljs.MATCH_NOTHING_RE,
contains: [
{
match: /\?>/,
scope: "meta",
endsParent: true
}
]
}
},
PREPROCESSOR,
{
scope: 'variable.language',
match: /\$this\b/
},
VARIABLE,
FUNCTION_INVOKE,
LEFT_AND_RIGHT_SIDE_OF_DOUBLE_COLON,
{
match: [
/const/,
/\s/,
IDENT_RE,
],
scope: {
1: "keyword",
3: "variable.constant",
},
},
CONSTRUCTOR_CALL,
{
scope: 'function',
relevance: 0,
beginKeywords: 'fn function',
end: /[;{]/,
excludeEnd: true,
illegal: '[$%\\[]',
contains: [
{ beginKeywords: 'use', },
hljs.UNDERSCORE_TITLE_MODE,
{
begin: '=>', // No markup, just a relevance booster
endsParent: true
},
{
scope: 'params',
begin: '\\(',
end: '\\)',
excludeBegin: true,
excludeEnd: true,
keywords: KEYWORDS,
contains: [
'self',
ATTRIBUTES,
VARIABLE,
LEFT_AND_RIGHT_SIDE_OF_DOUBLE_COLON,
hljs.C_BLOCK_COMMENT_MODE,
STRING,
NUMBER
]
},
]
},
{
scope: 'class',
variants: [
{
beginKeywords: "enum",
illegal: /[($"]/
},
{
beginKeywords: "class interface trait",
illegal: /[:($"]/
}
],
relevance: 0,
end: /\{/,
excludeEnd: true,
contains: [
{ beginKeywords: 'extends implements' },
hljs.UNDERSCORE_TITLE_MODE
]
},
// both use and namespace still use "old style" rules (vs multi-match)
// because the namespace name can include `\` and we still want each
// element to be treated as its own *individual* title
{
beginKeywords: 'namespace',
relevance: 0,
end: ';',
illegal: /[.']/,
contains: [ hljs.inherit(hljs.UNDERSCORE_TITLE_MODE, { scope: "title.class" }) ]
},
{
beginKeywords: 'use',
relevance: 0,
end: ';',
contains: [
// TODO: title.function vs title.class
{
match: /\b(as|const|function)\b/,
scope: "keyword"
},
// TODO: could be title.class or title.function
hljs.UNDERSCORE_TITLE_MODE
]
},
STRING,
NUMBER,
]
};
}
return php;
})();
hljs.registerLanguage('php', hljsGrammar);
})();

View File

@@ -0,0 +1,59 @@
/*! `php` grammar compiled for Highlight.js 11.11.1 */
(()=>{var e=(()=>{"use strict";return e=>{
const t=e.regex,a=/(?![A-Za-z0-9])(?![$])/,r=t.concat(/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/,a),n=t.concat(/(\\?[A-Z][a-z0-9_\x7f-\xff]+|\\?[A-Z]+(?=[A-Z][a-z0-9_\x7f-\xff])){1,}/,a),o=t.concat(/[A-Z]+/,a),c={
scope:"variable",match:"\\$+"+r},i={scope:"subst",variants:[{begin:/\$\w+/},{
begin:/\{\$/,end:/\}/}]},s=e.inherit(e.APOS_STRING_MODE,{illegal:null
}),l="[ \t\n]",d={scope:"string",variants:[e.inherit(e.QUOTE_STRING_MODE,{
illegal:null,contains:e.QUOTE_STRING_MODE.contains.concat(i)}),s,{
begin:/<<<[ \t]*(?:(\w+)|"(\w+)")\n/,end:/[ \t]*(\w+)\b/,
contains:e.QUOTE_STRING_MODE.contains.concat(i),"on:begin":(e,t)=>{
t.data._beginMatch=e[1]||e[2]},"on:end":(e,t)=>{
t.data._beginMatch!==e[1]&&t.ignoreMatch()}},e.END_SAME_AS_BEGIN({
begin:/<<<[ \t]*'(\w+)'\n/,end:/[ \t]*(\w+)\b/})]},_={scope:"number",variants:[{
begin:"\\b0[bB][01]+(?:_[01]+)*\\b"},{begin:"\\b0[oO][0-7]+(?:_[0-7]+)*\\b"},{
begin:"\\b0[xX][\\da-fA-F]+(?:_[\\da-fA-F]+)*\\b"},{
begin:"(?:\\b\\d+(?:_\\d+)*(\\.(?:\\d+(?:_\\d+)*))?|\\B\\.\\d+)(?:[eE][+-]?\\d+)?"
}],relevance:0
},p=["false","null","true"],b=["__CLASS__","__DIR__","__FILE__","__FUNCTION__","__COMPILER_HALT_OFFSET__","__LINE__","__METHOD__","__NAMESPACE__","__TRAIT__","die","echo","exit","include","include_once","print","require","require_once","array","abstract","and","as","binary","bool","boolean","break","callable","case","catch","class","clone","const","continue","declare","default","do","double","else","elseif","empty","enddeclare","endfor","endforeach","endif","endswitch","endwhile","enum","eval","extends","final","finally","float","for","foreach","from","global","goto","if","implements","instanceof","insteadof","int","integer","interface","isset","iterable","list","match|0","mixed","new","never","object","or","private","protected","public","readonly","real","return","string","switch","throw","trait","try","unset","use","var","void","while","xor","yield"],E=["Error|0","AppendIterator","ArgumentCountError","ArithmeticError","ArrayIterator","ArrayObject","AssertionError","BadFunctionCallException","BadMethodCallException","CachingIterator","CallbackFilterIterator","CompileError","Countable","DirectoryIterator","DivisionByZeroError","DomainException","EmptyIterator","ErrorException","Exception","FilesystemIterator","FilterIterator","GlobIterator","InfiniteIterator","InvalidArgumentException","IteratorIterator","LengthException","LimitIterator","LogicException","MultipleIterator","NoRewindIterator","OutOfBoundsException","OutOfRangeException","OuterIterator","OverflowException","ParentIterator","ParseError","RangeException","RecursiveArrayIterator","RecursiveCachingIterator","RecursiveCallbackFilterIterator","RecursiveDirectoryIterator","RecursiveFilterIterator","RecursiveIterator","RecursiveIteratorIterator","RecursiveRegexIterator","RecursiveTreeIterator","RegexIterator","RuntimeException","SeekableIterator","SplDoublyLinkedList","SplFileInfo","SplFileObject","SplFixedArray","SplHeap","SplMaxHeap","SplMinHeap","SplObjectStorage","SplObserver","SplPriorityQueue","SplQueue","SplStack","SplSubject","SplTempFileObject","TypeError","UnderflowException","UnexpectedValueException","UnhandledMatchError","ArrayAccess","BackedEnum","Closure","Fiber","Generator","Iterator","IteratorAggregate","Serializable","Stringable","Throwable","Traversable","UnitEnum","WeakReference","WeakMap","Directory","__PHP_Incomplete_Class","parent","php_user_filter","self","static","stdClass"],u={
keyword:b,literal:(e=>{const t=[];return e.forEach((e=>{
t.push(e),e.toLowerCase()===e?t.push(e.toUpperCase()):t.push(e.toLowerCase())
})),t})(p),built_in:E},g=e=>e.map((e=>e.replace(/\|\d+$/,""))),h={variants:[{
match:[/new/,t.concat(l,"+"),t.concat("(?!",g(E).join("\\b|"),"\\b)"),n],scope:{
1:"keyword",4:"title.class"}}]},m=t.concat(r,"\\b(?!\\()"),I={variants:[{
match:[t.concat(/::/,t.lookahead(/(?!class\b)/)),m],scope:{2:"variable.constant"
}},{match:[/::/,/class/],scope:{2:"variable.language"}},{
match:[n,t.concat(/::/,t.lookahead(/(?!class\b)/)),m],scope:{1:"title.class",
3:"variable.constant"}},{match:[n,t.concat("::",t.lookahead(/(?!class\b)/))],
scope:{1:"title.class"}},{match:[n,/::/,/class/],scope:{1:"title.class",
3:"variable.language"}}]},f={scope:"attr",
match:t.concat(r,t.lookahead(":"),t.lookahead(/(?!::)/))},v={relevance:0,
begin:/\(/,end:/\)/,keywords:u,contains:[f,c,I,e.C_BLOCK_COMMENT_MODE,d,_,h]
},O={relevance:0,
match:[/\b/,t.concat("(?!fn\\b|function\\b|",g(b).join("\\b|"),"|",g(E).join("\\b|"),"\\b)"),r,t.concat(l,"*"),t.lookahead(/(?=\()/)],
scope:{3:"title.function.invoke"},contains:[v]};v.contains.push(O)
;const y=[f,I,e.C_BLOCK_COMMENT_MODE,d,_,h],w={
begin:t.concat(/#\[\s*\\?/,t.either(n,o)),beginScope:"meta",end:/]/,
endScope:"meta",keywords:{literal:p,keyword:["new","array"]},contains:[{
begin:/\[/,end:/]/,keywords:{literal:p,keyword:["new","array"]},
contains:["self",...y]},...y,{scope:"meta",variants:[{match:n},{match:o}]}]}
;return{case_insensitive:!1,keywords:u,
contains:[w,e.HASH_COMMENT_MODE,e.COMMENT("//","$"),e.COMMENT("/\\*","\\*/",{
contains:[{scope:"doctag",match:"@[A-Za-z]+"}]}),{match:/__halt_compiler\(\);/,
keywords:"__halt_compiler",starts:{scope:"comment",end:e.MATCH_NOTHING_RE,
contains:[{match:/\?>/,scope:"meta",endsParent:!0}]}},{scope:"meta",variants:[{
begin:/<\?php/,relevance:10},{begin:/<\?=/},{begin:/<\?/,relevance:.1},{
begin:/\?>/}]},{scope:"variable.language",match:/\$this\b/},c,O,I,{
match:[/const/,/\s/,r],scope:{1:"keyword",3:"variable.constant"}},h,{
scope:"function",relevance:0,beginKeywords:"fn function",end:/[;{]/,
excludeEnd:!0,illegal:"[$%\\[]",contains:[{beginKeywords:"use"
},e.UNDERSCORE_TITLE_MODE,{begin:"=>",endsParent:!0},{scope:"params",
begin:"\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0,keywords:u,
contains:["self",w,c,I,e.C_BLOCK_COMMENT_MODE,d,_]}]},{scope:"class",variants:[{
beginKeywords:"enum",illegal:/[($"]/},{beginKeywords:"class interface trait",
illegal:/[:($"]/}],relevance:0,end:/\{/,excludeEnd:!0,contains:[{
beginKeywords:"extends implements"},e.UNDERSCORE_TITLE_MODE]},{
beginKeywords:"namespace",relevance:0,end:";",illegal:/[.']/,
contains:[e.inherit(e.UNDERSCORE_TITLE_MODE,{scope:"title.class"})]},{
beginKeywords:"use",relevance:0,end:";",contains:[{
match:/\b(as|const|function)\b/,scope:"keyword"},e.UNDERSCORE_TITLE_MODE]},d,_]}
}})();hljs.registerLanguage("php",e)})();

View File

@@ -0,0 +1,29 @@
/*! `plaintext` grammar compiled for Highlight.js 11.11.1 */
(function(){
var hljsGrammar = (function () {
'use strict';
/*
Language: Plain text
Author: Egor Rogov (e.rogov@postgrespro.ru)
Description: Plain text without any highlighting.
Category: common
*/
function plaintext(hljs) {
return {
name: 'Plain text',
aliases: [
'text',
'txt'
],
disableAutodetect: true
};
}
return plaintext;
})();
hljs.registerLanguage('plaintext', hljsGrammar);
})();

View File

@@ -0,0 +1,4 @@
/*! `plaintext` grammar compiled for Highlight.js 11.11.1 */
(()=>{var t=(()=>{"use strict";return t=>({name:"Plain text",
aliases:["text","txt"],disableAutodetect:!0})})()
;hljs.registerLanguage("plaintext",t)})();

View File

@@ -0,0 +1,327 @@
/*! `powershell` grammar compiled for Highlight.js 11.11.1 */
(function(){
var hljsGrammar = (function () {
'use strict';
/*
Language: PowerShell
Description: PowerShell is a task-based command-line shell and scripting language built on .NET.
Author: David Mohundro <david@mohundro.com>
Contributors: Nicholas Blumhardt <nblumhardt@nblumhardt.com>, Victor Zhou <OiCMudkips@users.noreply.github.com>, Nicolas Le Gall <contact@nlegall.fr>
Website: https://docs.microsoft.com/en-us/powershell/
Category: scripting
*/
function powershell(hljs) {
const TYPES = [
"string",
"char",
"byte",
"int",
"long",
"bool",
"decimal",
"single",
"double",
"DateTime",
"xml",
"array",
"hashtable",
"void"
];
// https://docs.microsoft.com/en-us/powershell/scripting/developer/cmdlet/approved-verbs-for-windows-powershell-commands
const VALID_VERBS =
'Add|Clear|Close|Copy|Enter|Exit|Find|Format|Get|Hide|Join|Lock|'
+ 'Move|New|Open|Optimize|Pop|Push|Redo|Remove|Rename|Reset|Resize|'
+ 'Search|Select|Set|Show|Skip|Split|Step|Switch|Undo|Unlock|'
+ 'Watch|Backup|Checkpoint|Compare|Compress|Convert|ConvertFrom|'
+ 'ConvertTo|Dismount|Edit|Expand|Export|Group|Import|Initialize|'
+ 'Limit|Merge|Mount|Out|Publish|Restore|Save|Sync|Unpublish|Update|'
+ 'Approve|Assert|Build|Complete|Confirm|Deny|Deploy|Disable|Enable|Install|Invoke|'
+ 'Register|Request|Restart|Resume|Start|Stop|Submit|Suspend|Uninstall|'
+ 'Unregister|Wait|Debug|Measure|Ping|Repair|Resolve|Test|Trace|Connect|'
+ 'Disconnect|Read|Receive|Send|Write|Block|Grant|Protect|Revoke|Unblock|'
+ 'Unprotect|Use|ForEach|Sort|Tee|Where';
const COMPARISON_OPERATORS =
'-and|-as|-band|-bnot|-bor|-bxor|-casesensitive|-ccontains|-ceq|-cge|-cgt|'
+ '-cle|-clike|-clt|-cmatch|-cne|-cnotcontains|-cnotlike|-cnotmatch|-contains|'
+ '-creplace|-csplit|-eq|-exact|-f|-file|-ge|-gt|-icontains|-ieq|-ige|-igt|'
+ '-ile|-ilike|-ilt|-imatch|-in|-ine|-inotcontains|-inotlike|-inotmatch|'
+ '-ireplace|-is|-isnot|-isplit|-join|-le|-like|-lt|-match|-ne|-not|'
+ '-notcontains|-notin|-notlike|-notmatch|-or|-regex|-replace|-shl|-shr|'
+ '-split|-wildcard|-xor';
const KEYWORDS = {
$pattern: /-?[A-z\.\-]+\b/,
keyword:
'if else foreach return do while until elseif begin for trap data dynamicparam '
+ 'end break throw param continue finally in switch exit filter try process catch '
+ 'hidden static parameter',
// "echo" relevance has been set to 0 to avoid auto-detect conflicts with shell transcripts
built_in:
'ac asnp cat cd CFS chdir clc clear clhy cli clp cls clv cnsn compare copy cp '
+ 'cpi cpp curl cvpa dbp del diff dir dnsn ebp echo|0 epal epcsv epsn erase etsn exsn fc fhx '
+ 'fl ft fw gal gbp gc gcb gci gcm gcs gdr gerr ghy gi gin gjb gl gm gmo gp gps gpv group '
+ 'gsn gsnp gsv gtz gu gv gwmi h history icm iex ihy ii ipal ipcsv ipmo ipsn irm ise iwmi '
+ 'iwr kill lp ls man md measure mi mount move mp mv nal ndr ni nmo npssc nsn nv ogv oh '
+ 'popd ps pushd pwd r rbp rcjb rcsn rd rdr ren ri rjb rm rmdir rmo rni rnp rp rsn rsnp '
+ 'rujb rv rvpa rwmi sajb sal saps sasv sbp sc scb select set shcm si sl sleep sls sort sp '
+ 'spjb spps spsv start stz sujb sv swmi tee trcm type wget where wjb write'
// TODO: 'validate[A-Z]+' can't work in keywords
};
const TITLE_NAME_RE = /\w[\w\d]*((-)[\w\d]+)*/;
const BACKTICK_ESCAPE = {
begin: '`[\\s\\S]',
relevance: 0
};
const VAR = {
className: 'variable',
variants: [
{ begin: /\$\B/ },
{
className: 'keyword',
begin: /\$this/
},
{ begin: /\$[\w\d][\w\d_:]*/ }
]
};
const LITERAL = {
className: 'literal',
begin: /\$(null|true|false)\b/
};
const QUOTE_STRING = {
className: "string",
variants: [
{
begin: /"/,
end: /"/
},
{
begin: /@"/,
end: /^"@/
}
],
contains: [
BACKTICK_ESCAPE,
VAR,
{
className: 'variable',
begin: /\$[A-z]/,
end: /[^A-z]/
}
]
};
const APOS_STRING = {
className: 'string',
variants: [
{
begin: /'/,
end: /'/
},
{
begin: /@'/,
end: /^'@/
}
]
};
const PS_HELPTAGS = {
className: "doctag",
variants: [
/* no paramater help tags */
{ begin: /\.(synopsis|description|example|inputs|outputs|notes|link|component|role|functionality)/ },
/* one parameter help tags */
{ begin: /\.(parameter|forwardhelptargetname|forwardhelpcategory|remotehelprunspace|externalhelp)\s+\S+/ }
]
};
const PS_COMMENT = hljs.inherit(
hljs.COMMENT(null, null),
{
variants: [
/* single-line comment */
{
begin: /#/,
end: /$/
},
/* multi-line comment */
{
begin: /<#/,
end: /#>/
}
],
contains: [ PS_HELPTAGS ]
}
);
const CMDLETS = {
className: 'built_in',
variants: [ { begin: '('.concat(VALID_VERBS, ')+(-)[\\w\\d]+') } ]
};
const PS_CLASS = {
className: 'class',
beginKeywords: 'class enum',
end: /\s*[{]/,
excludeEnd: true,
relevance: 0,
contains: [ hljs.TITLE_MODE ]
};
const PS_FUNCTION = {
className: 'function',
begin: /function\s+/,
end: /\s*\{|$/,
excludeEnd: true,
returnBegin: true,
relevance: 0,
contains: [
{
begin: "function",
relevance: 0,
className: "keyword"
},
{
className: "title",
begin: TITLE_NAME_RE,
relevance: 0
},
{
begin: /\(/,
end: /\)/,
className: "params",
relevance: 0,
contains: [ VAR ]
}
// CMDLETS
]
};
// Using statment, plus type, plus assembly name.
const PS_USING = {
begin: /using\s/,
end: /$/,
returnBegin: true,
contains: [
QUOTE_STRING,
APOS_STRING,
{
className: 'keyword',
begin: /(using|assembly|command|module|namespace|type)/
}
]
};
// Comperison operators & function named parameters.
const PS_ARGUMENTS = { variants: [
// PS literals are pretty verbose so it's a good idea to accent them a bit.
{
className: 'operator',
begin: '('.concat(COMPARISON_OPERATORS, ')\\b')
},
{
className: 'literal',
begin: /(-){1,2}[\w\d-]+/,
relevance: 0
}
] };
const HASH_SIGNS = {
className: 'selector-tag',
begin: /@\B/,
relevance: 0
};
// It's a very general rule so I'll narrow it a bit with some strict boundaries
// to avoid any possible false-positive collisions!
const PS_METHODS = {
className: 'function',
begin: /\[.*\]\s*[\w]+[ ]??\(/,
end: /$/,
returnBegin: true,
relevance: 0,
contains: [
{
className: 'keyword',
begin: '('.concat(
KEYWORDS.keyword.toString().replace(/\s/g, '|'
), ')\\b'),
endsParent: true,
relevance: 0
},
hljs.inherit(hljs.TITLE_MODE, { endsParent: true })
]
};
const GENTLEMANS_SET = [
// STATIC_MEMBER,
PS_METHODS,
PS_COMMENT,
BACKTICK_ESCAPE,
hljs.NUMBER_MODE,
QUOTE_STRING,
APOS_STRING,
// PS_NEW_OBJECT_TYPE,
CMDLETS,
VAR,
LITERAL,
HASH_SIGNS
];
const PS_TYPE = {
begin: /\[/,
end: /\]/,
excludeBegin: true,
excludeEnd: true,
relevance: 0,
contains: [].concat(
'self',
GENTLEMANS_SET,
{
begin: "(" + TYPES.join("|") + ")",
className: "built_in",
relevance: 0
},
{
className: 'type',
begin: /[\.\w\d]+/,
relevance: 0
}
)
};
PS_METHODS.contains.unshift(PS_TYPE);
return {
name: 'PowerShell',
aliases: [
"pwsh",
"ps",
"ps1"
],
case_insensitive: true,
keywords: KEYWORDS,
contains: GENTLEMANS_SET.concat(
PS_CLASS,
PS_FUNCTION,
PS_USING,
PS_ARGUMENTS,
PS_TYPE
)
};
}
return powershell;
})();
hljs.registerLanguage('powershell', hljsGrammar);
})();

View File

@@ -0,0 +1,39 @@
/*! `powershell` grammar compiled for Highlight.js 11.11.1 */
(()=>{var e=(()=>{"use strict";return e=>{const n={$pattern:/-?[A-z\.\-]+\b/,
keyword:"if else foreach return do while until elseif begin for trap data dynamicparam end break throw param continue finally in switch exit filter try process catch hidden static parameter",
built_in:"ac asnp cat cd CFS chdir clc clear clhy cli clp cls clv cnsn compare copy cp cpi cpp curl cvpa dbp del diff dir dnsn ebp echo|0 epal epcsv epsn erase etsn exsn fc fhx fl ft fw gal gbp gc gcb gci gcm gcs gdr gerr ghy gi gin gjb gl gm gmo gp gps gpv group gsn gsnp gsv gtz gu gv gwmi h history icm iex ihy ii ipal ipcsv ipmo ipsn irm ise iwmi iwr kill lp ls man md measure mi mount move mp mv nal ndr ni nmo npssc nsn nv ogv oh popd ps pushd pwd r rbp rcjb rcsn rd rdr ren ri rjb rm rmdir rmo rni rnp rp rsn rsnp rujb rv rvpa rwmi sajb sal saps sasv sbp sc scb select set shcm si sl sleep sls sort sp spjb spps spsv start stz sujb sv swmi tee trcm type wget where wjb write"
},s={begin:"`[\\s\\S]",relevance:0},i={className:"variable",variants:[{
begin:/\$\B/},{className:"keyword",begin:/\$this/},{begin:/\$[\w\d][\w\d_:]*/}]
},a={className:"string",variants:[{begin:/"/,end:/"/},{begin:/@"/,end:/^"@/}],
contains:[s,i,{className:"variable",begin:/\$[A-z]/,end:/[^A-z]/}]},t={
className:"string",variants:[{begin:/'/,end:/'/},{begin:/@'/,end:/^'@/}]
},r=e.inherit(e.COMMENT(null,null),{variants:[{begin:/#/,end:/$/},{begin:/<#/,
end:/#>/}],contains:[{className:"doctag",variants:[{
begin:/\.(synopsis|description|example|inputs|outputs|notes|link|component|role|functionality)/
},{
begin:/\.(parameter|forwardhelptargetname|forwardhelpcategory|remotehelprunspace|externalhelp)\s+\S+/
}]}]}),c={className:"class",beginKeywords:"class enum",end:/\s*[{]/,
excludeEnd:!0,relevance:0,contains:[e.TITLE_MODE]},l={className:"function",
begin:/function\s+/,end:/\s*\{|$/,excludeEnd:!0,returnBegin:!0,relevance:0,
contains:[{begin:"function",relevance:0,className:"keyword"},{className:"title",
begin:/\w[\w\d]*((-)[\w\d]+)*/,relevance:0},{begin:/\(/,end:/\)/,
className:"params",relevance:0,contains:[i]}]},o={begin:/using\s/,end:/$/,
returnBegin:!0,contains:[a,t,{className:"keyword",
begin:/(using|assembly|command|module|namespace|type)/}]},p={
className:"function",begin:/\[.*\]\s*[\w]+[ ]??\(/,end:/$/,returnBegin:!0,
relevance:0,contains:[{className:"keyword",
begin:"(".concat(n.keyword.toString().replace(/\s/g,"|"),")\\b"),endsParent:!0,
relevance:0},e.inherit(e.TITLE_MODE,{endsParent:!0})]
},g=[p,r,s,e.NUMBER_MODE,a,t,{className:"built_in",variants:[{
begin:"(Add|Clear|Close|Copy|Enter|Exit|Find|Format|Get|Hide|Join|Lock|Move|New|Open|Optimize|Pop|Push|Redo|Remove|Rename|Reset|Resize|Search|Select|Set|Show|Skip|Split|Step|Switch|Undo|Unlock|Watch|Backup|Checkpoint|Compare|Compress|Convert|ConvertFrom|ConvertTo|Dismount|Edit|Expand|Export|Group|Import|Initialize|Limit|Merge|Mount|Out|Publish|Restore|Save|Sync|Unpublish|Update|Approve|Assert|Build|Complete|Confirm|Deny|Deploy|Disable|Enable|Install|Invoke|Register|Request|Restart|Resume|Start|Stop|Submit|Suspend|Uninstall|Unregister|Wait|Debug|Measure|Ping|Repair|Resolve|Test|Trace|Connect|Disconnect|Read|Receive|Send|Write|Block|Grant|Protect|Revoke|Unblock|Unprotect|Use|ForEach|Sort|Tee|Where)+(-)[\\w\\d]+"
}]},i,{className:"literal",begin:/\$(null|true|false)\b/},{
className:"selector-tag",begin:/@\B/,relevance:0}],m={begin:/\[/,end:/\]/,
excludeBegin:!0,excludeEnd:!0,relevance:0,contains:[].concat("self",g,{
begin:"(string|char|byte|int|long|bool|decimal|single|double|DateTime|xml|array|hashtable|void)",
className:"built_in",relevance:0},{className:"type",begin:/[\.\w\d]+/,
relevance:0})};return p.contains.unshift(m),{name:"PowerShell",
aliases:["pwsh","ps","ps1"],case_insensitive:!0,keywords:n,
contains:g.concat(c,l,o,{variants:[{className:"operator",
begin:"(-and|-as|-band|-bnot|-bor|-bxor|-casesensitive|-ccontains|-ceq|-cge|-cgt|-cle|-clike|-clt|-cmatch|-cne|-cnotcontains|-cnotlike|-cnotmatch|-contains|-creplace|-csplit|-eq|-exact|-f|-file|-ge|-gt|-icontains|-ieq|-ige|-igt|-ile|-ilike|-ilt|-imatch|-in|-ine|-inotcontains|-inotlike|-inotmatch|-ireplace|-is|-isnot|-isplit|-join|-le|-like|-lt|-match|-ne|-not|-notcontains|-notin|-notlike|-notmatch|-or|-regex|-replace|-shl|-shr|-split|-wildcard|-xor)\\b"
},{className:"literal",begin:/(-){1,2}[\w\d-]+/,relevance:0}]},m)}}})()
;hljs.registerLanguage("powershell",e)})();

View File

@@ -0,0 +1,446 @@
/*! `python` grammar compiled for Highlight.js 11.11.1 */
(function(){
var hljsGrammar = (function () {
'use strict';
/*
Language: Python
Description: Python is an interpreted, object-oriented, high-level programming language with dynamic semantics.
Website: https://www.python.org
Category: common
*/
function python(hljs) {
const regex = hljs.regex;
const IDENT_RE = /[\p{XID_Start}_]\p{XID_Continue}*/u;
const RESERVED_WORDS = [
'and',
'as',
'assert',
'async',
'await',
'break',
'case',
'class',
'continue',
'def',
'del',
'elif',
'else',
'except',
'finally',
'for',
'from',
'global',
'if',
'import',
'in',
'is',
'lambda',
'match',
'nonlocal|10',
'not',
'or',
'pass',
'raise',
'return',
'try',
'while',
'with',
'yield'
];
const BUILT_INS = [
'__import__',
'abs',
'all',
'any',
'ascii',
'bin',
'bool',
'breakpoint',
'bytearray',
'bytes',
'callable',
'chr',
'classmethod',
'compile',
'complex',
'delattr',
'dict',
'dir',
'divmod',
'enumerate',
'eval',
'exec',
'filter',
'float',
'format',
'frozenset',
'getattr',
'globals',
'hasattr',
'hash',
'help',
'hex',
'id',
'input',
'int',
'isinstance',
'issubclass',
'iter',
'len',
'list',
'locals',
'map',
'max',
'memoryview',
'min',
'next',
'object',
'oct',
'open',
'ord',
'pow',
'print',
'property',
'range',
'repr',
'reversed',
'round',
'set',
'setattr',
'slice',
'sorted',
'staticmethod',
'str',
'sum',
'super',
'tuple',
'type',
'vars',
'zip'
];
const LITERALS = [
'__debug__',
'Ellipsis',
'False',
'None',
'NotImplemented',
'True'
];
// https://docs.python.org/3/library/typing.html
// TODO: Could these be supplemented by a CamelCase matcher in certain
// contexts, leaving these remaining only for relevance hinting?
const TYPES = [
"Any",
"Callable",
"Coroutine",
"Dict",
"List",
"Literal",
"Generic",
"Optional",
"Sequence",
"Set",
"Tuple",
"Type",
"Union"
];
const KEYWORDS = {
$pattern: /[A-Za-z]\w+|__\w+__/,
keyword: RESERVED_WORDS,
built_in: BUILT_INS,
literal: LITERALS,
type: TYPES
};
const PROMPT = {
className: 'meta',
begin: /^(>>>|\.\.\.) /
};
const SUBST = {
className: 'subst',
begin: /\{/,
end: /\}/,
keywords: KEYWORDS,
illegal: /#/
};
const LITERAL_BRACKET = {
begin: /\{\{/,
relevance: 0
};
const STRING = {
className: 'string',
contains: [ hljs.BACKSLASH_ESCAPE ],
variants: [
{
begin: /([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,
end: /'''/,
contains: [
hljs.BACKSLASH_ESCAPE,
PROMPT
],
relevance: 10
},
{
begin: /([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,
end: /"""/,
contains: [
hljs.BACKSLASH_ESCAPE,
PROMPT
],
relevance: 10
},
{
begin: /([fF][rR]|[rR][fF]|[fF])'''/,
end: /'''/,
contains: [
hljs.BACKSLASH_ESCAPE,
PROMPT,
LITERAL_BRACKET,
SUBST
]
},
{
begin: /([fF][rR]|[rR][fF]|[fF])"""/,
end: /"""/,
contains: [
hljs.BACKSLASH_ESCAPE,
PROMPT,
LITERAL_BRACKET,
SUBST
]
},
{
begin: /([uU]|[rR])'/,
end: /'/,
relevance: 10
},
{
begin: /([uU]|[rR])"/,
end: /"/,
relevance: 10
},
{
begin: /([bB]|[bB][rR]|[rR][bB])'/,
end: /'/
},
{
begin: /([bB]|[bB][rR]|[rR][bB])"/,
end: /"/
},
{
begin: /([fF][rR]|[rR][fF]|[fF])'/,
end: /'/,
contains: [
hljs.BACKSLASH_ESCAPE,
LITERAL_BRACKET,
SUBST
]
},
{
begin: /([fF][rR]|[rR][fF]|[fF])"/,
end: /"/,
contains: [
hljs.BACKSLASH_ESCAPE,
LITERAL_BRACKET,
SUBST
]
},
hljs.APOS_STRING_MODE,
hljs.QUOTE_STRING_MODE
]
};
// https://docs.python.org/3.9/reference/lexical_analysis.html#numeric-literals
const digitpart = '[0-9](_?[0-9])*';
const pointfloat = `(\\b(${digitpart}))?\\.(${digitpart})|\\b(${digitpart})\\.`;
// Whitespace after a number (or any lexical token) is needed only if its absence
// would change the tokenization
// https://docs.python.org/3.9/reference/lexical_analysis.html#whitespace-between-tokens
// We deviate slightly, requiring a word boundary or a keyword
// to avoid accidentally recognizing *prefixes* (e.g., `0` in `0x41` or `08` or `0__1`)
const lookahead = `\\b|${RESERVED_WORDS.join('|')}`;
const NUMBER = {
className: 'number',
relevance: 0,
variants: [
// exponentfloat, pointfloat
// https://docs.python.org/3.9/reference/lexical_analysis.html#floating-point-literals
// optionally imaginary
// https://docs.python.org/3.9/reference/lexical_analysis.html#imaginary-literals
// Note: no leading \b because floats can start with a decimal point
// and we don't want to mishandle e.g. `fn(.5)`,
// no trailing \b for pointfloat because it can end with a decimal point
// and we don't want to mishandle e.g. `0..hex()`; this should be safe
// because both MUST contain a decimal point and so cannot be confused with
// the interior part of an identifier
{
begin: `(\\b(${digitpart})|(${pointfloat}))[eE][+-]?(${digitpart})[jJ]?(?=${lookahead})`
},
{
begin: `(${pointfloat})[jJ]?`
},
// decinteger, bininteger, octinteger, hexinteger
// https://docs.python.org/3.9/reference/lexical_analysis.html#integer-literals
// optionally "long" in Python 2
// https://docs.python.org/2.7/reference/lexical_analysis.html#integer-and-long-integer-literals
// decinteger is optionally imaginary
// https://docs.python.org/3.9/reference/lexical_analysis.html#imaginary-literals
{
begin: `\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${lookahead})`
},
{
begin: `\\b0[bB](_?[01])+[lL]?(?=${lookahead})`
},
{
begin: `\\b0[oO](_?[0-7])+[lL]?(?=${lookahead})`
},
{
begin: `\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${lookahead})`
},
// imagnumber (digitpart-based)
// https://docs.python.org/3.9/reference/lexical_analysis.html#imaginary-literals
{
begin: `\\b(${digitpart})[jJ](?=${lookahead})`
}
]
};
const COMMENT_TYPE = {
className: "comment",
begin: regex.lookahead(/# type:/),
end: /$/,
keywords: KEYWORDS,
contains: [
{ // prevent keywords from coloring `type`
begin: /# type:/
},
// comment within a datatype comment includes no keywords
{
begin: /#/,
end: /\b\B/,
endsWithParent: true
}
]
};
const PARAMS = {
className: 'params',
variants: [
// Exclude params in functions without params
{
className: "",
begin: /\(\s*\)/,
skip: true
},
{
begin: /\(/,
end: /\)/,
excludeBegin: true,
excludeEnd: true,
keywords: KEYWORDS,
contains: [
'self',
PROMPT,
NUMBER,
STRING,
hljs.HASH_COMMENT_MODE
]
}
]
};
SUBST.contains = [
STRING,
NUMBER,
PROMPT
];
return {
name: 'Python',
aliases: [
'py',
'gyp',
'ipython'
],
unicodeRegex: true,
keywords: KEYWORDS,
illegal: /(<\/|\?)|=>/,
contains: [
PROMPT,
NUMBER,
{
// very common convention
scope: 'variable.language',
match: /\bself\b/
},
{
// eat "if" prior to string so that it won't accidentally be
// labeled as an f-string
beginKeywords: "if",
relevance: 0
},
{ match: /\bor\b/, scope: "keyword" },
STRING,
COMMENT_TYPE,
hljs.HASH_COMMENT_MODE,
{
match: [
/\bdef/, /\s+/,
IDENT_RE,
],
scope: {
1: "keyword",
3: "title.function"
},
contains: [ PARAMS ]
},
{
variants: [
{
match: [
/\bclass/, /\s+/,
IDENT_RE, /\s*/,
/\(\s*/, IDENT_RE,/\s*\)/
],
},
{
match: [
/\bclass/, /\s+/,
IDENT_RE
],
}
],
scope: {
1: "keyword",
3: "title.class",
6: "title.class.inherited",
}
},
{
className: 'meta',
begin: /^[\t ]*@/,
end: /(?=#)|$/,
contains: [
NUMBER,
PARAMS,
STRING
]
}
]
};
}
return python;
})();
hljs.registerLanguage('python', hljsGrammar);
})();

View File

@@ -0,0 +1,42 @@
/*! `python` grammar compiled for Highlight.js 11.11.1 */
(()=>{var e=(()=>{"use strict";return e=>{
const n=e.regex,a=/[\p{XID_Start}_]\p{XID_Continue}*/u,s=["and","as","assert","async","await","break","case","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","match","nonlocal|10","not","or","pass","raise","return","try","while","with","yield"],t={
$pattern:/[A-Za-z]\w+|__\w+__/,keyword:s,
built_in:["__import__","abs","all","any","ascii","bin","bool","breakpoint","bytearray","bytes","callable","chr","classmethod","compile","complex","delattr","dict","dir","divmod","enumerate","eval","exec","filter","float","format","frozenset","getattr","globals","hasattr","hash","help","hex","id","input","int","isinstance","issubclass","iter","len","list","locals","map","max","memoryview","min","next","object","oct","open","ord","pow","print","property","range","repr","reversed","round","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","vars","zip"],
literal:["__debug__","Ellipsis","False","None","NotImplemented","True"],
type:["Any","Callable","Coroutine","Dict","List","Literal","Generic","Optional","Sequence","Set","Tuple","Type","Union"]
},i={className:"meta",begin:/^(>>>|\.\.\.) /},r={className:"subst",begin:/\{/,
end:/\}/,keywords:t,illegal:/#/},l={begin:/\{\{/,relevance:0},o={
className:"string",contains:[e.BACKSLASH_ESCAPE],variants:[{
begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,
contains:[e.BACKSLASH_ESCAPE,i],relevance:10},{
begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,
contains:[e.BACKSLASH_ESCAPE,i],relevance:10},{
begin:/([fF][rR]|[rR][fF]|[fF])'''/,end:/'''/,
contains:[e.BACKSLASH_ESCAPE,i,l,r]},{begin:/([fF][rR]|[rR][fF]|[fF])"""/,
end:/"""/,contains:[e.BACKSLASH_ESCAPE,i,l,r]},{begin:/([uU]|[rR])'/,end:/'/,
relevance:10},{begin:/([uU]|[rR])"/,end:/"/,relevance:10},{
begin:/([bB]|[bB][rR]|[rR][bB])'/,end:/'/},{begin:/([bB]|[bB][rR]|[rR][bB])"/,
end:/"/},{begin:/([fF][rR]|[rR][fF]|[fF])'/,end:/'/,
contains:[e.BACKSLASH_ESCAPE,l,r]},{begin:/([fF][rR]|[rR][fF]|[fF])"/,end:/"/,
contains:[e.BACKSLASH_ESCAPE,l,r]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]
},b="[0-9](_?[0-9])*",c=`(\\b(${b}))?\\.(${b})|\\b(${b})\\.`,d="\\b|"+s.join("|"),g={
className:"number",relevance:0,variants:[{
begin:`(\\b(${b})|(${c}))[eE][+-]?(${b})[jJ]?(?=${d})`},{begin:`(${c})[jJ]?`},{
begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${d})`},{
begin:`\\b0[bB](_?[01])+[lL]?(?=${d})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${d})`
},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${d})`},{begin:`\\b(${b})[jJ](?=${d})`
}]},p={className:"comment",begin:n.lookahead(/# type:/),end:/$/,keywords:t,
contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},m={
className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,
end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:t,
contains:["self",i,g,o,e.HASH_COMMENT_MODE]}]};return r.contains=[o,g,i],{
name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:t,
illegal:/(<\/|\?)|=>/,contains:[i,g,{scope:"variable.language",match:/\bself\b/
},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"
},o,p,e.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,a],scope:{1:"keyword",
3:"title.function"},contains:[m]},{variants:[{
match:[/\bclass/,/\s+/,a,/\s*/,/\(\s*/,a,/\s*\)/]},{match:[/\bclass/,/\s+/,a]}],
scope:{1:"keyword",3:"title.class",6:"title.class.inherited"}},{
className:"meta",begin:/^[\t ]*@/,end:/(?=#)|$/,contains:[g,m,o]}]}}})()
;hljs.registerLanguage("python",e)})();

View File

@@ -0,0 +1,43 @@
/*! `shell` grammar compiled for Highlight.js 11.11.1 */
(function(){
var hljsGrammar = (function () {
'use strict';
/*
Language: Shell Session
Requires: bash.js
Author: TSUYUSATO Kitsune <make.just.on@gmail.com>
Category: common
Audit: 2020
*/
/** @type LanguageFn */
function shell(hljs) {
return {
name: 'Shell Session',
aliases: [
'console',
'shellsession'
],
contains: [
{
className: 'meta.prompt',
// We cannot add \s (spaces) in the regular expression otherwise it will be too broad and produce unexpected result.
// For instance, in the following example, it would match "echo /path/to/home >" as a prompt:
// echo /path/to/home > t.exe
begin: /^\s{0,3}[/~\w\d[\]()@-]*[>%$#][ ]?/,
starts: {
end: /[^\\](?=\s*$)/,
subLanguage: 'bash'
}
}
]
};
}
return shell;
})();
hljs.registerLanguage('shell', hljsGrammar);
})();

View File

@@ -0,0 +1,5 @@
/*! `shell` grammar compiled for Highlight.js 11.11.1 */
(()=>{var s=(()=>{"use strict";return s=>({name:"Shell Session",
aliases:["console","shellsession"],contains:[{className:"meta.prompt",
begin:/^\s{0,3}[/~\w\d[\]()@-]*[>%$#][ ]?/,starts:{end:/[^\\](?=\s*$)/,
subLanguage:"bash"}}]})})();hljs.registerLanguage("shell",s)})();

View File

@@ -0,0 +1,703 @@
/*! `sql` grammar compiled for Highlight.js 11.11.1 */
(function(){
var hljsGrammar = (function () {
'use strict';
/*
Language: SQL
Website: https://en.wikipedia.org/wiki/SQL
Category: common, database
*/
/*
Goals:
SQL is intended to highlight basic/common SQL keywords and expressions
- If pretty much every single SQL server includes supports, then it's a canidate.
- It is NOT intended to include tons of vendor specific keywords (Oracle, MySQL,
PostgreSQL) although the list of data types is purposely a bit more expansive.
- For more specific SQL grammars please see:
- PostgreSQL and PL/pgSQL - core
- T-SQL - https://github.com/highlightjs/highlightjs-tsql
- sql_more (core)
*/
function sql(hljs) {
const regex = hljs.regex;
const COMMENT_MODE = hljs.COMMENT('--', '$');
const STRING = {
scope: 'string',
variants: [
{
begin: /'/,
end: /'/,
contains: [ { match: /''/ } ]
}
]
};
const QUOTED_IDENTIFIER = {
begin: /"/,
end: /"/,
contains: [ { match: /""/ } ]
};
const LITERALS = [
"true",
"false",
// Not sure it's correct to call NULL literal, and clauses like IS [NOT] NULL look strange that way.
// "null",
"unknown"
];
const MULTI_WORD_TYPES = [
"double precision",
"large object",
"with timezone",
"without timezone"
];
const TYPES = [
'bigint',
'binary',
'blob',
'boolean',
'char',
'character',
'clob',
'date',
'dec',
'decfloat',
'decimal',
'float',
'int',
'integer',
'interval',
'nchar',
'nclob',
'national',
'numeric',
'real',
'row',
'smallint',
'time',
'timestamp',
'varchar',
'varying', // modifier (character varying)
'varbinary'
];
const NON_RESERVED_WORDS = [
"add",
"asc",
"collation",
"desc",
"final",
"first",
"last",
"view"
];
// https://jakewheat.github.io/sql-overview/sql-2016-foundation-grammar.html#reserved-word
const RESERVED_WORDS = [
"abs",
"acos",
"all",
"allocate",
"alter",
"and",
"any",
"are",
"array",
"array_agg",
"array_max_cardinality",
"as",
"asensitive",
"asin",
"asymmetric",
"at",
"atan",
"atomic",
"authorization",
"avg",
"begin",
"begin_frame",
"begin_partition",
"between",
"bigint",
"binary",
"blob",
"boolean",
"both",
"by",
"call",
"called",
"cardinality",
"cascaded",
"case",
"cast",
"ceil",
"ceiling",
"char",
"char_length",
"character",
"character_length",
"check",
"classifier",
"clob",
"close",
"coalesce",
"collate",
"collect",
"column",
"commit",
"condition",
"connect",
"constraint",
"contains",
"convert",
"copy",
"corr",
"corresponding",
"cos",
"cosh",
"count",
"covar_pop",
"covar_samp",
"create",
"cross",
"cube",
"cume_dist",
"current",
"current_catalog",
"current_date",
"current_default_transform_group",
"current_path",
"current_role",
"current_row",
"current_schema",
"current_time",
"current_timestamp",
"current_path",
"current_role",
"current_transform_group_for_type",
"current_user",
"cursor",
"cycle",
"date",
"day",
"deallocate",
"dec",
"decimal",
"decfloat",
"declare",
"default",
"define",
"delete",
"dense_rank",
"deref",
"describe",
"deterministic",
"disconnect",
"distinct",
"double",
"drop",
"dynamic",
"each",
"element",
"else",
"empty",
"end",
"end_frame",
"end_partition",
"end-exec",
"equals",
"escape",
"every",
"except",
"exec",
"execute",
"exists",
"exp",
"external",
"extract",
"false",
"fetch",
"filter",
"first_value",
"float",
"floor",
"for",
"foreign",
"frame_row",
"free",
"from",
"full",
"function",
"fusion",
"get",
"global",
"grant",
"group",
"grouping",
"groups",
"having",
"hold",
"hour",
"identity",
"in",
"indicator",
"initial",
"inner",
"inout",
"insensitive",
"insert",
"int",
"integer",
"intersect",
"intersection",
"interval",
"into",
"is",
"join",
"json_array",
"json_arrayagg",
"json_exists",
"json_object",
"json_objectagg",
"json_query",
"json_table",
"json_table_primitive",
"json_value",
"lag",
"language",
"large",
"last_value",
"lateral",
"lead",
"leading",
"left",
"like",
"like_regex",
"listagg",
"ln",
"local",
"localtime",
"localtimestamp",
"log",
"log10",
"lower",
"match",
"match_number",
"match_recognize",
"matches",
"max",
"member",
"merge",
"method",
"min",
"minute",
"mod",
"modifies",
"module",
"month",
"multiset",
"national",
"natural",
"nchar",
"nclob",
"new",
"no",
"none",
"normalize",
"not",
"nth_value",
"ntile",
"null",
"nullif",
"numeric",
"octet_length",
"occurrences_regex",
"of",
"offset",
"old",
"omit",
"on",
"one",
"only",
"open",
"or",
"order",
"out",
"outer",
"over",
"overlaps",
"overlay",
"parameter",
"partition",
"pattern",
"per",
"percent",
"percent_rank",
"percentile_cont",
"percentile_disc",
"period",
"portion",
"position",
"position_regex",
"power",
"precedes",
"precision",
"prepare",
"primary",
"procedure",
"ptf",
"range",
"rank",
"reads",
"real",
"recursive",
"ref",
"references",
"referencing",
"regr_avgx",
"regr_avgy",
"regr_count",
"regr_intercept",
"regr_r2",
"regr_slope",
"regr_sxx",
"regr_sxy",
"regr_syy",
"release",
"result",
"return",
"returns",
"revoke",
"right",
"rollback",
"rollup",
"row",
"row_number",
"rows",
"running",
"savepoint",
"scope",
"scroll",
"search",
"second",
"seek",
"select",
"sensitive",
"session_user",
"set",
"show",
"similar",
"sin",
"sinh",
"skip",
"smallint",
"some",
"specific",
"specifictype",
"sql",
"sqlexception",
"sqlstate",
"sqlwarning",
"sqrt",
"start",
"static",
"stddev_pop",
"stddev_samp",
"submultiset",
"subset",
"substring",
"substring_regex",
"succeeds",
"sum",
"symmetric",
"system",
"system_time",
"system_user",
"table",
"tablesample",
"tan",
"tanh",
"then",
"time",
"timestamp",
"timezone_hour",
"timezone_minute",
"to",
"trailing",
"translate",
"translate_regex",
"translation",
"treat",
"trigger",
"trim",
"trim_array",
"true",
"truncate",
"uescape",
"union",
"unique",
"unknown",
"unnest",
"update",
"upper",
"user",
"using",
"value",
"values",
"value_of",
"var_pop",
"var_samp",
"varbinary",
"varchar",
"varying",
"versioning",
"when",
"whenever",
"where",
"width_bucket",
"window",
"with",
"within",
"without",
"year",
];
// these are reserved words we have identified to be functions
// and should only be highlighted in a dispatch-like context
// ie, array_agg(...), etc.
const RESERVED_FUNCTIONS = [
"abs",
"acos",
"array_agg",
"asin",
"atan",
"avg",
"cast",
"ceil",
"ceiling",
"coalesce",
"corr",
"cos",
"cosh",
"count",
"covar_pop",
"covar_samp",
"cume_dist",
"dense_rank",
"deref",
"element",
"exp",
"extract",
"first_value",
"floor",
"json_array",
"json_arrayagg",
"json_exists",
"json_object",
"json_objectagg",
"json_query",
"json_table",
"json_table_primitive",
"json_value",
"lag",
"last_value",
"lead",
"listagg",
"ln",
"log",
"log10",
"lower",
"max",
"min",
"mod",
"nth_value",
"ntile",
"nullif",
"percent_rank",
"percentile_cont",
"percentile_disc",
"position",
"position_regex",
"power",
"rank",
"regr_avgx",
"regr_avgy",
"regr_count",
"regr_intercept",
"regr_r2",
"regr_slope",
"regr_sxx",
"regr_sxy",
"regr_syy",
"row_number",
"sin",
"sinh",
"sqrt",
"stddev_pop",
"stddev_samp",
"substring",
"substring_regex",
"sum",
"tan",
"tanh",
"translate",
"translate_regex",
"treat",
"trim",
"trim_array",
"unnest",
"upper",
"value_of",
"var_pop",
"var_samp",
"width_bucket",
];
// these functions can
const POSSIBLE_WITHOUT_PARENS = [
"current_catalog",
"current_date",
"current_default_transform_group",
"current_path",
"current_role",
"current_schema",
"current_transform_group_for_type",
"current_user",
"session_user",
"system_time",
"system_user",
"current_time",
"localtime",
"current_timestamp",
"localtimestamp"
];
// those exist to boost relevance making these very
// "SQL like" keyword combos worth +1 extra relevance
const COMBOS = [
"create table",
"insert into",
"primary key",
"foreign key",
"not null",
"alter table",
"add constraint",
"grouping sets",
"on overflow",
"character set",
"respect nulls",
"ignore nulls",
"nulls first",
"nulls last",
"depth first",
"breadth first"
];
const FUNCTIONS = RESERVED_FUNCTIONS;
const KEYWORDS = [
...RESERVED_WORDS,
...NON_RESERVED_WORDS
].filter((keyword) => {
return !RESERVED_FUNCTIONS.includes(keyword);
});
const VARIABLE = {
scope: "variable",
match: /@[a-z0-9][a-z0-9_]*/,
};
const OPERATOR = {
scope: "operator",
match: /[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,
relevance: 0,
};
const FUNCTION_CALL = {
match: regex.concat(/\b/, regex.either(...FUNCTIONS), /\s*\(/),
relevance: 0,
keywords: { built_in: FUNCTIONS }
};
// turns a multi-word keyword combo into a regex that doesn't
// care about extra whitespace etc.
// input: "START QUERY"
// output: /\bSTART\s+QUERY\b/
function kws_to_regex(list) {
return regex.concat(
/\b/,
regex.either(...list.map((kw) => {
return kw.replace(/\s+/, "\\s+")
})),
/\b/
)
}
const MULTI_WORD_KEYWORDS = {
scope: "keyword",
match: kws_to_regex(COMBOS),
relevance: 0,
};
// keywords with less than 3 letters are reduced in relevancy
function reduceRelevancy(list, {
exceptions, when
} = {}) {
const qualifyFn = when;
exceptions = exceptions || [];
return list.map((item) => {
if (item.match(/\|\d+$/) || exceptions.includes(item)) {
return item;
} else if (qualifyFn(item)) {
return `${item}|0`;
} else {
return item;
}
});
}
return {
name: 'SQL',
case_insensitive: true,
// does not include {} or HTML tags `</`
illegal: /[{}]|<\//,
keywords: {
$pattern: /\b[\w\.]+/,
keyword:
reduceRelevancy(KEYWORDS, { when: (x) => x.length < 3 }),
literal: LITERALS,
type: TYPES,
built_in: POSSIBLE_WITHOUT_PARENS
},
contains: [
{
scope: "type",
match: kws_to_regex(MULTI_WORD_TYPES)
},
MULTI_WORD_KEYWORDS,
FUNCTION_CALL,
VARIABLE,
STRING,
QUOTED_IDENTIFIER,
hljs.C_NUMBER_MODE,
hljs.C_BLOCK_COMMENT_MODE,
COMMENT_MODE,
OPERATOR
]
};
}
return sql;
})();
hljs.registerLanguage('sql', hljsGrammar);
})();

Some files were not shown because too many files have changed in this diff Show More