Make parser includes closer to uctags and sync parser license header
[geany-mirror.git] / ctags / parsers / html.c
blobec2123ab84b6d0106f265c58fbaba4444d672500
1 /*
2 * Copyright (c) 2003, Darren Hiebert
4 * This source code is released for free distribution under the terms of the
5 * GNU General Public License version 2 or (at your option) any later version.
7 * This module contains functions for generating tags for HTML language
8 * files.
9 */
12 * INCLUDE FILES
14 #include "general.h" /* must always come first */
15 #include "parse.h"
16 #include "routines.h"
19 * FUNCTION DEFINITIONS
22 static void installHtmlRegex (const langType language)
24 #define POSSIBLE_ATTRIBUTES "([ \t]+[a-z]+=\"?[^>\"]*\"?)*"
26 addTagRegex (language,
27 "<a"
28 POSSIBLE_ATTRIBUTES
29 "[ \t]+name=\"?([^>\"]+)\"?"
30 POSSIBLE_ATTRIBUTES
31 "[ \t]*>",
32 "\\2", "a,anchor,named anchors", "i");
34 addTagRegex (language, "^[ \t]*function[ \t]*([A-Za-z0-9_]+)[ \t]*\\(",
35 "\\1", "f,function,JavaScript functions", NULL);
37 /* the following matches headings with tags inside like
38 * <h1><a href="#id109"><i>Some Text</i></a></h1>
39 * and
40 * <h1>Some Text</h1> */
41 #define SPACES "[ \t]*"
42 #define ATTRS "[^>]*"
43 #define INNER_HEADING \
44 ATTRS ">" SPACES "(<" ATTRS ">" SPACES ")*([^<]+).*"
46 addTagRegex (language,
47 "<h1" INNER_HEADING "</h1>",
48 "\\2", "n,namespace,H1 heading", "i");
50 addTagRegex (language,
51 "<h2" INNER_HEADING "</h2>",
52 "\\2", "c,class,H2 heading", "i");
54 addTagRegex (language,
55 "<h3" INNER_HEADING "</h3>",
56 "\\2", "v,variable,H3 heading", "i");
59 /* Create parser definition structure */
60 extern parserDefinition* HtmlParser (void)
62 static const char *const extensions [] = { "htm", "html", NULL };
63 parserDefinition *const def = parserNew ("HTML");
64 def->extensions = extensions;
65 def->initialize = installHtmlRegex;
66 def->regex = TRUE;
67 return def;
70 /* vi:set tabstop=4 shiftwidth=4: */