https://github.com/seikichi/restructured
Pure JavaScript reStructuredText parser
https://github.com/seikichi/restructured
javascript restructuredtext restructuredtext-parser
Last synced: about 1 year ago
JSON representation
Pure JavaScript reStructuredText parser
- Host: GitHub
- URL: https://github.com/seikichi/restructured
- Owner: seikichi
- Created: 2016-01-02T09:25:59.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2019-03-30T23:51:18.000Z (about 7 years ago)
- Last Synced: 2025-03-24T10:38:50.963Z (about 1 year ago)
- Topics: javascript, restructuredtext, restructuredtext-parser
- Language: JavaScript
- Homepage:
- Size: 1 MB
- Stars: 62
- Watchers: 10
- Forks: 16
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# restructured
[](https://npmjs.org/package/restructured)
[](https://travis-ci.org/seikichi/restructured)
A reStructuredText parser for JavaScript.
## Online Demo
[demo](https://seikichi.github.io/restructured/).
## Example
```bash
> 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.
```javascript
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.
```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
- [x] Document Structure
- [x] Document
- [x] Sections
- [x] Transitions
- [ ] Body Elements
- [x] Paragraphs
- [x] Bullet Lists
- [x] Enumerated Lists
- [x] Definition Lists
- [ ] Field Lists
- [ ] Bibliographic Fields
- [ ] RCS Keywords
- [ ] Option Lists
- [x] Literal Blocks
- [x] Indented Literal Blocks
- [x] Quoted Literal Blocks
- [ ] Line Blocks
- [x] Block Quotes
- [ ] Doctest Blocks
- [ ] Tables
- [ ] Grid Tables
- [ ] Simple Tables
- [ ] List tables
- [ ] CSV 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
- [x] Comments
- [ ] Implicit Hyperlink Targets
- [ ] Inline Markup
- [x] Emphasis
- [x] Strong Emphasis
- [ ] Interpreted Text
- [x] Inline Literals
- [ ] Hyperlink References
- [ ] Embedded URIs and Aliases
- [ ] Inline Internal Targets
- [ ] Footnote References
- [ ] Citation References
- [ ] Substitution References
- [ ] Standalone Hyperlinks
## License
MIT