def processFileContent(self, document, s): s = BaseRenderer.processFileContent(self, document, s) # Put block level elements back in block_re = re.compile('(\\s*)\001\\[(\\d+)@+\\]') while 1: m = block_re.search(s) if not m: break space = '' before = m.group(1) if before is None: before = '' if '\n' in before: spaces = before.split('\n') space = spaces.pop() before = '\n'.join(spaces) + '\n' block = self.blocks[int(m.group(2))] block = space + block.replace('\n', u'\n%s' % space) s = block_re.sub('%s%s' % (before, block), s, 1) # Clean up newlines return re.sub(r'\s*\n\s*\n(\s*\n)+', r'\n\n\n', s)
def processFileContent(self, document, s): # process the bibliography information s = BaseRenderer.processFileContent(self, document, s) # Put block level elements back in block_re = re.compile('(\\s*)\001\\[(\\d+)@+\\]') while 1: m = block_re.search(s) if not m: break space = '' before = m.group(1) if before is None: before = '' if '\n' in before: spaces = before.split('\n') space = spaces.pop() before = '\n'.join(spaces) + '\n' block = self.blocks[int(m.group(2))] block = space + block.replace('\n', u'\n%s' % space) s = block_re.sub('%s%s' % (before, block), s, 1) # Hack to allow eqref to work s = re.sub(r'(\\eqref) ([^\s,.]+)', r'\1{\2}', s) # Remove single spaces at beginning of lines # Some in-line equations are not handled correctly s1 = re.sub(r'^\s(\S)', r'\1', s, flags=re.MULTILINE) # Clean up newlines return re.sub(r'\s*\n\s*\n(\s*\n)+', r'\n\n\n', s1)
def processFileContent(self, document, s): s = BaseRenderer.processFileContent(self, document, s) # Clean up newlines s = re.sub(r'\s*\n(\s*\n)+', r'\n\n', s) s = re.sub(r'(\s*\n)+(\.B[ld])', r'\n\2', s) s = re.sub(r'(\.E[ld])\s*(\.B[ld])', r'\1\n\n\2', s) s = re.sub(r'\.Ed\s*\.Bd', r'.Ed\n.Bd', s) s = s.lstrip() return s
def processFileContent(self, document, s): # Add width, height, and depth to images s = re.sub(r"&(\S+)-(width|height|depth);(?:&([a-z]+);)?", self.setImageData, s) # Convert characters >127 to entities if document.config["files"]["escape-high-chars"]: s = list(s) for i, item in enumerate(s): if ord(item) > 127: s[i] = "&#%.3d;" % ord(item) s = u"".join(s) return BaseRenderer.processFileContent(self, document, s)
def processFileContent(self, document, s): # Add width, height, and depth to images s = re.sub(r'&(\S+)-(width|height|depth);(?:&([a-z]+);)?', self.setImageData, s) # Convert characters >127 to entities if document.config['files']['escape-high-chars']: s = list(s) for i, item in enumerate(s): if ord(item) > 127: s[i] = '&#%.3d;' % ord(item) s = ''.join(s) return BaseRenderer.processFileContent(self, document, s)
def processFileContent(self, document, s): # Convert characters >127 to entities if document.config['files']['escape-high-chars']: s = list(s) for i, item in enumerate(s): if ord(item) > 127: s[i] = '&#%.3d;' % ord(item) s = ''.join(s) # Remove empty paragraphs s = EMPTY_PARAGRAPH.sub(r'', s) # Add a non-breaking space to empty table cells s = TABLE_NBSP.sub(r'\1 \3', s) return BaseRenderer.processFileContent(self, document, s)
def processFileContent(self, document, s): # Add width, height, and depth to images s = re.sub(r'&(\S+)-(width|height|depth);(?:&([a-z]+);)?', self.setImageData, s) # Convert characters >127 to entities if document.config['files']['escape-high-chars']: s = list(s) for i, item in enumerate(s): if ord(item) > 127: s[i] = '&#%.3d;' % ord(item) s = ''.join(s) # Remove empty paragraphs s = re.compile(r'<p>\s*</p>', re.I).sub(r'', s) # Add a non-breaking space to empty table cells s = re.compile(r'(<(td|th)\b[^>]*>)\s*(</\2>)', re.I).sub(r'\1 \3', s) return BaseRenderer.processFileContent(self, document, s)