Source code for atlas_doc_parser.nodes.node_table_cell
# -*- coding: utf-8 -*-importtypingasTimportdataclassesfromfunc_args.apiimportREQ,OPTfrom..type_enumimportTypeEnumfrom..mark_or_nodeimportBase,BaseNodefrom..markdown_helpersimportcontent_to_markdownifT.TYPE_CHECKING:# pragma: no coverfrom.node_paragraphimportNodeParagraphfrom.node_panelimportNodePanelfrom.node_blockquoteimportNodeBlockquotefrom.node_ordered_listimportNodeOrderedListfrom.node_bullet_listimportNodeBulletListfrom.node_ruleimportNodeRulefrom.node_headingimportNodeHeadingfrom.node_code_blockimportNodeCodeBlockfrom.node_media_singleimportNodeMediaSinglefrom.node_media_groupimportNodeMediaGroupfrom.node_decision_listimportNodeDecisionListfrom.node_task_listimportNodeTaskListfrom.node_block_cardimportNodeBlockCardfrom.node_embed_cardimportNodeEmbedCardfrom.node_extensionimportNodeExtensionfrom.node_nested_expandimportNodeNestedExpand
[docs]@dataclasses.dataclass(frozen=True)classNodeTableCellAttrs(Base):""" Attributes for :class:`NodeTableCell`. :param colspan: Optional. Number of columns this cell spans (defaults to 1). :param rowspan: Optional. Number of rows this cell spans (defaults to 1). :param colwidth: Optional. Array of column widths in pixels; use 0 for unfixed columns. :param background: Optional. Cell background color (hex codes or HTML color names). :param localId: Optional. A unique identifier for the node. """colspan:int=OPTrowspan:int=OPTcolwidth:list[int]=OPTbackground:str=OPTlocalId:str=OPT
[docs]@dataclasses.dataclass(frozen=True)classNodeTableCell(BaseNode):""" A cell within a table row. The tableCell node defines an individual cell within a tableRow. It contains block-level content such as paragraphs, lists, code blocks, and other block elements. - https://developer.atlassian.com/cloud/jira/platform/apis/document/nodes/table_cell/ """type:str=TypeEnum.tableCell.valueattrs:NodeTableCellAttrs=OPTcontent:list[T.Union["NodeParagraph","NodePanel","NodeBlockquote","NodeOrderedList","NodeBulletList","NodeRule","NodeHeading","NodeCodeBlock","NodeMediaSingle","NodeMediaGroup","NodeDecisionList","NodeTaskList","NodeBlockCard","NodeEmbedCard","NodeExtension","NodeNestedExpand",]]=REQ
[docs]defto_markdown(self,ignore_error:bool=False,)->str:md=content_to_markdown(content=self.content,ignore_error=ignore_error)md=md.replace("|","\\|")# Convert leading spaces to for HTML table rendering# (spaces after <br> are collapsed in HTML, so we need )lines=md.split("\n")processed_lines=[]forlineinlines:stripped=line.lstrip(" ")leading_spaces=len(line)-len(stripped)ifleading_spaces>0:# Replace leading spaces with line=" "*leading_spaces+strippedprocessed_lines.append(line)return"<br>".join(processed_lines)