Skip to content
This repository has been archived by the owner on Jul 1, 2023. It is now read-only.

Commit

Permalink
Store previously-static variable in a local
Browse files Browse the repository at this point in the history
The static local was used consistently for the `map()`, but the member
variable (or a static member variable) was messed up in future
iterations if a previous item contained a list - e.g. lists of lists
  • Loading branch information
fredemmott committed Mar 26, 2019
1 parent 7d96922 commit 6babf94
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/render/MarkdownRenderer.php
Original file line number Diff line number Diff line change
@@ -196,15 +196,16 @@ protected function renderListItem(
|> $sep.$$;
}

// Used to rotate between separators
private int $numberOfLists = 0;

<<__Override>>
protected function renderListOfItems(Blocks\ListOfItems $node): string {
++$this->numberOfLists;
$this_list = ++$this->numberOfLists;
return $node->getItems()
|> Vec\map(
$$,
$item ==> $this->renderListItem($this->numberOfLists, $node, $item),
$item ==> $this->renderListItem($this_list, $node, $item),
)
|> Str\join($$, "\n");
}

0 comments on commit 6babf94

Please sign in to comment.