WordPress.org

Ready to get started?Download WordPress

Forums

Preserved HTML Editor Markup
[resolved] HTML comments spanning multiple tags are not preserved (35 posts)

  1. cwlee_klagroup
    Member
    Posted 2 years ago #

    Original code loaded into HTML editor
    
    <!--  preserved-html-editor-markup TEST 1 -->
    
    <!-- test of code commented out across multiple tags -->
    
    <!--   <h2 style="margin-top:0px; padding-top:5px;">Welcome CPSL Sales Team</h2>
    <p>It’s never been more difficult to reach sales prospects, but  in this training program you’ll learn new strategies to combine cold calling, email, and social media prospecting to gain access to your top prospects.</p>
    <p>You’ll discover how to:</p>
    <ul>
      <li>Craft  attention-getting messages</li>
      <li>Initiate  memorable conversations</li>
      <li>Close  first appointments</li>
      <li>Handle  stubborn gatekeepers and objections</li>
    </ul> -->  // <== ENDING COMMENT TAG STARTED OUT AS '-->'
    
    <!-- End preserved-html-editor-markup TEST 1 -->
    
    Code returned by TinyMCE Visual Editor with preserved-html-editor-markup plug-in activated  
    
    <!--  preserved-html-editor-markup TEST 1 -->
    
    <!-- test of code commented out across multiple tags -->
    
    <!--   <h2 style="margin-top:0px; padding-top:5px;">Welcome CPSL Sales Team</h2>
    <p>It’s never been more difficult to reach sales prospects, but in this training program you’ll learn new strategies to combine cold calling, email, and social media prospecting to gain access to your top prospects.</p>
    <p>You’ll discover how to:</p>
    <ul>
    <li>Craft attention-getting messages</li>
    <li>Initiate memorable conversations</li>
    <li>Close first appointments</li>
    <li>Handle stubborn gatekeepers and objections</li>
    </ul>--> // <== ENDING COMMENT TAG CONVERTED TO --& g t ; (Ignore spaces between & g t ;)
    
    <!-- End preserved-html-editor-markup TEST 1 -->

    http://wordpress.org/extend/plugins/preserved-html-editor-markup/

  2. MarcusPope
    Member
    Plugin Author

    Posted 1 year ago #

    Hi cwlee - thanks for submitting the support request. Unfortunately there isn't much I can do about this paricular problem because my plugin relies on injecting special html comments to preserve the whitepsace and markup. Multi-line html comments end up with nested children comments that represent where newlines should be re-injected in html mode, and nested html comments are not supported by web browsers. Unfortunately this was my only option for preserving meta info between the two tabs.

    I'll add this to the FAQ as a warning for other users. If you happen to think of a way around this I'd be glad to implement a fix.

    Thanks,
    Marcus

  3. cwlee_klagroup
    Member
    Posted 1 year ago #

    Hi Marcus, Thank you. I have found a resolution for Preserving commented HTML code.

    <code><!-- </p>
    <p>commented HTML code</p>
    <p>--> <\code>
    
    This prevents the trailing > from being returned as '& g t ;'
  4. MarcusPope
    Member
    Plugin Author

    Posted 1 year ago #

    And even with a personal policy of "never saying something can't be done in software" it seems I get to eat my own words still :D. I'll look into what is happening at the tinymce layer with the above markup and implement a solution at the plugin layer that simulates the above. I don't think it will make it into the next release but I will try.

  5. MarcusPope
    Member
    Plugin Author

    Posted 1 year ago #

    Ok cwlee, I have a fix for this problem almost complete. But quick question, how do you get around wordpress texturize converting the closing html comment --> into this &8211;>? I'd hate to disable wp_texturize from my plugin because it's not really germane to its purpose. But from what I can tell it's pretty much required, and wordpress core seems to close bugs on the subject as wontfix. Let me know if you have an alternate solution - I'm so close to being able to publish this plugin tomorrow.

  6. cwlee_klagroup
    Member
    Posted 1 year ago #

    `<?php
    //disable auto p
    remove_filter ('the_content', 'wpautop');

    //disable wptexturize
    remove_filter('the_content', 'wptexturize');
    ?>

  7. cwlee_klagroup
    Member
    Posted 1 year ago #

    I put the hooks above in my theme's functions.php. Then I put the code /code tags before and after all commented code

  8. cwlee_klagroup
    Member
    Posted 1 year ago #

    Re-reading your note I believe the leading code tag and trailing /code tag are all that's required. I'm pretty sure wp_texturize leaves everything between these code tags unchanged except "php" tags which it never leaves alone! I'll pay a king's ransom to the bugger who solves that one!

  9. cwlee_klagroup
    Member
    Posted 1 year ago #

    So give this a try and see what results you get.`<code><!-- </p>
    <p>commented HTML code</p>
    <p>--> <\code>

    This prevents the trailing > from being returned as '& g t ;'`

  10. MarcusPope
    Member
    Plugin Author

    Posted 1 year ago #

    Yeah I discovered the code tag was the only tag necessary yesterday and that part works great. But since a code block with only an html comment in it will still render on screen depending on styling I actually only temporarily use a code tag while switching between the editor visual/html tabs. And I hard-code a display:none in it as well. Then on save I strip out the code tag and just leave the html comment which is where the wp_texturize problem steps in. After sleeping on it I have a solution to the wp_texturize problem that doesn't require disabling it entirely... though it's crazy that it will turn any instance of '--' into &8211; and the wp core devs don't see this as a problem... sheesh.

    I'll keep the php code block concept in mind for my next plugin project. Considering what I've managed to do with root relative urls and this plugin I just might be able to collect that king's ransom from you :D I'm glad to hear the other problem you were having was finally resolved. Sometime around lunch I should have the new version of this tool posted.

  11. MarcusPope
    Member
    Plugin Author

    Posted 1 year ago #

    Whew! Finally done, after every issue I fixed another would rear its head from the WP Core code! But alas, I was able to fix them all, including multi-line html comments. Just type them in the HTML editor as you would in any other editor, hack free and my plugin will ensure they are not trumped by wptexturize or wpautop.

    Some other good features were added too so check out version 1.2. (I just committed the code and it can take up to 20 minutes for the plugin download to be repackaged by WordPress.)

  12. peterdub
    Member
    Posted 1 year ago #

    RE: Just type them in the HTML editor as you would in any other editor, hack free and my plugin will ensure they are not trumped by wptexturize or wpautop.

    I have assumed I dont need to click on extra buttons or write some extra wrapping code like say [marcus tag] write anything here [/marcus tag]

    So:
    I was really happy that multiline HTML commenting was supposed to work
    Except it doesnt
    I only use html editor I never use visual thing
    Obviously I have activated the plug in etc I just downloaded it so assume its the latest version you speak of...

  13. peterdub
    Member
    Posted 1 year ago #

    Trying some more...

    I Explorer = worked like you say
    Firefox = I put the code tags around the comment tags so now work ok
    (like cwlee_klagroup suggestion)

    So hopefully "code" workaround is good for any other non complying browser

    Should say thanks too =
    its great that multiline spacing and & n b s p ;  and <center> tags and much else now works, presumably thanks to you
    (downloaded a bunch of plugins in frustration... would like to be able to code as if in blank notepad type editor!)

  14. MarcusPope
    Member
    Plugin Author

    Posted 1 year ago #

    @peterdub - Weird. I'm using FireFox version 14.0.1 on Windows 7 and it is working just fine for me. All of your assumptions were correct, and it should just work for you. I tried without accessing the visual tab, and that too worked as designed.

    I am the developer of the plugin, and I appreciate both the thanks, and the time on your part for letting me know about the problem you're having. I'd definitely like to figure out the problem you're having, so would you mind letting me know the browser version and OS you're using? Also if you could try disabling other plugins one by one until you have just mine enabled to see if that fixes the problem that would be awesome. Even if it's a compatibility issue with another plugin I can either fix it on my end, or send a patch to the other developer if it's an issue on their end.

    I almost didn't catch this because I had closed this support ticket. If you don't mind opening a new one to keep track of the issue I'd really appreciate it. I can't re-open this one otherwise I'd save you the hastle :D

    Thanks,
    Marcus

  15. peterdub
    Member
    Posted 1 year ago #

    Many Thanks Marcus

    Windows 7 Ultimate
    Firefox version 7.0
    (sounds old but seemingly from sep 2011.. er, maybe thats old!)

    If its not the old Firefox maybe some interaction like you say...

    btw click to donate goes to marcuspope.com that seems in redevelopment

  16. peterdub
    Member
    Posted 1 year ago #

    btw am using public computers this summer for a bit...
    so its not a big deal if it's the firefox, which I cant really upgrade,
    can still use other browsers for now
    maybe you can try in firefox 7, if thats possible, just to confirm thats the issue

  17. ViennaMex
    Member
    Posted 1 year ago #

    Hello Marcus! Love the Authentic Mex and Tex Mex in Austin!

    So here is the issue that I started getting as soon as I upgraded your very fine plugin a few days ago:

    A WordPress plugin that uses a Username and Password log-in to access a form suddenly partially disappeared as far as the fields required for data input before submission.

    The Username was a series of numbers -- always a 7 digit number. To make it easier for the user to "count" I separated the Username field into 7 inputs. Each time the user input a number the focus moved to the next field until they had entered 7 digits. It was more user-friendly and lessened mistakes.

    Before updating to the latest version of "Preserved HTML.." my code would look like this:

    <td>
    <input name="Benutzername0" type="text" id="Benutzername0" size="1" maxlength="1" onkeyup="if(this.value.length>=1) document.loginForm.Benutzername1.focus()"/>
    <input name="Benutzername1" type="text" id="Benutzername1" size="1" maxlength="1" onkeyup="if(this.value.length>=1) document.loginForm.Benutzername2.focus()" />
    <input name="Benutzername2" type="text" id="Benutzername2" size="1" maxlength="1" onkeyup="if(this.value.length>=1) document.loginForm.Benutzername3.focus()" />
    <input name="Benutzername3" type="text" id="Benutzername3" size="1" maxlength="1" onkeyup="if(this.value.length>=1) document.loginForm.Benutzername4.focus()"/>
    <input name="Benutzername4" type="text" id="Benutzername4" size="1" maxlength="1" onkeyup="if(this.value.length>=1) document.loginForm.Benutzername5.focus()" />
    <input name="Benutzername5" type="text" id="Benutzername5" size="1" maxlength="1" onkeyup="if(this.value.length>=1) document.loginForm.Benutzername6.focus()"/>
    <input name="Benutzername6" type="text" id="Benutzername6" size="1" maxlength="1" onkeyup="if(this.value.length>=1) document.loginForm.password.focus()" /></td>
    
    AFTER updating to 1.2 it turned into this with the ending value quote character " being rendered as ”
    And this stopped the form's inputs from displaying in all browsers.
    
    <table border="0" cellpadding="3" width="400">
    <tbody>
    <tr>
    <td><strong>Benutzername</strong></td>
    <td>
    <input name="Benutzername0" type="text" id="Benutzername0" size="1" maxlength="1" onkeyup="if(this.value.length>=1) document.loginForm.Benutzername1.focus()”/>
    <input name="Benutzername1" type="text" id="Benutzername1" size="1" maxlength="1" onkeyup="if(this.value.length>=1) document.loginForm.Benutzername2.focus()” />
    <input name="Benutzername2" type="text" id="Benutzername2" size="1" maxlength="1" onkeyup="if(this.value.length>=1) document.loginForm.Benutzername3.focus()” />
    <input name="Benutzername3" type="text" id="Benutzername3" size="1" maxlength="1" onkeyup="if(this.value.length>=1) document.loginForm.Benutzername4.focus()”/>
    <input name="Benutzername4" type="text" id="Benutzername4" size="1" maxlength="1" onkeyup="if(this.value.length>=1) document.loginForm.Benutzername5.focus()” />
    <input name="Benutzername5" type="text" id="Benutzername5" size="1" maxlength="1" onkeyup="if(this.value.length>=1) document.loginForm.Benutzername6.focus()”/>
    <input name="Benutzername6" type="text" id="Benutzername6" size="1" maxlength="1" onkeyup="if(this.value.length>=1) document.loginForm.password.focus()” /></td>
    </tr>

    [Moderator Note: Please post code or markup snippets between backticks or use the code button. Or better still - use the pastebin. As it stands, your code may now have been permanently damaged/corrupted by the forum's parser.]

    Why your plugin would be involved is because the plugin output is rendered through shortcode on a WordPress page.

    As far as I recall your previous version of this plugin did not impact the output of all of these " quote marks.

    I tried various ways in the plugin code itself to isolate and stop this from happening but your latest plugin version saves the worst for last on every line. That last quote mark gets "special" treatment. I found before that placing a ; after each focus() made no difference in the functionality so I removed them, by the way.

    So, unfortunately, I have to deactivate your spiffy plugin for now.

  18. MarcusPope
    Member
    Plugin Author

    Posted 1 year ago #

    @peterdub - thanks for the info, although 7 is pretty old by FireFox standards, I was able to download an archive version and try it out. Unfortunately it worked just fine for me, so I'm going to investigate further into @dreamdancerdesign's problem which should expose the root cause of both of your problems.

  19. MarcusPope
    Member
    Plugin Author

    Posted 1 year ago #

    @ViennaMex - Thanks for the kind remarks about the plugin. As a quick fix to get you running again, you can download version 1.1 from this link http://dreamdancerdesign.net/downloads/preserved-html-editor-markup.zip

    You can manually install that version to resume using the old plugin until I figure out a fix for the new one.

    I'm pretty busy catching up on some work at the moment, but I plan to have this fixed by the end of the weekend.

    Thanks,
    Marcus

  20. MarcusPope
    Member
    Plugin Author

    Posted 1 year ago #

    @peterdub - just noticed the comment about donations - it's no biggie, I think wordpress required me to put a url in that field so I just posted a link to my development server. Maybe one day I'll put up a real donations link but for now just enjoy the free software :D

  21. ViennaMex
    Member
    Posted 1 year ago #

    Okay, I see today that my "bad code" was all nicely cleaned up in my comment here.

    I have tried to show the actual rendering with dustbin now and the "code" button but this site simply will not allow the actual problem characters to show that wound up in the code such as below:

    input name="Benutzername0" type="text" id="Benutzername0" size="1" maxlength="1" onkeyup="if(this.value.length>=1) document.loginForm.Benutzername1.focus() here is the problem />

    So I will put a space between each character that was generated instead of the last quote mark " in each line. Remove the spaces and that was the replacement character string for a quote mark.

    & # 8 2 2 1 ;

    Thank you, Marcus, for kindly making version 1.1 available to me again!

  22. MarcusPope
    Member
    Plugin Author

    Posted 1 year ago #

    @ViennaMex - I'm pretty sure your problem is related to wp_texturize - a function that has other bugs very similar to yours. In fact it's what prevents multiline html comments by default. Anyway the fix for closing comment tags "-- >" turning into "& # 8211;" was easy so I should have this fixed soon.

    If you wanted to confirm my guess, you could upgrade to 1.2 again, and disable wptexturize by following this thread http://wordpress.org/support/topic/please-give-us-the-option-to-turn-of-smart-quotes?replies=15

    That should fix your problem but if you don't get this or don't have the time it's not a big deal.

    Thanks,
    Marcus

  23. MarcusPope
    Member
    Plugin Author

    Posted 1 year ago #

    @ViennaMex - Ok, after a lot of testing and trial and error I've done the best that I can for your situation in version 1.3 (just published.)

    As for your code sample above the biggest culprit was not having a space character between the last double quote and the closing tag. That made wordpress convert the quote into an HTML quote which caused many other cascading problems as a result.

    Things got a lot worse if you tried to use two ampersands (&&) or multiple less/greater than symbols in the inline code. I've done my best to support these characters. As it stands they will be preserved only if you disable wptexturize and convert_chars filters. I provided instructions in the readme on how to disable these functions. Doing so will mean wordpress will no longer encode certain characters like two dashes when they are entered via the Visual Tab. But it should encode all characters that require encoding for proper HTML like & and > etc.

    Hope it works out for you and if you have any other code samples that don't work just open a new support ticket and I'll try to fix them too.

    Thanks,
    Marcus

  24. MarcusPope
    Member
    Plugin Author

    Posted 1 year ago #

    @peterdub - you should also be able to upgrade to version 1.3 without any problems. I've added a feature to disable caching the javascript file in my plugin on version upgrades. Please open a new ticket if you still have problems so I'm notified of a new problem.

  25. ViennaMex
    Member
    Posted 1 year ago #

    Hi Marcus,

    Thank you so much for responding to this and for spending time working on it again!

    Before I posted here I had experimented with the spacing between the last double quote and the closing tag. I experimented with spacings including spacings between the last focus() and the last double quote and the last closing tag />

    None of my experiments helped the issue. I also tried \ in front of the quotes, etc.

    I know you have an extremely complex issue trying to create something that works across browsers and servers with different settings for magic quotes, etc.

    I am glad you are the expert on this, Marcus.

    It is also difficult to post the actual code example on this forum. The code blocks shown with backticks and the pastebin did not solve that problem in posting.

    Today I am going back to this issue and upgrade to 1.3 try the settings you mention.

  26. peterdub
    Member
    Posted 1 year ago #

    Thank you Marcus!
    I will try and upgrade so.
    Not sure how to do it (new at this) but assume I can just "deactivate" (rather than have to delete) the last one and can upload the new one - also in case want to go back to the old one for some reason!
    Anyway that's what I will try...

    I will let you know if I have any further problems, as you suggested
    (re @dreamdancerdesign apparent similarity)

  27. MarcusPope
    Member
    Plugin Author

    Posted 1 year ago #

    @peterdub - the plugins page should alert you to the new version and give you a link to upgrade it. If you need to revert to the old one I'm sure @dreamdancerdesign wouldn't mind you re-downloading for the time being. I'm working on a support site that will include links to older releases so people will have an option to downgrade.

    @ViennaMex - That's odd that adding spaces before /> didn't work for you - hopefully 1.3 does work for you. I'll admit that the practice of inline scripts and styles isn't a recommeded practice from the WP Core team, but if it does work or works partially I might create a separate plugin dedicated to just that feature.

    Thanks again for trying out my plugin.
    -Marcus

  28. dreamdancerdesign
    Member
    Posted 1 year ago #

    Yes, I can leave the link up to the older versions until the support site is ready.

    I know it isn't recommended but I do use inline styles a lot. Many times I need to override the default styles in Genesis, most common being making a div that has the text centered, but I don't want all type in the layout centered.

    The ticket widget that I needed to use (on the site that started this issue for me) has an inline javascript and it is on a page that the client needs to edit too. Without Preserved HTML Editor the code was breaking every time the page was edited. I would have had to try to use iFrames and other workarounds that really are funky.

    thanks again Marcus!

  29. peterdub
    Member
    Posted 1 year ago #

    Well.. it seems I cant keep the old version but am forced to update it
    I wanted just to daactivate previous so it was spare
    How I hate WordPress!
    It seems to require a mass of "plugins" to do anything
    As I like doing my own page coding,
    I'd have to say I find Blogspot much better
    It just seems that WordPress fights you at every turn,
    wheras Blogspot (perhaps ironically from being technically worse done) is much more forgiving - I even stuck an image in a title etc
    Also with Blogspot you can see on the design page exactly how everything is laid out, visually.
    Maybe not the right place top comment but as said, why the heck cant I keep an old deactivated plugin, if thats what I want
    Well, it's gone now anyway.
    I see dreamdancerdesign still has the old ones, however that works...
    (end of rant!)

  30. peterdub
    Member
    Posted 1 year ago #

    RE
    If you need to revert to the old one I'm sure @dreamdancerdesign wouldn't mind you re-downloading for the time being.
    "Yes, I can leave the link up to the older versions until the support site is ready."

    (I dont see how the old one is available, I clicked on dreamdancerdesign and not see anything...not that would need hopefully but still = none would be needed if one could deactivate old and download a new, keeping both OK its a wordpress.org thing I know)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic