Skip to content

Commit

Permalink
input: Add experimental rich-text support (#315)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bdarcus authored Jul 15, 2020
1 parent 892334e commit 4056538
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 12 deletions.
34 changes: 22 additions & 12 deletions schemas/input/csl-data.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -344,7 +344,7 @@
"type": "string"
},
"original-title": {
"type": "string"
"$ref": "#/definitions/title-string"
},
"page": {
"type": ["string", "number"]
Expand All @@ -356,7 +356,7 @@
"type": ["string", "number"]
},
"part-title": {
"type": "string"
"$ref": "#/definitions/title-string"
},
"PMCID": {
"type": "string"
Expand All @@ -377,7 +377,7 @@
"type": "string"
},
"reviewed-title": {
"type": "string"
"$ref": "#/definitions/title-string"
},
"scale": {
"type": "string"
Expand All @@ -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"
Expand Down Expand Up @@ -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.",
Expand Down
54 changes: 54 additions & 0 deletions schemas/input/csl-rich-text.yaml
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit 4056538

Please sign in to comment.