-
Notifications
You must be signed in to change notification settings - Fork 591
/
html.c
63 lines (53 loc) · 1.66 KB
/
html.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
* Copyright (c) 2003, Darren Hiebert
*
* This source code is released for free distribution under the terms of the
* GNU General Public License version 2 or (at your option) any later version.
*
* This module contains functions for generating tags for HTML language
* files.
*/
/*
* INCLUDE FILES
*/
#include "general.h" /* must always come first */
#include "parse.h"
#include "routines.h"
static tagRegexTable htmlTagRegexTable [] = {
#define POSSIBLE_ATTRIBUTES "([ \t]+[a-z]+=\"?[^>\"]*\"?)*"
{"<a"
POSSIBLE_ATTRIBUTES "[ \t]+name=\"?([^>\"]+)\"?" POSSIBLE_ATTRIBUTES
"[ \t]*>", "\\2",
"a,anchor,named anchors", "i"},
{"^[ \t]*function[ \t]*([A-Za-z0-9_]+)[ \t]*\\(", "\\1",
"f,function,JavaScript functions", NULL},
/* the following matches headings with tags inside like
* <h1><a href="#id109"><i>Some Text</i></a></h1>
* and
* <h1>Some Text</h1> */
#define SPACES "[ \t]*"
#define ATTRS "[^>]*"
#define INNER_HEADING \
ATTRS ">" SPACES "(<" ATTRS ">" SPACES ")*([^<]+).*"
{"<h1" INNER_HEADING "</h1>", "\\2",
"n,namespace,H1 heading", "i"},
{"<h2" INNER_HEADING "</h2>", "\\2",
"c,class,H2 heading", "i"},
{"<h3" INNER_HEADING "</h3>", "\\2",
"v,variable,H3 heading", "i"},
};
/*
* FUNCTION DEFINITIONS
*/
/* Create parser definition structure */
extern parserDefinition* HtmlParser (void)
{
static const char *const extensions [] = { "htm", "html", NULL };
parserDefinition *const def = parserNew ("HTML");
def->extensions = extensions;
def->tagRegexTable = htmlTagRegexTable;
def->tagRegexCount = ARRAY_SIZE (htmlTagRegexTable);
def->method = METHOD_NOT_CRAFTED|METHOD_REGEX;
return def;
}
/* vi:set tabstop=4 shiftwidth=4: */