A Pygments lexer for JSON Schema
Project description
Introduction
jsonschema-lexer is a Python package that provides a JSON Schema lexer for syntax highlighting JSON Schema documents based on the 2020-12 dialect. It utilizes Pygments, a syntax highlighting library, to tokenize JSON Schema documents according to the JSON Schema specification.
Usage
Once installed, you can use it in your Python code to highlight JSON Schema documents.
Here’s a simple example:
# Import the JSONSchemaLexer class from the package
from jsonschema_lexer.lexer import JSONSchemaLexer
from rich.console import Console
from rich.syntax import Syntax
console = Console()
code = """
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://example.com/product.schema.json",
"title": "Product",
"description": "A product from Acme's catalog",
"type": "object",
"properties": {
"productId": {
"description": "The unique identifier for a product",
"type": "integer"
},
"productName": {
"description": "Name of the product",
"type": "string"
}
}
}
"""
syntax = Syntax(code, lexer=JSONSchemaLexer(), background_color="default", word_wrap=True)
console.print(syntax)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
jsonschema_lexer-0.1.0.tar.gz
(8.7 kB
view hashes)
Built Distribution
Close
Hashes for jsonschema_lexer-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e600fddae61043fa6f53c78201bed3f9449b0bc2b36f94d8037ae6fab794958a |
|
MD5 | 0244841abfdd52edd40e24fe20f1ae18 |
|
BLAKE2b-256 | 6bae646398076abea9d42089d41bd3002cd0c6dfe53a97006f77e59e562a3b61 |