Markdown-preview-enhanced: [Discussion] Support Vizdown diagrams

Created on 24 Jul 2017  ·  10Comments  ·  Source: shd101wyy/markdown-preview-enhanced

Analogously to the way Mermaid and Graphviz code-blocks are rendered to diagrams, it would be super cool to support Vizdown diagrams (based on Vega-lite with YAML instead of JSON). For example,

    ```vis
    data:
      url: "data/cars.csv"
    mark: circle
    encoding:
      x:
        type: quantitative
        field: kmpl
        scale:
         domain: [12,25]
      y:
        type: quantitative
        field: price
        scale:
         domain: [100,900]
      color:
        type: nominal
        field: type
      size:
        type: quantitative
        field: bhp
    width: 450
    height: 300
    ```

Gets rendered to

vega

enhancement

Most helpful comment

Hooray!!! This is released in v0.14.4!

All 10 comments

I will have a look when I have time :)

Seems like Visdown is using vega-lite to render diagrams. So I think I will support both yaml and json format. Which one do you think is better to be as the default?

And should I still write it as ```vis or ```vega ?

So I think I will support both yaml and json format. Which one do you think is better to be as the default?

I think YAML is more friendly for writing by hand, so I would make it default. But on the other hand JSON and YAML are different enough to make both available (try to parse YAML, if doesn't work, try to parse JSON). What do you think?

And should I still write it as ```vis or ```vega ?

I would vote for ```vega or ```vega-lite to keep consistency with other formats. ```vis makes sense in Vizdown, because there's only one type of such visualization format.

sorry that I didn't notice this issue earlier

seems that issue 530 will be covered if this enhancement is released in the future

thanks

I think I have finished the implementation. You guys would see it this weekend.
However, I decide to use json as the default input type. You can change it by specifying ```vega-lite {type=yaml}

Cool! Any particular reason to chose JSON as default? (besides that it's default for vega-lite itself)

I just had an idea before I go to sleep.
So how about this:
If the code starts with the character "{", then it will be parsed as JSON. Otherwise it will be parsed as YAML. So you don't need to choose the input type anymore.

Yeah! Good idea 👍 That's more or less what I meant in https://github.com/shd101wyy/markdown-preview-enhanced/issues/524#issuecomment-317759985

Hooray!!! This is released in v0.14.4!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lhk picture lhk  ·  4Comments

lambdafu picture lambdafu  ·  3Comments

oneone1995 picture oneone1995  ·  5Comments

AdexoMing picture AdexoMing  ·  3Comments

rcmalli picture rcmalli  ·  4Comments