-
Notifications
You must be signed in to change notification settings - Fork 629
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
Readline-based parser of markdown #3233
Conversation
This parser is based on the asciidoc parser and tries to preserve all features of the regex-based parser (all kinds, full scope, sectionMarker field, running subparsers for code).
Codecov Report
@@ Coverage Diff @@
## master #3233 +/- ##
==========================================
+ Coverage 85.01% 85.28% +0.27%
==========================================
Files 206 206
Lines 49127 49084 -43
==========================================
+ Hits 41765 41862 +97
+ Misses 7362 7222 -140
Continue to review full report at Codecov.
|
Thank you. Of course, I will merge this C implementation. Let's fill the diff --git a/parsers/markdown.c b/parsers/markdown.c
index 173130e06..89358d89a 100644
--- a/parsers/markdown.c
+++ b/parsers/markdown.c
@@ -69,17 +69,22 @@ static NestingLevels *nestingLevels = NULL;
* FUNCTION DEFINITIONS
*/
-static NestingLevel *getNestingLevel(const int kind)
+static NestingLevel *getNestingLevel(const int kind, int adjustment_when_pop)
{
NestingLevel *nl;
tagEntryInfo *e;
+ unsigned long line = getInputLineNumber();
while (1)
{
nl = nestingLevelsGetCurrent(nestingLevels);
e = getEntryOfNestingLevel (nl);
if ((nl && (e == NULL)) || (e && (e->kindIndex >= kind)))
+ {
+ if (e && line > adjustment_when_pop)
+ e->extensionFields.endLine = line - adjustment_when_pop;
nestingLevelsPop(nestingLevels);
+ }
else
break;
}
@@ -88,7 +93,7 @@ static NestingLevel *getNestingLevel(const int kind)
static int makeMarkdownTag (const vString* const name, const int kind, const bool two_line)
{
- const NestingLevel *const nl = getNestingLevel(kind);
+ const NestingLevel *const nl = getNestingLevel(kind, two_line? 2: 1);
int r = CORK_NIL;
if (vStringLength (name) > 0) Could you include this? |
Instead of nestingLevelsNew, let's use nestingLevelsNewFull. We can add a callback function called when a level is popped. We can fill the deleteBlockData is an example of such a callback function. I will work on this topic tonight, JST. |
nesting level API must be extended to pass the line adjustment data.
So we can pass |
@techee, let me take over this pull request. |
Sure, no problem, less work for me :-). |
What's the |
$ cat -n /tmp/foo.c
1 struct point
2 {
3 int x;
4 int y;
5 };
6
7 int
8 main(void)
9 {
10 return 0;
11 }
12 $ ctags -o - --fields=+ne /tmp/foo.c
main /tmp/foo.c /^main(void)$/;" f line:8 typeref:typename:int end:11
point /tmp/foo.c /^struct point $/;" s line:1 file: end:5
x /tmp/foo.c /^ int x;$/;" m line:3 struct:point typeref:typename:int file: end:3
y /tmp/foo.c /^ int y;$/;" m line:4 struct:point typeref:typename:int file: end:4 |
Nice, I can imagine this information could be interesting for Geany too. I assume this is currently available only for some parsers, not all parsers reporting scope, right? |
No, not all parsers. `grep endLine parsers/*.c' may report what you want to know:-). |
See #3235. |
|
||
static int makeMarkdownTag (const vString* const name, const int kind, const bool two_line) | ||
{ | ||
const NestingLevel *const nl = getNestingLevel(kind); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In #3235, I move the getNestingLevel()
to...
int r = CORK_NIL; | ||
|
||
if (vStringLength (name) > 0) | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...here. The nesting level should be popped when making a tag for the name
.
The changes were merged via #3236. |
We have a rather bad markdown parser in Geany and when looking at uctags, I realized there's just a regex-based parser. From the past experience, these tend to be rather slow so for us it would be better to have a hand-written parser.
I created a simple readline-based parser based on the asciidoc parser and tried to preserve all the features of the regex-based parser (all kinds, full scope, sectionMarker field, running subparsers for code). Would such a parser be interesting for uctags or is the regex-based one the preferred solution?