0.0.11 • Published 10 years ago

restructured v0.0.11

Weekly downloads
3,737
License
MIT
Repository
github
Last release
10 years ago

restructured

NPM Build Status

A reStructuredText parser for JavaScript.

Online Demo

demo.

Example

> npm install -g restructured
> echo 'Hello, world' | restructured | jq
{
  "type": "document",
  "children": [
    {
      "type": "paragraph",
      "children": [
        {
          "type": "text",
          "value": "Hello, world\n"
        }
      ]
    }
  ]
}

Consider the following script.

import restructured from 'restructured';

const parsed = restructured.parse(`
=====
Title
=====

Subtitle
--------

This is a paragraph.

- This is item 1
- This is item 2
`);

console.log(JSON.stringify(parsed));

The above script outputs the following JSON.

{
  "type": "document",
  "children": [
    {
      "type": "section",
      "depth": 1,
      "children": [
        {
          "type": "title",
          "children": [
            {
              "type": "text",
              "value": "Title"
            }
          ]
        },
        {
          "type": "section",
          "depth": 2,
          "children": [
            {
              "type": "title",
              "children": [
                {
                  "type": "text",
                  "value": "Subtitle"
                }
              ]
            },
            {
              "type": "paragraph",
              "children": [
                {
                  "type": "text",
                  "value": "This is a paragraph.\n"
                }
              ]
            },
            {
              "type": "bullet_list",
              "bullet": "-",
              "children": [
                {
                  "type": "list_item",
                  "children": [
                    {
                      "type": "paragraph",
                      "children": [
                        {
                          "type": "text",
                          "value": "This is item 1\n"
                        }
                      ]
                    }
                  ]
                },
                {
                  "type": "list_item",
                  "children": [
                    {
                      "type": "paragraph",
                      "children": [
                        {
                          "type": "text",
                          "value": "This is item 2\n"
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}

Progress

  • Document Structure
    • Document
    • Sections
    • Transitions
  • Body Elements
    • Paragraphs
    • Bullet Lists
    • Enumerated Lists
    • Definition Lists
    • Field Lists
      • Bibliographic Fields
      • RCS Keywords
    • Option Lists
    • Literal Blocks
      • Indented Literal Blocks
      • Quoted Literal Blocks
    • Line Blocks
    • Block Quotes
    • Doctest Blocks
    • Tables
      • Grid Tables
      • Simple Tables
    • Explicit Markup Blocks
      • Footnotes
        • Auto-Numbered Footnotes
        • Auto-Symbol Footnotes
        • Mixed Manual and Auto-Numbered Footnotes
      • Citations
      • Hyperlink Targets
        • Anonymous Hyperlinks
      • Directives
      • Substitution Definitions
      • Comments
  • Implicit Hyperlink Targets
  • Inline Markup
    • Emphasis
    • Strong Emphasis
    • Interpreted Text
    • Inline Literals
    • Hyperlink References
      • Embedded URIs and Aliases
    • Inline Internal Targets
    • Footnote References
    • Citation References
    • Substitution References
    • Standalone Hyperlinks

License

MIT

0.0.11

10 years ago

0.0.10

10 years ago

0.0.9

10 years ago

0.0.8

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago

0.0.0

10 years ago