跳转到主要内容

JSON Schema的Pygments词法分析器

项目描述

PyPI version Supported Python versions Build status

简介

jsonschema-lexer提供了一个通过Pygments对JSON Schema文档进行语法高亮的词法分析器。

用法

安装后,您可以在Python代码中使用它来高亮JSON Schema文档。

以下是一个简单示例

from jsonschema_lexer import JSONSchemaLexer

from rich.console import Console
from rich.syntax import Syntax

console = Console()

code = """
{
  "$schema": "https://json-schema.fullstack.org.cn/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)

项目详情


下载文件

下载适用于您平台文件的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源分布

jsonschema_lexer-0.2.1.tar.gz (11.3 kB 查看散列值)

上传时间:

构建的发行版

jsonschema_lexer-0.2.1-py3-none-any.whl (9.7 kB 查看哈希值)

上传于 Python 3

支持