Add value plugin for inline JSON and YAML data in markdown fence blocks, schema definitions for inline data elements, and compiler support#130
Conversation
Co-authored-by: danmarshall <11507384+danmarshall@users.noreply.github.com>
Co-authored-by: danmarshall <11507384+danmarshall@users.noreply.github.com>
Co-authored-by: danmarshall <11507384+danmarshall@users.noreply.github.com>
|
@copilot since 'json' is used as a language prefix, we will need a 2nd identifier to trigger this plugin. so the markdown would be: json data variableId Also look at scriptElement.setAttribute('type', 'application/json'); in sanitize.html - lets make that section a general purpose function, and then use that instead of a pre tag for json. |
Co-authored-by: danmarshall <11507384+danmarshall@users.noreply.github.com>
Updated in commit ab43fa5:
|
|
@copilot :
|
Co-authored-by: danmarshall <11507384+danmarshall@users.noreply.github.com>
Fixed in commit e38425f:
|
packages/compiler/src/loader.ts
Outdated
| if (Array.isArray(dataSource.content) && typeof dataSource.content[0] === 'object') { | ||
| const newData: ValuesData = { | ||
| name: dataSourceName, | ||
| values: dataSource.content as object[], |
There was a problem hiding this comment.
@copilot but we don't want it embedded with the spec, we want it output as tickWrap(json data ${ds_raw}, content); here too
There was a problem hiding this comment.
Fixed in commit a67e6f8:
- JSON object arrays now stringified with
JSON.stringify(content, null, 2)and output astickWrap('json data ${ds_raw}', content) - No longer embedded directly in Vega spec
- Consistent with CSV/TSV/DSV behavior
Also renamed types per new requirement:
JsonInstance→JsonDataInstanceJsonSpec→JsonDataSpec
Co-authored-by: danmarshall <11507384+danmarshall@users.noreply.github.com>
|
@copilot Actually, we dont need special logic if we just call it the 'data' plugin |
Co-authored-by: danmarshall <11507384+danmarshall@users.noreply.github.com>
Changed in commit fb01c3a:
|
|
@copilot docs/schema/idoc_v1.d.ts should not be in the PR |
Co-authored-by: danmarshall <11507384+danmarshall@users.noreply.github.com>
|
@copilot last file: docs/schema/idoc_v1.json this needs to be omitted from this PR |
Co-authored-by: danmarshall <11507384+danmarshall@users.noreply.github.com>
…er parsing into a single utility function
…arsing and variable ID handling
…r handling and simplify delimiter logic
Value Plugin Implementation
Successfully implemented a
valueplugin that allows inline JSON and YAML values to be embedded directly in markdown fence blocks usingjson value variableIdoryaml value variableIdsyntax. Also added schema definitions for all inline data elements (CSV, TSV, DSV, JSON Value, YAML Value) and full compiler support.Summary of Changes
This PR adds:
packages/markdown/src/plugins/value.ts) - Handlesjson value variableIdandyaml value variableIdfence blockspackages/schema-doc/src/inline-data.ts) - Defines CsvElement, TsvElement, DsvElement, JsonValueElement, and YamlValueElementpackages/compiler/src/md.ts) - Converts inline data elements to markdown fence blockspackages/compiler/src/validate/element.ts) - Validates all inline data element typesHow It Works
Syntax (markdown fence blocks):
json value variableIdyaml value variableIdcsv variableIdtsv variableIddsv delimiter:| variableIdSyntax (JSON elements):
{ "type": "json-value", "variableId": "myData", "content": [{"key": "value"}] }Or with arrays for CSV/TSV/DSV:
{ "type": "csv", "variableId": "myData", "content": ["header1,header2", "value1,value2"] }Compiler Support:
When to use:
valueplugin for structured data with type preservation (numbers, booleans, nested objects)Features
<script type="application/json">tagsOriginal prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.