html5/spec-author-view patch.anolis,1.9,1.10 style.css,1.11,1.12

Update of /sources/public/html5/spec-author-view
In directory hutz:/tmp/cvs-serv20012

Modified Files:
	patch.anolis style.css 
Log Message:
make some index improvements based on further feedback from Hixie


Index: patch.anolis
===================================================================
RCS file: /sources/public/html5/spec-author-view/patch.anolis,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- patch.anolis	20 Aug 2010 18:16:57 -0000	1.9
+++ patch.anolis	21 Aug 2010 11:26:44 -0000	1.10
@@ -1,6 +1,6 @@
 diff -r 16550726fd0d anolis
 --- a/anolis	Sun Aug 30 16:53:19 2009 -0500
-+++ b/anolis	Sat Aug 21 03:00:25 2010 +0900
++++ b/anolis	Sat Aug 21 20:25:39 2010 +0900
 @@ -70,10 +70,10 @@
  
  def getOptParser():
@@ -16,7 +16,7 @@
  
 diff -r 16550726fd0d anolislib/processes/filter.py
 --- a/anolislib/processes/filter.py	Sun Aug 30 16:53:19 2009 -0500
-+++ b/anolislib/processes/filter.py	Sat Aug 21 03:00:25 2010 +0900
++++ b/anolislib/processes/filter.py	Sat Aug 21 20:25:39 2010 +0900
 @@ -5,23 +5,4 @@
          return
      selector = cssselect.CSSSelector(kwargs["filter"])
@@ -44,8 +44,8 @@
 +        element.drop_tree()
 diff -r 16550726fd0d anolislib/processes/terms.py
 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
-+++ b/anolislib/processes/terms.py	Sat Aug 21 03:00:25 2010 +0900
-@@ -0,0 +1,325 @@
++++ b/anolislib/processes/terms.py	Sat Aug 21 20:25:39 2010 +0900
+@@ -0,0 +1,362 @@
 +# coding=UTF-8
 +# Copyright (c) 2010 Michael(tm) Smith
 +#
@@ -140,14 +140,8 @@
 +                    term.tag = "span"
 +                    term.tail = "\n"
 +                    termName.append(term);
-+                    # we need a first letter so that we can build navigational
-+                    # links for the alphabetic nav bars injected into the index
-+                    termFirstLetter = term.text_content()[0].upper()
-+                    if termFirstLetter != prevTermFirstLetter and termFirstLetter.isalpha():
-+                        firstLetters.append(termFirstLetter)
-+                        indexNavHelpers[termFirstLetter] = etree.Element(u"div",{u"class": "index-nav", u"id": "index-terms_"+termFirstLetter})
-+                        prevTermFirstLetter = termFirstLetter
-+                        self.terms.append(indexNavHelpers[termFirstLetter])
++                    termName.tail= "\n"
++                    indexEntry.append(termName)
 +                    # normalize the text content of each <dfn> in the document
 +                    # and then normalize the text content of this <dfn>, then
 +                    # do a case-insensitive comparison of them and count how
@@ -158,15 +152,58 @@
 +                    if ElementTree.xpath(expr, content = term.text_content()) > 1:
 +                        # we have more than one <dfn> in the document whose
 +                        # content is a case-insensitive match for the
-+                        # textContent of this <dfn>; so, we qualify the name of
-+                        # each such term in the index listing by appending the
-+                        # id of the <dfn> to it
-+                        indexEntryID = etree.Element(u"span",{u"class": u"index-id", u"title": u""})
-+                        indexEntryID.text = "("+termID+")"
-+                        indexEntryID.tail = " "
-+                        termName.append(indexEntryID)
-+                    termName.tail= "\n"
-+                    indexEntry.append(termName)
++                        # textContent of this <dfn>; so, we attempt to
++                        # disambiguate them by copying the parent node of the
++                        # <dfn> and including that in our output as an excerpt,
++                        # to provide the context for the term
++                        dfnContext = etree.Element(u"dd",{u"class": u"dfn-excerpt"})
++                        dfnContext.text = "\n"
++                        dfnContext.tail = "\n"
++                        dfnParentNode = deepcopy(dfn.getparent())
++                        # if length of the parent node isn't greater than 1,
++                        # then the <dfn> is the only child node of its parent,
++                        # and so there is no useful context we can provide, so
++                        # we do nothing. Also, if the parent node is an h1-h6
++                        # heading, we are already listing it in the entry, to
++                        # it'd be redundant to be it here too, so we don't
++                        if len(dfnParentNode) > 1 and not re.match("^[hH][1-6]$",dfnParentNode.tag):
++                            if not dfnParentNode[0].tag == "dfn":
++                                dfnParentNode.text = "*** "
++                            else:
++                                dfnParentNode.text = ""
++                            dfnParentNode.tag = "span"
++                            # remove ID so that we don't duplicate it
++                            if "id" in dfnParentNode.attrib:
++                                del dfnParentNode.attrib["id"]
++                            descendants = dfnParentNode.xpath(".//*[self::dfn or @id]")
++                            for descendant in descendants:
++                                # if the text content of this descendant is the
++                                # same as the text content of the term, then we
++                                # don't want to repeat it, but instead we
++                                # replace it with ellipses
++                                if descendant.text_content().lower() == term.text_content().lower():
++                                    descendant.tag = "span"
++                                    tail = ""
++                                    if descendant.tail is not None:
++                                        tail = descendant.tail
++                                    # drop any children this element might have,
++                                    # and just put ellipsis in place of it
++                                    descendant.clear()
++                                    descendant.text = "..."+tail
++                                elif descendant == descendants[0]:
++                                    dfnParentNode.text = "*** "
++                                if "id" in descendant.attrib:
++                                    del descendant.attrib["id"]
++                            dfnContext.append(dfnParentNode)
++                            indexEntry.append(dfnContext)
++                    # we need a first letter so that we can build navigational
++                    # links for the alphabetic nav bars injected into the index
++                    termFirstLetter = term.text_content()[0].upper()
++                    if termFirstLetter != prevTermFirstLetter and termFirstLetter.isalpha():
++                        firstLetters.append(termFirstLetter)
++                        indexNavHelpers[termFirstLetter] = etree.Element(u"div",{u"class": "index-nav", u"id": "index-terms_"+termFirstLetter})
++                        prevTermFirstLetter = termFirstLetter
++                        self.terms.append(indexNavHelpers[termFirstLetter])
 +                    # #########################################################
 +                    # make a list of all the instances of terms in the document
 +                    # that are hyperlinked references back to the <dfn> term

Index: style.css
===================================================================
RCS file: /sources/public/html5/spec-author-view/style.css,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- style.css	20 Aug 2010 18:16:57 -0000	1.11
+++ style.css	21 Aug 2010 11:26:44 -0000	1.12
@@ -95,3 +95,12 @@
 html.chapter #index-filecontents {
   display: none;
 }
+.dfn-excerpt {
+  font-style: italic;
+  margin-left: 0;
+  font-size: 95%;
+  white-space: nowrap;
+  text-overflow: ellipsis;
+  overflow:hidden;
+  display:block;
+}

Received on Saturday, 21 August 2010 11:26:47 UTC