Open Infocatcher opened 5 years ago
Updated version: https://github.com/Infocatcher/AkelPad_scripts/blob/jsBeautifier_new/jsBeautifier.js Changes: https://github.com/Infocatcher/AkelPad_scripts/commits/jsBeautifier_new Merged with master branch: 532e193acb70db41c8e88cac090c5d76ea84ce15
Tests:
==== Old tests ============================================================ ---- input ------- #! ---- expected ---- #! ---- output ------ #! ---- expected-ws ------ #! ---- output-ws ------ #!\n ================================================================ ==== Old tests ============================================================ ---- input ------- #include ---- expected ---- #include ---- output ------ #include ---- expected-ws ------ #include ---- output-ws ------ #include\n ================================================================ ==== Old tests ============================================================ ---- input ------- #include "settings.jsxinc" ---- expected ---- #include "settings.jsxinc" ---- output ------ #include "settings.jsxinc" ---- expected-ws ------ #include_"settings.jsxinc" ---- output-ws ------ #include_"settings.jsxinc"\n ================================================================ ==== Tests for script and style Commented and cdata wapping (#1641) ============================================================ ---- input ------- <style><!----></style> ---- expected ---- <style> <!-- --> </style> ---- output ------ <style> < !----> </style> ---- expected-ws ------ <style>\n ____<!--\n ____-->\n </style> ---- output-ws ------ <style>\n ____<_!---->\n </style> ================================================================ ==== Tests for script and style Commented and cdata wapping (#1641) ============================================================ ---- input ------- <style><!-- --></style> ---- expected ---- <style> <!-- --> </style> ---- output ------ <style> < !-- --> </style> ---- expected-ws ------ <style>\n ____<!--\n ____-->\n </style> ---- output-ws ------ <style>\n ____<_!--_-->\n </style> ================================================================ ==== Tests for script and style Commented and cdata wapping (#1641) ============================================================ ---- input ------- <style><!-- the rest of this line is ignored --></style> ---- expected ---- <style> <!-- the rest of this line is ignored --> </style> ---- output ------ <style> < !-- the rest of this line is ignored --> </style> ---- expected-ws ------ <style>\n ____<!--_the_rest_of_this___line_is___ignored\n ____-->\n </style> ---- output-ws ------ <style>\n ____<_!--_the_rest_of_this_line_is_ignored_-->\n </style> ================================================================ ==== Tests for script and style Commented and cdata wapping (#1641) ============================================================ ---- input ------- <style type="test/null"><!-- --></style> ---- expected ---- <style type="test/null"> <!-- --> </style> ---- output ------ <style type="test/null"> <!-- --> </style> ---- expected-ws ------ <style_type="test/null">\n ____<!--\n ____-->\n </style> ---- output-ws ------ <style_type="test/null">\n ____<!--\n ____\n ____===|__\n ____\n ____-->\n </style> ================================================================ ==== Tests for script and style Commented and cdata wapping (#1641) ============================================================ ---- input ------- <div> <script><!-- console.log("</script>" + "</style>"); </script> </div> ---- expected ---- <div> <script><!-- console.log("</script>" + "</style>"); </script> </div> ---- output ------ <div> <script> <!-- console.log("</script>" + "</style>"); < /script> < /div> ---- expected-ws ------ <div>\n ____<script><!--\n console.log("</script>"_+_"</style>");\n _</script>\n </div> ---- output-ws ------ <div>\n ____<script>\n ________<!--\n ________console.log("</script>"_+_"</style>");_<\n ________/script>_<\n ________/div> ================================================================ ==== Tests for script and style Commented and cdata wapping (#1641) ============================================================ ---- input ------- <style><!-- .selector { font-family: "</script></style>"; } --></style> ---- expected ---- <style> <!-- .selector { font-family: "</script></style>"; } --> </style> ---- output ------ <style> < !-- .selector { font-family: "</script></style>"; } --> </style> ---- expected-ws ------ <style>\n ____<!--\n ____.selector_{\n ________font-family:_"</script></style>";\n ____}\n ____-->\n </style> ---- output-ws ------ <style>\n ____<_!--_.selector_{\n ________font-family:_"</script></style>";\n ____}\n \n ____-->\n </style> ================================================================ ==== Tests for script and style Commented and cdata wapping (#1641) ============================================================ ---- input ------- <script type="test/null"> <!-- console.log("</script>" + "</style>"); console.log("</script>" + "</style>"); --></script> ---- expected ---- <script type="test/null"> <!-- console.log("</script>" + "</style>"); console.log("</script>" + "</style>"); --> </script> ---- output ------ <script type="test/null"> <!-- console.log("</script>" + "</style>"); console.log("</script>" + "</style>"); --> </script> ---- expected-ws ------ <script_type="test/null">\n ____<!--\n ____console.log("</script>"_+_"</style>");\n _____console.log("</script>"_+_"</style>");\n ____-->\n </script> ---- output-ws ------ <script_type="test/null">\n ____<!--\n _______console.log("</script>"_+_"</style>");\n ____console.log("</script>"_+_"</style>");\n ____-->\n </script> ================================================================ ==== Tests for script and style Commented and cdata wapping (#1641) ============================================================ ---- input ------- <script type="test/null"><!-- console.log("</script>" + "</style>"); console.log("</script>" + "</style>"); --></script> ---- expected ---- <script type="test/null"> <!-- console.log("</script>" + "</style>"); console.log("</script>" + "</style>"); --> </script> ---- output ------ <script type="test/null"> <!-- console.log("</script>" + "</style>"); console.log("</script>" + "</style>"); --> </script> ---- expected-ws ------ <script_type="test/null">\n ____<!--\n ____console.log("</script>"_+_"</style>");\n _________console.log("</script>"_+_"</style>");\n ____-->\n </script> ---- output-ws ------ <script_type="test/null">\n ____<!--\n _____console.log("</script>"_+_"</style>");\n __________console.log("</script>"_+_"</style>");\n ____-->\n </script> ================================================================ ==== Tests for script and style Commented and cdata wapping (#1641) ============================================================ ---- input ------- <script><![CDATA[ console.log("</script>" + "</style>"); ]]></script> ---- expected ---- <script> <![CDATA[ console.log("</script>" + "</style>"); ]]> </script> ---- output ------ <script> < ![CDATA[ console.log("</script>" + "</style>"); ]] > </script> ---- expected-ws ------ <script>\n ____<![CDATA[\n ____console.log("</script>"_+_"</style>");\n ____]]>\n </script> ---- output-ws ------ <script>\n ____<_![CDATA[\n ________console.log("</script>"_+_"</style>");\n ____]]_>\n </script> ================================================================ ==== Tests for script and style Commented and cdata wapping (#1641) ============================================================ ---- input ------- <style><![CDATA[ .selector { font-family: "</script></style>"; } ]]></style> ---- expected ---- <style> <![CDATA[ .selector { font-family: "</script></style>"; } ]]> </style> ---- output ------ <style> < ![CDATA[ .selector { font-family: "</script></style>"; } ]]> </style> ---- expected-ws ------ <style>\n ____<![CDATA[\n ____.selector_{\n ________font-family:_"</script></style>";\n ____}\n ____]]>\n </style> ---- output-ws ------ <style>\n ____<_![CDATA[_.selector_{\n ________font-family:_"</script></style>";\n ____}\n \n ____]]>\n </style> ================================================================ ==== Tests for script and style Commented and cdata wapping (#1641) ============================================================ ---- input ------- <script type="test/null"> <![CDATA[ console.log("</script>" + "</style>"); console.log("</script>" + "</style>"); ]]></script> ---- expected ---- <script type="test/null"> <![CDATA[ console.log("</script>" + "</style>"); console.log("</script>" + "</style>"); ]]> </script> ---- output ------ <script type="test/null"> <![CDATA[ console.log("</script>" + "</style>"); console.log("</script>" + "</style>"); ]]> </script> ---- expected-ws ------ <script_type="test/null">\n ____<![CDATA[\n ____console.log("</script>"_+_"</style>");\n _____console.log("</script>"_+_"</style>");\n ____]]>\n </script> ---- output-ws ------ <script_type="test/null">\n ____<![CDATA[\n _______console.log("</script>"_+_"</style>");\n ____console.log("</script>"_+_"</style>");\n ____]]>\n </script> ================================================================ ==== Tests for script and style Commented and cdata wapping (#1641) ============================================================ ---- input ------- <script type="test/null"><![CDATA[ console.log("</script>" + "</style>"); console.log("</script>" + "</style>"); ]]></script> ---- expected ---- <script type="test/null"> <![CDATA[ console.log("</script>" + "</style>"); console.log("</script>" + "</style>"); ]]> </script> ---- output ------ <script type="test/null"> <![CDATA[ console.log("</script>" + "</style>"); console.log("</script>" + "</style>"); ]]> </script> ---- expected-ws ------ <script_type="test/null">\n ____<![CDATA[\n ____console.log("</script>"_+_"</style>");\n _________console.log("</script>"_+_"</style>");\n ____]]>\n </script> ---- output-ws ------ <script_type="test/null">\n ____<![CDATA[\n _____console.log("</script>"_+_"</style>");\n __________console.log("</script>"_+_"</style>");\n ____]]>\n </script> ================================================================ ==== unformatted_content_delimiter ^^ ============================================================ ---- input ------- <span>0 0001 0002 0003 0004 0005 0006 0007 0008 ^^09 0010 0011 0012 0013 0014 0015 ^^16 0017 0018 0019 0020</span> ---- expected ---- <span>0 0001 0002 0003 0004 0005 0006 0007 0008 ^^09 0010 0011 0012 0013 0014 0015 ^^16 0017 0018 0019 0020</span> ---- output ------ <span>0 0001 0002 0003 0004 0005 0006 0007 0008 ^^09 0010 0011 0012 0013 0014 0015 ^^16 0017 0018 0019 0020</span> ---- expected-ws ------ <span>0_0001_0002_0003_0004_0005_0006_0007_0008\n ____^^09_0010_0011_0012_0013_0014_0015_^^16_0017_0018_0019_0020</span> ---- output-ws ------ <span>0_0001_0002_0003_0004_0005_0006_0007_0008_^^09_0010_0011_0012_0013_0014\n ____0015_^^16_0017_0018_0019_0020</span> ================================================================ ==== unformatted_content_delimiter ^^ ============================================================ ---- input ------- <span>0 0001 0002 0003 0004 0005 0006 0007 0008 0009 ^^10 0011 0012 0013 0014 0015 0016 0^^7 0018 0019 0020</span> ---- expected ---- <span>0 0001 0002 0003 0004 0005 0006 0007 0008 0009 ^^10 0011 0012 0013 0014 0015 0016 0^^7 0018 0019 0020</span> ---- output ------ <span>0 0001 0002 0003 0004 0005 0006 0007 0008 0009 ^^10 0011 0012 0013 0014 0015 0016 0^^7 0018 0019 0020</span> ---- expected-ws ------ <span>0_0001_0002_0003_0004_0005_0006_0007_0008_0009\n ____^^10___0011___0012___0013___0014___0015___0016___0^^7_0018_0019_0020</span> ---- output-ws ------ <span>0_0001_0002_0003_0004_0005_0006_0007_0008_0009_^^10_0011_0012_0013_0014\n ____0015_0016_0^^7_0018_0019_0020</span> ================================================================ 17 tests failed.
Updated version: https://github.com/Infocatcher/AkelPad_scripts/blob/jsBeautifier_new/jsBeautifier.js Changes: https://github.com/Infocatcher/AkelPad_scripts/commits/jsBeautifier_newMerged with master branch: 532e193acb70db41c8e88cac090c5d76ea84ce15Tests: