Vivify icon indicating copy to clipboard operation
Vivify copied to clipboard

YAML formatter

Open Praczet opened this issue 1 year ago • 4 comments

Hi,

I feel like some ungrateful spammer, but here I am (sorry).

In the nutshell: Would be possible to render YAML Fromatter differently or not at all?

I don't know how to explain so lets go for examples. I am using quite often in my md files at the very top of file yaml formatter

For example: image

This is rendered like this: image

So the YAML part in this case is treated as `H1.

But in this file: image

it is rendered like this: image

This case is a mess. It detects the list of tags and put every thing in it.

What I would like to have? Something like this: image

And by default it could be folded: image

/Best regards Adam

Praczet avatar Aug 31 '24 09:08 Praczet

Hello! No worries haha, I think this might turn into a cool addition to Vivify, so thanks for the idea!

That said, I'm not entirely sure what you would like to see here. I'll make a proposal.

What we could do is:

  1. Detect the front matter and hide it completely so it doesn't pollute the viewer.
  2. Parse the YAML of the front matter, convert it to JSON and expose it to your custom client-side JS. This way you can use your Vivify config to do whatever you want with the data of the front matter, e.g. display something on the viewer based on some value there.

The idea behind this is that YAML is meant to be read by machines, not humans (hence (1) no displaying on the viewer) and that there are no common conventions for what the front matter contains/defines (hence (2) customized behavior).

jannis-baum avatar Aug 31 '24 18:08 jannis-baum

Hey @Praczet are you still interested in this?

jannis-baum avatar Sep 11 '24 14:09 jannis-baum

Sorry, Of course I am interested in this. I was quite sure I've answered you. For me the solution to parse and convert to JSON is working. I would probably then write a script that would inject some html just below navigation, with possibility to display information from YAML front matter.. Personally I am using YAML front matter quite heavily.

Only, I would need some little help (or point when I can find the help) about this client-side.js how to start, where to put etc

Praczet avatar Sep 12 '24 07:09 Praczet

Okay nice! I'll get to work on this some time soon then and once it's merged I'll let you know how to use it :)

jannis-baum avatar Sep 12 '24 14:09 jannis-baum

Hello! Sorry for not having worked on this for a year. I'll hopefully get back to this soon.

Just as a note to self: It seems the frontmatter plugin adds a token of type front_matter that we can use to inject the data, here is an example of another project using the same plugin and that token: https://github.com/jupyter-book/mystmd/blob/46214294c2de409538c888545034b2f72662153d/packages/myst-parser/src/plugins.ts

jannis-baum avatar Sep 16 '25 06:09 jannis-baum

Hello @Praczet @bingocaller @jqfeld I'm happy to let you know that we just released Vivify 0.10.0 with front matter features! Now there are

  • a foldable front matter section in the top of the document that you can see in the GIF below
  • an easy way to access front matter from client-side scripting, already parsed and ready to use from JS, so you can do whatever else you like with it

Image

jannis-baum avatar Sep 24 '25 04:09 jannis-baum

@jannis-baum Amazing! Thank you so much for adding this feature and for creating Vivify in the first place. ❤️

bingocaller avatar Sep 24 '25 05:09 bingocaller