mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-26 00:32:42 +01:00
Add ability to pass width
arg to dot remarkup interpeter
Summary: Allows to keep really wide graphs inside the div: dot (width=100%) {{{ }}} Test Plan: Created a graph that is wider than a phriction page. Added `(width=100%)` and now the images stays within the div. Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley CC: Korvin, epriestley, aran Differential Revision: https://secure.phabricator.com/D8235
This commit is contained in:
parent
0efce646c9
commit
dbe3818d8c
1 changed files with 14 additions and 0 deletions
|
@ -13,6 +13,8 @@ final class PhabricatorRemarkupBlockInterpreterGraphviz
|
||||||
pht('Unable to locate the `dot` binary. Install Graphviz.'));
|
pht('Unable to locate the `dot` binary. Install Graphviz.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$width = $this->parseDimension(idx($argv, 'width'));
|
||||||
|
|
||||||
$future = id(new ExecFuture('dot -T%s', 'png'))
|
$future = id(new ExecFuture('dot -T%s', 'png'))
|
||||||
->setTimeout(15)
|
->setTimeout(15)
|
||||||
->write(trim($content));
|
->write(trim($content));
|
||||||
|
@ -41,7 +43,19 @@ final class PhabricatorRemarkupBlockInterpreterGraphviz
|
||||||
'img',
|
'img',
|
||||||
array(
|
array(
|
||||||
'src' => $file->getBestURI(),
|
'src' => $file->getBestURI(),
|
||||||
|
'width' => nonempty($width, null),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: This is duplicated from PhabricatorRemarkupRuleEmbedFile since they
|
||||||
|
// do not share a base class.
|
||||||
|
private function parseDimension($string) {
|
||||||
|
$string = trim($string);
|
||||||
|
|
||||||
|
if (preg_match('/^(?:\d*\\.)?\d+%?$/', $string)) {
|
||||||
|
return $string;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue