Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Commit

Permalink
change reading syntax highlighting
Browse files Browse the repository at this point in the history
  • Loading branch information
redve authored and redve committed Aug 26, 2023
1 parent a490141 commit 51da95e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
23 changes: 19 additions & 4 deletions paste_bin/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from pydantic import BaseModel, BaseSettings, validator, SecretStr
from pytz import all_timezones_set
import json


class StorageTypes(str, Enum):
Expand Down Expand Up @@ -74,16 +75,30 @@ def ensure_valid(self):


class Settings(BaseSettings):
TIME_ZONE: str = "Europe/London"
NEW_AT_INDEX: bool = False
TIME_ZONE: str = "Europe/Warsaw"
NEW_AT_INDEX: bool = True
ENABLE_PUBLIC_LIST: bool = False
USE_LONG_ID: bool = False
UI_DEFAULT: DefaultsSettings = DefaultsSettings()
BRANDING: BrandSettings = BrandSettings()
STORAGE: StorageSettings = StorageSettings()
CACHE: CacheSettings = CacheSettings()
# SYNTAX_HIGHLIGHTING_LANGUAGES: list[str] = ['c', 'cpp', 'python']
SYNTAX_HIGHLIGHTING_LANGUAGES: list[str] = []
SYNTAX_HIGHLIGHTING_LANGUAGES: list[str] = [
'c',
'cpp',
'python',
'rust',
'java',
'csharp',
'bash',
'json',
'csv'
]

def get_syntax_highlighting_languages(self) -> list[str]:
with open('/app/syntax_highlighting.json') as f:
return list(json.load(f))


MAX_BODY_SIZE: int = 2*(10**6)
LOG_LEVEL: str = "WARNING"
Expand Down
2 changes: 1 addition & 1 deletion paste_bin/core/renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def get_highlighter_names() -> Generator[str, None, None]:
:yield: Each highlighter name
"""
try:
allowed_highlighters = get_settings().SYNTAX_HIGHLIGHTING_LANGUAGES
allowed_highlighters = get_settings().get_syntax_highlighting_languages()
except AttributeError:
allowed_highlighters = []
if allowed_highlighters is not None and len(allowed_highlighters) > 0:
Expand Down

0 comments on commit 51da95e

Please sign in to comment.