We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 6890
    • 21 Posts
    This is an auto-generated topic for xTidy 0.1-beta1 by deathtiger.

    Brief Description:

    xTidy is a plugin aimed at formatting the modx document output (resource syntax) regardless of it’s language (xml, html, php) to ease bug tracking and readability.
    Features:

    • Merge all syntax onto one line.
    • Strip out comments (including <!-- -->, //, /* */).
    • Remove empty lines
    • Customizable indent characters. (\t for tab or ’ ’ multiple space characters).
    • Remove duplicate words (case sensitive).
    Changelog:

    • Resolved issue where conditional statements were not indenting correctly.(New issue arisen)
    • Increase comment removal to support removing more comments while preserving SiteCatalyst tracking code (amended to preserve remaining --> tag).
    I cannot stress enough that this is a beta and if there are any issues please report them with an example.




      • 33976 ☆ A M B ☆
      • 571 Posts
      Hi DeathTiger,

      Really nice idea. It works pretty fine here (beside the fact that some conditional comments are indented).
      I would really like an output filter version to be used only where needed (like rich text TVs, ie. [[*content:xtidy]])

      Thanks for the share
        • 6890
        • 21 Posts
        That sounds like an awesome idea, the result would clearly be a snippet rather than a plugin but I will look into it regardless.

        Thanks for the quick feedback.

        Could you give me an example of where the conditionals are formatting incorrectly?

        DT
          • 33337
          • 3,975 Posts
          There are some scenarios, where JS is between <!-- --> such as sitecatalyst tracking code, this is stripping it off altogether.
          
          <script language="javascript" type="text/javascript">
          
          		<!-- 
          
          			/* Copyright 1997-2011 Omniture, Inc. */
          
          			
          
          			// ELQ GUID 
          
          			if(!s.c_r('elqCustomerGUID')) {
          
          				d=new Date;
          
          				d.setTime(d.getTime()+(365*24*60*60*1000));
          
          				s.c_w('elqCustomerGUID',GetElqCustomerGUID(),d);
          
          			}
          
          				
          
          			/* PAGE SPECIFIC */
          
          			
          			s.pageName='SiteCatalyst';
          			s.channel='Products';
          			s.prop6='English';
          			if(s && s.c_r('tc_demo')==1 && s.c_r('tc_extra_info') != 'milestone=touchclarity') {
          
          			tc_extra_info = 'milestone=sitecatalyst';
          
          			s.c_w('tc_extra_info','milestone=sitecatalyst');
          
          	}
          
          			
          
          			/*TNT FOOTER CONTINUED */
          
          			if(typeof mboxCreate == 'function') {
          
          				
          
          				var epi_offer_name;
          
          				var epi_offer_product;
          
          				var epi_offer_centricity;
          
          				var epi_offer_type;
          
          				
          
          				if(s.pageName==undefined)
          
          					s.pageName=window.location;
          
          				mboxCreate('global_page_vars','pageinfo_name='+s.pageName,'pageinfo_section='+s.channel,'pageinfo_url='+window.location,'pageinfo_offer_name='+epi_offer_name,'pageinfo_offer_product='+epi_offer_product,'pageinfo_offer_centricity='+epi_offer_centricity,'pageinfo_offer_type='+epi_offer_type);
          
          			}
          
          			/*TNT FOOTER END AGAIN */
          
          			
          
          			mboxLoadSCPlugin(s);
          
          			
          
          			/************* DO NOT ALTER ANYTHING BELOW THIS LINE ! **************/
          
          			var s_code=s.t();if(s_code)document.write(s_code)
          
          			//-->
          
          		</script>
          
          
            Zaigham R - MODX Professional | Skype | Email | Twitter

            Digging the interwebs for #MODX gems and bringing it to you. modx.link
            • 6890
            • 21 Posts
            Wow, I can honestly say I’ve never encountered something like this!
            Naturally I’m assuming that you’d want to keep the Javascript comment tags (<!-- -->) but strip any single or multi-line comments (// /* */)?

            DT
              • 6890
              • 21 Posts
              Zi & Romain,

              I’ve modified the plugin to fix the conditional indentation (crosses fingers, works for me grin) and only remove comments from the sitecatalyst tracking. Once again, only based on my testing.

              DT
                • 33976 ☆ A M B ☆
                • 571 Posts
                Thanks DT, will definitely give it a try.
                By any chance, are you on Github ?
                  • 33337
                  • 3,975 Posts
                  Looks fine so far.

                  One thing, it doesn’t seem to see the custom property set.
                    Zaigham R - MODX Professional | Skype | Email | Twitter

                    Digging the interwebs for #MODX gems and bringing it to you. modx.link
                    • 33337
                    • 3,975 Posts
                    One more thing, its omitting the last //--> in the above example.
                      Zaigham R - MODX Professional | Skype | Email | Twitter

                      Digging the interwebs for #MODX gems and bringing it to you. modx.link
                      • 33976 ☆ A M B ☆
                      • 571 Posts
                      With the beta2, if i choose to strip comments, conditional comments are removed.
                      If i set StripComments to no, conditional comments are still indented.