{"id":135125,"date":"2011-10-28T08:00:00","date_gmt":"2011-10-28T08:00:00","guid":{"rendered":"https:\/\/www.weixiaoduo.com\/plugins\/2024\/02\/22\/preserved-html-editor-markup\/"},"modified":"2012-09-04T00:51:00","modified_gmt":"2012-09-04T00:51:00","slug":"preserved-html-editor-markup","status":"publish","type":"post","link":"https:\/\/www.weixiaoduo.com\/plugins\/preserved-html-editor-markup\/","title":{"rendered":"Preserved HTML Editor Markup"},"content":{"rendered":"<p>This plugin preserves the user-generated HTML markup in the TinyMCE editor.  Unlike other plugins this one allows developers to work in the HTML tab AND end-users to work in the WYSIWYG Visual tab at the same time!  No longer will your HTML markup be completely munged into an unrecognizable form when you switch between those tabs.  And you don\u2019t have to hang your users\/editors out to dry when you hand off the project with a disabled Visual tab.<\/p>\n<h4>IMPORTANT: Please read the installation instructions carefully.  If you have existing content it will not render properly after activating this plugin until you use the Fix It Tools.<\/h4>\n<p>(One user didn\u2019t read or follow these steps and panicked thinking I ruined their website.)<\/p>\n<p>It also supports HTML5 Block Anchor tags in addition to other HTML5 elements, something that is currently not supported in WordPress via any existing plugins.<\/p>\n<p>Version 1.5 will probably be the last version I release for a while since my daughter will be born soon.  I\u2019ve added support for full JavaScript code blocks in the HTML tab.  They are compatible and preserved when switching to Visual mode.  This rounds out the support for almost complete html preservation, with full use of the WYSIWYG editor. And you don\u2019t need to wrap comment codes around it per the recommendations located here: <a href=\"https:\/\/codex.wordpress.org\/Using_Javascript\" rel=\"nofollow ugc\">https:\/\/codex.wordpress.org\/Using_Javascript<\/a> but you can leave them in if you want.<\/p>\n<p>Version 1.4 was just a minor patch release.  User @denl noticed a problem with the plugin CataBlog which implements its own administrative management features by disabling the \u2018show_ui\u2019 flag for its custom post type.  I was ignoring any custom post type that didn\u2019t have a GUI, but it was an unecessary filter that probably limited other plugins.  This fix allows any post type that supports the TinyMCE editor to be \u201cfixed\u201d using the tools under Admin > Settings > Writing.<\/p>\n<p>Since version 1.3 you can now use inline CSS and JavaScript in the HTML editor and everything should be preserved.  To be clear, this applies to tags only, like <code>onclick<\/code> events and style definitions \u2013 not script blocks themselves.  To enable this feature you must disable the <code>wptexturize<\/code> and <code>convert_chars<\/code> filters by adding the following code to your theme\u2019s <code>functions.php<\/code>:<\/p>\n<pre><code>remove_filter(\"the_content\", \"wptexturize\");\nremove_filter(\"the_content\", \"convert_chars\");\n<\/code><\/pre>\n<p>This new feature is pretty experimental at the moment.  I tried to make it compatible with wptexturize but that proved close to impossible without duplicating a lot of core code in my plugin.  It\u2019s also not compatible with TinyMCE Advanced when the \u201cstop removing p and br tags\u201d setting is enabled.<br \/>\nI\u2019ve tested it on a variety of code samples and I\u2019m pleased with the results but if you find any content that isn\u2019t preserved just open a support ticket and I should be able to fix it.<\/p>\n<p>Since version 1.2, you now have a little more control over how content is created.  And most of the previous caveats to using this plugin are now resolved.<\/p>\n<ol>\n<li>\n<p>You can now choose whether to use BR tags OR P tags for newlines.  Even better you can use both, where one return key press injects a BR tag, and two return key presses will wrap a Paragraph tag.  This is great for being able to wrap headers at specific break points all while enjoying the semantic perks of paragraphs.<\/p>\n<\/li>\n<li>\n<p>In addition to choosing what type of tags to use, you can also change the behavior depending on the type of post, including custom post types.  So Pages can default to BR tags, and Blog Posts can default to Paragraph tags.<\/p>\n<\/li>\n<li>\n<p>If you have existing content that was created before activating this plugin, you can now use the Fixit feature to convert your existing content in a way that makes it render the same as before. Only use this feature (located under Admin > Settings > Writing: Fixing Existing Content) if you are installing this plugin for the first time, otherwise it will remove all of the formatted white space in your posts.<\/p>\n<\/li>\n<li>\n<p>Multi-line HTML comments are now supported (Thanks to <a href=\"https:\/\/wordpress.org\/support\/profile\/cwlee_klagroup\" rel=\"ugc\">@cwlee_klagroup<\/a> for suggesting the working fix!)<\/p>\n<\/li>\n<li>\n<p>The Format drop down in the TinyMCE editor had a bug which is now fixed.  It will now select \u201cFormat\u201d if you place the cursor on a section of bare text.  Currently the editor just leaves the previously selected format option in place.  It\u2019s minor but it\u2019s good to know when you have bare text in your content.<\/p>\n<\/li>\n<li>\n<p>There was a fairly problematic bug in the old version where in some browsers you couldn\u2019t change the formatting of a single line in the Visual editor if you started from scratch.  Choosing a different Format option would change the entire document, with the only work around being to edit the document in HTML mode.  That was bad, and somehow went unnoticed for far too long.  Anyway, that is fixed now.<\/p>\n<\/li>\n<\/ol>\n<p>The caveats that still remains are:<\/p>\n<ol>\n<li>\n<p>With script blocks added to your HTML markup, the right arrow key does not pass over them in the Visual Tab.  You can down arrow over them however so this will likely never be addressed.<\/p>\n<\/li>\n<li>\n<p>If you use the Paragraph tag setting for newlines there is a minor bug where it will only wrap your content in Paragraph tags if you specify Paragraph in the Format drop down or if you enter more than one paragraph of text.  So if you just type one sentence and click save it will not wrap the content in Paragraph tags.  I tried to fix this but ran out of my allotted time working on other core issues.  Should be fixed in the next release.<\/p>\n<\/li>\n<li>\n<p>For performance reasons, it will only preserve spaces if 4 spaces are used consecutively \u2013 i.e. an expanded tab in developer terms.  It will not preserve intra-tag white space like <p\u00a0\u00a0\u00a0\u00a0>.<\/p>\n<\/li>\n<li>\n<p>If you do add 4 or more spaces inside of an element tag it will corrupt the markup and mangle the output.  But as this is intended for developer edits, this should be an extreme rarity given the habit is virtually non-existent in development communities.<\/p>\n<\/li>\n<li>\n<p>PRE tags are not affected and behave as you would expect, however due to how browsers parse tags, the first newline in the content of a PRE tag will be wiped out unless it is padded with either another new line or multiple spaces.<\/p>\n<\/li>\n<li>\n<p>CODE tags are not preserving white space at all, and when wrapped with PRE tags white space is still removed.  I\u2019m working to resolve this problem.<\/p>\n<\/li>\n<\/ol>\n<h3>Arbitrary section<\/h3>\n","protected":false},"excerpt":{"rendered":"<p>Preserves white space and developer edits in HTML AND WYSIWYG tab.  Supports inline scripts\/css, JavaScript code blocks and HTML5 content editing<\/p>\n","protected":false},"author":65,"featured_media":326778,"comment_status":"open","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"slim_seo":{"title":"Preserved HTML Editor Markup - \u8587\u6653\u6735\u63d2\u4ef6\u76ee\u5f55","description":"Preserves white space and developer edits in HTML AND WYSIWYG tab. Supports inline scripts\/css, JavaScript code blocks and HTML5 content editing"},"footnotes":""},"categories":[1],"tags":[574,63,500,36662,17624],"class_list":["post-135125","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized","tag-editor","tag-html","tag-markup","tag-white-space","tag-wpautop"],"_links":{"self":[{"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/posts\/135125","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/users\/65"}],"replies":[{"embeddable":true,"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/comments?post=135125"}],"version-history":[{"count":0,"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/posts\/135125\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/media\/326778"}],"wp:attachment":[{"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/media?parent=135125"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/categories?post=135125"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/tags?post=135125"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}