Podlove Share Sheet Fixing + Wagtail Code Blocks

, Jochen

This week's programming stream was about fixing the share sheet for the Podlove Player on the Python Podcast website and adding code blocks to Wagtail.

The second part about adding code blocks to Wagtail starts at 01:12:30. Here's an example of a code block 😎:

class CodeBlock(StructBlock):
    language = CharBlock(help_text="The language of the code block")
    source = TextBlock(rows=8, help_text="The source code of the block")

    def render_basic(self, value, context=None):
        if value:
            lexer = get_lexer_by_name(value["language"], stripall=True)
            highlighted = highlight(value["source"], lexer, HtmlFormatter())
            return mark_safe(highlighted)
        else:
            return ""

Return to blog