FFenceLilt
Workflows

Coding workflows · Restricted backtick block extraction

03
Built around your work

A concrete starting point

Extract column-zero triple-backtick blocks from text of at most 4096 characters with optional ASCII language labels. Test empty blocks and normalized line breaks, reject an unclosed block and leave unsupported Markdown forms uninterpreted without executing code.

01

Open the context

Choose the project folder and name the files or behavior involved.

02

Define the change

Describe the input, expected output and boundaries that must stay intact.

03

Inspect the work

Review the proposed edits and any commands before relying on their result.

04

Check the outcome

Compare actual behavior with the expected result. If a check fails, investigate it before applying more changes.

Restricted backtick block extraction

A concrete starting point
import re

def fenced_blocks(text):
    if type(text) is not str or len(text) > 4096:
        raise ValueError("fence.input")
    blocks, body, language = [], None, None
    for line in text.splitlines():
        if body is None:
            opening = re.fullmatch(r"```([A-Za-z0-9_-]*)", line)
            if opening:
                body, language = [], opening[1]
        elif line == "```":
            blocks.append((language, "\n".join(body)))
            body = None
        else:
            body.append(line)
    if body is not None:
        raise ValueError("fence.unclosed")
    return blocks

The example is a starting point for a real project, not a claim that generated code is already tested. Adjust paths, dependencies and expected behavior to match your application.

AI coding workspace

Your next change starts here.

Get the Windows app ↗