Keep Markup: the markup is removed if it's the last element
Open
Nobody has claimed this yet.
bug
help wanted
plugins
- Dominant language
- JavaScript
- Stars
- 13k
- Forks
- 1.4k
- Avg merge
- 15h 36m
- Merged PRs (30d)
- 3
Description
I don't if this is intended or not but if the markup (in the exemple below <div class="keep"></div>") is the last element, the Keep Markup plugin will remove it:
<!DOCTYPE html>
<html>
<head>
<link href="prism.css" rel="stylesheet" />
<style>
.keep {
height: 1rem;
width: 1rem;
background-color: red;
}
</style>
</head>
<body>
<pre><code class="language-css"><div class="keep"></div>p { color: red }<div class="keep"></div></code></pre>
<script src="prism.js"></script>
</body>
</html>
And here's the result:

As you can see the first <div class="keep"></div> is preserved but the last is removed.
If I add some content after the div then it's working as expected:

Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Keep Markup plugin and reproduce the issue using the HTML example in the report, comparing markup at the beginning and end of the highlighted code. The fix is complete when a final empty
is preserved just like an earlier one, including when no content follows it.Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100