1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-12-25 01:20:30 +00:00

Added ability for TW2 cooking to strip //# comments from JavaScript source

This commit is contained in:
Jeremy Ruston 2012-07-12 17:37:10 +01:00
parent 05d9cb60fc
commit 84a1337792
2 changed files with 34 additions and 8 deletions

View File

@ -0,0 +1,27 @@
/*\
title: $:/plugins/stripcomments.js
type: application/javascript
module-type: tiddlerserializer
Special serializer for cooking old versions of TiddlyWiki. It removes JavaScript comments formatted as `//#`
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
exports["text/plain-strip-comments"] = function(tiddler) {
var lines =tiddler.fields.text.split("\n"),
out = [];
for(var line=0; line<lines.length; line++) {
var text = lines[line];
if(!/^\s*\/\/#/.test(text)) {
out.push(text);
}
}
return out.join("\n");
};
})();

View File

@ -60,26 +60,25 @@ Welcome to TiddlyWiki created by Jeremy Ruston; Copyright &copy; 2004-2007 Jerem
<!--POST-BODY-END-->
<script id="jsArea" type="text/javascript">
//<![CDATA[
<<include "[prefix[{prejs}]]" text/plain>>
<<include "[prefix[{js}]]" text/plain>>
<<include "[prefix[{postjs}]]" text/plain>>
<<include "[prefix[{prejs}]]" text/plain-strip-comments>>
<<include "[prefix[{js}]]" text/plain-strip-comments>>
<<include "[prefix[{postjs}]]" text/plain-strip-comments>>
//]]>
</script>
<<include "[prefix[{jsext}]]" text/plain>>
<<include "[prefix[{jsext}]]" text/plain-strip-comments>>
<script id="jsdeprecatedArea" type="text/javascript">
//<![CDATA[
<<include "[prefix[{jsdeprecated}]]" text/plain>>
<<include "[prefix[{jsdeprecated}]]" text/plain-strip-comments>>
//]]>
</script>
<script id="jslibArea" type="text/javascript">
//<![CDATA[
<<include "[prefix[{jslib}]]" text/plain>>
<<include "[prefix[{jslib}]]" text/plain-strip-comments>>
//]]>
</script>
<script id="jqueryArea" type="text/javascript">
//<![CDATA[
<<include "[prefix[{jquery}]]" text/plain>>
<<include "[prefix[{jquery}]]" text/plain-strip-comments>>
//]]>
</script>
<script type="text/javascript">