diff --git a/asciidoc.install b/asciidoc.install
index 8f8b628..309ccd2 100644
--- a/asciidoc.install
+++ b/asciidoc.install
@@ -9,8 +9,21 @@
* Implements hook_requirements().
*/
function asciidoc_requirements($phase) {
- exec('asciidoc --version', $output, $ret);
- if ($ret == 0) {
+ $commands = [
+ 'asciidoc',
+ 'asciidoctor',
+ ];
+
+ $is_command_avaiable = FALSE;
+ foreach ($commands as $command) {
+ exec(sprintf('%s --version', $command), $output, $ret);
+ if ($ret == 0) {
+ $is_command_avaiable = TRUE;
+ break;
+ }
+ }
+
+ if ($is_command_avaiable) {
$severity = NULL;
$version = substr(array_shift($output), 9);
}
diff --git a/src/Plugin/Filter/Asciidoc.php b/src/Plugin/Filter/Asciidoc.php
index 229911b..ddc9dfe 100644
--- a/src/Plugin/Filter/Asciidoc.php
+++ b/src/Plugin/Filter/Asciidoc.php
@@ -32,8 +32,10 @@ class Asciidoc extends FilterBase {
return '';
}
+ $command = self::getCommand();
+
// we use basically asciidoc defaults: --doctype article --backend xhtml11
- $command = sprintf('echo %s | asciidoc --no-header-footer -o - -', escapeshellarg($text));
+ $command = sprintf('echo %s | %s --no-header-footer -o - -', escapeshellarg($text), $command);
exec($command, $lines);
$output = implode("\n", $lines);
@@ -54,4 +56,24 @@ class Asciidoc extends FilterBase {
return $this->t('You can use AsciiDoc syntax to format and style the text. For a quick reference see the cheatsheet.', array('@user_guide' => 'http://www.methods.co.nz/asciidoc/userguide.html', '@cheatsheet' => 'http://powerman.name/doc/asciidoc'));
}
+ /**
+ * Returns an available command.
+ *
+ * @return string
+ * Command name to use.
+ */
+ private static function getCommand() {
+ $commands = [
+ 'asciidoc',
+ 'asciidoctor',
+ ];
+
+ foreach ($commands as $command) {
+ exec(sprintf('%s --version', $command), $output, $ret);
+ if ($ret == 0) {
+ return $command;
+ }
+ }
+ }
+
}