This distinction matters when an internal help desk stores editable notices in Quill but also needs a Markdown copy for a repository. Keep one authoritative editable representation and treat Markdown as a defined import or export format.
Start with one notice whose structure you can inspect
Use this original fixture in a development record:
## Loan laptop return
Bring the **power adapter** with the laptop.
- Remove personal files
- Return the carrying case
The expected editable result has a level-two heading, an emphasized phrase, and two separate list items. A screenshot of bold text alone would miss whether the list remained a list.
Before implementing conversion, decide which Markdown structures the application accepts. If authors use tables, task lists, fenced code, or embedded HTML, check each against the chosen parser, sanitizer, Quill formats, and exporter. Supporting a heading and a list does not establish support for every Markdown extension.
Convert Markdown through a deliberate import action
The following fragment assumes Quill 2 is initialized and the application has installed marked and dompurify for its browser build:
import { marked } from 'marked';
import DOMPurify from 'dompurify';
function replaceFromMarkdown(markdown) {
const generatedHtml = marked.parse(markdown, { async: false });
const permittedHtml = DOMPurify.sanitize(generatedHtml);
const delta = quill.clipboard.convert({ html: permittedHtml });
quill.setContents(delta, 'api');
}
Run this when the user intentionally imports or replaces a document, after resolving unsaved edits. Repeating it as someone types can overwrite their current work. The Quill Clipboard module interprets HTML through its conversion rules; exact tag spelling can change.
Marked's documentation warns that its output is not sanitized. Configure DOMPurify and the surrounding application for the content and link policy you need. A permitted HTML fragment can still lose unsupported structures when Quill converts it to Delta. The DOMPurify documentation describes its configuration and the risk of changing sanitized markup afterward.
This fragment demonstrates the import boundary. It does not configure an editor, install packages, or save a record. For an existing HTML source instead of Markdown, use the Quill HTML import guide.
Preserve the editable document as Delta
After editing the notice, capture the document model:
const editableDelta = quill.getContents();
const readableHtml = quill.getSemanticHTML();
Delta retains Quill's supported formatting and document structure. The Delta documentation explains that line formats, including headings and lists, attach to newline characters. Inspect those attributes when a conversion appears visually close but reopens incorrectly.
Store and restore the editable representation through your application's normal persistence path. Keep a Markdown export separate from that authoritative record unless your application deliberately defines Markdown as its source of truth and accepts the conversion losses.
For the fixture, change “power adapter” to “labeled power adapter.” Save the Delta, reopen it with the same supported formats, and verify the changed wording, heading, emphasis, and two list items. Checking only getText() would hide a lost heading.
Export with an explicit HTML-to-Markdown converter
For a browser application that has installed Turndown, a basic export fragment is:
import TurndownService from 'turndown';
const exporter = new TurndownService({ headingStyle: 'atx' });
const markdownExport = exporter.turndown(quill.getSemanticHTML());
Use the resulting string in the application's download or repository workflow. The Turndown documentation documents supported rules and extensions. Define additional behavior where Quill formats have no agreed Markdown representation, such as text colors, font choices, or custom embeds.
Compare the exported meaning with the fixture: a heading, the corrected emphasized phrase, and two return instructions. Whitespace or bullet-marker changes can be harmless. A missing instruction or a flattened list needs a conversion fix.
Test typed shortcuts separately
Quill's Keyboard module supports context-sensitive bindings and includes list-related behavior. A typed pattern handled by a keyboard binding does not imply that pasting a complete Markdown file uses a Markdown parser. The API reference also provides no general Markdown export method.
Label the actions authors actually receive: Import Markdown, Edit notice, and Export Markdown. Before sending the repository copy, open that exported text in the repository's renderer and confirm that the return instructions still describe the desk's actual process.