Look for the designated element for TOC -- nav > ol Gather data required to support manifest and opfspine gather data required to support toc.ncx.ejs
438470
function(next) {
            var doc = jsdom.jsdom(tocHtml, {});
            
            var navs = doc.getElementsByTagName("nav");
            var thenav;
            for (var navno = 0; navno < navs.length; navno++) {
                if (navs[navno].id === config.akashacmsEPUB.bookmetadata.toc.id) {
                    thenav = navs[navno];
                    break;
                }
            }
            if (!thenav) {
                return next(new Error('no <nav id="'+ config.akashacmsEPUB.bookmetadata.toc.id +'">'));
            }
            // logger.info('found nav');
            
            var topol;
            for (var navchild = 0; navchild < thenav.childNodes.length; navchild++) {
                if (thenav.childNodes[navchild].nodeName
                 && thenav.childNodes[navchild].nodeName.toUpperCase() === 'ol'.toUpperCase()
                 && thenav.childNodes[navchild].hasAttributes()
                 && thenav.childNodes[navchild].getAttribute('start')
                 && thenav.childNodes[navchild].getAttribute('type')) {
                    topol = thenav.childNodes[navchild];
                    break;
                }
            }
            if (!topol) {
                return next(new Error('no <nav><ol type= start=></ol></nav>'));
            }
            // logger.info('found topol');
            
            
            // cover image/file manifest and opfspine entries are added in _makeCoverFiles
            
            // Add specific manifest and opfspine entries for TOC and NCX files
            
            config.akashacmsEPUB.manifest.push({
                id: config.akashacmsEPUB.bookmetadata.toc.id,
                properties: "nav",
                type: "application/xhtml+xml",
                href: config.akashacmsEPUB.bookmetadata.toc.href
            });
            config.akashacmsEPUB.opfspine.push({
                idref: config.akashacmsEPUB.bookmetadata.toc.id,
                linear: "yes"
            });
            // logger.trace('_scanForBookMetadata '+ util.inspect(config.akashacmsEPUB.manifest));
            if (config.akashacmsEPUB.bookmetadata.ncx) {
                config.akashacmsEPUB.manifest.push({
                    id: config.akashacmsEPUB.bookmetadata.ncx.id,
                    type: "application/x-dtbncx+xml",
                    href: config.akashacmsEPUB.bookmetadata.ncx.href
                });
            }
            
            // Scan the nested tree of ol's to capture data for .manifest .opfspine and .chapters
            var spineorder = 0;
            function scanOL(ol) {
                // logger.info('scanOL ol.length='+ ol.childNodes.length);
                var chaps = [];
                for (var olno = 0; olno < ol.childNodes.length; olno++) {
                    var olchild = ol.childNodes[olno];
                    // logger.info('olchild.nodeName '+ olchild.nodeName);
                    if (olchild.nodeName && olchild.nodeName.toUpperCase() === 'li'.toUpperCase()) {
                        var section; // section refers to chapters or subchapters
                        var subchapters;
                        section = undefined;
                        subchapters = undefined;
                        for (var childno = 0; childno < olchild.childNodes.length; childno++) {
                            // logger.info('olchild.childNodes[childno].nodeName '+ olchild.childNodes[childno].nodeName);
                            if (olchild.childNodes[childno].nodeName
                             && olchild.childNodes[childno].nodeName.toUpperCase() === 'ol'.toUpperCase()) {
                                subchapters = scanOL(olchild.childNodes[childno]);
                            } else if (olchild.childNodes[childno].nodeName
                                    && olchild.childNodes[childno].nodeName.toUpperCase() === 'a'.toUpperCase()) {
                                var anchor = olchild.childNodes[childno];
                                
                                config.akashacmsEPUB.manifest.push({
                                    id: anchor.getAttribute('id'),
                                    type: "application/xhtml+xml",
                                    href: anchor.getAttribute('href')
                                });
                                
                                config.akashacmsEPUB.opfspine.push({
                                    idref: anchor.getAttribute('id'),
                                    linear: "yes"
                                });
                                
                                section = {
                                    id: anchor.getAttribute('id'),
                                    title: anchor.nodeValue,
                                    href: anchor.getAttribute('href'),
                                    type: "application/xhtml+xml",
                                    navclass: "book",
                                    spineorder: ++spineorder
                                };
                            }
                        }
                        if (!section) {
                            return next(new Error('<li> has no <a> children'))
                        }
                        if (subchapters) section.subchapters = subchapters;
                        chaps.push(section);
                    }
                }
                // logger.info(util.inspect(chaps));
                return chaps;
            };
            config.akashacmsEPUB.chapters = [];
            config.akashacmsEPUB.chapters = scanOL(topol);
            
            // logger.info(util.inspect(config.akashacmsEPUB.chapters));
            
            next();
        }
