How to use the lookatme.config.STYLE function in lookatme

To help you get started, we’ve selected a few lookatme examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github d0c-s4vage / lookatme / lookatme / pres.py View on Github external
if data is None:
            with open(self.input_filename, "r") as f:
                data = f.read()

        parser = Parser()
        self.meta, self.slides = parser.parse(data)
        lookatme.contrib.load_contribs(self.meta.get("extensions", []))

        self.styles = lookatme.themes.ensure_defaults(self.theme_mod)
        dict_deep_update(self.styles, self.meta.get("styles", {}))

        # now apply any command-line style overrides
        if self.style_override is not None:
            self.styles["style"] = self.style_override

        lookatme.config.STYLE = self.styles
github d0c-s4vage / lookatme / lookatme / tui.py View on Github external
def update_creation(self):
        """Update the author and date
        """
        author = self.pres.meta.get('author', '')
        author_spec = spec_from_style(config.STYLE["author"])

        date = self.pres.meta.get('date', '')
        date_spec = spec_from_style(config.STYLE["date"])

        self.creation.set_text([
            (author_spec, f"  {author} "),
            (date_spec, f" {date} "),
        ])
github d0c-s4vage / lookatme / lookatme / render / markdown_inline.py View on Github external
def link(link_uri, title, link_text):
    raw_link_text = []
    for x in link_text:
        if isinstance(x, tuple):
            raw_link_text.append(x[1])
        else:
            raw_link_text.append(x)
    raw_link_text = "".join(raw_link_text)

    spec, text = styled_text(link_text, spec_from_style(config.STYLE["link"]))
    spec = LinkIndicatorSpec(raw_link_text, link_uri, spec)
    return [(spec, text)]
github d0c-s4vage / lookatme / lookatme / render / markdown_block.py View on Github external
'4':
            bg: default
            fg: '#66a,bold'
            prefix: "░░░░░ "
            suffix: ""
          default:
            bg: default
            fg: '#579,bold'
            prefix: "░░░░░ "
            suffix: ""

    :returns: A list of urwid Widgets or a single urwid Widget
    """
    headings = config.STYLE["headings"]
    level = token["level"]
    style = config.STYLE["headings"].get(str(level), headings["default"])

    prefix = styled_text(style["prefix"], style)
    suffix = styled_text(style["suffix"], style)

    rendered = render_text(text=token["text"])
    styled_rendered = styled_text(rendered, style, supplement_style=True)

    return [
        urwid.Divider(),
        ClickableText([prefix] + styled_text(rendered, style) + [suffix]),
        urwid.Divider(),
    ]
github d0c-s4vage / lookatme / lookatme / render / pygments.py View on Github external
def render_text(text, lang="text", style_name=None, plain=False):
    """Render the provided text with the pygments renderer
    """
    if style_name is None:
        style_name = config.STYLE["style"]

    lexer = get_lexer(lang)
    formatter, style_bg = get_formatter(style_name)

    start = time.time()
    code_tokens = lexer.get_tokens(text)
    config.LOG.debug(f"Took {time.time()-start}s to render {len(text)} bytes")

    markup = []
    for x in formatter.formatgenerator(code_tokens):
        if style_bg:
            x[0].background = style_bg
        markup.append(x)

    if markup[-1][1] == "\n":
        markup = markup[:-1]
github d0c-s4vage / lookatme / lookatme / widgets / table.py View on Github external
)

        def header_modifier(cell):
            return ClickableText(styled_text(cell, "bold"), align=cell.align)

        if self.table_headers is not None:
            self.rend_headers = self.create_cells(
                [self.table_headers], modifier=header_modifier
            )
        else:
            self.rend_headers = []
        self.rend_rows = self.create_cells(self.table_rows)

        self.column_maxes = self.calc_column_maxes()

        cell_spacing = config.STYLE["table"]["column_spacing"]
        self.total_width = sum(self.column_maxes.values()) + (
            cell_spacing * (self.num_columns - 1)
        )

        # final rows
        final_rows = []

        # put headers in Columns
        if self.table_headers is not None:
            header_columns = []
            for idx, header in enumerate(self.rend_headers[0]):
                header_with_div = urwid.Pile([
                    self.watch(header),
                    urwid.Divider(config.STYLE["table"]["header_divider"]),
                ])
                header_columns.append((self.column_maxes[idx], header_with_div))