Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/Converter.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,13 @@ class Converter
*/
protected $indent = '';

/**
* previous indentation, when we want to disable current indentation and get it back later
*
* @var string
*/
static $previousIndent = '';

/**
* constructor, set options, setup parser
*
Expand Down Expand Up @@ -534,8 +541,7 @@ protected function handleTagToText()
// don't indent inside <pre> tags
if ($this->parser->tagName == 'pre') {
$this->out($this->parser->node);
static $indent;
$indent = $this->indent;
$this->previousIndent = $this->indent;
$this->indent = '';
} else {
$this->out($this->parser->node . "\n" . $this->indent);
Expand All @@ -556,8 +562,7 @@ protected function handleTagToText()
} else {
// reset indentation
$this->out($this->parser->node);
static $indent;
$this->indent = $indent;
$this->indent = $this->previousIndent;
}

if (in_array($this->parent(), ['ins', 'del'])) {
Expand Down