diff --git a/src/Plugins/Litedown/Parser.js b/src/Plugins/Litedown/Parser.js
index <HASH>..<HASH> 100644
--- a/src/Plugins/Litedown/Parser.js
+++ b/src/Plugins/Litedown/Parser.js
@@ -508,7 +508,7 @@ function matchBlockLevelMarkup()
 				tagPos = matchPos + ignoreLen;
 				tagLen = lfPos - tagPos;
 
-				if (m[5].charAt(0) === codeFence)
+				if (codeTag && m[5].charAt(0) === codeFence)
 				{
 					endTag = addEndTag('CODE', tagPos, tagLen);
 					endTag.pairWith(codeTag);
diff --git a/src/Plugins/Litedown/Parser.php b/src/Plugins/Litedown/Parser.php
index <HASH>..<HASH> 100644
--- a/src/Plugins/Litedown/Parser.php
+++ b/src/Plugins/Litedown/Parser.php
@@ -509,7 +509,7 @@ class Parser extends ParserBase
 					$tagPos = $matchPos + $ignoreLen;
 					$tagLen = $lfPos - $tagPos;
 
-					if ($m[5][0][0] === $codeFence)
+					if (isset($codeTag) && $m[5][0][0] === $codeFence)
 					{
 
 						$endTag = $this->parser->addEndTag('CODE', $tagPos, $tagLen);
Litedown: added isset() check. No functional change intended