Parse title/name of the book and URL of the book.

    Args:
        html_chunk (obj): HTMLElement containing slice of the page with details.

    Returns:
        tuple: (title, url), both as strings.
488128
def _parse_title_url(html_chunk):
    
    title = html_chunk.find("div", {"class": "comment"})

    if not title:
        return _parse_alt_title(html_chunk), None

    title = title[0].find("h2")
    if not title:
        return _parse_alt_title(html_chunk), None

    # look for the url of the book if present
    url = None
    url_tag = title[0].find("a")
    if url_tag:
        url = url_tag[0].params.get("href", None)
        title = url_tag

    return title[0].getContent(), normalize_url(BASE_URL, url)
679206
def _parse_format_pages_isbn(html_chunk):
    
    ppi = get_first_content(
        html_chunk.find("div", {"class": "price-overflow"})
    )

    if not ppi:
        return None, None, None

    # all information this function should parse are at one line
    ppi = filter(lambda x: x.strip(), ppi.split("<br />"))[0]

    # parse isbn
    isbn = dhtmlparser.parseString(ppi)
    isbn = isbn.find("b")
    isbn = isbn[0].getContent() if isbn else None

    # parse pages and format
    pages = None
    book_format = None
    details = ppi.split("|")

    if len(details) >= 2:
        book_format = details[0].strip()
        pages = details[1].strip()

    return book_format, pages, isbn
790891
def get_select_title_url(self, attach=None):
        
        return self._post(
            'biz/getselecttitleurl',
            data={
                'attach': attach,
            },
            result_processor=lambda x: x['url'],
        )
172969
def get_pages(url):
    
    while True:
        yield url
        doc = html.parse(url).find("body")
        links = [a for a in doc.findall(".//a") if a.text and a.text.startswith("next ")]
        if not links:
            break
        url = urljoin(url, links[0].get('href'))
171739
def html_page(title="Page Title", body=""):
    """"""
    html = "<html>\n<head><title>%s</title></head>\n<body>\n" % (title)
    html += "<h1>%s</h1>\n" % (title)
    html += body
    html += "</body>\n</html>\n"
    return html
390988
def _parse_authors(details):
    
    authors = details.find(
        "tr",
        {"id": "ctl00_ContentPlaceHolder1_tblRowAutor"}
    )

    if not authors:
        return []  # book with unspecified authors

    # parse authors from HTML and convert them to Author objects
    author_list = []
    for author in authors[0].find("a"):
        author_obj = Author(author.getContent())

        if "href" in author.params:
            author_obj.URL = author.params["href"]

        author_list.append(author_obj)

    return author_list
870582
def _parse_from_table(html_chunk, what):
    
    ean_tag = html_chunk.find("tr", fn=must_contain("th", what, "td"))

    if not ean_tag:
        return None

    return get_first_content(ean_tag[0].find("td"))
