From 40565384065d0e8a9e60f6ee8e27d25d8007b8b9 Mon Sep 17 00:00:00 2001 From: Bruce D'Arcus Date: Wed, 15 Jul 2020 10:21:50 -0400 Subject: [PATCH] input: Add experimental rich-text support (#315) This adds an experimental csl-rich-text.yaml schema that defines a structure for rich-text formatting in JSON. Also adds a definition for rich-text variables, and title-string definitions that uses that variable, and then redefines all title and other fields to use these definitions. So it will be easy to merge the rich text support in the future. Addresses in part #278 --- schemas/input/csl-data.json | 34 +++++++++++++------- schemas/input/csl-rich-text.yaml | 54 ++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 12 deletions(-) create mode 100644 schemas/input/csl-rich-text.yaml diff --git a/schemas/input/csl-data.json b/schemas/input/csl-data.json index 0e34f1de..0875f8ed 100644 --- a/schemas/input/csl-data.json +++ b/schemas/input/csl-data.json @@ -221,10 +221,10 @@ "$ref": "#/definitions/date-variable" }, "abstract": { - "type": "string" + "$ref": "#/definitions/rich-text-string" }, "annote": { - "type": "string" + "$ref": "#/definitions/rich-text-string" }, "archive": { "type": "string" @@ -257,13 +257,13 @@ "type": ["string", "number"] }, "collection-title": { - "type": "string" + "$ref": "#/definitions/title-string" }, "container-title": { - "type": "string" + "$ref": "#/definitions/title-string" }, "container-title-short": { - "type": "string" + "$ref": "#/definitions/title-string" }, "dimensions": { "type": "string" @@ -344,7 +344,7 @@ "type": "string" }, "original-title": { - "type": "string" + "$ref": "#/definitions/title-string" }, "page": { "type": ["string", "number"] @@ -356,7 +356,7 @@ "type": ["string", "number"] }, "part-title": { - "type": "string" + "$ref": "#/definitions/title-string" }, "PMCID": { "type": "string" @@ -377,7 +377,7 @@ "type": "string" }, "reviewed-title": { - "type": "string" + "$ref": "#/definitions/title-string" }, "scale": { "type": "string" @@ -395,16 +395,16 @@ "type": ["string", "number"] }, "title": { - "type": "string" + "$ref": "#/definitions/title-string" }, "title-short": { - "type": "string" + "$ref": "#/definitions/title-string" }, "translated-title": { - "type": "string" + "$ref": "#/definitions/title-string" }, "translated-title-short": { - "type": "string" + "$ref": "#/definitions/title-string" }, "URL": { "type": "string" @@ -437,6 +437,16 @@ "additionalProperties": false }, "definitions": { + "rich-text-string": { + "title": "Rich Text String", + "description": "A string that may include sub-string formatting for bold, italic, subscript, superscript, math, etc. The accompanying `csl-rich-text.yaml` schema defines experimental support for this in CSL JSON input.", + "type": "string" + }, + "title-string": { + "title": "Title String", + "description": "Titles are a primary example of rich text strings in CSL.", + "$ref": "#definitions/rich-text-string" + }, "edtf-string": { "title": "EDTF date string", "description": "CSL input supports EDTF, levels 0 and 1.", diff --git a/schemas/input/csl-rich-text.yaml b/schemas/input/csl-rich-text.yaml new file mode 100644 index 00000000..a7984d94 --- /dev/null +++ b/schemas/input/csl-rich-text.yaml @@ -0,0 +1,54 @@ +--- +description: JSON schema for CSL input rich text representation +"$schema": http://json-schema.org/draft-07/schema# +"$id": https://resource.citationstyles.org/schema/latest/input/json/csl-rich-text.json +definitions: + rich-text-content: + title: Rich Text Content + description: Rich text content can be represented as an array of strings and formatted object strings. + examples: + - title: + - A title with a + - quote: quoted string. + - title: + - A title with tex math + - math-tex: x=y^2 + - title: + - A title with mathml + - math-ml: x=y^2 + oneOf: + - "$ref": "#/definitions/rich-text" + - type: string + rich-text: + type: array + items: + anyOf: + - title: Unformatted Sub-String + type: string + - bold: + title: Bold Text + "#ref": "#/definitions/rich-text-content" + - code: + title: Code/Verbatim Text + "#ref": "#/definitions/rich-text-content" + - italic: + title: Italicized Text + "#ref": "#/definitions/rich-text-content" + - math-ml: + title: MathML + "#ref": "#/definitions/rich-text-content" + - math-tex: + title: Math-TeX + "#ref": "#/definitions/rich-text-content" + - preserve: + title: Preserve Case Text + "#ref": "#/definitions/rich-text-content" + - quote: + title: Quote + "#ref": "#/definitions/rich-text-content" + - sc: + title: Small-Cap Text + "#ref": "#/definitions/rich-text-content" + - strike: + title: Strike-Through Text + "#ref": "#/definitions/rich-text-content"