Skip to content

Commit

Permalink
Merge pull request #3236 from techee/markdown3
Browse files Browse the repository at this point in the history
Markdown: rewrite in C
  • Loading branch information
masatake authored Jan 2, 2022
2 parents c4378f2 + 78320f2 commit e7f2c05
Show file tree
Hide file tree
Showing 19 changed files with 430 additions and 826 deletions.
1 change: 1 addition & 0 deletions Units/parser-markdown.r/backquote.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/backquote.d/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
A input.md /^# A$/;" c
3 changes: 3 additions & 0 deletions Units/parser-markdown.r/backquote.d/input.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
`O`
# A

1 change: 1 addition & 0 deletions Units/parser-markdown.r/frontmatter.d/input.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ tags: ['code','python']
menu:
main:
parent: 'code'
layout: default
---

# About this input
Expand Down
11 changes: 9 additions & 2 deletions Units/parser-markdown.r/simple-markdown.d/expected.tags
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,17 @@ t input.md /^###### t #$/;" u l4subsection:h""k""o""q""s end:59 sectionMarker:##
u input.md /^###### u #######$/;" u l4subsection:h""k""o""q""s end:61 sectionMarker:##
A input.md /^A$/;" c end:64 sectionMarker:=
B input.md /^B$/;" c end:74 sectionMarker:=
C input.md /^C$/;" c end:105 sectionMarker:=
C input.md /^C$/;" c end:128 sectionMarker:=
D input.md /^D$/;" s chapter:C end:100 sectionMarker:-
E input.md /^E$/;" s chapter:C end:103 sectionMarker:-
F input.md /^F$/;" s chapter:C end:105 sectionMarker:-
F input.md /^F$/;" s chapter:C end:106 sectionMarker:-
G input.md /^ G$/;" s chapter:C end:109 sectionMarker:-
H input.md /^ H$/;" s chapter:C end:112 sectionMarker:-
I input.md /^ I$/;" s chapter:C end:128 sectionMarker:-
C\\# input.md /^# C\\#$/;" c end:146 sectionMarker:#
J input.md /^J$/;" s chapter:C\\# end:133 sectionMarker:-
K input.md /^K$/;" s chapter:C\\# end:136 sectionMarker:-
L input.md /^L$/;" s chapter:C\\# end:146 sectionMarker:-
x input.md /^function x$/;" f
y input.md /^function y$/;" f
z input.md /^z()$/;" f
Expand Down
41 changes: 41 additions & 0 deletions Units/parser-markdown.r/simple-markdown.d/input.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,44 @@ E

F
---

G
-

H
-

I
-

indented
-

indented_with_tab
-

indented_with_space_and_tab
-

text
- ignored
-

# C\#

J
-

K
-

L
-

ignored
-

```foo```

> quoted
---
1 change: 1 addition & 0 deletions Units/parser-markdown.r/xml-comment.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/xml-comment.d/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
EXTRACT ME 1 input.md /^# EXTRACT ME 1$/;" c
7 changes: 7 additions & 0 deletions Units/parser-markdown.r/xml-comment.d/input.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!--
# SKIP ME 1
-->

<!-- # SKIP ME 2 -->

# EXTRACT ME 1
2 changes: 1 addition & 1 deletion docs/news.rst
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ The following parsers have been added:
* GNU linker script(LdScript)
* LEX *optlib*
* Man page *optlib*
* Markdown *optlib*
* Markdown
* Maven2 *libxml*
* MesonBuild (Meson) *optlib*
* MesonOptions *optlib+script*
Expand Down
10 changes: 5 additions & 5 deletions main/nestlevel.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
*/

extern NestingLevels *nestingLevelsNewFull(size_t userDataSize,
void (* deleteUserData)(NestingLevel *))
void (* deleteUserData)(NestingLevel *, void *))
{
NestingLevels *nls = xCalloc (1, NestingLevels);
nls->userDataSize = userDataSize;
Expand All @@ -42,7 +42,7 @@ extern NestingLevels *nestingLevelsNew(size_t userDataSize)
return nestingLevelsNewFull (userDataSize, NULL);
}

extern void nestingLevelsFree(NestingLevels *nls)
extern void nestingLevelsFreeFull(NestingLevels *nls, void *ctxData)
{
int i;
NestingLevel *nl;
Expand All @@ -51,7 +51,7 @@ extern void nestingLevelsFree(NestingLevels *nls)
{
nl = NL_NTH(nls, i);
if (nls->deleteUserData)
nls->deleteUserData (nl);
nls->deleteUserData (nl, ctxData);
nl->corkIndex = CORK_NIL;
}
if (nls->levels) eFree(nls->levels);
Expand Down Expand Up @@ -89,13 +89,13 @@ extern NestingLevel *nestingLevelsTruncate(NestingLevels *nls, int depth, int co
}


extern void nestingLevelsPop(NestingLevels *nls)
extern void nestingLevelsPopFull(NestingLevels *nls, void *ctxData)
{
NestingLevel *nl = nestingLevelsGetCurrent(nls);

Assert (nl != NULL);
if (nls->deleteUserData)
nls->deleteUserData (nl);
nls->deleteUserData (nl, ctxData);
nl->corkIndex = CORK_NIL;
nls->n--;
}
Expand Down
12 changes: 8 additions & 4 deletions main/nestlevel.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,23 @@ struct NestingLevels
int n; /* number of levels in use */
int allocated;
size_t userDataSize;
void (* deleteUserData) (NestingLevel *);
/* The second argument is given via nestinglevelsPopFull
* or nestinglevelFreeFull */
void (* deleteUserData) (NestingLevel *, void *);
};

/*
* FUNCTION PROTOTYPES
*/
extern NestingLevels *nestingLevelsNew(size_t userDataSize);
extern NestingLevels *nestingLevelsNewFull(size_t userDataSize,
void (* deleteUserData)(NestingLevel *));
extern void nestingLevelsFree(NestingLevels *nls);
void (* deleteUserData)(NestingLevel *, void *));
#define nestingLevelsFree(NLS) nestingLevelsFreeFull(NLS, NULL)
extern void nestingLevelsFreeFull(NestingLevels *nls, void *ctxData);
extern NestingLevel *nestingLevelsPush(NestingLevels *nls, int corkIndex);
extern NestingLevel * nestingLevelsTruncate(NestingLevels *nls, int depth, int corkIndex);
extern void nestingLevelsPop(NestingLevels *nls);
#define nestingLevelsPop(NLS) nestingLevelsPopFull(NLS, NULL)
extern void nestingLevelsPopFull(NestingLevels *nls, void *ctxData);
#define nestingLevelsGetCurrent(NLS) nestingLevelsGetNthParent((NLS), 0)
extern NestingLevel *nestingLevelsGetNthFromRoot(const NestingLevels *nls, int n);
extern NestingLevel *nestingLevelsGetNthParent(const NestingLevels *nls, int n);
Expand Down
Loading

0 comments on commit e7f2c05

Please sign in to comment.