Skip to content

Commit

Permalink
Markdown: skip the area of frontmatter
Browse files Browse the repository at this point in the history
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
  • Loading branch information
masatake committed May 19, 2021
1 parent f932373 commit 12cd52f
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 0 deletions.
1 change: 1 addition & 0 deletions Units/parser-markdown.r/frontmatter.d/args.ctags
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--sort=no
1 change: 1 addition & 0 deletions Units/parser-markdown.r/frontmatter.d/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
About this input input.md /^# About this input$/;" c
13 changes: 13 additions & 0 deletions Units/parser-markdown.r/frontmatter.d/input.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
title: Python
draft: false
date: 2021-05-16T13:15:31-05:00
tags: ['code','python']
menu:
main:
parent: 'code'
---

# About this input

This input is taken from #3027 at github submitted by @rickalex21.
13 changes: 13 additions & 0 deletions optlib/markdown.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ static void initializeMarkdownParser (const langType language)
" } def\n"
"}}");

addLanguageRegexTable (language, "frontmatter");
addLanguageRegexTable (language, "main");
addLanguageRegexTable (language, "main_sharp");
addLanguageRegexTable (language, "chapter");
Expand All @@ -63,6 +64,18 @@ static void initializeMarkdownParser (const langType language)
addLanguageRegexTable (language, "codeblockBacktick");
addLanguageRegexTable (language, "codeblockTildes");

addLanguageTagMultiTableRegex (language, "frontmatter",
"^(---[\n]).*(---[\n])",
"", "", "{tjump=main}", NULL);
addLanguageTagMultiTableRegex (language, "frontmatter",
"^(;;;[\n]).*(;;;[\n])",
"", "", "{tjump=main}", NULL);
addLanguageTagMultiTableRegex (language, "frontmatter",
"^(\\+\\+\\+[\n]).*(\\+\\+\\+[\n])",
"", "", "{tjump=main}", NULL);
addLanguageTagMultiTableRegex (language, "frontmatter",
"^.",
"", "", "{_advanceTo=0start}{tjump=main}", NULL);
addLanguageTagMultiTableRegex (language, "main",
"^#",
"", "", "{_advanceTo=0start}{tjump=main_sharp}", NULL);
Expand Down
19 changes: 19 additions & 0 deletions optlib/markdown.ctags
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
} def
}}

--_tabledef-Markdown=frontmatter
--_tabledef-Markdown=main
--_tabledef-Markdown=main_sharp
--_tabledef-Markdown=chapter
Expand Down Expand Up @@ -99,6 +100,24 @@
--_mtable-regex-Markdown=code/^[ \t]*````*[ \t]*([a-zA-Z0-9][-#+a-zA-Z0-9]*)?[^`\n]*[\n]//{tenter=codeblockBacktick}{_guest=\1,0end,}
--_mtable-regex-Markdown=code/^[ \t]*~~~~*[ \t]*([a-zA-Z0-9][-#+a-zA-Z0-9]*)?[^~\n]*[\n]//{tenter=codeblockTildes}{_guest=\1,0end,}

#
# Frontmatter
#
# https://gohugo.io/content-management/front-matter/
#

# YAML area
--_mtable-regex-Markdown=frontmatter/(---[\n]).*(---[\n])//{tjump=main}

# JSON area
--_mtable-regex-Markdown=frontmatter/(;;;[\n]).*(;;;[\n])//{tjump=main}

# TOML area
--_mtable-regex-Markdown=frontmatter/(\+\+\+[\n]).*(\+\+\+[\n])//{tjump=main}

# No frontmatter
--_mtable-regex-Markdown=frontmatter/.//{_advanceTo=0start}{tjump=main}


#
# Main
Expand Down

0 comments on commit 12cd52f

Please sign in to comment.