All Projects → portabletext → Portabletext

portabletext / Portabletext

Licence: mit
Portable Text is a JSON based rich text specification for modern content editing platforms.

Projects that are alternatives of or similar to Portabletext

Render
Go package for easily rendering JSON, XML, binary data, and HTML templates responses.
Stars: ✭ 1,562 (+105.8%)
Mutual labels:  json, text
Ps Webapi
(Migrated from CodePlex) Let PowerShell Script serve or command-line process as WebAPI. PSWebApi is a simple library for building ASP.NET Web APIs (RESTful Services) by PowerShell Scripts or batch/executable files out of the box.
Stars: ✭ 24 (-96.84%)
Mutual labels:  json, text
rulex
A ruby environment for Latex files
Stars: ✭ 14 (-98.16%)
Mutual labels:  text, markup
Rumble
⛈️ Rumble 1.11.0 "Banyan Tree"🌳 for Apache Spark | Run queries on your large-scale, messy JSON-like data (JSON, text, CSV, Parquet, ROOT, AVRO, SVM...) | No install required (just a jar to download) | Declarative Machine Learning and more
Stars: ✭ 58 (-92.36%)
Mutual labels:  json, text
Snodge
Randomly mutate JSON, XML, HTML forms, text and binary data for fuzz testing
Stars: ✭ 121 (-84.06%)
Mutual labels:  json, text
markdown
markdown tools, libraries & scripts
Stars: ✭ 52 (-93.15%)
Mutual labels:  text, markup
awesome-web-styling
Awesome Web Styling with CSS Animation Effects ⭐️
Stars: ✭ 109 (-85.64%)
Mutual labels:  text, markup
Wal2json
JSON output plugin for changeset extraction
Stars: ✭ 705 (-7.11%)
Mutual labels:  json
Adjusttext
A small library for automatically adjustment of text position in matplotlib plots to minimize overlaps.
Stars: ✭ 731 (-3.69%)
Mutual labels:  text
Encoding
Go package containing implementations of efficient encoding, decoding, and validation APIs.
Stars: ✭ 705 (-7.11%)
Mutual labels:  json
Marshal
Marshaling the typeless wild west of [String: Any]
Stars: ✭ 694 (-8.56%)
Mutual labels:  json
Conf
Simple config handling for your app or module
Stars: ✭ 707 (-6.85%)
Mutual labels:  json
Api
姬长信API For Docker 一个基于多种编程语言开源免费不限制提供生活常用,出行服务,开发工具,金融服务,通讯服务和公益大数据的平台.
Stars: ✭ 743 (-2.11%)
Mutual labels:  json
Dsl Json
High performance JVM JSON library
Stars: ✭ 706 (-6.98%)
Mutual labels:  json
Factbook.json
World Factbook Country Profiles in JSON - Free Open Public Domain Data - No API Key Required ;-)
Stars: ✭ 750 (-1.19%)
Mutual labels:  json
Sheetjs
📗 SheetJS Community Edition -- Spreadsheet Data Toolkit
Stars: ✭ 28,479 (+3652.17%)
Mutual labels:  json
Himalaya
JavaScript HTML to JSON Parser
Stars: ✭ 758 (-0.13%)
Mutual labels:  json
Googlephotostakeouthelper
Script that organizes the Google Takeout archive into one big chronological folder
Stars: ✭ 740 (-2.5%)
Mutual labels:  json
Jsonq
A PHP query builder for JSON
Stars: ✭ 729 (-3.95%)
Mutual labels:  json
Wrap
The easy to use Swift JSON encoder
Stars: ✭ 725 (-4.48%)
Mutual labels:  json

Portable Text Logo

Specification for Portable Text

v0.0.1 - WORKING DRAFT

Portable Text is a JSON based rich text specification for modern content editing platforms.

Portable Text is an agnostic abstraction of rich text that can be serialized into pretty much any markup language, be it HTML, Markdown, SSML, XML, etc. It's designed to be efficient for real-time collaborative interfaces, and makes it possible to annotate rich text with additional data structures recursively.

Portable Text is built on the idea of rich text as an array of blocks, themselves arrays of children spans. Each block can have a style and a set of mark definitions, which describe data structures distributed on the children spans. Portable Text also allows for inserting arbitrary data objects in the array, only requiring _type-key. Portable Text also allows for custom content objects in the root array, enabling editing- and rendering environments to mix rich text with custom content types.

Example of a text block with some text annotated with some data:

{
  "style": "normal",
  "_type": "block",
  "children": [
    {
      "_type": "span",
      "marks": ["a-key", "emphasis"],
      "text": "some text"
    }
  ],
  "markDefs": [
    {
      "_key": "a-key",
      "_type": "markType",
      "extraData": "some data"
    }
  ]
}

Anatomy

Portable Text is a recursive composition of arrays and objects. In its simplest form it's an array of objects of a type with an array of children.

Block

A block is what's typically recognized as a section of a text, e.g. a paragraph or a heading.

children (array)

Children is an array of spans or custom inline types that is contained within a block.

_type (string)

All blocks must be of a type. The type makes it possible for a serializer to parse the contents of the block.

style (string)

Style typically describes a visual property for the whole block.

{
  "style": "h1",
  "_type": "block",
  "children": [
    {
      "_type": "span",
      "text": "This is a heading"
    }
  ]
}

markDefs (array)

Mark definitions is an array of objects with a key, type and some data. Mark definitions are tied to spans by adding the referring _key in the marks array.

{
  "markDefs": [
    {
      "_key": "some-random-key",
      "_type": "link",
      "href": "https://portabletext.org"
    },
    {
      "_key": "some-other-random-key",
      "_type": "comment",
      "text": "Change to https://",
      "author": "some-author-id"
    }
  ]
}

listItem

A block can be given the property listItem with a value that describes which kind of list it is. Typically bullet, number, square and so on. The list position is derived from the position the block has in the array and surrounding list items on the same level.

level

Level is used to express visual nesting and hierarchical structures between blocks in the array.

span

A span is the standard way to express inline text within a block

_type (string)

All children must be typed. The type makes it possible for a serializer to parse the contents of the child.

marks (array)

An array of decorators or keys that corresponds with those in the block mark definitions (markDefs). A decorator is a string that describes some arbitrary feature of the span:

[
  {
    "_type": "span",
    "marks": [],
    "text": "This is"
  },
  {
    "_type": "span",
    "marks": ["emphasis"],
    "text": "important"
  }
]

Text (string)

The text contents of the span.

Custom blocks

Custom blocks is typically images, code blocks, tables, video embeds, or any data structure. Custom blocks should be given a _type.

Examples of custom blocks:

{
  "_type": "image",
  "asset": {
    "_ref": "some-asset-reference"
  }
}
{
  "_type": "code",
  "language": "javascript",
  "code": "console.log(\"hello world\");"
}

Serialization

Tools

JavaScript

PHP

C#


Portable Text is presented by Sanity.io

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].