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

Frontmatter parser #3032

Closed
masatake opened this issue May 18, 2021 · 1 comment · Fixed by #3311
Closed

Frontmatter parser #3032

masatake opened this issue May 18, 2021 · 1 comment · Fixed by #3311

Comments

@masatake
Copy link
Member

masatake commented May 18, 2021

I proposed skipping frontmatter areas in #3031 as a temporary solution.
It is not ideal. I would like to introduce Frontmatter parser and run as a guest of the Markdown parser.

I wouldn't say this is a major topic, but a very interesting topic.

In a markdown file, the frontmatter represented at least 3 ways.

---
frontmatter in yaml
---
;;;
frontmatter in JSON without top level { and } pair
;;;
+++
frontmatter in TOML
+++

Base on the above notation, the markdown parser may schedule running YAML, JSON, or TOML parser as a guest.

Ideal Frontmatter parser runs as a sub parser of YAML, JSON, and/or TOML.

When I designed the sub parser mechanism, I assumed a sub parser might have multiple base parsers.
I implemented the mechanism with the assumption. However, I have no chance to test the implementation.


@masatake

Is this written in the standard markdown syntax?

No it's not markdown, it's it's frontmatter language yaml. Special information(meta data) used by static site generators like hugo and how you mentioned jekyll. Pandoc, vuepress and many other's use it. This is extra information that is needed to create html documents.

Your default markdown.ctags ignores it because it does not match the patterns.

Could you tell me a web page where the syntax is explained?

You found it that's a good example.

This is an example template:

 ---
title: "{{ replace .Name "-" " " | title }}"
date: {{ .Date }}
draft: false
tags: ['code','{{.Name}}']
menu:
    main:
        parent: 'code'
---

Then this would be created:

---
title: "Example"
date: 2021-05-17T23:20:21-05:00
draft: false
tags: ['code','example']
menu:
    main:
        parent: 'code'
---

## Introduction

Markdown starts here.

I want to fix the markdown parser of ctags not to make the tag for "parent: 'code'".

I agree the command ctags/ctags --options=NONE --options=mymd.ctags --extras=+'{pseudo}' --fields=+'{extras}' -o - input.md should not be capturing the front matter tags, it should ignore front matter, anything
in between the 3 dashes---.

I already have another tags file that I create that captures the frontmatter (the 'code' and 'example' tags).

frontmatter.ctags

--langdef=frontmatter
--map-frontmatter=+.md

--kinddef-frontmatter=t,tags,front matter tags
--_tabledef-frontmatter=toplevel
--_tabledef-frontmatter=tag

--_mtable-regex-frontmatter=toplevel/\ntags:[ \t]*\[[ ]?['"]//{tenter=tag}

--_mtable-regex-frontmatter=toplevel/.//

--_mtable-regex-frontmatter=tag/([a-zA-Z0-9]+)/\1/t/
--_mtable-regex-frontmatter=tag/['"]\]//{tquit}


--_mtable-regex-frontmatter=tag/.//

--exclude=.git
--exclude=vim.md

Originally posted by @rickalex21 in #3027 (comment)

@masatake
Copy link
Member Author

As the first trial, extacting title is enough.

https://bookdown.org/yihui/rmarkdown/html-document.html

@masatake masatake changed the title Forntmatter parser Frontmatter parser Mar 15, 2022
masatake added a commit to masatake/ctags that referenced this issue Mar 17, 2022
In this version, just extracting "foo" in "title: foo" written
in Yaml. JSON(;;;) and TOML(+++) are not supported yet.

Close universal-ctags#3032.

Signed-off-by: Masatake YAMATO <[email protected]>
masatake added a commit to masatake/ctags that referenced this issue Mar 17, 2022
In this version, just extracting "foo" in "title: foo" written
in Yaml. JSON(;;;) and TOML(+++) are not supported yet.

Close universal-ctags#3032.

Signed-off-by: Masatake YAMATO <[email protected]>
masatake added a commit to masatake/ctags that referenced this issue Mar 18, 2022
In this version, just extracting "foo" in "title: foo" written
in Yaml. JSON(;;;) and TOML(+++) are not supported yet.

Close universal-ctags#3032.

Signed-off-by: Masatake YAMATO <[email protected]>
masatake added a commit to masatake/ctags that referenced this issue Mar 18, 2022
In this version, just extracting "foo" in "title: foo" written
in Yaml. JSON(;;;) and TOML(+++) are not supported yet.

Close universal-ctags#3032.

Signed-off-by: Masatake YAMATO <[email protected]>
masatake added a commit to masatake/ctags that referenced this issue Mar 18, 2022
In this version, just extracting "foo" in "title: foo" written
in Yaml. JSON(;;;) and TOML(+++) are not supported yet.

Close universal-ctags#3032.

Signed-off-by: Masatake YAMATO <[email protected]>
masatake added a commit to masatake/ctags that referenced this issue Mar 18, 2022
In this version, just extracting "foo" in "title: foo" written
in Yaml. JSON(;;;) and TOML(+++) are not supported yet.

Close universal-ctags#3032.

Signed-off-by: Masatake YAMATO <[email protected]>
masatake added a commit to masatake/ctags that referenced this issue Mar 18, 2022
In this version, just extracting "foo" in "title: foo" written
in Yaml. JSON(;;;) and TOML(+++) are not supported yet.

Close universal-ctags#3032.

Signed-off-by: Masatake YAMATO <[email protected]>
masatake added a commit to masatake/ctags that referenced this issue Mar 23, 2022
In this version, just extracting "foo" in "title: foo" written
in Yaml. JSON(;;;) and TOML(+++) are not supported yet.

Close universal-ctags#3032.

Signed-off-by: Masatake YAMATO <[email protected]>
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 a pull request may close this issue.

1 participant