File tree 3 files changed +26
-12
lines changed
3 files changed +26
-12
lines changed Original file line number Diff line number Diff line change
1
+ import { Button } from 'rebass'
2
+
1
3
# AST
2
4
5
+ export const AST_EXPLORER_LINK = 'https://astexplorer.net/#/gist/2befce6edce1475eb4bbec001356b222/35997d3b44347daabad8dd1a107adc22dd873de2 '
6
+
7
+ <Button is =" a " href ={AST_EXPLORER_LINK} >Explore the AST</Button >
8
+
3
9
This document defines two syntax trees:
4
10
5
11
* [ MDXAST] [ ] , a superset of [ mdast] [ ] , to represent markdown with embedded JSX
Original file line number Diff line number Diff line change @@ -156,4 +156,5 @@ following commands:
156
156
[ next ] : https://github.com/zeit/next.js
157
157
158
158
[ context ] : https://reactjs.org/docs/context.html
159
+
159
160
[ context-caveats ] : https://reactjs.org/docs/context.html#caveats
Original file line number Diff line number Diff line change @@ -27,23 +27,30 @@ function mdx(_options) {
27
27
}
28
28
29
29
function attachParser ( parser ) {
30
- const tokenizers = parser . prototype . blockTokenizers
31
- const blocks = parser . prototype . blockMethods
32
- const html = tokenizers . html
30
+ const blocks = parser . prototype . blockTokenizers
31
+ const inlines = parser . prototype . inlineTokenizers
32
+ const methods = parser . prototype . blockMethods
33
33
34
- tokenizers . esSyntax = tokenizeEsSyntax
35
- tokenizers . html = tokenizeJsx
34
+ blocks . esSyntax = tokenizeEsSyntax
35
+ blocks . html = wrap ( blocks . html )
36
+ inlines . html = wrap ( inlines . html )
36
37
37
- blocks . splice ( blocks . indexOf ( 'paragraph' ) , 0 , 'esSyntax' )
38
+ methods . splice ( methods . indexOf ( 'paragraph' ) , 0 , 'esSyntax' )
38
39
39
- function tokenizeJsx ( ) {
40
- const node = html . apply ( this , arguments )
40
+ function wrap ( original ) {
41
+ tokenizeJsx . locator = original . locator
41
42
42
- if ( node ) {
43
- node . type = 'jsx'
44
- }
43
+ return tokenizeJsx
44
+
45
+ function tokenizeJsx ( ) {
46
+ const node = original . apply ( this , arguments )
45
47
46
- return node
48
+ if ( node ) {
49
+ node . type = 'jsx'
50
+ }
51
+
52
+ return node
53
+ }
47
54
}
48
55
}
49
56
You can’t perform that action at this time.
0 commit comments