示例#1
0
    def _prettify_instructions(self, text):
        """
        Prettify instructions text to make it more suitable for offline reading.

        @param text: HTML (kinda) text to prettify.
        @type text: str

        @return: Prettified HTML with several markup tags replaced with HTML
            equivalents.
        @rtype: str
        """
        soup = BeautifulSoup(text)
        self._convert_instructions_basic(soup)
        self._convert_instructions_images(soup)
        return soup.prettify()
示例#2
0
    def __call__(self, markup):
        """
        Convert instructions markup to make it more suitable for
        offline reading.

        @param markup: HTML (kinda) markup to prettify.
        @type markup: str

        @return: Prettified HTML with several markup tags replaced with HTML
            equivalents.
        @rtype: str
        """
        soup = BeautifulSoup(markup)
        self._convert_markup_basic(soup)
        self._convert_markup_images(soup)
        self._convert_markup_audios(soup)
        return soup.prettify()
示例#3
0
 def _replace_tag(self, text, initial_tag, target_tag):
     soup = BeautifulSoup(text)
     while soup.find(initial_tag):
         soup.find(initial_tag).name = target_tag
     return soup.prettify()