Fix a defect in how inline html blocks (& comments) are handled;

if the line with the closing tag has text after the close tag, break
that into a new line so it can be blockified in the normal fashion.
This commit is contained in:
David Parsons
2010-03-14 00:09:46 -08:00
parent 444178882d
commit f70287c060
2 changed files with 65 additions and 1 deletions
+22 -1
View File
@@ -171,6 +171,8 @@ typedef struct _flo {
int i;
} FLO;
#define floindex(x) (x.i)
static int
flogetc(FLO *f)
@@ -186,6 +188,22 @@ flogetc(FLO *f)
}
static void
splitline(Line *t, int cutpoint)
{
if ( t && (cutpoint < S(t->text)) ) {
Line *tmp = calloc(1, sizeof *tmp);
tmp->next = t->next;
t->next = tmp;
tmp->dle = t->dle;
SUFFIX(tmp->text, T(t->text)+cutpoint, S(t->text)-cutpoint);
S(t->text) = cutpoint;
}
}
static Line *
htmlblock(Paragraph *p, struct kw *tag)
{
@@ -232,6 +250,7 @@ htmlblock(Paragraph *p, struct kw *tag)
}
if ( !f.t )
return 0;
splitline(f.t, floindex(f));
ret = f.t->next;
f.t->next = 0;
return ret;
@@ -248,9 +267,11 @@ static Line *
comment(Paragraph *p)
{
Line *t, *ret;
char *end;
for ( t = p->text; t ; t = t->next) {
if ( strstr(T(t->text), "-->") ) {
if ( end = strstr(T(t->text), "-->") ) {
splitline(t, 3 + (end - T(t->text)) );
ret = t->next;
t->next = 0;
return ret;
+43
View File
@@ -90,5 +90,48 @@ so is this</div>'
try 'unfinished tags' '<foo bar' '<p>&lt;foo bar</p>'
try 'comment with trailing text' '<!-- this is -->a test' \
'<!-- this is -->
<p>a test</p>'
try 'block with trailing text' '<p>this is</p>a test' \
'<p>this is</p>
<p>a test</p>'
COMMENTS='<!-- 1. -->line 1
<!-- 2. -->line 2'
try 'two comments' "$COMMENTS" \
'<!-- 1. -->
<p>line 1</p>
<!-- 2. -->
<p>line 2</p>'
COMMENTS='<!-- 1. -->line 1
<!-- 2. -->line 2'
try 'two adjacent comments' "$COMMENTS" \
'<!-- 1. -->
<p>line 1</p>
<!-- 2. -->
<p>line 2</p>'
summary $0
exit $rc