-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move the text rendering out for reusability
- Loading branch information
Showing
3 changed files
with
39 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import markdown | ||
|
||
|
||
class Render: | ||
"""Default text rendering into HTML for the UI""" | ||
|
||
@staticmethod | ||
def collapsible(header, content, open: bool = False) -> str: | ||
"""Render an HTML friendly collapsible section""" | ||
o = " open" if open else "" | ||
return f"<details{o}><summary>{header}</summary>{content}</details><br>" | ||
|
||
@staticmethod | ||
def table(text: str) -> str: | ||
"""Render table from markdown format into HTML""" | ||
return markdown.markdown(text, extensions=["markdown.extensions.tables"]) | ||
|
||
@staticmethod | ||
def highlight(text: str) -> str: | ||
"""Highlight text""" | ||
return f"<mark>{text}</mark>" |