summaryrefslogtreecommitdiff
path: root/misc.c
diff options
context:
space:
mode:
authorJacob Nevins <jacobn@chiark.greenend.org.uk>2007-01-01 21:27:39 +0000
committerJacob Nevins <jacobn@chiark.greenend.org.uk>2007-01-01 21:27:39 +0000
commit0a93e0f4e52191819069b0a32b5fb051fae7d0da (patch)
treeca8c7c9c872b1e3ebed47ecc168a438ec6d08e29 /misc.c
parent86c2b2e8b4ebbbe18f1668eec6fea03b454cce9d (diff)
downloadhalibut-0a93e0f4e52191819069b0a32b5fb051fae7d0da.zip
halibut-0a93e0f4e52191819069b0a32b5fb051fae7d0da.tar.gz
halibut-0a93e0f4e52191819069b0a32b5fb051fae7d0da.tar.bz2
halibut-0a93e0f4e52191819069b0a32b5fb051fae7d0da.tar.xz
Fix the behaviour of constructions like \e{index \i{term}} -- the index tag
was causing emphasis to be broken (particularly noticeable in text-like backends). There are some instances of this in the PuTTY manual, for instance. Unfortunately, \k references in similar situations still aren't quite right, but fixing that will be more involved, and I haven't found any instances yet. [originally from svn r7049]
Diffstat (limited to 'misc.c')
-rw-r--r--misc.c31
1 files changed, 23 insertions, 8 deletions
diff --git a/misc.c b/misc.c
index 1d407de..3f2483c 100644
--- a/misc.c
+++ b/misc.c
@@ -237,17 +237,32 @@ void mark_attr_ends(word *words)
wp = NULL;
for (w = words; w; w = w->next) {
- if (isattr(w->type)) {
- int before = (wp && isattr(wp->type) &&
- sameattr(wp->type, w->type));
- int after = (w->next && isattr(w->next->type) &&
- sameattr(w->next->type, w->type));
- w->aux |= (before ?
- (after ? attr_Always : attr_Last) :
- (after ? attr_First : attr_Only));
+ int both;
+ if (!isvis(w->type))
+ /* Invisible elements should not affect this calculation */
+ continue;
+ both = (isattr(w->type) &&
+ wp && isattr(wp->type) &&
+ sameattr(wp->type, w->type));
+ w->aux |= both ? attr_Always : attr_First;
+ if (wp && !both) {
+ /* If previous considered word turns out to have been
+ * the end of a run, tidy it up. */
+ int wp_attr = attraux(wp->aux);
+ wp->aux = (wp->aux & ~attr_mask) |
+ ((wp_attr == attr_Always) ? attr_Last
+ /* attr_First */ : attr_Only);
}
wp = w;
}
+
+ /* Tidy up last word touched */
+ if (wp) {
+ int wp_attr = attraux(wp->aux);
+ wp->aux = (wp->aux & ~attr_mask) |
+ ((wp_attr == attr_Always) ? attr_Last
+ /* attr_First */ : attr_Only);
+ }
}
/*