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: new subparser parser run from Markdown parser #3311

Merged
merged 7 commits into from
Mar 25, 2022

Conversation

masatake
Copy link
Member

@masatake masatake commented Mar 17, 2022

In this version, just extracting "foo" in "title: foo" written
in Yaml. JSON(;;;) and TOML(+++) are not supported yet.

Tagging a, b, and c in tags: [ a b c ] is another TODO item.
Much more work is needed in the Yaml parser.

Close #3032.

@masatake masatake force-pushed the frontmatter branch 3 times, most recently from 86516fc to fd0b229 Compare March 18, 2022 14:55
@masatake masatake force-pushed the frontmatter branch 2 times, most recently from a113724 to 2cbb25f Compare March 18, 2022 15:59
@codecov
Copy link

codecov bot commented Mar 18, 2022

Codecov Report

Merging #3311 (5328660) into master (4492555) will increase coverage by 0.02%.
The diff coverage is 95.61%.

@@            Coverage Diff             @@
##           master    #3311      +/-   ##
==========================================
+ Coverage   85.31%   85.33%   +0.02%     
==========================================
  Files         212      214       +2     
  Lines       49987    50086      +99     
==========================================
+ Hits        42645    42740      +95     
- Misses       7342     7346       +4     
Impacted Files Coverage Δ
main/read.c 95.44% <62.50%> (-0.54%) ⬇️
parsers/frontmatter.c 94.73% <94.73%> (ø)
parsers/yamlfrontmatter.c 98.33% <98.33%> (ø)
main/dependency.c 96.51% <100.00%> (+0.04%) ⬆️
main/entry.c 88.22% <100.00%> (+0.02%) ⬆️
main/parse.c 95.72% <100.00%> (+<0.01%) ⬆️
parsers/markdown.c 99.46% <100.00%> (+0.01%) ⬆️
parsers/openapi.c 96.49% <100.00%> (ø)
parsers/yaml.c 97.16% <100.00%> (+0.81%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4492555...5328660. Read the comment docs.

…tream

By calling makePromise() with passing (0, 0, 0, 0) as arguments
specifying the area, you can run a guest parser on the whole the area
of the current input file.

Internally, the main part reuses the current input stream for the
guest parser.

I found there is a case that it is impossible to reuse the current
input stream in the guest parser; the current input stream is
opened as as FILE based MIO and the guest parser needs a MEMORY
based MIO.

In this case, the main part should abort reusing and open a new MEMORY
based MIO derived from the underlying FILE based MIO.  However,
reopening is not easy because the main part has no reliable way for
calculating the area information for the MEMORY based MIO.  The
calculation is needed because the caller just passes (0, 0, 0, 0) as
the area information.

Till we can find a good way for calculating the area, what we can do
is just printing warnings.

Signed-off-by: Masatake YAMATO <[email protected]>
They were derrived from ansibleplaybook.c.

Signed-off-by: Masatake YAMATO <[email protected]>
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 masatake marked this pull request as ready for review March 23, 2022 22:29
@masatake masatake merged commit 759c349 into universal-ctags:master Mar 25, 2022
@helins
Copy link

helins commented Mar 12, 2024

How is this meant to be used? I tried several ways but the title: in the frontmatters of my Markdown files is never parsed.

Are there currently efforts to extend parsing to full YAML?

@masatake
Copy link
Member Author

Could you show the input file? I also want to know the name of the file.

@helins
Copy link

helins commented Apr 15, 2024

Just a quick try with a file name foo.md and that kind of content:

---
title: Some title
---

# Foo

This is a test.

I am running on version 6.1.0.

@masatake
Copy link
Member Author

$ ctags --options=NONE --extras=+g -o - /tmp/foo.md 
ctags: Notice: No options will be read from files or environment
Foo     /tmp/foo.md     /^# Foo$/;"     c
Some title      /tmp/foo.md     /^title: Some title$/;" t

You may have to add --extras=+g.

@helins
Copy link

helins commented Apr 16, 2024

Indeed, it works with --extras=+g, 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.

Frontmatter parser
2 participants