Skip to content

Commit

Permalink
Adds two core blocks beyond generic blocks
Browse files Browse the repository at this point in the history
Adds image and quote blocks.
Meant for experimenting with possible parse ideas.

This directly embeds certain core block types into the spec parser. The
benefit is that we have tight coupling and integration of those block
types. The cost is that we have tight coupling and integration of those
block types.

There's a bit more flexibility in integrating this higher-level parser
into the string parser, but I think it may be just as easy to include a
JS pass over the parse tree to convert generic into more specific nodes.

This is pretty verbose now but I could imagine a basic DSL (or an
existing one) to compare tree structure and (choke) load data from HTML

```
[
  'core/image',
  or( !! caption,
    [ [ 'img', { src: [ 'url', types.url ] } ] ],
    [ [ 'figure', [
        [ 'img', { src: [ 'url', types.url ] } ],
        [ 'figcaption', 'caption' ]
      ]
    ] ]
  )
] >>> {
  type: 'core/image',
  url: '...',
  caption: [
    // subtree inside of caption tag, maybe blocks
  ]
}
```

^^^ that's just playing around, but the idea could be used to both load
and generate the serialized data
  • Loading branch information
dmsnell committed Apr 19, 2017
1 parent cdfd596 commit 3adcc9e
Show file tree
Hide file tree
Showing 2 changed files with 314 additions and 194 deletions.
Loading

0 comments on commit 3adcc9e

Please sign in to comment.