692688
function parse2 (title, body) {
    /*  generate body headline  */
    html_spec += "<h2>" + mklink(1, title) + "</h2>\n";

    /*  start navigation entry  */
    html_navi += "<h2>" + mklink(0, title) + "</h2>\n";
    html_navi += "<ul>\n";

    /*  parse second-level structure (part 1)  */
    body = xre.replace(body, xre(
        "^(.+?\\n)" +           // intro paragraph
        "(?=\\n-[ \\t]+\\S+)",  // start of first function
    "s"), function (m0, m1) {
        html_spec += "<div class=\"intro\">" + addpara(conv(0, m1)) + "</div>";
    });
    function addpara (txt) {
        txt = xre.replace(txt, xre("(\\n).[ \\t]+([^\\n]*(?:\\n[ \\t]+[^\\n]+)*)", "sg"), "$1<li>$2</li>");
        txt = xre.replace(txt, xre("(\\n\\n)(<li>)", "sg"), "$1<ul>$2");
        txt = xre.replace(txt, xre("(<\/li>)(\\n\\n)", "sg"), "$1</ul>$2");
        txt = xre.replace(txt, xre("\\n{2,}", "sg"), "<p/>\n");
        return txt;
    }

    /*  parse second-level structure (part 2)  */
    body = xre.replace(body, xre(
        "-[ \\t]+(\\S+.+?)" +  // function start
        "(?=-[ \\t]+\\S+" +    // start of next function
        "|$)",                 // or end of file
    "sg"), function (m0, m1) {
        parse3(title, m1);
    });

    /*  process third-level structure  */
    function parse3 (title, body) {
        html_spec += "<ul>\n";

        /*  parse forth-level structure  */
        body = xre.replace(body, xre(
            "^" +
            "(.+?)\\n" +  //  synopsis
            "\\n" +       //  blank line
            "(.+)" +      //  body
            "$",
        "sx"), function (m0, m1, m2) {
            parse4(title, m1, m2);
        });

        /*  process forth-level structure  */
        function parse4 (title, synopsis, body) {
            html_spec += "<li>";

            /*  parse fifth-level structure (part 1)  */
            var txt = synopsis;
            txt = xre.replace(txt, xre("M<(.+?)>", "sg"), function (m0, m1) {
                parse5a(title, m1);
            });

            /*  process fifth-level structure  */
            function parse5a (title, txt) {
                if (!cache[title + ":" + txt]) {
                    html_navi += "<li>" + mklink(0, txt) + "</li>";
                    cache[title + ":" + txt] = true;
                }
            }

            /*  generate synopsis  */
            html_spec += "<div class=\"synopsis\">";
            synopsis = xre.replace(synopsis, xre("[ \\t]{2,}", "sg"), " ");
            synopsis = conv(1, synopsis);
            synopsis = xre.replace(synopsis, xre("(\\[|\\]|:|\\s+=\\s+)", "sg"), "<span class=\"meta\">$1</span>");
            synopsis = xre.replace(synopsis, xre(";", "sg"), "</div><div class=\"synopsis\">");
            synopsis = xre.replace(synopsis, xre("\\(\\s+", "sg"), "(");
            synopsis = xre.replace(synopsis, xre("\\s+\\)", "sg"), ")");
            html_spec += synopsis + "\n";
            html_spec += "</div>";

            /*  parse fifth-level structure (part 2)  */
            txt = body + "\n";
            txt = xre.replace(txt, xre(
                "(.+?\\n)" +
                "(?= \\n | $ )",
            "sgx"), function (m0, m1) {
                parse5b(m1);
            });

            /*  process fifth-level structure  */
            function parse5b (txt) {
                if (xre.test(txt, xre("^\\s*\\|\\s", "s"))) {
                    txt = xre.replace(txt, xre("^\\s*\\|\\s", "mg"), "");
                    txt = conv(0, txt);
                    txt = xre.replace(txt, xre("\\n+$", "s"), "");
                    txt = xre.replace(txt, xre("^\\s+", "s"), "");
                    html_spec += "<div class=\"example\">";
                    html_spec += txt + "\n";
                    html_spec += "</div>";
                }
                else if (xre.test(txt, xre("^\\s*Notice:\\s+", "s"))) {
                    txt = conv(0, txt);
                    html_spec += "<div class=\"notice\">";
                    html_spec += txt + "\n";
                    html_spec += "</div>";
                }
                else if (xre.test(txt, xre("^\\s*\\.\\s", "s"))) {
                    txt = xre.replace(txt, xre("([ \\t]+)\\.([ \\t]+)(.+?\\n(?:\\1 \\2.*?\\n)*)", "sg"), "<li>$3</li>");
                    txt = conv(0, txt);
                    html_spec += "<ul class=\"list\">";
                    html_spec += txt + "\n";
                    html_spec += "</ul>";
                }
                else if (xre.test(txt, xre("^\\s*\\+\\s", "s"))) {
                    txt = xre.replace(txt, xre("^\\s*\\+\\s", "mg"), "");
                    txt = conv(0, txt);
                    txt = xre.replace(txt, xre("^(.+)$", "mg"), "<tr><td>$1</td></tr>");
                    txt = xre.replace(txt, xre("(\\s+)\\+(\\s+)", "sg"), "</td><td>");
                    html_spec += "<table class=\"tabular\">";
                    html_spec += txt + "\n";
                    html_spec += "</table>";
                }
                else if (!xre.test(txt, xre("^\\s+$", "s"))) {
                    txt = conv(0, txt);
                    txt = xre.replace(txt, xre("[ \\t]{2,}", "sg"), " ");
                    html_spec += "<div class=\"desc\">";
                    html_spec += txt + "\n";
                    html_spec += "</div>";
                }
            }

            html_spec += "</li>";
        }

        html_spec += "</ul>\n";
    }

    /*  finish navigation entry  */
    html_navi += "</ul>\n";
}
552278
function parsePage(book, page) {
    var fs = book.getContentFS();
    var file = page.getFile();

    return fs.readAsString(file.getPath())
    .then(function(content) {
        return parsePageFromString(page, content);
    });
}
1293310
def get_text(self, title):
        
        r = requests.get(self.api,
                         params={'action': 'parse', 'page': title, 'format': 'json'},
                         headers=self.header)
        jsd = r.json()
        return jsd['parse']['text']['*']
