Skip to content
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

YAML formatter #177

Open
Praczet opened this issue Aug 31, 2024 · 4 comments
Open

YAML formatter #177

Praczet opened this issue Aug 31, 2024 · 4 comments
Assignees
Labels
type:feature New feature or request

Comments

@Praczet
Copy link

Praczet commented Aug 31, 2024

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 Praczet added the type:feature New feature or request label Aug 31, 2024
@jannis-baum
Copy link
Owner

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
Copy link
Owner

Hey @Praczet are you still interested in this?

@Praczet
Copy link
Author

Praczet commented Sep 12, 2024

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

@jannis-baum
Copy link
Owner

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 jannis-baum self-assigned this Sep 12, 2024
bingocaller added a commit to bingocaller/Vivify that referenced this issue Nov 11, 2024
**Why:**

Some users add metadata to their Markdown files in the form of
YAML-style front matter and it currently gets treated as regular
content, which looks a bit odd when rendered on the page.

Instead, we would like to be able to identify front matter and not
render it to the page. Ideally we would like to make the metadata
available and/or optionally render it to the page in some way, but this
would require some reworking of the current setup.

**What:**

* Install `markdown-it-front-matter`[^1], which enables `markdown-it` to
  parse YAML-style front matter.
* Enable `markdown-it-front-matter` via `MarkdownIt.use()` like we do
  with other plugins.
  * **Note:** This doesn’t actually do anything other than enable
    `markdown-it` to recognise front matter and not treat it as regular
    content.

[^1]: https://github.com/ParkSB/markdown-it-front-matter

---

jannis-baum#177
bingocaller added a commit to bingocaller/Vivify that referenced this issue Nov 11, 2024
**Why:**

Some users add metadata to their Markdown files in the form of
YAML-style front matter and it currently gets treated as regular
content, which looks a bit odd when rendered on the page.

Instead, we would like to be able to identify front matter and not
render it to the page. Ideally we would like to make the metadata
available and/or optionally render it to the page in some way, but this
would require some reworking of the current setup.

**What:**

* Install `markdown-it-front-matter`[^1], which enables `markdown-it` to
  parse YAML-style front matter.
* Enable `markdown-it-front-matter` via `MarkdownIt.use()` like we do
  with other plugins.
  * **Note:** This doesn’t actually do anything other than enable
    `markdown-it` to recognise front matter and not treat it as regular
    content.

[^1]: https://github.com/ParkSB/markdown-it-front-matter

---

jannis-baum#177
jannis-baum added a commit that referenced this issue Nov 12, 2024
feat(#177): enable understanding of front matter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:feature New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants