Kaydet (Commit) c0990b5e authored tarafından Enrico Tröger's avatar Enrico Tröger

Add HTML parser to get h1, h2, h3 symbols as well as link anchors and JavaScript…

Add HTML parser to get h1, h2, h3 symbols as well as link anchors and JavaScript functions (closes #1896068).


git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@2317 ea778897-0a13-0410-b9d1-a72fbfd435f5
üst 3eca552b
......@@ -3,6 +3,10 @@
* src/document.c:
Use SCI_SETSCROLLWIDTHTRACKING to improve horizontal scrollbar
behaviour by always adjusting to the longest line (part of #1905141).
* src/filetypes.c, src/symbols.c, tagmanager/parsers.h,
tagmanager/makefile.win32, tagmanager/html.c, tagmanager/Makefile.am:
Add HTML parser to get h1, h2, h3 symbols as well as link anchors and
JavaScript functions (closes #1896068).
2008-03-07 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
......
......@@ -364,7 +364,7 @@ void filetypes_init_types()
#define HTML
filetypes[GEANY_FILETYPES_HTML]->id = GEANY_FILETYPES_HTML;
filetypes[GEANY_FILETYPES_HTML]->uid = FILETYPE_UID_HTML;
filetypes[GEANY_FILETYPES_HTML]->lang = -2;
filetypes[GEANY_FILETYPES_HTML]->lang = 29;
filetypes[GEANY_FILETYPES_HTML]->name = g_strdup("HTML");
filetypes[GEANY_FILETYPES_HTML]->title = g_strdup_printf(_("%s source file"), "HTML");
filetypes[GEANY_FILETYPES_HTML]->extension = g_strdup("html");
......
......@@ -615,6 +615,17 @@ static void init_tag_list(gint idx)
/*&(tv_iters.tag_other), _("Other"), NULL);*/
break;
}
case GEANY_FILETYPES_HTML:
{
tag_list_add_groups(tag_store,
&(tv_iters.tag_function), _("JavaScript functions"), NULL,
&(tv_iters.tag_member), _("Anchor"), NULL,
&(tv_iters.tag_namespace), _("Heading (H1)"), NULL,
&(tv_iters.tag_class), _("Heading (H2)"), NULL,
&(tv_iters.tag_variable), _("Heading (H3)"), NULL,
NULL);
break;
}
case GEANY_FILETYPES_REST:
{
tag_list_add_groups(tag_store,
......
......@@ -36,6 +36,7 @@ libtagmanager_a_SOURCES =\
fortran.c\
haskell.c\
haxe.c\
html.c\
js.c\
lua.c\
make.c\
......
/*
* $Id$
*
* Copyright (c) 2003, Darren Hiebert
*
* This source code is released for free distribution under the terms of the
* GNU General Public License.
*
* This module contains functions for generating tags for HTML language
* files.
*/
/*
* INCLUDE FILES
*/
#include "general.h" /* must always come first */
#include "parse.h"
/*
* FUNCTION DEFINITIONS
*/
static void installHtmlRegex (const langType language)
{
#define POSSIBLE_ATTRIBUTES "([ \t]+[a-z]+=\"?[^>\"]*\"?)*"
/* the following matches headings with "<a>" tags inside like
* <h1><a href="#id109">Some Text</a></h1>
* but it fails matching simple headings like
* <h1>Some Text</h1> */
/*#define INNER_HEADING "[ \t]*(<.*>(.*+)<.*>[ \t]*"*/
/* this matches simple heading without nested tags */
/** TODO combine both pattern to be able to match both heading styles */
#define INNER_HEADING "[ \t]*(.*+)[ \t]*"
addTagRegex (language,
"<a"
POSSIBLE_ATTRIBUTES
"[ \t]+name=\"?([^>\"]+)\"?"
POSSIBLE_ATTRIBUTES
"[ \t]*>",
"\\2", "m,member,named anchors", "i");
addTagRegex (language,
"<h1>" INNER_HEADING "</h1>",
"\\1", "n,namespace,H1 heading", "i");
addTagRegex (language,
"<h2>" INNER_HEADING "</h2>",
"\\1", "c,class,H2 heading", "i");
addTagRegex (language,
"<h3>" INNER_HEADING "</h3>",
"\\1", "v,variable,H3 heading", "i");
addTagRegex (language, "^[ \t]*function[ \t]*([A-Za-z0-9_]+)[ \t]*\\(",
"\\1", "f,function,JavaScript functions", NULL);
}
/* Create parser definition stucture */
extern parserDefinition* HtmlParser (void)
{
static const char *const extensions [] = { "htm", "html", NULL };
parserDefinition *const def = parserNew ("HTML");
def->extensions = extensions;
def->initialize = installHtmlRegex;
def->regex = TRUE;
return def;
}
/* vi:set tabstop=4 shiftwidth=4: */
......@@ -35,10 +35,10 @@ clean:
-$(RM) deps.mak *.o $(COMPLIB)
$(COMPLIB): args.o c.o fortran.o make.o conf.o pascal.o perl.o php.o diff.o vhdl.o lua.o js.o \
haskell.o haxe.o python.o lregex.o rest.o sh.o ctags.o entry.o get.o keyword.o options.o parse.o basic.o \
read.o sort.o strlist.o latex.o docbook.o tcl.o ruby.o asm.o sql.o css.o vstring.o regex.o \
tm_workspace.o tm_work_object.o tm_source_file.o tm_project.o tm_tag.o tm_symbol.o tm_file_entry.o \
tm_tagmanager.o
haskell.o haxe.o html.o python.o lregex.o rest.o sh.o ctags.o entry.o get.o keyword.o options.o \
parse.o basic.o read.o sort.o strlist.o latex.o docbook.o tcl.o ruby.o asm.o sql.o css.o \
vstring.o regex.o tm_workspace.o tm_work_object.o tm_source_file.o tm_project.o tm_tag.o \
tm_symbol.o tm_file_entry.o tm_tagmanager.o
$(AR) rc $@ $^
$(RANLIB) $@
......
......@@ -43,7 +43,8 @@
CsharpParser, \
FreeBasicParser,\
HaxeParser,\
RestParser
RestParser, \
HtmlParser
/*
langType of each parser
......@@ -76,6 +77,7 @@ langType of each parser
26 FreeBasicParser
27 HaxeParser
28 RestParser
29 HtmlParser
*/
#endif /* _PARSERS_H */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment