From 6babf946014e5665c34cd943d376318e5b350d1b Mon Sep 17 00:00:00 2001 From: Fred Emmott Date: Tue, 26 Mar 2019 13:30:14 -0700 Subject: [PATCH] Store previously-static variable in a local 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 --- src/render/MarkdownRenderer.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/render/MarkdownRenderer.php b/src/render/MarkdownRenderer.php index e73bc03..11d6770 100644 --- a/src/render/MarkdownRenderer.php +++ b/src/render/MarkdownRenderer.php @@ -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"); }