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

Ignore front-matter #109

Merged
merged 2 commits into from
Nov 14, 2017
Merged

Conversation

pavloo
Copy link
Contributor

@pavloo pavloo commented Nov 5, 2017

Currently vmd tries to parse front-matter as it's a valid markdown. This PR adds a feature of ignoring front-matter. By default it's configured to ignore yaml front-matter, but there is an option to set the list of ignored formats.

.use(fixHeadings)
.use(fixCheckListStyles)
.use(slug)
.use(...frontmatter(opts.ignorefrontmatter))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you perhaps use Object.assign() instead of the splat? Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it can be polyfilled with just Object.assign (it uses apply under the hood) in this case. I will just refactor it not to use splat at all.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@yoshuawuyts yoshuawuyts merged commit a992374 into yoshuawuyts:master Nov 14, 2017
@maxkueng
Copy link
Collaborator

maxkueng commented Nov 21, 2017

I just did some checking. GitHub actually doesn't strip front-matter but renders it as a nested table. But only if YAML syntax is used. If the front-matter is TOML or JSON style it just renders it like regular text.

vmd should behave the same, if possible. We can strip it (i.e. not render it) and also add support for TOML and JSON but those behaviors should be turned off by default and can be enabled through config parameters / command-line arguments.

I tried some front-matter that I copied from the hugo docs.

YAML:

---
title: "spf13-vim 3.0 release and new website"
description: "spf13-vim is a cross platform distribution of vim plugins and resources for Vim."
tags: [ ".vimrc", "plugins", "spf13-vim", "vim" ]
lastmod: 2015-12-23
date: "2012-04-06"
categories:
  - "Development"
  - "VIM"
slug: "spf13-vim-3-0-release-and-new-website"
---

sdasdasd

Is rendered like this:

image

TOML-syntax front-matter is just rendered as text:

+++
title = "spf13-vim 3.0 release and new website"
description = "spf13-vim is a cross platform distribution of vim plugins and resources for Vim."
tags = [ ".vimrc", "plugins", "spf13-vim", "vim" ]
date = "2012-04-06"
categories = [
  "Development",
  "VIM"
]
slug = "spf13-vim-3-0-release-and-new-website"
+++

sdasdasd

Looks like this:

image

Same with JSON-syntax front-matter:

{
    "title": "spf13-vim 3.0 release and new website",
    "description": "spf13-vim is a cross platform distribution of vim plugins and resources for Vim.",
    "tags": [ ".vimrc", "plugins", "spf13-vim", "vim" ],
    "date": "2012-04-06",
    "categories": [
        "Development",
        "VIM"
    ],
    "slug": "spf13-vim-3-0-release-and-new-website"
}

sdasdasd

Looks like this:

image

Invalid YAML front-matter is rendered like this:

image

@maxkueng maxkueng mentioned this pull request Nov 22, 2017
7 tasks
@maxkueng
Copy link
Collaborator

I've created a new issue based on my comment.

@maxkueng
Copy link
Collaborator

@pavloo : I'm not sure if you got the notification emails as it happened in a different issue. But I made a couple changes to the Front Matter behavior in PR #112:

  • By default Front Matter is rendered as a nested table like on GitHub.
  • The behavior of ignorefrontmatter = [yaml] can be achieved like this: frontmatter.renderer=none and the rendering for all enabled formats is the same.
  • YAML and TOML can be enabled through frontmatter.formats=yaml,toml. By default only YAML is enabled.

@pavloo
Copy link
Contributor Author

pavloo commented Nov 30, 2017

@maxkueng Sorry was on vacation. Looks nice. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants