You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To output multiple tables in different formats i often need a MarkupHeader - i created the following helper class today to streamline the process:
"""Created on 19.11.2023@author: wf"""classMarkupHeader:
""" Helper to generate tabulate compatible markup header lines. """@classmethoddefget_markup(cls, title: str, markup_format: str, level: int=1) ->str:
""" Generates a formatted header string based on the specified markup format. Args: title (str): The title to be formatted as the header. markup_format (str): The markup format for the header. level (int): The section level to generate a header for. Returns: str: The formatted header string. """ifmarkup_format=="github":
returnf"{'#'*level}{title}\n"elifmarkup_format=="mediawiki":
returnf"{'='*level}{title}{'='*level}\n"elifmarkup_format=="html"ormarkup_format=="unsafehtml":
returnf"<h{level}>{title}</h{level}>"elifmarkup_format=="latex":
iflevel==1:
returnf"\\section{{{title}}}"eliflevel==2:
returnf"\\subsection{{{title}}}"eliflevel==3:
returnf"\\subsubsection{{{title}}}"elifmarkup_format=="textile":
returnf"h{level}. {title}"elifmarkup_format=="plain":
returntitleelse:
# Default case for other formatsreturntitle
To output multiple tables in different formats i often need a MarkupHeader - i created the following helper class today to streamline the process:
Here is the unit test for it:
The text was updated successfully, but these errors were encountered: