0.12.18 • Published 1 year ago

@curvenote/schema v0.12.18

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

@curvenote/schema

@curvenote/schema on npm MIT License CI

Schema for interactive scientific writing, with translations to MyST flavoured markdown, LaTeX, and HTML.

@curvenote/schema in curvenote.com

Overview & Goals

  • Provide a typed schema for writing reactive scientific documents using @curvenote/components
    • Uses Web Components in the rendered HTML output for non-standard components
    • Uses standard html for all other compnents, with no styling enforced
  • Interoperability with CommonMark markdown and MyST
    • Through fromMarkdown and toMarkdown methods
  • Provide components for WYSIWYG editing of reactive documents

Choices

  • The internal representation for the library is a ProseMirror Document structure (that can be rendered as JSON)
  • markdown-it is used parse and tokenize markdown content

Schema

The schema has Nodes and Marks where Nodes are basically a block of content (paragraph, code, etc.), and Marks are inline modifications to the content (bold, emphasis, links, etc.). See the ProseMirror docs for a visual explanation.

Overview of Nodes

Overview of Marks

  • link
  • code
  • em
  • strong
  • superscript
  • subscript
  • strikethrough
  • underline
  • abbr

Simple Example

This moves from markdown --> JSON --> HTML. The JSON is the intermediate representation for @curvenote/editor.

import { Schema, nodes, marks, fromMarkdown, toHTML } from '@curvenote/schema';
import { JSDOM } from 'jsdom';

const schema = new Schema({ nodes, marks });

const content = '# Hello `@curvenote/schema`!';
const doc = fromMarkdown(content, schema);

console.log(doc.toJSON());
>> {
    "type": "doc",
    "content": [
      {
        "type": "heading",
        "attrs": { "level": 1 },
        "content": [
          { "type": "text", "text": "Hello " },
          {
            "type": "text",
            "marks": [ { "type": "code" } ],
            "text": "@curvenote/schema"
          },
          { "type": "text", "text": "!" }
        ]
      }
    ]
  }

// Assuming we are in node, just use `document` if in a browser!
const { document } = new JSDOM('').window;

// Now move the document back out to html
const html = toHTML(doc, schema, document);

console.log(html);
>> "<h1>Hello <code>@curvenote/schema</code>!</h1>"

Roadmap

  • Integrate other @curvenote/components as nodes
  • Improve equation and start to go to/from various MyST syntax for this
  • Add figure properties (name, width, caption etc.)
  • Provide citations, probably bring in a bibtex parser
    • Introduce citation and reference component to curvenote/components or article
  • Add overlaping roles/directives with MyST (e.g. see executablebooks/meta#70) for pointers
    • Add the necessary pieces to curvenote/components that are not basic html (MyST uses sphinx for the heavy lifting, cross-refs etc.)
  • Provide other sereializers from the document strucutre (e.g. latex or simple html without curvenote/components, possibly idyll)

See also:

  • Idyll Lang has a different markdown-like serialization with very similar base components to curvenote - see curvenote/article#8 for a comparison.
0.12.18

1 year ago

0.12.16

2 years ago

0.12.17

2 years ago

0.12.16-rc.1

2 years ago

0.12.14

2 years ago

0.12.15

2 years ago

0.12.15-rc.0

2 years ago

0.12.10

2 years ago

0.12.11

2 years ago

0.12.12

2 years ago

0.12.13

2 years ago

0.12.7

2 years ago

0.12.8

2 years ago

0.12.9

2 years ago

0.12.6

2 years ago

0.12.0

2 years ago

0.12.1

2 years ago

0.12.2

2 years ago

0.12.3

2 years ago

0.12.4

2 years ago

0.12.5

2 years ago

0.11.12

2 years ago

0.11.13

2 years ago

0.11.8

2 years ago

0.11.9

2 years ago

0.11.0

2 years ago

0.11.1

2 years ago

0.11.2

2 years ago

0.11.3

2 years ago

0.11.4

2 years ago

0.11.5

2 years ago

0.11.6

2 years ago

0.11.7

2 years ago

0.9.3

2 years ago

0.11.10

2 years ago

0.10.0

2 years ago

0.11.11

2 years ago

0.9.0

2 years ago

0.8.1

2 years ago

0.9.2

2 years ago

0.9.1

2 years ago

0.8.0

3 years ago

0.7.2

3 years ago

0.7.1

3 years ago

0.7.0

3 years ago

0.6.1

3 years ago

0.6.0

3 years ago

0.5.5

3 years ago

0.5.4

3 years ago

0.5.3

3 years ago

0.5.0

3 years ago

0.5.2

3 years ago

0.5.1

3 years ago

0.4.1

3 years ago

0.4.0

3 years ago

0.4.3

3 years ago

0.4.2

3 years ago

0.3.9

3 years ago

0.3.0

3 years ago

0.3.6

3 years ago

0.2.7

3 years ago

0.3.5

3 years ago

0.2.6

3 years ago

0.3.8

3 years ago

0.3.7

3 years ago

0.2.8

3 years ago

0.3.2

3 years ago

0.3.1

3 years ago

0.3.4

3 years ago

0.3.3

3 years ago

0.2.5

3 years ago

0.2.3

3 years ago

0.2.2

3 years ago

0.2.4

3 years ago

0.2.1

3 years ago