[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
texinfo/makeinfo html.c,1.2,1.3
From: |
dirt |
Subject: |
texinfo/makeinfo html.c,1.2,1.3 |
Date: |
Sun, 28 Dec 2003 13:40:36 +0100 |
Update of /cvsroot/texinfo/texinfo/makeinfo
In directory sheep:/tmp/cvs-serv12893/makeinfo
Modified Files:
html.c
Log Message:
2003-12-28 Alper Ersoy <address@hidden>
* makeinfo/html.c (rollback_empty_tag): new function.
(insert_html_tag): try rollback_empty_tag before closing both
tag and old_tag.
Index: html.c
===================================================================
RCS file: /cvsroot/texinfo/texinfo/makeinfo/html.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** html.c 2003/12/28 11:48:52 1.2
--- html.c 2003/12/28 12:40:34 1.3
***************
*** 413,416 ****
--- 413,458 ----
}
+ /* Check if tag is an empty or a whitespace only element.
+ If so, remove it, keeping whitespace intact. */
+ int
+ rollback_empty_tag (tag)
+ char *tag;
+ {
+ int check_position = output_paragraph_offset;
+ char *tag_with_lt_gt = xmalloc (strlen (tag) + sizeof ("<>"));
+ char *whitespace;
+
+ /* Prepare check tag. */
+ snprintf (tag_with_lt_gt, strlen (tag) + sizeof ("<>"), "<%s>", tag);
+
+ /* Skip whitespace at the end of output_paragraph. */
+ while (output_paragraph[check_position-1] == ' '
+ || output_paragraph[check_position-1] == '\n'
+ || output_paragraph[check_position-1] == '\t')
+ check_position--;
+
+ if (check_position != output_paragraph_offset)
+ { /* We have whitespace to save. */
+ whitespace = xmalloc (output_paragraph_offset - check_position);
+ memcpy (whitespace, output_paragraph + check_position,
+ output_paragraph_offset - check_position);
+ }
+
+ /* Adjust check_position so it shows the start of opening tag. */
+ /* (-1 is for NULL.) */
+ check_position -= strlen (tag) + sizeof ("<>") - 1;
+
+ /* Actual check. */
+ if (strncmp ((char *) output_paragraph + check_position,
+ tag_with_lt_gt, strlen (tag_with_lt_gt)) == 0)
+ {
+ /* Rollback. */
+ output_paragraph_offset = check_position;
+ return 1;
+ }
+ else
+ return 0;
+ }
+
/* Open or close TAG according to START_OR_END. */
void
***************
*** 440,465 ****
/* texinfo.tex doesn't support more than one font attribute
at the same time. */
! if ((start_or_end == START) && old_tag && *old_tag)
! {
! add_word ("</");
! add_word (old_tag);
! add_char ('>');
! }
if (*tag)
! {
! add_char ('<');
! if (start_or_end != START)
! add_char ('/');
! add_word (tag);
! add_char ('>');
! }
if ((start_or_end != START) && old_tag && *old_tag)
! {
! add_char ('<');
! add_word (old_tag);
! add_char ('>');
! }
}
--- 482,499 ----
/* texinfo.tex doesn't support more than one font attribute
at the same time. */
! if ((start_or_end == START) && old_tag && *old_tag
! && !rollback_empty_tag (old_tag))
! add_word_args ("</%s>", old_tag);
if (*tag)
! if (start_or_end == START)
! add_word_args ("<%s>", tag);
! else if (!rollback_empty_tag (tag))
! /* Insert close tag only if we didn't rollback,
! in which case the opening tag is removed. */
! add_word_args ("</%s>", tag);
if ((start_or_end != START) && old_tag && *old_tag)
! add_word_args ("<%s>", old_tag);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- texinfo/makeinfo html.c,1.2,1.3,
dirt <=