Installed module: /Users/zhiyang/Developer/highquailty-bloger/tools/lab-venv/lib/python3.11/site-packages/markdownify/__init__.py Options: False def convert_table(self, el, text, parent_tags): return '\n\n' + text.strip() + '\n\n' def convert_tr(self, el, text, parent_tags): cells = el.find_all(['td', 'th']) is_first_row = el.find_previous_sibling() is None is_headrow = ( all([cell.name == 'th' for cell in cells]) or (el.parent.name == 'thead' # avoid multiple tr in thead and len(el.parent.find_all('tr')) == 1) ) is_head_row_missing = ( (is_first_row and not el.parent.name == 'tbody') or (is_first_row and el.parent.name == 'tbody' and len(el.parent.parent.find_all(['thead'])) < 1) ) overline = '' underline = '' full_colspan = 0 for cell in cells: if 'colspan' in cell.attrs and cell['colspan'].isdigit(): full_colspan += max(1, min(1000, int(cell['colspan']))) else: full_colspan += 1 if ((is_headrow or (is_head_row_missing and self.options['table_infer_header'])) and is_first_row): # first row and: # - is headline or # - headline is missing and header inference is enabled # print headline underline underline += '| ' + ' | '.join(['---'] * full_colspan) + ' |' + '\n' elif ((is_head_row_missing and not self.options['table_infer_header']) or (is_first_row and (el.parent.name == 'table' or (el.parent.name == 'tbody' and not el.parent.find_previous_sibling())))): # headline is missing and header inference is disabled or: # first row, not headline, and: # - the parent is table or # - the parent is tbody at the beginning of a table. # print empty headline above this row overline += '| ' + ' | '.join([''] * full_colspan) + ' |' + '\n' overline += '| ' + ' | '.join(['---'] * full_colspan) + ' |' + '\n' return overline + '|' + text + '\n' + underline def convert_td(self, el, text, parent_tags): colspan = 1 if 'colspan' in el.attrs and el['colspan'].isdigit(): colspan = max(1, min(1000, int(el['colspan']))) return ' ' + text.strip().replace("\n", " ") + ' |' * colspan def convert_th(self, el, text, parent_tags): colspan = 1 if 'colspan' in el.attrs and el['colspan'].isdigit(): colspan = max(1, min(1000, int(el['colspan']))) return ' ' + text.strip().replace("\n", " ") + ' |' * colspan def convert_br(self, el, text, parent_tags): if '_inline' in parent_tags: return text + ' ' if text else ' ' if self.options['newline_style'].lower() == BACKSLASH: return '\\\n' + text else: return ' \n' + text def escape(self, text, parent_tags): if not text: return '' if self.options['escape_misc']: text = re_escape_misc_chars.sub(r'\\\1', text) text = re_escape_misc_dash_sequences.sub(r'\1\\\2', text) text = re_escape_misc_hashes.sub(r'\1\\\2', text) text = re_escape_misc_list_items.sub(r'\1\\\2', text) if self.options['escape_asterisks']: text = text.replace('*', r'\*') if self.options['escape_underscores']: text = text.replace('_', r'\_') return text