Skip to documentation

Design system / Molecules

Molecule / Presentation

BasicMarkdown

BasicMarkdown renders bold, italic and allowed links from a source string while preserving whitespace. It escapes input HTML before generating markup. It is neither a full Markdown parser nor an editor.

Live example

Live preview

Current component with fictional data. Example changes are not persisted.

Bold, italic and the composition guide. No full Markdown block parser is implied.

Responsibility

The renderer handles one limited formatted-text concern. It normalizes line endings, escapes HTML and converts supported inline markers and links. Editing and document-level Markdown features remain outside its contract.

Public contract

The table describes supported inputs, exported parts and caller responsibilities. A callback supplies a command, such as saving a draft. These notes are maintained manually; check current source types before integration.

Maintained component API notes; current source is authoritative
Prop / partTypeRequirementResponsibility
childrenstringRequiredRaw Markdown source, not ReactNode.
classNamestringOptionalApplied to the whitespace-pre-wrap div wrapper.

API notes are curated documentation, not generated types. The source linked above is the current implementation; update these notes alongside API changes.

State and behavior

Identify which values the caller controls and which behavior the component or underlying primitive owns. A local example does not supply persistence, authorization or a complete product lifecycle.

Memoizes generated HTML from children. Normalizes line endings, escapes HTML, replaces bold/italic markers and builds allowed links. No editor, preview state or data lifecycle.

Dependencies

  • React useMemo
  • Private renderBasicMarkdown, escapeHtml and isSafeMarkdownHref functions
  • Native strong, em and anchor markup

Token and styling contract

These notes identify theme roles, utilities and direct style values used by the source. Direct colors or timings are implementation exceptions, not recommendations to bypass the theme.

whitespace-pre-wrap
Preserves whitespace and newlines, without paragraph conversion.
underline / underline-offset-2
Generated link styling.
Consumer className
Typography and surface come from the caller.

Boundaries and limitations

  • Only bold, italic, links and whitespace are supported; no full Markdown block syntax.
  • Links allow HTTP(S), single-slash root paths, ./, ../, # and ?; unsupported schemes render the label without an anchor. Protocol-relative // links are not allowed.
  • Escaping and an allowlist are observed implementation, not a comprehensive security certification.
  • Generated anchors use target=_blank and rel=noopener noreferrer.

Where to make a change

Change parser behavior in basic-markdown.tsx with explicit compatibility/security consideration. Change source text and surrounding type in consumers. Do not assume MarkdownTextarea gains a preview just because this renderer exists.

Selected real uses

SubmissionForm

Uses the renderer for supplied submission-related text. Editing, validation and saving remain separate concerns.

src/components/submissions/submissionForm.tsx

CategoryEditor

Uses the limited renderer alongside category editing UI, without making it a general rich-text workflow.

Repository path: src/components/editions/categories/categoryEditor.tsx

These traces describe selected uses, not every dependency. Repository-only paths are shown as references; only approved files have public source views.

Usage contract

import { BasicMarkdown } from "@/components/ui/basic-markdown";

<BasicMarkdown className="text-supporting">{description}</BasicMarkdown>

Illustrative consumer bindings, not a self-contained product workflow. Live examples supply only local state or explicit fictional props.

All molecules
Current components and theme tokens. Fictional example data. Source views refresh on deployment; authors maintain contract notes.