def index(document, filename, chapterReference): entries = domhelpers.findElementsWithAttribute(document, "class", "index") if not entries: return i = 0; for entry in entries: i += 1 anchor = 'index%02d' % i if chapterReference: ref = getSectionReference(entry) or chapterReference else: ref = 'link' indexer.addEntry(filename, anchor, entry.attributes['value'], ref) # does nodeName even affect anything? entry.nodeName = entry.tagName = entry.endTagName = 'a' entry.attributes = InsensitiveDict({'name': anchor})
def index(document, filename, chapterReference): """ Extract index entries from the given document and store them for later use and insert named anchors so that the index can link back to those entries. Any node with a C{class} attribute set to C{index} is considered an index entry. @type document: A DOM Node or Document @param document: The input document which contains all of the content to be presented. @type filename: C{str} @param filename: A link to the output for the given document which will be included in the index to link to any index entry found here. @type chapterReference: ??? @param chapterReference: ??? @return: C{None} """ entries = domhelpers.findElementsWithAttribute(document, "class", "index") if not entries: return i = 0 for entry in entries: i += 1 anchor = 'index%02d' % i if chapterReference: ref = getSectionReference(entry) or chapterReference else: ref = 'link' indexer.addEntry(filename, anchor, entry.getAttribute('value'), ref) # does nodeName even affect anything? entry.nodeName = entry.tagName = entry.endTagName = 'a' for attrName in entry.attributes.keys(): entry.removeAttribute(attrName) entry.setAttribute('name', anchor)
def index(document, filename, chapterReference): """ Extract index entries from the given document and store them for later use and insert named anchors so that the index can link back to those entries. Any node with a C{class} attribute set to C{index} is considered an index entry. @type document: A DOM Node or Document @param document: The input document which contains all of the content to be presented. @type filename: C{str} @param filename: A link to the output for the given document which will be included in the index to link to any index entry found here. @type chapterReference: ??? @param chapterReference: ??? @return: C{None} """ entries = domhelpers.findElementsWithAttribute(document, "class", "index") if not entries: return i = 0; for entry in entries: i += 1 anchor = 'index%02d' % i if chapterReference: ref = getSectionReference(entry) or chapterReference else: ref = 'link' indexer.addEntry(filename, anchor, entry.getAttribute('value'), ref) # does nodeName even affect anything? entry.nodeName = entry.tagName = entry.endTagName = 'a' for attrName in entry.attributes.keys(): entry.removeAttribute(attrName) entry.setAttribute('name', anchor)