zmarkdown
zmarkdown copied to clipboard
[API] Heading shift option for single text
The heading _shift
option doesn't seem to work when sending a single string through the API.
A workaround has been to send an array with only that single string, such as:
$query = Http::post(config('zmarkdown.html'), [
'md' => [
'text' => $value,
],
'opts' => [
'heading_shift' => 0,
'disable_ping' => true,
'disable_jsfiddle' => false,
'stats' => false,
]
]);
$json = $query->json();
if (isset($json[0]) && isset($json[0]['text'])) {
$this->attributes['content_html'] = $json[0]['text'];
} else {
$this->attributes['content_html'] = '';
}
This makes my code rather heavy and a bit dirty-looking, so it would be nice to be able to use this option without needing that extra array structure:
$query = Http::post(config('zmarkdown.html'), [
'md' => $value,
'opts' => [
'heading_shift' => 0,
'disable_ping' => true,
'disable_jsfiddle' => false,
'stats' => false,
]
]);
$json = $query->json();
if (isset($json['text'])) {
$this->attributes['content_html'] = $json[0]['text'];
} else {
$this->attributes['content_html'] = '';
}