567739
def get_item_mdata():
    """"""
    return {
        'learning_objectives': {
            'element_label': {
                'text': 'learning objectives',
                'languageTypeId': str(DEFAULT_LANGUAGE_TYPE),
                'scriptTypeId': str(DEFAULT_SCRIPT_TYPE),
                'formatTypeId': str(DEFAULT_FORMAT_TYPE),
            },
            'instructions': {
                'text': 'accepts an osid.id.Id[] object',
                'languageTypeId': str(DEFAULT_LANGUAGE_TYPE),
                'scriptTypeId': str(DEFAULT_SCRIPT_TYPE),
                'formatTypeId': str(DEFAULT_FORMAT_TYPE),
            },
            'required': False,
            'read_only': False,
            'linked': False,
            'array': True,
            'default_id_values': [],
            'syntax': 'ID',
            'id_set': [],
        },
    }
871285
def _top_element(self):
        """"""
        attrs = {"project-id": self.config["polarion-project-id"]}
        document_relative_path = self.config.get("requirements-document-relative-path")
        if document_relative_path:
            attrs["document-relative-path"] = document_relative_path
        top = etree.Element("requirements", attrs)
        return top
997346
function (p_oOverlay) {

            var oOverlay = this.find(p_oOverlay),
                nTopZIndex,
                oTopOverlay,
                aOverlays;

            if (oOverlay) {

                aOverlays = this.overlays;
                aOverlays.sort(this.compareZIndexDesc);

                oTopOverlay = aOverlays[0];

                if (oTopOverlay) {
                    nTopZIndex = Dom.getStyle(oTopOverlay.element, "zIndex");

                    if (!isNaN(nTopZIndex)) {

                        var bRequiresBump = false;

                        if (oTopOverlay !== oOverlay) {
                            bRequiresBump = true;
                        } else if (aOverlays.length > 1) {
                            var nNextZIndex = Dom.getStyle(aOverlays[1].element, "zIndex");
                            // Don't rely on DOM order to stack if 2 overlays are at the same zindex.
                            if (!isNaN(nNextZIndex) && (nTopZIndex == nNextZIndex)) {
                                bRequiresBump = true;
                            }
                        }

                        if (bRequiresBump) {
                            oOverlay.cfg.setProperty("zindex", (parseInt(nTopZIndex, 10) + 2));
                        }
                    }
                    aOverlays.sort(this.compareZIndexDesc);
                }
            }
        }
578682
def retrieve_element_or_default(self, location, default=None):
        
        loc_descriptor = self._get_location_descriptor(location)
        # find node
        node = None
        try:
            node = self._get_node(loc_descriptor)
        except Exception as e:
            return default

        return node.get_element()
395001
function getRequired(element) {
        var elementRole = axs.utils.getRoles(element);
        if (!elementRole || !elementRole.applied)
            return [];
        var appliedRole = elementRole.applied;
        if (!appliedRole.valid)
            return [];
        return appliedRole.details['mustcontain'] || [];
    }
1114650
def getitem(self, index, context=None):
        
        return _container_getitem(self, self.elts, index, context=context)
596854
function findContentNode(el) {
        if (!el) {
            return;
        }
        var oldCebContentId = el.getAttribute(OLD_CONTENT_ID_ATTR_NAME);
        if (oldCebContentId) {
            return findContentNode(el.querySelector('[' + oldCebContentId + ']')) || el;
        }
        return el;
    }
1056653
function getFilesInDirectory(entry, reader, accumEntries, existingPromise) {
        var promise = existingPromise || new qq.Promise(),
            dirReader = reader || entry.createReader();

        dirReader.readEntries(
            function readSuccess(entries) {
                var newEntries = accumEntries ? accumEntries.concat(entries) : entries;

                if (entries.length) {
                    setTimeout(function() { // prevent stack overflow, however unlikely
                        getFilesInDirectory(entry, dirReader, newEntries, promise);
                    }, 0);
                }
                else {
                    promise.success(newEntries);
                }
            },

            promise.failure
        );

        return promise;
    }
