Comments (5)
@BlackGlory From which AST are they missing? Do you find them missing in the result from the parser (orga
), or in results from one of the other packages?
from orgajs.
@GuiltyDolphin The descendant types defined in the AST definition file types.ts
are missing.
The children
type of these nodes is inherited from UnistParent
, which is ChildNode[]
, and you can use Document
as children
, this is meaningless:
const document: Document = {
type: 'document'
, children: []
, properties: {}
}
const item: ListItem = {
type: 'list.item'
, indent: 2
, children: [document]
}
from orgajs.
@BlackGlory Yup, it's pretty consistent throughout (in 2.4.9). In #104 I've updated some of the children types (and will continue to update them) so that they are more aligned with the specification.
from orgajs.
Rewritten an AST type definition for my project based on orga v2.4.9, if someone needs it:
import { Literal as UnistLiteral, Node, Parent } from 'unist'
export { Node, Parent } from 'unist'
interface Child {
parent?: Parent
}
type Primitive = string | number | boolean
interface Attributes {
[key: string]: Primitive | Record<string, Primitive>
}
interface Attributed {
attributes: Attributes
}
interface Timestamp {
date: Date
end?: Date
}
interface Literal extends UnistLiteral {
value: string
}
export type DocumentContent =
| UniversalBlockContent
| Section
| Footnote
export type SectionContent =
| UniversalBlockContent
| Section
| Headline
| Planning
export type TableContent = TableRow | TableRule
export type HeadlineContent =
| Stars
| Todo
| Priority
| Tags
| UniversalInlineContent
export type ListContent = List | ListItem
export type ListItemContent =
| ListItemBullet
| ListItemCheckbox
| UniversalInlineContent
export type UniversalBlockContent =
| Paragraph
| Block
| Drawer
| List
| Table
| HorizontalRule
export type UniversalInlineContent =
| StyledText
| Link
| FootnoteReference
| Newline
export interface Document extends Child, Parent {
type: 'document'
properties: Record<string, string>
children: DocumentContent[]
}
export interface Section extends Child, Parent {
type: 'section'
level: number
properties: Record<string, string>
children: SectionContent[]
}
export interface Headline extends Child, Parent {
type: 'headline'
level: number
actionable: boolean
priority?: string
tags?: string[]
content: string
children: HeadlineContent[]
}
export interface Footnote extends Child, Parent {
type: 'footnote'
label: string
children: UniversalBlockContent[]
}
export interface FootnoteReference extends Child, Parent {
type: 'footnote.reference'
label: string
children: UniversalInlineContent[]
}
export interface Block extends Literal, Attributed {
type: 'block'
name: string
params: string[]
value: string
}
export interface Drawer extends Literal {
type: 'drawer'
name: string
value: string
}
export interface Planning extends Node {
type: 'planning'
keyword: string
timestamp: Timestamp
}
export interface List extends Child, Parent, Attributed {
type: 'list'
indent: number
ordered: boolean
children: ListContent[]
}
export interface ListItem extends Child, Parent {
type: 'list.item'
indent: number
tag?: string
children: ListItemContent[]
}
export interface Table extends Child, Parent, Attributed {
type: 'table'
children: TableContent[]
}
export interface TableRow extends Child, Parent {
type: 'table.row'
children: TableCell[]
}
export interface TableCell extends Child, Parent {
type: 'table.cell'
children: UniversalInlineContent[]
}
export interface TableRule extends Node {
type: 'table.hr'
}
export interface Paragraph extends Child, Parent, Attributed {
type: 'paragraph'
children: UniversalInlineContent[]
}
export interface HorizontalRule extends Node {
type: 'hr'
}
export interface Newline extends Node {
type: 'newline'
}
export interface StyledText extends Literal {
type: 'text.plain'
| 'text.bold'
| 'text.verbatim'
| 'text.italic'
| 'text.strikeThrough'
| 'text.underline'
| 'text.code'
}
export interface Link extends Literal {
type: 'link'
protocol: string
description?: string
value: string
search?: string | number
}
export interface Stars extends Node {
type: 'stars'
level: number
}
export interface Todo extends Node {
type: 'todo'
keyword: string
actionable: boolean
}
export interface Priority extends Literal {
type: 'priority'
value: string
}
export interface Tags extends Node {
type: 'tags'
tags: string[]
}
export interface ListItemCheckbox extends Node {
type: 'list.item.checkbox'
checked: boolean
}
export interface ListItemBullet extends Node {
type: 'list.item.bullet'
ordered: boolean
indent: number
}
from orgajs.
v3.0.0
import { Node, Parent } from 'unist'
export { Node, Parent } from 'unist'
type Primitive = string | number | boolean
interface Attributes {
[key: string]: Primitive | Record<string, Primitive>
}
interface Attributed {
attributes: Attributes
}
interface Timestamp {
date: Date
end?: Date
}
export type DocumentContent =
| UniversalBlockContent
| Section
| Footnote
export type SectionContent =
| UniversalBlockContent
| Section
| Headline
| Planning
export type TableContent = TableRow | TableRule
export type TableRowContent = TableColumnSeparator | TableCell
export type HeadlineContent =
| Stars
| Todo
| Priority
| Tags
| UniversalInlineContent
export type ListContent = List | ListItem
export type ListItemContent =
| ListItemBullet
| ListItemTag
| ListItemCheckbox
| UniversalInlineContent
export type LinkContent =
| UniversalInlineContent
| Opening
| Closing
| LinkPath
export type PlanningContent =
| PlanningKeyword
| PlanningTimestamp
export type FootnoteReferenceContent =
| FootnoteLabel
| Opening
| Closing
| UniversalInlineContent
export type FootnoteContent =
| FootnoteLabel
| UniversalBlockContent
export type DrawerContent =
| DrawerBegin
| DrawerEnd
| UniversalInlineContent
export type UniversalBlockContent =
| Paragraph
| Block
| Drawer
| List
| Table
| HorizontalRule
export type UniversalInlineContent =
| Text
| Link
| FootnoteReference
| Newline
export interface Document extends Parent {
type: 'document'
properties: Record<string, string>
children: DocumentContent[]
}
export interface Section extends Parent {
type: 'section'
level: number
properties: Record<string, string>
children: SectionContent[]
}
export interface Headline extends Parent {
type: 'headline'
level: number
actionable: boolean
priority?: string
tags?: string[]
children: HeadlineContent[]
}
export interface Footnote extends Parent {
type: 'footnote'
label: string
children: FootnoteContent[]
}
export interface FootnoteReference extends Parent {
type: 'footnote.reference'
label?: string
children: FootnoteReferenceContent[]
}
export interface Block extends Node, Attributed {
type: 'block'
name: string
params: string[]
value: string
}
export interface Drawer extends Node, Parent {
type: 'drawer'
name: string
value: string
children: DrawerContent[]
}
export interface DrawerBegin {
type: 'drawer.begin'
name: string
}
export interface DrawerEnd {
type: 'drawer.end'
}
export interface Planning extends Node, Parent {
type: 'planning'
keyword: string
timestamp: Timestamp
children: PlanningContent[]
}
export interface List extends Parent, Attributed {
type: 'list'
indent: number
ordered: boolean
children: ListContent[]
}
export interface ListItem extends Parent {
type: 'list.item'
indent: number
tag?: string
children: ListItemContent[]
}
export interface Table extends Parent, Attributed {
type: 'table'
children: TableContent[]
}
export interface TableRow extends Parent {
type: 'table.row'
children: TableRowContent[]
}
export interface TableCell extends Parent {
type: 'table.cell'
children: UniversalInlineContent[]
}
export interface TableRule extends Node {
type: 'table.hr'
}
export interface TableColumnSeparator extends Node {
type: 'table.columnSeparator'
}
export interface Paragraph extends Parent, Attributed {
type: 'paragraph'
children: UniversalInlineContent[]
}
export interface HorizontalRule extends Node {
type: 'hr'
}
export interface Newline extends Node {
type: 'newline'
}
export interface Text extends Node {
type: 'text'
style?: 'bold'
| 'verbatim'
| 'italic'
| 'strikeThrough'
| 'underline'
| 'code'
value: string
}
export interface Link extends Parent {
type: 'link'
path: {
protocol: string
value: string
search?: string | number
}
children: LinkContent[]
}
export interface LinkPath extends Node {
type: 'link.path'
protocol: string
value: string
search?: string | number
}
export interface Opening extends Node {
type: 'opening'
element: string
}
export interface Closing extends Node {
type: 'closing'
element: string
}
export interface Stars extends Node {
type: 'stars'
level: number
}
export interface Todo extends Node {
type: 'todo'
keyword: string
actionable: boolean
}
export interface Priority extends Node {
type: 'priority'
value: string
}
export interface Tags extends Node {
type: 'tags'
tags: string[]
}
export interface ListItemCheckbox extends Node {
type: 'list.item.checkbox'
checked: boolean
}
export interface ListItemBullet extends Node {
type: 'list.item.bullet'
ordered: boolean
indent: number
}
export interface ListItemTag extends Node {
type: 'list.item.tag'
value: string
}
export interface FootnoteLabel extends Node {
type: 'footnote.label'
label: string
}
export interface PlanningKeyword extends Node {
type: 'planning.keyword'
value: string
}
export interface PlanningTimestamp extends Node {
type: 'planning.timestamp'
value: Timestamp
}
from orgajs.
Related Issues (20)
- 📦 About ESM HOT 1
- How to use OrgaJS with Next? HOT 2
- orga v2.5.0 has breaking changes HOT 2
- [v2.5.0] Missing a section node in AST
- Provide instructions for upgrading HOT 2
- The ASTs of CRLF and LF files are different HOT 1
- Cannot find module ./dist/gatsby-node when running examples HOT 3
- mathjax HOT 4
- Ka/Mathjax support for Next HOT 1
- orga v3.2.1 should be v4 HOT 2
- gatsby-plugin-orga with page-creator React is not defined HOT 1
- Document data does not escape single quotes for JSX.
- org file properties ignored HOT 1
- Project Status
- Destructuring and prototype with ESM builds
- `<<a>>` and `[[a]]` not supported.
- Basic TypeScript example using `reorg-rehype` fails to compile
- Comparison with uniorg
- fix the parser bug
- Get HTML from Editor
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from orgajs.