Convert images of instructions markup. Images are downloaded,
        base64-encoded and inserted into <img> tags.

        @param soup: BeautifulSoup instance.
        @type soup: BeautifulSoup
502866
def _convert_markup_images(self, soup):
        
        # 6. Replace <img> assets with actual image contents
        images = [image for image in soup.find_all('img')
                  if image.attrs.get('assetid') is not None]
        if not images:
            return

        # Get assetid attribute from all images
        asset_ids = [image.attrs.get('assetid') for image in images]
        self._asset_retriever(asset_ids)

        for image in images:
            # Encode each image using base64
            asset = self._asset_retriever[image['assetid']]
            if asset.data is not None:
                encoded64 = base64.b64encode(asset.data).decode()
                image['src'] = 'data:%s;base64,%s' % (
                    asset.content_type, encoded64)
1079898
def convert_html_to_xml(self):
        

        if hasattr(self, 'content') and self.content != '':
            regex = r'<(?!/)(?!!)'
            xml_content = re.sub(regex, '<xhtml:', self.content)
            return xml_content
        else:
            return ''
425450
def htmlDocContentDumpOutput(self, buf, encoding):
        
        if buf is None: buf__o = None
        else: buf__o = buf._o
        libxml2mod.htmlDocContentDumpOutput(buf__o, self._o, encoding)
848717
def _html_to_img_tuples(html:str, format:str='jpg', n_images:int=10) -> list:    
    ""
    bs = BeautifulSoup(html, 'html.parser')
    img_tags = bs.find_all('div', {'class': 'rg_meta'})
    metadata_dicts = (json.loads(e.text) for e in img_tags)
    img_tuples = ((_img_fname(d['ou']), d['ou']) for d in metadata_dicts if d['ity'] == format)
    return list(itertools.islice(img_tuples, n_images))
1176191
def extract_imgs_from_page(page)
      return Set[] if page.is_redirect?
      page.doc.search('//img[@src]').reduce(Set[]) do |result, elem|
        u = elem.attributes['src'].content
        result << page.to_absolute(URI.parse(URI.encode(u)))
      end
    end
367396
def create_html(api_key, attrs):
    ''''''
    gif = get_gif(api_key, attrs['gif_id'])

    if 'alt' not in attrs.keys():
        attrs['alt'] = 'source: {}'.format(gif['data']['source'])

    html_out = '<a href="{}">'.format(gif['data']['url'])
    html_out += '<img src="{}" alt="{}">'.format(
        gif['data']['images']['original']['url'],
        attrs['alt'])
    html_out += '</a>'

    return html_out
573789
def as_html(self):
        
        url = '{prefix}{code}.html?download'.format(prefix=EPSG_IO_URL,
                                                    code=self.id)
        return requests.get(url).text
489212
def create_image_base64():
    
    code, file = create_image()
    b64str = "data:image/png;base64,"
    with open(file, "rb") as f:
        if sys.version_info.major == 2:
            b64str += base64.b64encode(f.read())
        else:
            b64str += base64.b64encode(f.read()).decode()
    os.remove(file)
    return True, {"code": code, "base64": b64str}
294729
public static BufferedImage toImage(String base64) throws IORuntimeException {
		byte[] decode = Base64.decode(base64, CharsetUtil.CHARSET_UTF_8);
		return toImage(decode);
	}
837595
private void inlineImages(Document doc) {
        Elements allImages = doc.getElementsByTag(IMG_TAG);
        for (Element img : allImages) {
            if (img.attr(DATA_INLINE_ATTR).equals("true")) {
                String src = img.attr(IMG_SRC_ATTR);
                try {
                    URL url = new URL(src);
                    URLConnection urlConnection = url.openConnection();
                    urlConnection.connect();
                    String contentType = urlConnection.getContentType();

                    urlConnection.getContent();
                    byte[] srcContent = IOUtils.toByteArray(url.openStream());
                    String base64 = new Base64().encodeToString(srcContent);

                    img.attr(IMG_SRC_ATTR, MessageFormat.format("data:{0};base64,{1}", contentType, base64));
                } catch (Exception e) {
                    LOG.log(Level.WARNING, null, e);
                }
            }
        }
    }
703212
def convert_html_to_text(
        filename: str = None,
        blob: bytes = None,
        config: TextProcessingConfig = _DEFAULT_CONFIG) -> str:
    
    with get_filelikeobject(filename, blob) as fp:
        soup = bs4.BeautifulSoup(fp)
        return soup.get_text()
873094
def _find_all_images(self, soup, data, url):
        
        all_images = soup.find_all('img')
        for image in all_images:
            item = normalize_image_data(image, url)

            data['images'].append(item)
624353
def bake(src):
    
    src = os.path.realpath(src)
    path = os.path.dirname(src)
    filename = os.path.basename(src)
    html = _load_file(src).read()
    if imghdr.what("", html):
        html = "<html><body><img src='{}'/></body></html>".format(cgi.escape(filename))

    # Change to the file's directory so image files with relative paths can be loaded correctly
    cwd = os.getcwd()
    os.chdir(path)
    bs_html = bs4.BeautifulSoup(html, "html.parser")
    images = bs_html.find_all("img")
    for image in images:
        _image_to_data(image)
    for link in bs_html.find_all("link"):
        _bake_css(link)
    for script in bs_html.find_all("script"):
        _bake_script(script)
    os.chdir(cwd)
    return bs_html
787857
def serialize_base64(attr, **kwargs):
        
        encoded = b64encode(attr).decode('ascii')
        return encoded.strip('=').replace('+', '-').replace('/', '_')
940221
def to_html(self):
        
        if self.text is None:
            return
        else:
            return '<p%s>%s%s</p>' % (
                self.html_attributes(), self.html_icon(), self.text.to_html())
99171
def inline_graphics(soup):
    
    inline_graphics = []

    inline_graphic_tags = raw_parser.inline_graphic(soup)

    position = 1

    for tag in inline_graphic_tags:
        item = {}

        copy_attribute(tag.attrs, 'xlink:href', item, 'xlink_href')

        # Get the tag type
        nodenames = ["sub-article"]
        details = tag_details(tag, nodenames)
        copy_attribute(details, 'type', item)

        # Increment the position
        item['position'] = position
        # Ordinal should be the same as position in this case but set it anyway
        item['ordinal'] = tag_ordinal(tag)

        inline_graphics.append(item)

    return inline_graphics
174318
def htmlDocContentDumpOutput(self, cur, encoding):
        
        if cur is None: cur__o = None
        else: cur__o = cur._o
        libxml2mod.htmlDocContentDumpOutput(self._o, cur__o, encoding)