mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-25 16:22:43 +01:00
Fix two rendering issues with Jupyter notebooks
Summary: See PHI1752. - Early exit of document layout can cause us to fail to populate available rows. - Some Jupyter documents have "markdown" cells with plain strings, apparently. Test Plan: Successfully rendered example diff from PHI1752. Differential Revision: https://secure.phabricator.com/D21285
This commit is contained in:
parent
87fb35abb7
commit
4fd0628fae
2 changed files with 15 additions and 5 deletions
|
@ -61,6 +61,7 @@ final class PhabricatorDocumentEngineBlocks
|
|||
$lists = $this->lists;
|
||||
|
||||
if (count($lists) != 2) {
|
||||
$this->layoutAvailableRowCount = 0;
|
||||
return array();
|
||||
}
|
||||
|
||||
|
|
|
@ -63,6 +63,7 @@ final class PhabricatorJupyterDocumentEngine
|
|||
$blocks->addBlockList($uref, $u_blocks);
|
||||
$blocks->addBlockList($vref, $v_blocks);
|
||||
} catch (Exception $ex) {
|
||||
phlog($ex);
|
||||
$blocks->addMessage($ex->getMessage());
|
||||
}
|
||||
|
||||
|
@ -85,10 +86,14 @@ final class PhabricatorJupyterDocumentEngine
|
|||
switch ($utype) {
|
||||
case 'markdown':
|
||||
$usource = idx($ucell, 'source');
|
||||
$usource = implode('', $usource);
|
||||
if (is_array($usource)) {
|
||||
$usource = implode('', $usource);
|
||||
}
|
||||
|
||||
$vsource = idx($vcell, 'source');
|
||||
$vsource = implode('', $vsource);
|
||||
if (is_array($vsource)) {
|
||||
$vsource = implode('', $vsource);
|
||||
}
|
||||
|
||||
$diff = id(new PhutilProseDifferenceEngine())
|
||||
->getDiff($usource, $vsource);
|
||||
|
@ -254,7 +259,10 @@ final class PhabricatorJupyterDocumentEngine
|
|||
$hash_input = $cell['raw'];
|
||||
break;
|
||||
case 'markdown':
|
||||
$hash_input = implode('', $cell['source']);
|
||||
$hash_input = $cell['source'];
|
||||
if (is_array($hash_input)) {
|
||||
$hash_input = implode('', $cell['source']);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$hash_input = serialize($cell);
|
||||
|
@ -367,10 +375,11 @@ final class PhabricatorJupyterDocumentEngine
|
|||
$results = array();
|
||||
foreach ($cells as $cell) {
|
||||
$cell_type = idx($cell, 'cell_type');
|
||||
|
||||
if ($cell_type === 'markdown') {
|
||||
$source = $cell['source'];
|
||||
$source = implode('', $source);
|
||||
if (is_array($source)) {
|
||||
$source = implode('', $source);
|
||||
}
|
||||
|
||||
// Attempt to split contiguous blocks of markdown into smaller
|
||||
// pieces.
|
||||
|
|
Loading…
Reference in a new issue