forked from universal-ctags/ctags
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request universal-ctags#1727 from masatake/markdown
Markdown parser
- Loading branch information
Showing
15 changed files
with
300 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--sort=no | ||
--fields-Markdown=+{sectionMarker} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
a input.md /^# a$/;" c sectionMarker:# | ||
b input.md /^## b$/;" s sectionMarker:# | ||
c input.md /^### c$/;" S sectionMarker:# | ||
d input.md /^#### d$/;" t sectionMarker:# | ||
e input.md /^##### e$/;" T sectionMarker:# | ||
f input.md /^###### f$/;" u sectionMarker:# | ||
g input.md /^# g #$/;" c sectionMarker:## | ||
h input.md /^# h ##$/;" c sectionMarker:## | ||
i input.md /^## i #$/;" s sectionMarker:## | ||
j input.md /^## j ##$/;" s sectionMarker:## | ||
k input.md /^## k ###$/;" s sectionMarker:## | ||
l input.md /^### l #$/;" S sectionMarker:## | ||
m input.md /^### m ##$/;" S sectionMarker:## | ||
n input.md /^### n ###$/;" S sectionMarker:## | ||
o input.md /^### o ###$/;" S sectionMarker:## | ||
p input.md /^#### p #$/;" t sectionMarker:## | ||
q input.md /^#### q #####$/;" t sectionMarker:## | ||
r input.md /^##### r #$/;" T sectionMarker:## | ||
s input.md /^##### s ######$/;" T sectionMarker:## | ||
t input.md /^###### t #$/;" u sectionMarker:## | ||
u input.md /^###### u #######$/;" u sectionMarker:## | ||
A input.md /^A$/;" c sectionMarker:= | ||
B input.md /^B$/;" c sectionMarker:= | ||
C input.md /^C$/;" c sectionMarker:= | ||
D input.md /^D$/;" s sectionMarker:- | ||
E input.md /^E$/;" s sectionMarker:- | ||
F input.md /^F$/;" s sectionMarker:- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# a | ||
|
||
## b | ||
|
||
### c | ||
|
||
#### d | ||
|
||
##### e | ||
|
||
###### f | ||
|
||
# g # | ||
# h ## | ||
|
||
## i # | ||
## j ## | ||
## k ### | ||
|
||
### l # | ||
### m ## | ||
### n ### | ||
### o ### | ||
|
||
#### p # | ||
#### q ##### | ||
|
||
##### r # | ||
##### s ###### | ||
|
||
###### t # | ||
###### u ####### | ||
|
||
A | ||
= | ||
|
||
B | ||
== | ||
|
||
C | ||
=== | ||
|
||
D | ||
- | ||
|
||
E | ||
-- | ||
|
||
F | ||
--- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--map-passwd=+.passwd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
bin input.passwd /^bin:x:1:1:bin:\/bin:\/sbin\/nologin$/;" u home:/bin shell:/sbin/nologin | ||
root input.passwd /^root:x:0:0:root:\/root:\/bin\/bash$/;" u home:/root shell:/bin/bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
root:x:0:0:root:/root:/bin/bash | ||
bin:x:1:1:bin:/bin:/sbin/nologin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
/* | ||
* Generated by ./misc/optlib2c from optlib/markdown.ctags, Don't edit this manually. | ||
*/ | ||
#include "general.h" | ||
#include "parse.h" | ||
#include "routines.h" | ||
|
||
|
||
static void initializeMarkdownParser (const langType language CTAGS_ATTR_UNUSED) | ||
{ | ||
|
||
addLanguageRegexTable (language, "main"); | ||
addLanguageRegexTable (language, "sharp"); | ||
|
||
addLanguageTagMultiTableRegex (language, "main", | ||
"^#", | ||
"", "", "{tjump=sharp}{_advanceTo=0start}", NULL); | ||
addLanguageTagMultiTableRegex (language, "main", | ||
"^([^\n]+)[\n]=+[\n]", | ||
"\\1", "c", "{_field=sectionMarker:=}", NULL); | ||
addLanguageTagMultiTableRegex (language, "main", | ||
"^([^\n]+)[\n]-+[\n]", | ||
"\\1", "s", "{_field=sectionMarker:-}", NULL); | ||
addLanguageTagMultiTableRegex (language, "main", | ||
"^[^\n]+[\n]", | ||
"", "", "", NULL); | ||
addLanguageTagMultiTableRegex (language, "main", | ||
"^[\n]+", | ||
"", "", "", NULL); | ||
addLanguageTagMultiTableRegex (language, "main", | ||
"^[^\n]+", | ||
"", "", "", NULL); | ||
addLanguageTagMultiTableRegex (language, "sharp", | ||
"^#[ \t]+([^\n]+)([ \t]+#+)[\n]", | ||
"\\1", "c", "{_field=sectionMarker:##}{tjump=main}", NULL); | ||
addLanguageTagMultiTableRegex (language, "sharp", | ||
"^##[ \t]+([^\n]+)([ \t]+#+)[\n]", | ||
"\\1", "s", "{_field=sectionMarker:##}{tjump=main}", NULL); | ||
addLanguageTagMultiTableRegex (language, "sharp", | ||
"^###[ \t]+([^\n]+)([ \t]+#+)[\n]", | ||
"\\1", "S", "{_field=sectionMarker:##}{tjump=main}", NULL); | ||
addLanguageTagMultiTableRegex (language, "sharp", | ||
"^####[ \t]+([^\n]+)([ \t]+#+)[\n]", | ||
"\\1", "t", "{_field=sectionMarker:##}{tjump=main}", NULL); | ||
addLanguageTagMultiTableRegex (language, "sharp", | ||
"^#####[ \t]+([^\n]+)([ \t]+#+)[\n]", | ||
"\\1", "T", "{_field=sectionMarker:##}{tjump=main}", NULL); | ||
addLanguageTagMultiTableRegex (language, "sharp", | ||
"^######[ \t]+([^\n]+)([ \t]+#+)[\n]", | ||
"\\1", "u", "{_field=sectionMarker:##}{tjump=main}", NULL); | ||
addLanguageTagMultiTableRegex (language, "sharp", | ||
"^#[ \t]+([^\n]+)[\n]", | ||
"\\1", "c", "{_field=sectionMarker:#}{tjump=main}", NULL); | ||
addLanguageTagMultiTableRegex (language, "sharp", | ||
"^##[ \t]+([^\n]+)[\n]", | ||
"\\1", "s", "{_field=sectionMarker:#}{tjump=main}", NULL); | ||
addLanguageTagMultiTableRegex (language, "sharp", | ||
"^###[ \t]+([^\n]+)[\n]", | ||
"\\1", "S", "{_field=sectionMarker:#}{tjump=main}", NULL); | ||
addLanguageTagMultiTableRegex (language, "sharp", | ||
"^####[ \t]+([^\n]+)[\n]", | ||
"\\1", "t", "{_field=sectionMarker:#}{tjump=main}", NULL); | ||
addLanguageTagMultiTableRegex (language, "sharp", | ||
"^#####[ \t]+([^\n]+)[\n]", | ||
"\\1", "T", "{_field=sectionMarker:#}{tjump=main}", NULL); | ||
addLanguageTagMultiTableRegex (language, "sharp", | ||
"^######[ \t]+([^\n]+)[\n]", | ||
"\\1", "u", "{_field=sectionMarker:#}{tjump=main}", NULL); | ||
addLanguageTagMultiTableRegex (language, "sharp", | ||
"^[^\n]+[\n]", | ||
"", "", "{tjump=main}", NULL); | ||
addLanguageTagMultiTableRegex (language, "sharp", | ||
"^[\n]+", | ||
"", "", "{tjump=main}", NULL); | ||
addLanguageTagMultiTableRegex (language, "sharp", | ||
"^[^\n]+", | ||
"", "", "{tjump=main}", NULL); | ||
} | ||
|
||
extern parserDefinition* MarkdownParser (void) | ||
{ | ||
static const char *const extensions [] = { | ||
"md", | ||
"markdown", | ||
NULL | ||
}; | ||
|
||
static const char *const aliases [] = { | ||
NULL | ||
}; | ||
|
||
static const char *const patterns [] = { | ||
NULL | ||
}; | ||
|
||
static kindDefinition MarkdownKindTable [] = { | ||
{ | ||
true, 'c', "chapter", "chapsters", | ||
}, | ||
{ | ||
true, 's', "section", "sections", | ||
}, | ||
{ | ||
true, 'S', "subsection", "subsections", | ||
}, | ||
{ | ||
true, 't', "subsubsection", "subsubsections", | ||
}, | ||
{ | ||
true, 'T', "l4subsection", "level 4 subsections", | ||
}, | ||
{ | ||
true, 'u', "l5subsection", "level 5 subsections", | ||
}, | ||
}; | ||
static fieldDefinition MarkdownFieldTable [] = { | ||
{ | ||
.enabled = false, | ||
.name = "sectionMarker", | ||
.description = "character used for declaring section(#, ##, =, or -)", | ||
}, | ||
}; | ||
|
||
parserDefinition* const def = parserNew ("Markdown"); | ||
|
||
def->enabled = true; | ||
def->extensions = extensions; | ||
def->patterns = patterns; | ||
def->aliases = aliases; | ||
def->method = METHOD_NOT_CRAFTED|METHOD_REGEX; | ||
def->kindTable = MarkdownKindTable; | ||
def->kindCount = ARRAY_SIZE(MarkdownKindTable); | ||
def->fieldTable = MarkdownFieldTable; | ||
def->fieldCount = ARRAY_SIZE(MarkdownFieldTable); | ||
def->initialize = initializeMarkdownParser; | ||
|
||
return def; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# | ||
# | ||
# Copyright (c) 2018, Red Hat, Inc. | ||
# Copyright (c) 2018, Masatake YAMATO | ||
# | ||
# Author: Masatake YAMATO <yamato@redhat.com> | ||
# | ||
# This program is free software; you can redistribute it and/or | ||
# modify it under the terms of the GNU General Public License | ||
# as published by the Free Software Foundation; either version 2 | ||
# of the License, or (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program; if not, write to the Free Software | ||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||
# USA. | ||
# | ||
# | ||
|
||
# | ||
# TODO: Tracking the scope | ||
# | ||
|
||
--langdef=Markdown | ||
--map-Markdown=+.md | ||
--map-Markdown=+.markdown | ||
|
||
--kinddef-Markdown=c,chapter,chapsters | ||
--kinddef-Markdown=s,section,sections | ||
--kinddef-Markdown=S,subsection,subsections | ||
--kinddef-Markdown=t,subsubsection,subsubsections | ||
--kinddef-Markdown=T,l4subsection,level 4 subsections | ||
--kinddef-Markdown=u,l5subsection,level 5 subsections | ||
|
||
--_fielddef-Markdown=sectionMarker,character used for declaring section(#, ##, =, or -) | ||
|
||
--_tabledef-Markdown=main | ||
--_tabledef-Markdown=sharp | ||
|
||
|
||
--_mtable-regex-Markdown=main/^#///{tjump=sharp}{_advanceTo=0start} | ||
--_mtable-regex-Markdown=main/^([^\n]+)[\n]=+[\n]/\1/c/{_field=sectionMarker:=} | ||
--_mtable-regex-Markdown=main/^([^\n]+)[\n]-+[\n]/\1/s/{_field=sectionMarker:-} | ||
--_mtable-regex-Markdown=main/^[^\n]+[\n]// | ||
--_mtable-regex-Markdown=main/[\n]+// | ||
--_mtable-regex-Markdown=main/^[^\n]+// | ||
|
||
|
||
--_mtable-regex-Markdown=sharp/^#[ \t]+([^\n]+)([ \t]+#+)[\n]/\1/c/{_field=sectionMarker:##}{tjump=main} | ||
--_mtable-regex-Markdown=sharp/^##[ \t]+([^\n]+)([ \t]+#+)[\n]/\1/s/{_field=sectionMarker:##}{tjump=main} | ||
--_mtable-regex-Markdown=sharp/^###[ \t]+([^\n]+)([ \t]+#+)[\n]/\1/S/{_field=sectionMarker:##}{tjump=main} | ||
--_mtable-regex-Markdown=sharp/^####[ \t]+([^\n]+)([ \t]+#+)[\n]/\1/t/{_field=sectionMarker:##}{tjump=main} | ||
--_mtable-regex-Markdown=sharp/^#####[ \t]+([^\n]+)([ \t]+#+)[\n]/\1/T/{_field=sectionMarker:##}{tjump=main} | ||
--_mtable-regex-Markdown=sharp/^######[ \t]+([^\n]+)([ \t]+#+)[\n]/\1/u/{_field=sectionMarker:##}{tjump=main} | ||
--_mtable-regex-Markdown=sharp/^#[ \t]+([^\n]+)[\n]/\1/c/{_field=sectionMarker:#}{tjump=main} | ||
--_mtable-regex-Markdown=sharp/^##[ \t]+([^\n]+)[\n]/\1/s/{_field=sectionMarker:#}{tjump=main} | ||
--_mtable-regex-Markdown=sharp/^###[ \t]+([^\n]+)[\n]/\1/S/{_field=sectionMarker:#}{tjump=main} | ||
--_mtable-regex-Markdown=sharp/^####[ \t]+([^\n]+)[\n]/\1/t/{_field=sectionMarker:#}{tjump=main} | ||
--_mtable-regex-Markdown=sharp/^#####[ \t]+([^\n]+)[\n]/\1/T/{_field=sectionMarker:#}{tjump=main} | ||
--_mtable-regex-Markdown=sharp/^######[ \t]+([^\n]+)[\n]/\1/u/{_field=sectionMarker:#}{tjump=main} | ||
--_mtable-regex-Markdown=sharp/^[^\n]+[\n]//{tjump=main} | ||
--_mtable-regex-Markdown=sharp/[\n]+//{tjump=main} | ||
--_mtable-regex-Markdown=sharp/^[^\n]+//{tjump=main} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters