All articles
Inside Textend6 min read

Why a code block inside a quote needs more than a border

Nested content tests the whole editing experience: code remains editable as code, copied scope is clear, and surrounding structure survives. How Textend handles these details in one Markdown document.

Nested paper arches surround a small stack of graphite paper layers.

Structured documents should still feel natural to write

A list item can contain several paragraphs. A quotation can include code or a list of points. These are ordinary document structures that clarify content and require an editor to understand where each part belongs. The writer still needs familiar actions: edit, add a line, select, copy, and continue.

Textend lets you edit formatted content directly. Entering a quote or list should not force you into Markdown source to repair markers and indentation on every line. The editor handles that structure so visible content and editing actions stay aligned.

This is where immediate editing goes beyond immediate rendering. Displaying nested content establishes its current appearance. An editor built for sustained use must also determine what it becomes after each change. Textend’s work on these basic actions supports writing through complex documents.

Keep the surrounding structure while editing the code

Code inside a quotation retains its own indentation, blank lines, and line breaks. Quote markers identify its surrounding structure; spaces within the code may affect the program itself. Although both appear at the start of a line, editing and copying must distinguish their roles.

Textend identifies the child content and its parents from the current Markdown text. Local code edits use the code’s content range. New content lines receive the surrounding markers required at that location. Code indentation and literal characters remain content rather than being stripped as apparent prefixes.

The structure and position mappings derive from the same Markdown text. Textend does not maintain a second rich-document body and convert the whole result back. Content edits stay within the relevant range where possible; structural changes adjust the markers and indentation they need. That supports direct editing while treating the existing source with care.

Optional: quote markers and indentation within code
> ```javascript
> const count = 1;
>   console.log(count);
> ```

Equal indentation does not mean shared ownership

Adjacent list items can share a depth, and separate quotations can have identical borders. They look similar but have different owners. Counting indentation or quote markers alone can mistake separate content for one unit and let an edit to one item affect the next.

To determine whether content across lines shares a container, Textend compares the full chain of ownership: whether each level is an item or quote, and its actual range in the current document. Order matters too. A quote inside a list differs from a list inside a quote.

This distinction affects selection replacement, copying across lines, and structural changes. Writers do not need to know how container identity works internally. Its value is clearer scope: neighboring content that was not selected should not become an incidental part of the action.

Route an action to the content being edited

Tab indents code, navigates table cells, or changes list depth depending on the current target. A surrounding list should not turn every Tab press into a list command. Textend identifies the active content before routing the action.

An easily missed distinction is an action that was handled without changing content. When code has no indentation left to remove, the action can still belong to the code. It should not propagate outward and move the surrounding quote or list. Handoff to the immediate parent requires a defined exit boundary.

This division keeps familiar keys predictable. Nesting adds relationships, but a single action should not unexpectedly change several levels. Leaving code, continuing prose, and adjusting outer structure each need a clear target and destination.

Keep borders, content height, and editing positions aligned

A quote border expresses the range of content it contains. A quote may continue into prose after code, and an outer quote may continue after an inner one ends. Each level needs its own endpoint rather than automatically extending through a child or stopping at its bottom.

Horizontal positions also follow the actual order of parents. Outer list markers, quote borders, inner list markers, and the code surface must retain that order. Textend shares parent layout information so each child type does not independently guess indentation and drift out of alignment.

Layout also affects input. After wrapping, expanding a preview, or changing fonts, the editor needs an updated measure of occupied space so clicks in later prose reach the right text position. Nested content needs dependable editing as well as clear appearance, with visual and operational boundaries maintained together.

Copying content and copying structure serve different purposes

Selecting text within code and explicitly copying a whole quote or list item operate at different scales in Textend. The first needs code content; the second needs document structure. Handling follows the selection and action target rather than universally keeping or removing every marker.

Copying code content removes the identified parent prefixes while preserving spaces and characters belonging to the code. A literal greater-than sign at the start of a code line must survive even though it resembles a quote marker. The copied text should reflect the selected content without its host syntax.

Pasting into a new location also requires interpreting the destination. Textend’s content-paste paths restore the necessary destination prefixes while preserving the fragment’s internal structure. Whole-container pasting checks source and target classes as well; a copyable fragment is not automatically suitable for every destination.

Action targetWhat to retain
Text selected inside codeSelected code, including its own indentation and characters, without parent quote or list prefixes.
A prose fragment within one containerProse and the internal structure of complete child blocks, with the shared host removed for placement at the destination.
Explicitly copying a whole quote or list itemThe Markdown structure of that container and its contents, rather than treating the selection as pure code.

Preserve unselected content and keep structural changes reversible

Editing inner content and moving its entire list item have different scopes. Textend’s content-editing paths stay within the relevant content range, while block and container commands use their object ranges. Structural paths do not infer shared ownership from equal indentation when the target identity is unclear.

When an action changes both text and surrounding prefixes, those changes need to undo together. Restoring the words while leaving the new hierarchy would force the writer to guess how many more steps remain. Relevant commands treat content, required structural changes, and selection restoration as one action rather than exposing internal stages.

Code, tables, equations, and diagrams have different content rules. Support for one cannot stand in for the others. We check implementations and regressions by content type, parent arrangement, and action, rather than treating “nesting supported” as a complete answer. Boundary protection and recovery are part of a dependable editor.

Keep the complexity inside the editor

This underlying work serves a straightforward experience: writers can place explanations, quotations, steps, and code where they belong, then keep editing. Copying content yields content; moving structure retains structure. Everyday writing should not revolve around repairing source markers.

These foundations matter when Textend learns from mature editors. Immediate editing must withstand continuous revision, with careful handling of input, hierarchy, selection, clipboard actions, and undo alongside rendering. Textend takes its own Markdown text implementation route, building direct writing on complete editing capabilities.