mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-11-23 06:51:26 +03:00
[project @ 2006-04-04 10:56:21 by dsilvers]
New way to do the <pre> newline stripping to cope with tags in the <pre> svn path=/import/netsurf/; revision=2486
This commit is contained in:
parent
cb243c8565
commit
e32213f5e4
@ -67,6 +67,7 @@ struct box * box_create(struct css_style *style,
|
||||
box->length = 0;
|
||||
box->space = 0;
|
||||
box->clone = 0;
|
||||
box->strip_leading_newline = 0;
|
||||
box->href = href;
|
||||
box->target = target;
|
||||
box->title = title;
|
||||
|
@ -163,6 +163,10 @@ struct box {
|
||||
/** This box is a continuation of the previous box (eg from line
|
||||
* breaking). */
|
||||
unsigned int clone : 1;
|
||||
/** This box represents a <pre> tag which has not yet had its white
|
||||
* space stripped if possible
|
||||
*/
|
||||
unsigned int strip_leading_newline : 1;
|
||||
|
||||
char *href; /**< Link, or 0. */
|
||||
const char *target; /**< Link target, or 0. */
|
||||
|
@ -115,6 +115,7 @@ static bool box_frameset(BOX_SPECIAL_PARAMS);
|
||||
static bool box_select_add_option(struct form_control *control, xmlNode *n);
|
||||
static bool box_object(BOX_SPECIAL_PARAMS);
|
||||
static bool box_embed(BOX_SPECIAL_PARAMS);
|
||||
static bool box_pre(BOX_SPECIAL_PARAMS);
|
||||
/*static bool box_applet(BOX_SPECIAL_PARAMS);*/
|
||||
static bool box_iframe(BOX_SPECIAL_PARAMS);
|
||||
static bool box_get_attribute(xmlNode *n, const char *attribute,
|
||||
@ -141,6 +142,7 @@ static const struct element_entry element_table[] = {
|
||||
{"img", box_image},
|
||||
{"input", box_input},
|
||||
{"object", box_object},
|
||||
{"pre", box_pre},
|
||||
{"select", box_select},
|
||||
{"textarea", box_textarea}
|
||||
};
|
||||
@ -293,7 +295,13 @@ bool box_construct_element(xmlNode *n, struct content *content,
|
||||
assert(inline_container);
|
||||
|
||||
gui_multitask();
|
||||
|
||||
|
||||
/* In case the parent is a pre block, we clear the
|
||||
* strip_leading_newline flag since it is not used if we
|
||||
* follow the pre with a tag
|
||||
*/
|
||||
parent->strip_leading_newline = 0;
|
||||
|
||||
style = box_get_style(content, parent_style, n);
|
||||
if (!style)
|
||||
return false;
|
||||
@ -627,13 +635,16 @@ bool box_construct_text(xmlNode *n, struct content *content,
|
||||
current = text;
|
||||
|
||||
/* swallow a single leading new line */
|
||||
switch (*current) {
|
||||
case '\n':
|
||||
current++; break;
|
||||
case '\r':
|
||||
current++;
|
||||
if (*current == '\n') current++;
|
||||
break;
|
||||
if (parent->strip_leading_newline) {
|
||||
switch (*current) {
|
||||
case '\n':
|
||||
current++; break;
|
||||
case '\r':
|
||||
current++;
|
||||
if (*current == '\n') current++;
|
||||
break;
|
||||
}
|
||||
parent->strip_leading_newline = 0;
|
||||
}
|
||||
|
||||
do {
|
||||
@ -1150,6 +1161,15 @@ bool box_br(BOX_SPECIAL_PARAMS)
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Preformatted text [9.3.4].
|
||||
*/
|
||||
|
||||
bool box_pre(BOX_SPECIAL_PARAMS)
|
||||
{
|
||||
box->strip_leading_newline = 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Anchor [12.2].
|
||||
|
Loading…
Reference in New Issue
Block a user