530356
function determineTitle(title, notitle, lines, info) {
  var defaultTitle = '**Table of Contents**  *generated with [DocToc](https://github.com/thlorenz/doctoc)*';

  if (notitle) return '';
  if (title) return title;
  return info.hasStart ? lines[info.startIdx + 2] : defaultTitle;
}
817376
def adapt_single_html(html):
    
    html_root = etree.fromstring(html)

    metadata = parse_metadata(html_root.xpath('//*[@data-type="metadata"]')[0])
    id_ = metadata['cnx-archive-uri'] or 'book'

    binder = Binder(id_, metadata=metadata)
    nav_tree = parse_navigation_html_to_tree(html_root, id_)

    body = html_root.xpath('//xhtml:body', namespaces=HTML_DOCUMENT_NAMESPACES)
    _adapt_single_html_tree(binder, body[0], nav_tree, top_metadata=metadata)

    return binder
82203
function getOPF(document) {
  var content = structuralFiles.getOPF(document);
  return replacements(document, replacements(document, content));
}
392440
function getGeneralHelpContents() {
    let options = {
        head: chalk.bold(`Available actions are:`),
        table: [
            [chalk.cyan.bold("add"), "add a resource"],
            [chalk.cyan.bold("clone"), "clone a resource"],
            [chalk.cyan.bold("delete"), "delete a resource"],
            [chalk.cyan.bold("export"), "export resources"],
            [chalk.cyan.bold("package"), "package resources"],
            [chalk.cyan.bold("get"), "get a resource"],
            [chalk.cyan.bold("import"), "import resources"],
            [chalk.cyan.bold('init'), 'Initializes the .luisrc file with settings specific to your LUIS instance'],
            [chalk.cyan.bold("list"), "list resources"],
            [chalk.cyan.bold("publish"), "publish resource"],
            [chalk.cyan.bold("query"), "query model for prediction"],
            [chalk.cyan.bold("rename"), "change the name of a resource"],
            [chalk.cyan.bold("set"), "change the .luisrc settings"],
            [chalk.cyan.bold("suggest"), "suggest resources"],
            [chalk.cyan.bold("train"), "train resource"],
            [chalk.cyan.bold("update"), "update resources"]
        ]
    };

    let sections = [];
    sections.push(options);
    sections.push(configSection);
    sections.push(globalArgs);
    return sections;
}
1308174
def toc_html(self):
        
        if self._toc is None:
            return None

        def indent():
            return '  ' * (len(h_stack) - 1)
        lines = []
        h_stack = [0]   # stack of header-level numbers
        for level, id, name in self._toc:
            if level > h_stack[-1]:
                lines.append("%s<ul>" % indent())
                h_stack.append(level)
            elif level == h_stack[-1]:
                lines[-1] += "</li>"
            else:
                while level < h_stack[-1]:
                    h_stack.pop()
                    if not lines[-1].endswith("</li>"):
                        lines[-1] += "</li>"
                    lines.append("%s</ul></li>" % indent())
            lines.append('%s<li><a href="#%s">%s</a>' % (
                indent(), id, name))
        while len(h_stack) > 1:
            h_stack.pop()
            if not lines[-1].endswith("</li>"):
                lines[-1] += "</li>"
            lines.append("%s</ul>" % indent())
        return '\n'.join(lines) + '\n'
183396
def get_element_desc(element, ar_tree, ns):
    # type: (_Element, _DocRoot, str) -> str
    """"""
    desc = get_child(element, "DESC", ar_tree, ns)
    txt = get_child(desc, 'L-2[@L="DE"]', ar_tree, ns)
    if txt is None:
        txt = get_child(desc, 'L-2[@L="EN"]', ar_tree, ns)
    if txt is None:
        txt = get_child(desc, 'L-2', ar_tree, ns)
    if txt is not None:
        return txt.text
    else:
        return ""
1231116
def parse_navigation_html_to_tree(html, id):
    
    def xpath(x):
        return html.xpath(x, namespaces=HTML_DOCUMENT_NAMESPACES)
    try:
        value = xpath('//*[@data-type="binding"]/@data-value')[0]
        is_translucent = value == 'translucent'
    except IndexError:
        is_translucent = False
    if is_translucent:
        id = TRANSLUCENT_BINDER_ID
    tree = {'id': id,
            'title': xpath('//*[@data-type="document-title"]/text()')[0],
            'contents': [x for x in _nav_to_tree(xpath('//xhtml:nav')[0])]
            }
    return tree
791133
function getNCX(document) {
  var content = structuralFiles.getNCX(document);
  return replacements(document, replacements(document, content));
}