Frontend School

Interactive Markdown Previewer

Machine Coding
medium

Interactive Markdown Previewer

Medium
React
Frontend
UI
Markdown
Machine Coding

Overview

Delhivery leverages internal tools for efficient documentation and communication across various teams. A key component for such tools is a robust, yet simple, markdown editor that provides immediate visual feedback. This problem simulates building a core piece of functionality for an internal content management system, enhancing the user experience for our technical writers and content creators by offering a live preview of their markdown input.

What you need to do / Task

Your primary goal is to build a functional, interactive markdown editor with a live preview capability. Specifically, you must:

  1. Layout Creation: Implement a user interface with two distinct panels: one for Markdown text input and another for displaying the rendered HTML preview.
  2. Real-time Preview: As the user types or modifies Markdown text in the input area, the preview panel must update dynamically to reflect the rendered HTML.
  3. Basic Markdown Parsing: Implement a basic parser to convert a subset of Markdown syntax into corresponding HTML. The supported elements are:
    • Headings: H1 (# Heading), H2 (## Subheading), H3 (### Minor Heading)
    • Bold text: **bold text**
    • Italic text: *italic text*
    • Unordered Lists: - List item (support multiple consecutive list items)
    • Paragraphs: Any line of text not matching the above rules should be treated as a paragraph.
  4. Reset Functionality: Add a "Reset" button that, when clicked, clears both the Markdown input area and the HTML preview panel.

UI/UX expectations

  • Layout: The editor should present a clear two-column layout. The left column will house the Markdown input, and the right column will display the HTML preview.
  • Input Area: Use a textarea element for Markdown input. It should be scrollable and adequately sized to accommodate several lines of text.
  • Preview Area: The preview area should be a div or similar block element, rendering the parsed HTML. It should also be scrollable if the content overflows.
  • Controls: The "Reset" button should be clearly visible and accessible, ideally below the input area.
  • Responsiveness: While full responsiveness is not required, the layout should be presentable and usable on a standard desktop browser viewport.
  • Styling: Basic styling (e.g., borders, padding, distinct backgrounds for panels) is provided in styles.css to ensure readability and separation of concerns. You may augment it as needed for clarity, but focus on functionality.

Acceptance criteria

Your solution will be evaluated based on the following observable behaviors:

  • The application loads with an empty Markdown input and an empty HTML preview.
  • Entering # Hello World in the input renders <h1>Hello World</h1> in the preview.
  • Entering **Important** information renders <strong>Important</strong> information.
  • Entering *italicized* text renders <em>italicized</em> text.
  • Entering multiple lines like `
  • Item 1
  • Item 2renders<ul><li>Item 1</li><li>Item 2</li></ul>`.
  • Entering a mix of supported Markdown (e.g., a heading, then a paragraph, then a list) renders correctly in the preview.
  • Clicking the "Reset" button clears all text from the Markdown input and the HTML preview.
  • The preview updates instantly as typing occurs in the input area.

Constraints

Constraints & assumptions

  • You must use React for building the user interface.
  • You are not allowed to use any external Markdown parsing libraries (e.g., marked, markdown-it, showdown). The basic parsing logic for the specified Markdown subset must be implemented by you.
  • Focus on client-side rendering; server-side rendering is not in scope.
  • The solution should prioritize correctness and readability over extreme performance optimization for very large inputs. Assume typical documentation sizes.
  • The target browser environment is modern Chrome/Firefox.

Out of scope

  • Advanced Markdown features (e.g., tables, code blocks, images, links, blockquotes, nested lists).
  • Saving or loading content from persistence.
  • Full accessibility compliance beyond basic semantic HTML elements.
  • Complex styling, themes, or custom fonts.

What interviewers evaluate

  • Architectural Design: How well the React components are structured, how state is managed, and the overall clarity of the application flow.
  • Core Logic & Parsing: The effectiveness and correctness of the custom basic Markdown parsing implementation, including handling different syntax elements and edge cases within the specified scope.
  • UI Implementation: Accuracy of rendering the Markdown into HTML, responsiveness of the live preview, and correct implementation of the reset functionality.
  • Code Quality: Readability, maintainability, adherence to modern React best practices, and error handling for expected scenarios.

Loading editor...