css load via href="xxx"
Federico Luna <[email protected]>
| Newsgroups | gmane.editors.qemacs.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi, I submit two patchs. Currently i working on "switch-buffer" to suggest the buffer from which we come. PATCHES: qemacs_csslink_1.patch a first version that implement file referencing of a css via: (<?xml-stylesheet type="text/css" href="xxx"?>, and <link href="xxx" > by the moment href="xxx" is interpreted as a relative to current document path. Next step is work on a "docroot_path" attribute in xmlparse with a coma separated list of path, that will search when referencing a css (or img) via href/src. This can solve the problem when a href/src has absolute path, in this case the user set the docroot path attribute for help xmlparse to find the correct file. Fabrice, what do you think? qemacs_msp_2.patch: This a very util patch for me, It add a flag to xmlparse the "MSP_SYNTAX", MSP stands "markup server page" (like JSP, ASP, PHP). With this flag set, the parse will accept: * <> inside of tags: <input type="text" <%=readonly%> /> * <> inside of attributes: <input type="hidden" name="<%=foo%>" /> (this are not a valid xml syntax, for that reason i add as a flag) This rules cause a better render of html. Of course html-mode, set MSP_SYNTAX flag in the xmlparse when initialize it. note: this patch work without apply the previous with some automatic HUNK offset correction _______________________________________________ Qemacs-devel mailing list [email protected] http://mail.nongnu.org/mailman/listinfo/qemacs-devel
qemacs_csslink_1.path
(application/octet-stream, 5 KB) - not displayed
qemacs_msp_2.patch
(application/octet-stream, 4.5 KB)
--- qemacs-0.3.1/libqhtml/xmlparse.c Fri Dec 19 11:45:08 2003
+++ qemacs-0.3.1_cssmsp/libqhtml/xmlparse.c Fri Dec 19 11:44:53 2003
@@ -246,6 +246,7 @@
CSSBox *box;
int is_html;
int html_syntax;
+ int msp_syntax; /* markup sever page syntax. (asp, jsp, etc) */
int ignore_case;
int flags;
CSSStyleSheet *style_sheet; /* if non NULL, all style sheets are
@@ -281,6 +282,7 @@
s->flags = flags;
s->is_html = flags & XML_HTML;
s->html_syntax = flags & XML_HTML_SYNTAX;
+ s->msp_syntax = flags & XML_MSP_SYNTAX;
s->ignore_case = flags & XML_IGNORE_CASE;
s->state = XML_STATE_TEXT;
s->box = NULL;
@@ -967,10 +970,21 @@
} else {
p++;
q = value;
- while (*p != och && *p != '\0' && *p != '<') {
- ch = parse_entity(&p);
- if ((q - value) < sizeof(value) - 1)
- *q++ = ch;
+ if (s->msp_syntax) {
+ /* for MSP syntax end of attribute is exclusive a " or '
+ * if not MSP, we are less restrictive
+ */
+ while (*p != och && *p != '\0') {
+ ch = parse_entity(&p);
+ if ((q - value) < sizeof(value) - 1)
+ *q++ = ch;
+ }
+ } else {
+ while (*p != och && *p != '\0' && *p != '<') {
+ ch = parse_entity(&p);
+ if ((q - value) < sizeof(value) - 1)
+ *q++ = ch;
+ }
}
*q = '\0';
if (*p != och) {
@@ -1151,6 +1165,7 @@
{
int ch, offset, offset0, text_offset_start, ret, offset_end;
const char *buf_end, *buf;
+ int nested_tag;
buf = buf_start;
buf_end = buf + buf_len;
@@ -1158,6 +1173,8 @@
offset_end = offset_start + buf_len;
offset0 = 0; /* not used */
text_offset_start = 0; /* not used */
+ nested_tag=0; /* used for MSP syntax */
+
for(;;) {
if (buf) {
if (buf >= buf_end)
@@ -1179,7 +1196,13 @@
switch(s->state) {
case XML_STATE_TAG:
- if (ch == '>') {
+ /* In MSP syntax we accept a '<xxxx>' inside a tag. */
+ if (s->msp_syntax) {
+ if (ch == '<')
+ nested_tag++;
+ }
+
+ if (ch == '>' && nested_tag==0) {
strbuf_addch(&s->str, '\0');
ret = parse_tag(s, s->str.buf);
switch(ret) {
@@ -1206,6 +1229,13 @@
s->state = XML_STATE_COMMENT;
}
}
+
+ /* this is for accept '<xxxxxx>' inside a tag. Used for MSP syntax */
+ if (s->msp_syntax) {
+ if (ch == '>' && nested_tag>0)
+ nested_tag--;
+ }
+
break;
case XML_STATE_TEXT:
if (ch == '<') {
--- qemacs-0.3.1/libqhtml/css.h Mon Apr 21 19:01:43 2003
+++ qemacs-0.3.1_cssmsp/libqhtml/css.h Fri Dec 19 02:37:44 2003
@@ -612,6 +612,8 @@
#define XML_IGNORE_CASE 0x0002 /* ignore case for both xml/css tag parsing */
#define XML_DOCBOOK 0x0004 /* programlisting is handled as PRE */
#define XML_HTML_SYNTAX 0x0008 /* modify xml parser to accept HTML syntax */
+#define XML_MSP_SYNTAX 0x0010 /* modify xml parser to accept Markup Server Page
+ syntax (like, asp, jsp, php, etc) */
XMLState *xml_begin(CSSStyleSheet *style_sheet, int flags,
CSSAbortFunc *abort_func, void *abort_opaque,
--- qemacs-0.3.1/html.c Mon Apr 21 19:01:42 2003
+++ qemacs-0.3.1_cssmsp/html.c Fri Dec 19 02:45:06 2003
@@ -39,7 +39,7 @@
CSSRect invalid_rect; /* this rectangle should be redrawn */
int up_to_date; /* true if css representation is synced with
buffer content */
- int parse_flags; /* can contain XML_HTML and XML_IGNORE_CASE */
+ int parse_flags; /* can contain XML_HTML and XML_IGNORE_CASE and XML_MSP_SYNTAX */
} HTMLState;
extern const char html_style[];
@@ -806,7 +806,8 @@
static int html_mode_init(EditState *s, ModeSavedData *saved_data)
{
return gxml_mode_init(s, saved_data,
- XML_HTML | XML_HTML_SYNTAX | XML_IGNORE_CASE,
+ XML_HTML | XML_HTML_SYNTAX |
+ XML_IGNORE_CASE | XML_MSP_SYNTAX,
html_style);
}