The plugin has no ticket API of its own. When a thread entry is created, it sets the format if the request carries one, and it can optionally detect Markdown syntax automatically.
The signal handler threadentry.created determines the format in this order:
format in $_POST.Content-Type: application/json, the field format in the JSON body.Valid values are markdown, html and text (case-insensitive). Any other value becomes html. The plugin then writes the determined format to the format column of the thread entry.
{
"name": "Max Mustermann",
"email": "max@example.com",
"subject": "Ticket with Markdown",
"message": "## Problem\n\nThe server does **not** respond.",
"format": "markdown"
}
The plugin reads the text for line break restoration and auto-detection from the fields response, note, message and body (the first non-empty field wins).
osTicket partly strips line breaks when saving. The plugin restores them if the text in
$_POSTcontains line breaks and the saved entry has none.
With the option Auto-Convert Markdown Syntax, the plugin stores entries as Markdown when the request carries no format in $_POST and the text contains Markdown syntax.
Each pattern counts once, no matter how often it occurs:
| Pattern | Points | Example |
|---|---|---|
| Code block | 20 | ```code``` |
| Heading | 15 | # Title |
| Link | 15 | [text](url) |
| Bullet list | 12 | - item or * item |
| Numbered list | 12 | 1. item |
| Bold | 10 | **bold** |
| Quote | 10 | > quote |
| Italic | 8 | *italic* |
| Inline code | 5 | `code` |
| Horizontal rule | 5 | --- |
The threshold is fixed at 5. A single detected pattern is therefore enough to store the entry as Markdown.
The detection is very sensitive: even a line like
- itemor a word in*asterisks*counts as Markdown. For API calls, rather send theformatfield explicitly.
The API Endpoints plugin accepts format on POST /tickets and validates the value. It merges the JSON body into $_POST before the ticket is created. This is how the signal handler of this plugin finds the format.
noteFormat applies. If it is missing, API Endpoints uses markdown.format=markdown with an error if Markdown Support is not active. API Endpoints recognizes the plugin by the existence of the class MarkdownThreadEntryBody. The class only exists when Markdown Support is activated and Parsedown has been loaded.markdown in requests. Markdown Support does not know other spellings that API Endpoints accepts.The plugin converts Markdown to HTML in advance for outgoing emails only for requests with format=markdown in $_POST (see Technical details). This conversion runs when osTicket starts and does not yet see the JSON body of an API request. For API tickets the plugin therefore only sets the format of the stored entry.