Markus Michalski FAQ

Markdown Support: Usage

Using Markdown Support: editor and format switcher, toolbar and shortcuts, live preview, image upload, canned responses, supported Markdown syntax and how HTML is handled.

Deutsche Version

Back to overview

Markdown Support: Usage

Where the editor appears

The plugin includes the editor files on pages whose script is named tickets.php or ticket.php (ticket views), and on ajax.php calls whose URL contains ticket. AJAX requests themselves get no assets. The plugin does not distinguish between the staff area and the client portal: it only checks the script name.

It takes over input fields named response (reply), note (internal note) and message (message). Other fields with the class richtext get a compact editor: toolbar without the image button, without preview and without image upload.

Format switcher

Above the input field (with Allow Format Switching on) a Format selector with Markdown and HTML appears. Switching to HTML brings back the normal osTicket editor, switching to Markdown shows the toolbar and preview. The editor sends the chosen format with the form as a hidden format field.

Toolbar and keyboard shortcuts

Button Markdown Shortcut Effect
Bold **text** Ctrl+B Wraps the selection
Italic *text* Ctrl+I Wraps the selection
Heading # to ###### Ctrl+H Raises the level from 1 to 6 with every click, then back to 1
Link [text](URL) Ctrl+K Asks for the URL in a dialog
Inline code `code` Wraps the selection
Code block ```language Asks for the programming language in a dialog
List - item Bullet list, one line per item
Numbered list 1. item Numbering from 1
Quote > text Quote per line
Rule --- Horizontal rule
Image ![alt](URL) Opens the file dialog for an image upload

On a Mac, Cmd applies instead of Ctrl. The dialogs for link and code block are labeled in German in the plugin (URL eingeben:, Programmiersprache (optional):).

Live preview

The preview appears below the input field. It is rendered on the server 500 ms after the last keystroke via the endpoint api/markdown-preview.php. If the server does not answer correctly, a simple converter in the browser renders a simplified preview. This fallback preview does not know tables or strikethrough syntax.

On narrow screens the Toggle Preview button in the toolbar shows and hides the preview.

Inserting images

In Markdown mode (not in the compact editor) images can be inserted in three ways:

Way Steps
Drag and drop Drag an image file into the editor
Clipboard Paste an image or screenshot with Ctrl+V
Toolbar Click the image button and pick a file in the file dialog

JPEG, PNG, GIF, WebP and BMP are allowed. SVG is not allowed. The plugin uploads the image through the osTicket draft API ajax.php/draft/.../attach, inserts the placeholder ![Uploading image-1...](/) during the upload and replaces it afterwards with ![filename](URL). The alt text is the file name without its extension, with the characters [, ], ( and ) removed. As a URL the plugin only accepts http://, https:// and file.php?.... Anything else is replaced with #invalid-url.

The upload needs the draft context of the input field (attribute data-draft-namespace or data-draft-id) and a CSRF token on the page. Without a draft context the upload is not available, without a CSRF token it aborts.

Canned responses

When you pick a canned response from the #cannedResp selector in Markdown mode, the plugin loads it through the osTicket AJAX interface and converts the HTML to Markdown in the browser. In HTML mode the standard osTicket behavior stays. Attachments of the canned response are taken over in both modes.

HTML element Markdown
h1 to h6 # to ######
strong, b **bold**
em, i *italic*
a [text](URL)
img ![alt](URL)
blockquote > quote
ul, ol - item, 1. item
pre, code code block, inline code
hr ---

The canned responses in the database stay unchanged.

Supported Markdown syntax

Rendering uses Parsedown (version 1.7.4 according to composer.lock) in SafeMode.

# Heading 1
## Heading 2

**bold**, *italic*, ~~strikethrough~~, `inline code`

- Bullet list
- Second item

1. Numbered list
2. Second item

> Quote

[Link text](https://example.com)
![Alt text](https://example.com/image.png)

---
```php
echo "Hello world";
```

Where Markdown entries are shown

Entries with the format markdown are rendered by the class MarkdownThreadEntryBody wherever osTicket outputs the entry through its thread entry classes: the agents' ticket view, the client portal, PDF export and emails. In the PDF export the plugin replaces images with an http(s) URL with the text [Image]. Search uses the HTML content converted to text.

How Markdown gets into outgoing emails is described on the Technical details page.