1023932
def parse_page(raw_page):
  
  ret = {"title": get_title(raw_page), "id": get_id(raw_page)}
  if ":" in ret["title"]:
    return None
  ret["revisions"] = get_revisions(raw_page)
  return ret
385871
def _html_title(page):
    
    link = "<a href=\"%s\">%s</a>" % (page.data.get('url'),
                                      page.data.get('title'))
    desc = page.data.get('description')
    if desc:
        link += "&mdash;<i>%s</i>" % desc
    else:
        link += "&mdash;<i>description</i>"
    if link:
        return "<p>%s</p>" % link
970421
def _page_text(page, nowrap=False):
    
    title = page.data['title']
    title = "%s\n%s" % (title, "=" * len(title))

    desc = page.data.get('description')
    if desc:
        desc = "_%s_" % desc

    img = _text_image(page)

    pars = page.data.get('extext')

    if pars:
        # pars = pars.replace(' * ', '\n * ')
        pars = re.sub(r'[ ]+\*[ ]+', '* ', pars)

    if pars and not nowrap:
        parlist = []
        for par in pars.split("\n\n"):
            parlist.append("\n".join(textwrap.wrap(par)))

        disambiguation = page.data.get('disambiguation')
        if disambiguation:
            parlist.append(' * ' + "\n * ".join(page.data.get('links')))

        pars = "\n\n".join(parlist)

    url = '<%s>' % page.data['url']

    txt = []
    txt.append(title)
    txt.append(desc)
    txt.append(url)
    txt.append(pars)
    txt.append(img)

    return "\n\n".join([x for x in txt if x])
374907
def render_title_tag(context, is_og=False):
    
    request = context['request']
    content = ''

    # Try to get the title from the context object (e.g. DetailViews).
    if context.get('object'):
        try:
            content = context['object'].get_meta_title()
        except AttributeError:
            pass
    elif context.get('meta_tagger'):
        content = context['meta_tagger'].get('title')

    if not content:
        # Try to get the title from the cms page.
        try:
            content = request.current_page.get_page_title()  # Try the `page_title` before the `title of the CMS page.
            if not content:
                content = request.current_page.get_title()
        except (AttributeError, NoReverseMatch):
            pass

    if not is_og:
        return content
    else:
        return mark_safe('<meta property="og:title" content="{content}">'.format(content=content))
922232
def parse_html(self, text):
        
        bs = BeautifulSoup(text, "html5lib")
        file_reg = re.compile(MARKDOWN_IMAGE_REGEX, flags=re.IGNORECASE)
        tags = bs.findAll('img')

        for tag in tags:
            # Look for src attribute, remove formatting if added to image
            src_text = tag.get("src") or ""
            formatted_src_match = file_reg.search(src_text)
            src_text = formatted_src_match.group(2) if formatted_src_match else src_text

            alt_text = tag.get("alt") or ""
            tag.replaceWith("![{alt}]({src})".format(alt=alt_text, src=src_text))
        return html.unescape(bs.find('body').renderContents().decode('utf-8'))
549519
def _parse_description(details):
    
    description = details.find("div", {"class": "detailPopis"})

    # description not found
    if not description:
        return None

    # remove links to ebook version
    ekniha = description[0].find("div", {"class": "ekniha"})
    if ekniha:
        ekniha[0].replaceWith(dhtmlparser.HTMLElement(""))

    # remove links to other books from same cathegory
    detail = description[0].find("p", {"class": "detailKat"})
    if detail:
        detail[0].replaceWith(dhtmlparser.HTMLElement(""))

    # remove all HTML elements
    description = dhtmlparser.removeTags(description[0]).strip()

    # description is blank
    if not description:
        return None

    return description
469565
def parse_html(html):
    
    paragraphs = re.split("</?p[^>]*>", html)

    # Convert <br>s to line breaks and remove empty paragraphs
    paragraphs = [re.split("<br */?>", p) for p in paragraphs if p]

    # Convert each line in each paragraph to plain text:
    return [[get_text(l) for l in p] for p in paragraphs]