Skip to content
Snippets Groups Projects
Verified Commit 5c53eefb authored by Dan Allen's avatar Dan Allen
Browse files

align expected output with latest ASG schema

- condense location data to start/end tuple
- remove object wrapper around inlines in value of title and principal properties
- remove blocks property when value is empty
parent e675d266
No related branches found
No related tags found
No related merge requests found
Pipeline #17581 waiting for manual action
...@@ -14,7 +14,7 @@ export function stringifyASG (asg) { ...@@ -14,7 +14,7 @@ export function stringifyASG (asg) {
return JSON.stringify(asg, (key, val) => (key === 'location' ? locations.push(val) - 1 : val), 2).replace( return JSON.stringify(asg, (key, val) => (key === 'location' ? locations.push(val) - 1 : val), 2).replace(
/("location": )(\d+)/g, /("location": )(\d+)/g,
(_, key, idx) => { (_, key, idx) => {
return key + JSON.stringify(locations[Number(idx)], null, 2).replace(/\n */g, ' ') return key + JSON.stringify(locations[Number(idx)], null, 2).replace(/\n */g, ' ').replace(/(\[) | (\])/g, '$1$2')
} }
) )
} }
......
...@@ -3,15 +3,15 @@ ...@@ -3,15 +3,15 @@
"type": "block", "type": "block",
"attributes": { "icons": "font", "toc": "" }, "attributes": { "icons": "font", "toc": "" },
"header": { "header": {
"title": { "title": [
"inlines": [{ {
"name": "text", "name": "text",
"type": "string", "type": "string",
"value": "Document Title", "value": "Document Title",
"location": { "start": { "line": 1, "column": 3 }, "end": { "line": 1, "column": 16 } } "location": [{ "line": 1, "col": 3 }, { "line": 1, "col": 16 }]
}] }
} ],
"location": [{ "line": 1, "col": 1 }, { "line": 3, "col": 5 }]
}, },
"blocks": [], "location": [{ "line": 1, "col": 1 }, { "line": 3, "col": 5 }]
"location": { "start": { "line": 1,"column": 1 }, "end": { "line": 3, "column": 5 } }
} }
...@@ -12,22 +12,19 @@ ...@@ -12,22 +12,19 @@
"name": "listItem", "name": "listItem",
"type": "block", "type": "block",
"marker": "*", "marker": "*",
"principal": { "principal": [
"inlines": [ {
{ "name": "text",
"name": "text", "type": "string",
"type": "string", "value": "water",
"value": "water", "location": [{ "line": 1, "col": 3 }, { "line": 1, "col": 7 }]
"location": { "start": { "line": 1, "column": 3 }, "end": { "line": 1, "column": 7 } } }
} ],
] "location": [{ "line": 1, "col": 1 }, { "line": 1, "col": 7 }]
},
"blocks": [],
"location": { "start": { "line": 1, "column": 1 }, "end": { "line": 1, "column": 7 } }
} }
], ],
"location": { "start": { "line": 1, "column": 1 }, "end": { "line": 1, "column": 7 } } "location": [{ "line": 1, "col": 1 }, { "line": 1, "col": 7 }]
} }
], ],
"location": { "start": { "line": 1, "column": 1 }, "end": { "line": 1, "column": 7 } } "location": [{ "line": 1, "col": 1 }, { "line": 1, "col": 7 }]
} }
...@@ -10,11 +10,11 @@ ...@@ -10,11 +10,11 @@
"name": "text", "name": "text",
"type": "string", "type": "string",
"value": "A paragraph that consists of a single line.", "value": "A paragraph that consists of a single line.",
"location": { "start": { "line": 1, "column": 1 }, "end": { "line": 1, "column": 43 } } "location": [{ "line": 1, "col": 1 }, { "line": 1, "col": 43 }]
} }
], ],
"location": { "start": { "line": 1, "column": 1 }, "end": { "line": 1, "column": 43 } } "location": [{ "line": 1, "col": 1 }, { "line": 1, "col": 43 }]
} }
], ],
"location": { "start": { "line": 1, "column": 1 }, "end": { "line": 1, "column": 43 } } "location": [{ "line": 1, "col": 1 }, { "line": 1, "col": 43 }]
} }
...@@ -5,18 +5,16 @@ ...@@ -5,18 +5,16 @@
{ {
"name": "section", "name": "section",
"type": "block", "type": "block",
"title": { "title": [
"inlines": [ {
{ "name": "text",
"name": "text", "type": "string",
"type": "string", "value": "Section Title",
"value": "Section Title", "location": [{ "line": 1, "col": 4 }, { "line": 1, "col": 16 }]
"location": { "start": { "line": 1, "column": 4 }, "end": { "line": 1, "column": 16 } } }
} ],
]
},
"level": 1, "level": 1,
"location": { "start": { "line": 1, "column": 1 }, "end": { "line": 1, "column": 16 } }, "location": [{ "line": 1, "col": 1 }, { "line": 3, "col": 9 }],
"blocks": [ "blocks": [
{ {
"name": "paragraph", "name": "paragraph",
...@@ -26,13 +24,13 @@ ...@@ -26,13 +24,13 @@
"name": "text", "name": "text",
"type": "string", "type": "string",
"value": "paragraph", "value": "paragraph",
"location": { "start": { "line": 3, "column": 1 }, "end": { "line": 3, "column": 9 } } "location": [{ "line": 3, "col": 1 }, { "line": 3, "col": 9 }]
} }
], ],
"location": { "start": { "line": 3, "column": 1 }, "end": { "line": 3, "column": 9 } } "location": [{ "line": 3, "col": 1 }, { "line": 3, "col": 9 }]
} }
] ]
} }
], ],
"location": { "start": { "line": 1, "column": 1 }, "end": { "line": 3, "column": 9 } } "location": [{ "line": 1, "col": 1 }, { "line": 3, "col": 9 }]
} }
...@@ -3,6 +3,6 @@ ...@@ -3,6 +3,6 @@
"name": "text", "name": "text",
"type": "string", "type": "string",
"value": "hello", "value": "hello",
"location": { "start": { "line": 1, "column": 1 },"end": { "line": 1, "column": 5 } } "location": [{ "line": 1, "col": 1 }, { "line": 1, "col": 5 }]
} }
] ]
...@@ -9,9 +9,9 @@ ...@@ -9,9 +9,9 @@
"name": "text", "name": "text",
"type": "string", "type": "string",
"value": "s", "value": "s",
"location": { "start": { "line": 1, "column": 2 }, "end": { "line": 1, "column": 2 } } "location": [{ "line": 1, "col": 2 }, { "line": 1, "col": 2 }]
} }
], ],
"location": { "start": { "line": 1, "column": 1 }, "end": { "line": 1, "column": 3 } } "location": [{ "line": 1, "col": 1 }, { "line": 1, "col": 3 }]
} }
] ]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment