This is a duplicate of another question and (I’m sorry!) a bug in WP. As @Otto says in the comments to that question, this is an edge case problem (not many users know or care about using comments) and is not likely to get fixed soon unless you’d be interested in contributing.
EDIT:
I looked for more information on this in trac, and found a few related bugs describing exactly this problem. There is a workaround suggested:
Just before the close comment tag, put another open comment tag. That second open comment tag will be commented out, but it forces the close tag to be recognized and not be reformatted as an en-dash.
Example that fails:
<!-- <b> text </b> -->
Example that works:
<!-- <b> text </b> <!-- -->
In other words, if you have comments that enclose other tags, just make sure the last tag is another open comment tag.
Hope this helps! (Better late than never!)
Related Posts:
- prevent wordpress from rendering line breaks as br tags
- Removing buttons from the html editor
- Contents of HTML editor mangled after multiple UPDATES
- functional quicktag
- How to process html editor whole content of a single post
- pop-up options for custom quicktags
- Remove TEXT EDITOR form page [duplicate]
- Create keyboard shortcuts for HTML mode
- How can I create an alternate full-HTML editor for posts?
- Adding Html in text editor automagically adds undesirable paragraphs when publishing
- How to prevent WordPress CodeEditor adding fake closing tags that corrupt the page?
- How can you change the non-visual editor’s background color?
- I have a question in Basic HTML [closed]
- Why is `–` converted into ndash and how can I get rid of it?
- unexpected added in HTML at each update [closed]
- WordPress adding in anchor elements when I save a page in html editor
- Set or change default text in hyperlink popup in post editor
- How to use “Add link” pop up for a WordPress widget
- WordPress Visual Editor Stripping HTML Changes
- Add quicktag buttons to the HTML editor
- Disable the Code View in the content editor?
- Stop WordPress From Removing HTML Comments In Content
- Can I force WordPress to use instead of ?
- Enable / Add Custom Keyboard Shortcuts To Work With WordPress’ HTML Editor
- How to to stop html editor from addig tags to shortcodes, images, etc
- serialize_blocks breaking html tags in content
- Prevent WordPress from adding linebreaks to javascript embedded in a page
- strip only specific tags (like ), but keep other tags (like )
- Preserve white-space in Page
- WP Editor strips input placeholder attribute
- how to make stylesheet appear in theme editor?
- ID’s being stripped out of editor for Admin user in Multi-Site
- data-accordion removed in Visual Editor
- How to make WordPress and TinyMCE accept tags wrapping block-level elements as allowed in HTML5?
- How to add JavaScript code on WordPress properly?
- Why does the custom HTML block not preserve the HTML characters?
- WordPress tinymce prints empty P tag and break html format
- add_meta_box Callback not being called
- How can I control the HTML output of my post?
- unwanted and tags in text editor
- Strange problems when I try to insert HTML\XML code snippet in my posts
- Recommended tools for Theme Development with SASS [closed]
- Can “ and “ tags be used in the HTML editor?
- How to display php source code inside a post using visual editor?
- Custom settings page TinyMce: no formatting when echoing value of editor
- Prevent WordPress from messing my HTML
- Visual/Text tabs in wp editor Not Showing
- Selectively remove empty line after line change
- Prevent the Editor From Moving My
- HTML editor accessing quicktag buttons
- Text Editor Tags
- How to Add Custom Button to Text(HTML) Editor and NOT Visual Editor
- WordPress editor not creating tags properly in tables
- Product Custom Fields with HTML and JS
- Removing line breaks when in text view with wp_editor
- Visual editor keeps stripping my tags
- How to set wp_editor to be email friendly?
- Inline Style attribute getting stripped off
- Disable TinyMCE Table formatting width/height
- In context click and edit: is it feasible?
- How can I remove line breaks from manually formatted HTML?
- How can I make the page editor trust me?
- WordPress adding a to my anchor for Read More
- Why does WordPress change a file’s permissions?
- Can’t give tags rels
- HTML tables in content areas
- how can default_content filter tell if content will load in block editor or classic editor?
- How can a TinyMCE modal return formatted/visual text?
- Notion-like editing and layout with a convenient freeform collaborative editor in WordPress? [closed]
- Problem with some keys when editing HTML in wordpress “text” editor
- Why exactly does WordPress use p tags, not divs?
- Visual composer causing conflict with TinyMCE [closed]
- How to show the contants in front end same as visual editor with space / linebreak?
- Commenting out in HTML editor breaks template
- How to determine if a post was last edited in the Visual Editor
- qTranslate 2.5.28 and WordPress 3.3.1 issues [closed]
- Using WP just to edit pages of an existing site
- How to add custom HTML tags in the visual mode via keyboard only?
- Block editor: content resets to the previous state in “Edit as HTML” by clicking somewhere outside of the editing window
- How do I prevent WordPress from eating my code?
- Classic TinyMCE messing up only Contributor’s HTML
- Locating the HTML piece of code in wordpress
- How to create different gallery-types and let the editor choose between them?
- Why is every single HTML tag being stripped out of liveblog entries?
- Callback function quicktags that uses variable in start tag
- My WordPress editor deletes all characters after emoji – how can I fix this?
- Custom code in all text between ?
- How to disable style filtering in post?
- WYSIWYG with HTML source?
- insert link in wordpress editor greyout whole screen?
- Disable html in custom post types
- Which subset of html does WordPress support?
- image overlay on image not working in wordpress, but works in “normal html editors”
- wordpress not saving form code in code editor
- WordPress HTML editor panel is not showing HTML elements
- Add Custom CSS Class in Child Theme [closed]
- Can you not edit the HTML and PHP of your WordPress without paying?
- WordPress “HTML editor” which doesn’t trash hand-coded HTML?
- WordPress adds and tags into HTML blocks after saving
- Can’t have two simultaneous charts using Apex Charts