Frontend School

Simple Markdown Previewer

Machine Coding
medium

Simple Markdown Previewer

Medium
React
Frontend
UI
Markdown
Editor
String Manipulation

Overview

In many modern web applications, content creation and documentation often leverage Markdown for its simplicity and readability. This problem challenges you to build a lightweight, client-side Markdown editor with a real-time preview pane. This feature is crucial for enabling users to write and format content efficiently, providing immediate visual feedback on their input without needing to save or publish.

What you need to do / Task

Your goal is to build a React component that functions as a basic Markdown editor and previewer.

  1. Layout: Create a two-panel layout where the left panel contains a text editor for Markdown input, and the right panel displays the rendered HTML preview.
  2. Editor Functionality: Implement a textarea element for users to type their Markdown content.
  3. Real-time Preview: As the user types in the editor, the preview pane should update dynamically to show the rendered HTML.
  4. Markdown Parsing: Implement a simple Markdown parser that converts specific Markdown syntax into HTML. You are not allowed to use external Markdown parsing libraries. Focus on the following:
    • Headings: Support H1 (# Header), H2 (## Header), and H3 (### Header).
    • Bold: Support **bold text** syntax.
    • Italic: Support *italic text* syntax.
    • Unordered Lists: Support - list item syntax.

UI/UX expectations

  • The application should present a clear split-pane interface.
  • The left pane (editor) should contain a scrollable textarea with a monospace font.
  • The right pane (preview) should render the HTML output in a standard browser font, also scrollable if content overflows.
  • There should be a visible separator or distinct styling to differentiate the editor from the preview.
  • The layout should comfortably fit on a standard desktop screen.

Acceptance criteria

  • User can type Markdown text into the editor pane.
  • The preview pane updates instantly as the user types.
  • Markdown headings (#, ##, ###) are correctly rendered as <h1>, <h2>, <h3> tags in the preview.
  • Markdown bold text (**text**) is correctly rendered as <strong> tags.
  • Markdown italic text (*text*) is correctly rendered as <em> tags.
  • Markdown unordered list items (- item) are correctly rendered within <ul> and <li> tags.
  • The editor and preview panes are displayed side-by-side.

Constraints

Constraints & assumptions

  • You must use React for building the UI components.
  • Crucially, you are not allowed to use any third-party Markdown parsing libraries (e.g., marked.js, react-markdown). You need to implement the parsing logic yourself using basic string manipulation (e.g., regular expressions, string methods). This is a core part of the problem.
  • The application should run entirely client-side. No backend integration is required.
  • Assume a modern browser environment for rendering.
  • Focus on the specified Markdown features only; comprehensive Markdown support is not expected.

Out of scope

  • Implementing a full Markdown specification (e.g., links, images, tables, code blocks, blockquotes).
  • Advanced editor features like syntax highlighting, auto-completion, undo/redo history.
  • Accessibility features beyond basic semantic HTML elements.
  • Persistence of content (e.g., saving to local storage or a server).
  • Error handling for malformed or complex Markdown edge cases beyond basic parsing.

What interviewers evaluate

  • Component Design & State Management: How effectively you structure your React components and manage the application's state.
  • Logical Parsing Implementation: The correctness and clarity of your custom Markdown parsing logic using string manipulation.
  • Real-time Responsiveness: Ensuring the preview updates efficiently without noticeable lag.
  • Code Quality: Readability, maintainability, and adherence to best practices.

Loading editor...