mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
[blockquote] Changed rendering of blockquote. Refs #103
Previously blockquote was adding two spaces to the left margin. Now it adds >. It is not finished yet, needs some testing and feedback.
This commit is contained in:
parent
f351fbcf6a
commit
c72569d723
@ -101,6 +101,7 @@ struct par_attrib {
|
|||||||
int rightmargin;
|
int rightmargin;
|
||||||
int width;
|
int width;
|
||||||
int list_level;
|
int list_level;
|
||||||
|
int blockquote_level;
|
||||||
unsigned list_number;
|
unsigned list_number;
|
||||||
int dd_margin;
|
int dd_margin;
|
||||||
enum format_list_flag flags;
|
enum format_list_flag flags;
|
||||||
|
@ -529,8 +529,19 @@ void
|
|||||||
html_blockquote(struct html_context *html_context, char *a,
|
html_blockquote(struct html_context *html_context, char *a,
|
||||||
char *xxx3, char *xxx4, char **xxx5)
|
char *xxx3, char *xxx4, char **xxx5)
|
||||||
{
|
{
|
||||||
par_format.leftmargin += 2;
|
|
||||||
par_format.align = ALIGN_LEFT;
|
par_format.align = ALIGN_LEFT;
|
||||||
|
if (par_format.blockquote_level == 0) {
|
||||||
|
par_format.blockquote_level++;
|
||||||
|
}
|
||||||
|
par_format.blockquote_level++;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
html_blockquote_close(struct html_context *html_context, char *a,
|
||||||
|
char *xxx3, char *xxx4, char **xxx5)
|
||||||
|
{
|
||||||
|
if (par_format.blockquote_level == 2) par_format.blockquote_level--;
|
||||||
|
if (par_format.blockquote_level > 0) par_format.blockquote_level--;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -11,6 +11,7 @@ extern "C" {
|
|||||||
element_handler_T html_address;
|
element_handler_T html_address;
|
||||||
element_handler_T html_base;
|
element_handler_T html_base;
|
||||||
element_handler_T html_blockquote;
|
element_handler_T html_blockquote;
|
||||||
|
element_handler_T html_blockquote_close;
|
||||||
element_handler_T html_body;
|
element_handler_T html_body;
|
||||||
element_handler_T html_bold;
|
element_handler_T html_bold;
|
||||||
element_handler_T html_br;
|
element_handler_T html_br;
|
||||||
|
@ -433,7 +433,7 @@ static struct element_info elements[] = {
|
|||||||
{"B", html_bold, NULL, 0, ET_NESTABLE },
|
{"B", html_bold, NULL, 0, ET_NESTABLE },
|
||||||
{"BASE", html_base, NULL, 0, ET_NON_PAIRABLE},
|
{"BASE", html_base, NULL, 0, ET_NON_PAIRABLE},
|
||||||
{"BASEFONT", html_font, NULL, 0, ET_NON_PAIRABLE},
|
{"BASEFONT", html_font, NULL, 0, ET_NON_PAIRABLE},
|
||||||
{"BLOCKQUOTE", html_blockquote, NULL, 2, ET_NESTABLE },
|
{"BLOCKQUOTE", html_blockquote, html_blockquote_close,2, ET_NESTABLE },
|
||||||
{"BODY", html_body, NULL, 0, ET_NESTABLE },
|
{"BODY", html_body, NULL, 0, ET_NESTABLE },
|
||||||
{"BR", html_br, NULL, 1, ET_NON_PAIRABLE},
|
{"BR", html_br, NULL, 1, ET_NON_PAIRABLE},
|
||||||
{"BUTTON", html_button, NULL, 0, ET_NESTABLE },
|
{"BUTTON", html_button, NULL, 0, ET_NESTABLE },
|
||||||
|
@ -531,6 +531,23 @@ set_hline(struct html_context *html_context, char *chars, int charslen,
|
|||||||
Y(y), X(x) + charslen);
|
Y(y), X(x) + charslen);
|
||||||
if (orig_length < 0) /* error */
|
if (orig_length < 0) /* error */
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
if (part->begin) {
|
||||||
|
if (par_format.blockquote_level) {
|
||||||
|
int i;
|
||||||
|
x = part->cx - par_format.blockquote_level;
|
||||||
|
schar->data = '>';
|
||||||
|
for (i = 1; i < par_format.blockquote_level; i++) {
|
||||||
|
copy_screen_chars(&POS(x, y), schar, 1);
|
||||||
|
part->char_width[x++] = 1;
|
||||||
|
}
|
||||||
|
schar->data = ' ';
|
||||||
|
copy_screen_chars(&POS(x, y), schar, 1);
|
||||||
|
part->char_width[x++] = 1;
|
||||||
|
}
|
||||||
|
part->begin = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (utf8) {
|
if (utf8) {
|
||||||
char *const end = chars + charslen;
|
char *const end = chars + charslen;
|
||||||
unicode_val_T data;
|
unicode_val_T data;
|
||||||
@ -765,6 +782,22 @@ set_hline(struct html_context *html_context, char *chars, int charslen,
|
|||||||
Y(y), X(x) + charslen - 1) < 0)
|
Y(y), X(x) + charslen - 1) < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (part->begin) {
|
||||||
|
if (par_format.blockquote_level) {
|
||||||
|
int i;
|
||||||
|
x = part->cx - par_format.blockquote_level;
|
||||||
|
schar->data = '>';
|
||||||
|
for (i = 1; i < par_format.blockquote_level; i++) {
|
||||||
|
copy_screen_chars(&POS(x, y), schar, 1);
|
||||||
|
part->char_width[x++] = 1;
|
||||||
|
}
|
||||||
|
schar->data = ' ';
|
||||||
|
copy_screen_chars(&POS(x, y), schar, 1);
|
||||||
|
part->char_width[x++] = 1;
|
||||||
|
}
|
||||||
|
part->begin = 0;
|
||||||
|
}
|
||||||
|
|
||||||
for (; charslen > 0; charslen--, x++, chars++) {
|
for (; charslen > 0; charslen--, x++, chars++) {
|
||||||
if (*chars == NBSP_CHAR) {
|
if (*chars == NBSP_CHAR) {
|
||||||
schar->data = ' ';
|
schar->data = ' ';
|
||||||
@ -937,6 +970,7 @@ move_chars(struct html_context *html_context, int x, int y, int nx, int ny)
|
|||||||
if_assert_failed return;
|
if_assert_failed return;
|
||||||
|
|
||||||
if (LEN(y) - x <= 0) return;
|
if (LEN(y) - x <= 0) return;
|
||||||
|
|
||||||
copy_chars(html_context, nx, ny, LEN(y) - x, &POS(x, y));
|
copy_chars(html_context, nx, ny, LEN(y) - x, &POS(x, y));
|
||||||
|
|
||||||
assert_comb_x_y_ok(part->document);
|
assert_comb_x_y_ok(part->document);
|
||||||
@ -1042,16 +1076,15 @@ split_line_at(struct html_context *html_context, int width)
|
|||||||
#ifdef CONFIG_UTF8
|
#ifdef CONFIG_UTF8
|
||||||
if (html_context->options->utf8
|
if (html_context->options->utf8
|
||||||
&& width < part->spaces_len && part->char_width[width] == 2) {
|
&& width < part->spaces_len && part->char_width[width] == 2) {
|
||||||
move_chars(html_context, width, part->cy, par_format.leftmargin, part->cy + 1);
|
move_chars(html_context, width, part->cy, par_format.leftmargin + par_format.blockquote_level, part->cy + 1);
|
||||||
del_chars(html_context, width, part->cy);
|
del_chars(html_context, width, part->cy);
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
assertm(POS(width, part->cy).data == ' ',
|
assertm(POS(width, part->cy).data == ' ',
|
||||||
"bad split: %c", POS(width, part->cy).data);
|
"bad split: %c", POS(width, part->cy).data);
|
||||||
move_chars(html_context, width + 1, part->cy, par_format.leftmargin, part->cy + 1);
|
move_chars(html_context, width + 1, part->cy, par_format.leftmargin + par_format.blockquote_level, part->cy + 1);
|
||||||
del_chars(html_context, width, part->cy);
|
del_chars(html_context, width, part->cy);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1078,13 +1111,13 @@ split_line_at(struct html_context *html_context, int width)
|
|||||||
memset(part->char_width + tmp, 0, width);
|
memset(part->char_width + tmp, 0, width);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (par_format.leftmargin > 0) {
|
if (par_format.leftmargin + par_format.blockquote_level > 0) {
|
||||||
tmp = part->spaces_len - par_format.leftmargin;
|
tmp = part->spaces_len - (par_format.leftmargin + par_format.blockquote_level);
|
||||||
assertm(tmp > 0, "part->spaces_len - par_format.leftmargin == %d", tmp);
|
assertm(tmp > 0, "part->spaces_len - par_format.leftmargin == %d", tmp);
|
||||||
/* So tmp is zero, memmove() should survive that. Don't recover. */
|
/* So tmp is zero, memmove() should survive that. Don't recover. */
|
||||||
memmove(part->spaces + par_format.leftmargin, part->spaces, tmp);
|
memmove(part->spaces + par_format.leftmargin + par_format.blockquote_level, part->spaces, tmp);
|
||||||
#ifdef CONFIG_UTF8
|
#ifdef CONFIG_UTF8
|
||||||
memmove(part->char_width + par_format.leftmargin, part->char_width, tmp);
|
memmove(part->char_width + par_format.leftmargin + par_format.blockquote_level, part->char_width, tmp);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1095,7 +1128,7 @@ split_line_at(struct html_context *html_context, int width)
|
|||||||
int_lower_bound(&part->box.height, part->cy);
|
int_lower_bound(&part->box.height, part->cy);
|
||||||
return 2;
|
return 2;
|
||||||
} else {
|
} else {
|
||||||
part->cx -= width - par_format.leftmargin;
|
part->cx -= width - (par_format.leftmargin + par_format.blockquote_level);
|
||||||
int_lower_bound(&part->box.height, part->cy + 1);
|
int_lower_bound(&part->box.height, part->cy + 1);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -1125,33 +1158,33 @@ split_line(struct html_context *html_context)
|
|||||||
|
|
||||||
#ifdef CONFIG_UTF8
|
#ifdef CONFIG_UTF8
|
||||||
if (html_context->options->utf8) {
|
if (html_context->options->utf8) {
|
||||||
for (x = overlap(par_format); x >= par_format.leftmargin; x--) {
|
for (x = overlap(par_format); x >= (par_format.leftmargin + par_format.blockquote_level); x--) {
|
||||||
|
|
||||||
if (x < part->spaces_len && (part->spaces[x]
|
if (x < part->spaces_len && (part->spaces[x]
|
||||||
|| (part->char_width[x] == 2
|
|| (part->char_width[x] == 2
|
||||||
/* Ugly hack. If we haven't place for
|
/* Ugly hack. If we haven't place for
|
||||||
* double-width characters we print two
|
* double-width characters we print two
|
||||||
* double-width characters. */
|
* double-width characters. */
|
||||||
&& x != par_format.leftmargin)))
|
&& x != (par_format.leftmargin + par_format.blockquote_level))))
|
||||||
return split_line_at(html_context, x);
|
return split_line_at(html_context, x);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (x = par_format.leftmargin; x < part->cx ; x++) {
|
for (x = par_format.leftmargin + par_format.blockquote_level; x < part->cx ; x++) {
|
||||||
if (x < part->spaces_len && (part->spaces[x]
|
if (x < part->spaces_len && (part->spaces[x]
|
||||||
|| (part->char_width[x] == 2
|
|| (part->char_width[x] == 2
|
||||||
/* We want to break line after _second_
|
/* We want to break line after _second_
|
||||||
* double-width character. */
|
* double-width character. */
|
||||||
&& x > par_format.leftmargin)))
|
&& x > (par_format.leftmargin + par_format.blockquote_level))))
|
||||||
return split_line_at(html_context, x);
|
return split_line_at(html_context, x);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
for (x = overlap(par_format); x >= par_format.leftmargin; x--)
|
for (x = overlap(par_format); x >= (par_format.leftmargin + par_format.blockquote_level); x--)
|
||||||
if (x < part->spaces_len && part->spaces[x])
|
if (x < part->spaces_len && part->spaces[x])
|
||||||
return split_line_at(html_context, x);
|
return split_line_at(html_context, x);
|
||||||
|
|
||||||
for (x = par_format.leftmargin; x < part->cx ; x++)
|
for (x = par_format.leftmargin + par_format.blockquote_level; x < part->cx ; x++)
|
||||||
if (x < part->spaces_len && part->spaces[x])
|
if (x < part->spaces_len && part->spaces[x])
|
||||||
return split_line_at(html_context, x);
|
return split_line_at(html_context, x);
|
||||||
}
|
}
|
||||||
@ -1632,7 +1665,10 @@ put_link_number(struct html_context *html_context)
|
|||||||
|
|
||||||
/* We might have ended up on a new line after the line breaking
|
/* We might have ended up on a new line after the line breaking
|
||||||
* or putting the link number chars. */
|
* or putting the link number chars. */
|
||||||
if (part->cx == -1) part->cx = par_format.leftmargin;
|
if (part->cx == -1) {
|
||||||
|
part->cx = par_format.leftmargin + par_format.blockquote_level;
|
||||||
|
part->begin = 1;
|
||||||
|
}
|
||||||
|
|
||||||
format.link = fl;
|
format.link = fl;
|
||||||
format.target = ft;
|
format.target = ft;
|
||||||
@ -1845,7 +1881,8 @@ put_chars(struct html_context *html_context, char *chars, int charslen)
|
|||||||
if (charslen < 1) return;
|
if (charslen < 1) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
part->cx = par_format.leftmargin;
|
part->cx = par_format.leftmargin + par_format.blockquote_level;
|
||||||
|
part->begin = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* For preformatted html always update 'the last tag' so we never end
|
/* For preformatted html always update 'the last tag' so we never end
|
||||||
@ -1909,7 +1946,7 @@ put_chars(struct html_context *html_context, char *chars, int charslen)
|
|||||||
|
|
||||||
if (html_context->options->wrap || !html_is_preformatted()) {
|
if (html_context->options->wrap || !html_is_preformatted()) {
|
||||||
while (part->cx > overlap(par_format)
|
while (part->cx > overlap(par_format)
|
||||||
&& part->cx > par_format.leftmargin) {
|
&& part->cx > (par_format.leftmargin + par_format.blockquote_level)) {
|
||||||
int x = split_line(html_context);
|
int x = split_line(html_context);
|
||||||
|
|
||||||
if (!x) break;
|
if (!x) break;
|
||||||
@ -1926,7 +1963,7 @@ put_chars(struct html_context *html_context, char *chars, int charslen)
|
|||||||
part->xa += charslen;
|
part->xa += charslen;
|
||||||
#endif /* CONFIG_UTF8 */
|
#endif /* CONFIG_UTF8 */
|
||||||
int_lower_bound(&part->max_width, part->xa
|
int_lower_bound(&part->max_width, part->xa
|
||||||
+ par_format.leftmargin + par_format.rightmargin
|
+ par_format.leftmargin + par_format.blockquote_level + par_format.rightmargin
|
||||||
- (chars[charslen - 1] == ' '
|
- (chars[charslen - 1] == ' '
|
||||||
&& (html_context->options->wrap || !html_is_preformatted())));
|
&& (html_context->options->wrap || !html_is_preformatted())));
|
||||||
}
|
}
|
||||||
@ -1961,7 +1998,7 @@ line_break(struct html_context *html_context)
|
|||||||
if (!realloc_lines(part->document, part->box.height + part->cy + 1))
|
if (!realloc_lines(part->document, part->box.height + part->cy + 1))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (part->cx > par_format.leftmargin && LEN(part->cy) > part->cx - 1
|
if (part->cx > (par_format.leftmargin + par_format.blockquote_level) && LEN(part->cy) > part->cx - 1
|
||||||
&& POS(part->cx - 1, part->cy).data == ' ') {
|
&& POS(part->cx - 1, part->cy).data == ' ') {
|
||||||
del_chars(html_context, part->cx - 1, part->cy);
|
del_chars(html_context, part->cx - 1, part->cy);
|
||||||
part->cx--;
|
part->cx--;
|
||||||
@ -2556,7 +2593,7 @@ render_html_document(struct cache_entry *cached, struct document *document,
|
|||||||
done_string(&title);
|
done_string(&title);
|
||||||
|
|
||||||
part = format_html_part(html_context, start, end, par_format.align,
|
part = format_html_part(html_context, start, end, par_format.align,
|
||||||
par_format.leftmargin,
|
par_format.leftmargin + par_format.blockquote_level,
|
||||||
document->options.document_width, document,
|
document->options.document_width, document,
|
||||||
0, 0, head.source, 1);
|
0, 0, head.source, 1);
|
||||||
|
|
||||||
|
@ -59,6 +59,7 @@ struct part {
|
|||||||
int xa;
|
int xa;
|
||||||
int cx, cy;
|
int cx, cy;
|
||||||
int link_num;
|
int link_num;
|
||||||
|
unsigned int begin:1;
|
||||||
};
|
};
|
||||||
|
|
||||||
void expand_lines(struct html_context *html_context, struct part *part,
|
void expand_lines(struct html_context *html_context, struct part *part,
|
||||||
|
Loading…
Reference in New Issue
Block a user