Link Search Menu Expand Document

Overview

  • interface for processing text using syntax trees
  • syntax trees are fed to plugins
  • plugins, take these trees and inspect and modify them
  • To get from that back to text, there is a compiler.
  • This is the process of a processor.
| ........................ process ........................... |
| .......... parse ... | ... run ... | ... stringify ..........|

          +--------+                     +----------+
Input ->- | Parser | ->- Syntax Tree ->- | Compiler | ->- Output
          +--------+          |          +----------+
                              X
                              |
                       +--------------+
                       | Transformers |

Parts

Processor

  • Every processor implements another processor.
  • To create a processor, call another processor. The new processor is configured to work the same as its ancestor. But when the descendant processor is configured in the future it does not affect the ancestral processor.

Nodes

  • unist nodes
  • A node is a plain JavaScript objects with a type field
  • The semantics of nodes and format of syntax trees is defined by other projects.
  • There are several utilities for working with nodes.
    • hast — HTML
    • mdast — Markdown
    • nlcst — Natural language
    • xast — XML

File

When processing a document, metadata is often gathered about that document. vfile is a virtual file format that stores data, metadata, and messages about files for unified and its plugins.

Integrations

unified can integrate with the file system with unified-engine. CLI apps can be created with unified-args, Gulp plugins with unified-engine-gulp, and Atom Linters with unified-engine-atom.

Processor Modes

Bridge mode transforms the syntax tree from one format (origin) to another (destination). Another processor runs on the destination tree. Finally, the original processor continues transforming the origin tree.

Mutate mode also transforms the syntax tree from one format to another. But the original processor continues transforming the destination tree.


init

Summary

Flows

Main

export = unified().freeze

unified {
    $processor.data = data
    return processor
}

Ref

Diff Links


markdown liknk

[link](normal-link)
{
          "children": Array [
            Object {
              "position": Position {
                "end": Object {
                  "column": 6,
                  "line": 2,
                  "offset": 6,
                },
                "indent": Array [],
                "start": Object {
                  "column": 2,
                  "line": 2,
                  "offset": 2,
                },
              },
              "type": "text",
              "value": "link",
            },
          ],
          "position": Position {
            "end": Object {
              "column": 20,
              "line": 2,
              "offset": 20,
            },
            "indent": Array [],
            "start": Object {
              "column": 1,
              "line": 2,
              "offset": 1,
            },
          },
          "title": null,
          "type": "link",
          "url": "normal-link",
        }
{
  type: "image",
  title: null,
  url: "link-path.jpg",
  alt: "link-alt",
  position: {
    start: {
      line: 1,
      column: 1,
      offset: 0,
    },
    end: {
      line: 1,
      column: 27,
      offset: 26,
    },
    indent: [
    ],
  },
}
- [[foo-wiki-link]]
{
"data": Object {
  "alias": "foo-wiki-link",
  "exists": false,
  "hChildren": Array [
    Object {
      "type": "text",
      "value": "foo-wiki-link",
    },
  ],
  "hName": "a",
  "hProperties": Object {
    "className": "internal new",
    "href": "#/page/foo-wiki-link",
  },
  "permalink": "foo-wiki-link",
}
- [[label|foo-wiki-link]]
{
"data": Object {
  "alias": "foo-wiki-link",
  "exists": false,
  "hChildren": Array [
    Object {
      "type": "text",
      "value": "foo-wiki-link",
    },
  ],
  "hName": "a",
  "hProperties": Object {
    "className": "internal new",
    "href": "#/page/label",
  },
  "permalink": "label",
},
"type": "wikiLink",
"value": "label",
}

results

61 results - 1 file

engine-server • src/topics/markdown/__snapshots__/markdown.spec.ts.snap:
    22:           "type": "text",
    40:       "type": "heading",
    58:           "type": "text",
    75:       "type": "paragraph",
    93:           "type": "text",
   110:       "type": "paragraph",
   128:           "type": "text",
   146:       "type": "heading",
   164:           "type": "text",
   181:       "type": "paragraph",
   199:           "type": "text",
   217:       "type": "heading",
   235:           "type": "text",
   252:       "type": "paragraph",
   275:                   "type": "text",
   292:               "type": "paragraph",
   309:           "type": "listItem",
   330:                   "type": "text",
   347:               "type": "paragraph",
   364:           "type": "listItem",
   385:       "type": "list",
   408:                   "type": "text",
   425:               "type": "paragraph",
   442:           "type": "listItem",
   463:                   "type": "text",
   480:               "type": "paragraph",
   497:           "type": "listItem",
   518:       "type": "list",
   539:       "type": "code",
   558:           "type": "inlineCode",
   575:       "type": "paragraph",
   600:                       "type": "text",
   618:                   "type": "link",
   635:               "type": "paragraph",
   652:           "type": "listItem",
   675:                   "type": "image",
   692:               "type": "paragraph",
   709:           "type": "listItem",
   730:                   "type": "text",
   749:                       "type": "text",
   768:                   "referenceType": "shortcut",
   769:                   "type": "linkReference",
   785:                   "type": "text",
   802:               "type": "paragraph",
   819:           "type": "listItem",
   840:                   "type": "text",
   859:                       "type": "text",
   878:                   "referenceType": "shortcut",
   879:                   "type": "linkReference",
   895:                   "type": "text",
   912:               "type": "paragraph",
   929:           "type": "listItem",
   950:                   "type": "text",
   969:                       "type": "text",
   988:                   "referenceType": "shortcut",
   989:                   "type": "linkReference",
  1005:                   "type": "text",
  1022:               "type": "paragraph",
  1039:           "type": "listItem",
  1063:       "type": "list",
  1078:   "type": "root",


Copyright © 2020 Thence LLC