~ubuntu-branches/ubuntu/raring/geany/raring-proposed

« back to all changes in this revision

Viewing changes to tagmanager/html.c

  • Committer: Bazaar Package Importer
  • Author(s): Damián Viano
  • Date: 2008-05-02 11:37:45 UTC
  • mfrom: (1.2.1 upstream) (9 hardy)
  • mto: (3.2.1 squeeze)
  • mto: This revision was merged to the branch mainline in revision 12.
  • Revision ID: james.westby@ubuntu.com-20080502113745-xzp4g6dmovrpoj17
Tags: 0.14-1
New upstream release (Closes: #478126)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
*   $Id: html.c 2317 2008-03-09 18:50:41Z eht16 $
 
3
*
 
4
*   Copyright (c) 2003, Darren Hiebert
 
5
*
 
6
*   This source code is released for free distribution under the terms of the
 
7
*   GNU General Public License.
 
8
*
 
9
*   This module contains functions for generating tags for HTML language
 
10
*   files.
 
11
*/
 
12
 
 
13
/*
 
14
*   INCLUDE FILES
 
15
*/
 
16
#include "general.h"  /* must always come first */
 
17
#include "parse.h"
 
18
 
 
19
/*
 
20
*   FUNCTION DEFINITIONS
 
21
*/
 
22
 
 
23
static void installHtmlRegex (const langType language)
 
24
{
 
25
#define POSSIBLE_ATTRIBUTES "([ \t]+[a-z]+=\"?[^>\"]*\"?)*"
 
26
/* the following matches headings with "<a>" tags inside like
 
27
 * <h1><a href="#id109">Some Text</a></h1>
 
28
 * but it fails matching simple headings like
 
29
 * <h1>Some Text</h1> */
 
30
/*#define INNER_HEADING "[ \t]*(<.*>(.*+)<.*>[ \t]*"*/
 
31
 
 
32
/* this matches simple heading without nested tags */
 
33
/** TODO combine both pattern to be able to match both heading styles */
 
34
#define INNER_HEADING "[ \t]*(.*+)[ \t]*"
 
35
 
 
36
        addTagRegex (language,
 
37
                "<a"
 
38
                POSSIBLE_ATTRIBUTES
 
39
                "[ \t]+name=\"?([^>\"]+)\"?"
 
40
                POSSIBLE_ATTRIBUTES
 
41
                "[ \t]*>",
 
42
                "\\2", "m,member,named anchors", "i");
 
43
 
 
44
        addTagRegex (language,
 
45
                "<h1>" INNER_HEADING "</h1>",
 
46
                "\\1", "n,namespace,H1 heading", "i");
 
47
 
 
48
        addTagRegex (language,
 
49
                "<h2>" INNER_HEADING "</h2>",
 
50
                "\\1", "c,class,H2 heading", "i");
 
51
 
 
52
        addTagRegex (language,
 
53
                "<h3>" INNER_HEADING "</h3>",
 
54
                "\\1", "v,variable,H3 heading", "i");
 
55
 
 
56
        addTagRegex (language, "^[ \t]*function[ \t]*([A-Za-z0-9_]+)[ \t]*\\(",
 
57
                "\\1", "f,function,JavaScript functions", NULL);
 
58
}
 
59
 
 
60
/* Create parser definition stucture */
 
61
extern parserDefinition* HtmlParser (void)
 
62
{
 
63
        static const char *const extensions [] = { "htm", "html", NULL };
 
64
        parserDefinition *const def = parserNew ("HTML");
 
65
        def->extensions = extensions;
 
66
        def->initialize = installHtmlRegex;
 
67
        def->regex      = TRUE;
 
68
        return def;
 
69
}
 
70
 
 
71
/* vi:set tabstop=4 shiftwidth=4: */