-
Notifications
You must be signed in to change notification settings - Fork 21
Replace useYaml with granular pluginFormat system, fix mermaid YAML support, and externalize js-yaml from bundles #51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
danmarshall
merged 21 commits into
main
from
copilot/fix-743245ab-c436-4e2b-b7be-b32c1030eb97
Aug 24, 2025
Merged
Changes from 3 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
95ea22e
Initial plan
Copilot 136118a
Add YAML support to markdown package and compiler
Copilot dfe3d05
Add documentation and examples for YAML support
Copilot 88ec312
Replace useYaml with pluginFormat for granular control and remove doc…
Copilot 8543f53
Merge remote-tracking branch 'origin/main' into copilot/fix-743245ab-…
Copilot 9ae5e46
whitespace options
danmarshall a312653
Remove legacy flaggableJsonPlugin function as requested
Copilot 9ee2656
Add YAML support to mermaid plugin fence parsing
Copilot 5e4e30c
Exclude js-yaml from markdown bundle following css-tree pattern
Copilot 2f3b08e
Add js-yaml to vscode extension following css-tree pattern
Copilot b55d8fa
Add js-yaml to sandbox getDependencies() following css-tree pattern
Copilot b38f732
Add js-yaml to remaining getDependencies() methods in UMD bundles
Copilot 7bcee13
Revert changes to generated UMD files as requested
Copilot 28931f2
Merge branch 'main' of https://github.com/microsoft/chartifact into c…
Copilot ad98d44
rename tabulator
danmarshall fa6e986
add sales report demo
danmarshall e7aecba
rebuild
danmarshall af3f7da
undo primer
danmarshall 03dd242
use json for tabulator
danmarshall d7e67e2
MermaidProps extends OptionalVariableControl
danmarshall d6d5d3a
rebuild
danmarshall File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| # YAML Support | ||
|
|
||
| The chartifact markdown package now supports YAML as an alternative to JSON in all plugin blocks. | ||
|
|
||
| ## Quick Start | ||
|
|
||
| Instead of using `json` prefix, you can now use `yaml`: | ||
|
|
||
| ```yaml vega-lite | ||
| $schema: "https://vega.github.io/schema/vega-lite/v5.json" | ||
| description: "A simple bar chart" | ||
| data: | ||
| values: | ||
| - category: "A" | ||
| amount: 28 | ||
| - category: "B" | ||
| amount: 55 | ||
| mark: "bar" | ||
| encoding: | ||
| x: | ||
| field: "category" | ||
| type: "nominal" | ||
| y: | ||
| field: "amount" | ||
| type: "quantitative" | ||
| ``` | ||
|
|
||
| ## Supported Formats | ||
|
|
||
| All plugins support both JSON and YAML: | ||
| - `yaml vega` / `json vega` | ||
| - `yaml vega-lite` / `json vega-lite` | ||
| - `yaml textbox` / `json textbox` | ||
| - `yaml slider` / `json slider` | ||
| - `yaml dropdown` / `json dropdown` | ||
| - `yaml checkbox` / `json checkbox` | ||
| - And all other plugins... | ||
|
|
||
| ## Benefits | ||
|
|
||
| - More readable and concise syntax | ||
| - Better for complex nested structures | ||
| - Familiar format for configuration files | ||
| - Full backward compatibility with JSON | ||
|
|
||
| See the [full documentation](./yaml-support-docs.md) for detailed examples and migration guide. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| # JSON vs YAML Comparison | ||
|
|
||
| This document shows the same functionality implemented in both JSON and YAML to demonstrate the differences. | ||
|
|
||
| ## JSON Version | ||
|
|
||
| ```json vega-lite | ||
| { | ||
| "$schema": "https://vega.github.io/schema/vega-lite/v5.json", | ||
| "description": "Sales by quarter", | ||
| "data": { | ||
| "values": [ | ||
| {"quarter": "Q1", "sales": 120000, "profit": 15000}, | ||
| {"quarter": "Q2", "sales": 135000, "profit": 18000}, | ||
| {"quarter": "Q3", "sales": 142000, "profit": 22000}, | ||
| {"quarter": "Q4", "sales": 158000, "profit": 28000} | ||
| ] | ||
| }, | ||
| "mark": { | ||
| "type": "bar", | ||
| "color": "#2E86AB" | ||
| }, | ||
| "encoding": { | ||
| "x": { | ||
| "field": "quarter", | ||
| "type": "nominal", | ||
| "axis": {"title": "Quarter"} | ||
| }, | ||
| "y": { | ||
| "field": "sales", | ||
| "type": "quantitative", | ||
| "axis": {"title": "Sales ($)", "format": "$,.0f"} | ||
| }, | ||
| "tooltip": [ | ||
| {"field": "quarter", "type": "nominal"}, | ||
| {"field": "sales", "type": "quantitative", "format": "$,.0f"}, | ||
| {"field": "profit", "type": "quantitative", "format": "$,.0f"} | ||
| ] | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ## YAML Version | ||
|
|
||
| ```yaml vega-lite | ||
| $schema: "https://vega.github.io/schema/vega-lite/v5.json" | ||
| description: "Sales by quarter" | ||
| data: | ||
| values: | ||
| - quarter: "Q1" | ||
| sales: 120000 | ||
| profit: 15000 | ||
| - quarter: "Q2" | ||
| sales: 135000 | ||
| profit: 18000 | ||
| - quarter: "Q3" | ||
| sales: 142000 | ||
| profit: 22000 | ||
| - quarter: "Q4" | ||
| sales: 158000 | ||
| profit: 28000 | ||
| mark: | ||
| type: "bar" | ||
| color: "#2E86AB" | ||
| encoding: | ||
| x: | ||
| field: "quarter" | ||
| type: "nominal" | ||
| axis: | ||
| title: "Quarter" | ||
| y: | ||
| field: "sales" | ||
| type: "quantitative" | ||
| axis: | ||
| title: "Sales ($)" | ||
| format: "$,.0f" | ||
| tooltip: | ||
| - field: "quarter" | ||
| type: "nominal" | ||
| - field: "sales" | ||
| type: "quantitative" | ||
| format: "$,.0f" | ||
| - field: "profit" | ||
| type: "quantitative" | ||
| format: "$,.0f" | ||
| ``` | ||
|
|
||
| ## Key Differences | ||
|
|
||
| | Aspect | JSON | YAML | | ||
| |--------|------|------| | ||
| | Syntax | Uses brackets `{}` and commas | Uses indentation and dashes | | ||
| | Readability | More verbose | More concise and readable | | ||
| | Data arrays | `[{"key": "value"}]` | `- key: "value"` | | ||
| | Nesting | Bracket-based | Indentation-based | | ||
| | Quotes | Required for all strings | Optional for simple strings | | ||
|
|
||
| Both versions produce identical functionality - choose the format that works best for your team and use case! |
87 changes: 87 additions & 0 deletions
87
docs/assets/examples/markdown/yaml/weather-dashboard.idoc.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| # YAML Example Document | ||
|
|
||
| This document demonstrates YAML syntax support in chartifact. | ||
|
|
||
| ```yaml vega | ||
| $schema: "https://vega.github.io/schema/vega/v5.json" | ||
| description: "Interactive temperature dashboard" | ||
| signals: | ||
| - name: "selectedCity" | ||
| value: "New York" | ||
| - name: "temperature" | ||
| value: 22 | ||
| - name: "showGrid" | ||
| value: true | ||
| data: | ||
| - name: "weather" | ||
| values: | ||
| - city: "New York" | ||
| temperature: 22 | ||
| humidity: 65 | ||
| - city: "Los Angeles" | ||
| temperature: 28 | ||
| humidity: 45 | ||
| - city: "Chicago" | ||
| temperature: 18 | ||
| humidity: 70 | ||
| ``` | ||
|
|
||
| ## User Controls | ||
|
|
||
| Select a city to view its weather data: | ||
|
|
||
| ```yaml dropdown | ||
| variableId: "selectedCity" | ||
| value: "New York" | ||
| label: "Choose a city" | ||
| options: | ||
| - "New York" | ||
| - "Los Angeles" | ||
| - "Chicago" | ||
| ``` | ||
|
|
||
| Adjust the temperature: | ||
|
|
||
| ```yaml slider | ||
| variableId: "temperature" | ||
| value: 22 | ||
| label: "Temperature (°C)" | ||
| min: -10 | ||
| max: 40 | ||
| step: 1 | ||
| ``` | ||
|
|
||
| Toggle grid display: | ||
|
|
||
| ```yaml checkbox | ||
| variableId: "showGrid" | ||
| value: true | ||
| label: "Show grid lines" | ||
| ``` | ||
|
|
||
| ## Weather Chart | ||
|
|
||
| ```yaml vega-lite | ||
| $schema: "https://vega.github.io/schema/vega-lite/v5.json" | ||
| description: "Temperature by city" | ||
| data: | ||
| name: "weather" | ||
| mark: | ||
| type: "bar" | ||
| color: "#1f77b4" | ||
| encoding: | ||
| x: | ||
| field: "city" | ||
| type: "nominal" | ||
| axis: | ||
| title: "City" | ||
| y: | ||
| field: "temperature" | ||
| type: "quantitative" | ||
| axis: | ||
| title: "Temperature (°C)" | ||
| grid: | ||
| signal: "showGrid" | ||
| ``` | ||
|
|
||
| This example shows how YAML makes the configuration more readable and easier to maintain compared to JSON. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot There should be more granularity to
useYaml: for example, we generally want json for vega plugins. so instead of a prop named useYaml: boolean lets have a prop named pluginFormat that takes a map of plugin names to "json" | "yaml". so we can add more serializers in the future. there should be a wildcard. and we will have a default that should be mixed in. the default is {"*": "yaml", "vega": "json", "vega-lite": "json"}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replaced
useYaml: booleanwith granularpluginFormat: Record<string, "json" | "yaml">as requested. Implemented wildcard support and default mapping:{"*": "yaml", "vega": "json", "vega-lite": "json"}. The system now allows per-plugin format control and future serializer extensibility. (commit 88ec312)