mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-23 10:07:19 +00:00
First pass at global disabling of parser rules
This is to address #1875 more quickly than via #345. This commit only includes a partial implementation of the UI - see the ticket for details.
This commit is contained in:
parent
9e1741a549
commit
d5e690a06d
30
core/modules/filters/wikiparserrules.js
Normal file
30
core/modules/filters/wikiparserrules.js
Normal file
@ -0,0 +1,30 @@
|
||||
/*\
|
||||
title: $:/core/modules/filters/wikiparserrules.js
|
||||
type: application/javascript
|
||||
module-type: filteroperator
|
||||
|
||||
Filter operator for returning the names of the wiki parser rules in this wiki
|
||||
|
||||
\*/
|
||||
(function(){
|
||||
|
||||
/*jslint node: true, browser: true */
|
||||
/*global $tw: false */
|
||||
"use strict";
|
||||
|
||||
/*
|
||||
Export our filter function
|
||||
*/
|
||||
exports.wikiparserrules = function(source,operator,options) {
|
||||
var results = [];
|
||||
$tw.utils.each($tw.modules.types.wikirule,function(mod) {
|
||||
var exp = mod.exports;
|
||||
if(exp.types[operator.operand]) {
|
||||
results.push(exp.name);
|
||||
}
|
||||
});
|
||||
results.sort();
|
||||
return results;
|
||||
};
|
||||
|
||||
})();
|
@ -29,12 +29,15 @@ var WikiParser = function(type,text,options) {
|
||||
// Initialise the classes if we don't have them already
|
||||
if(!this.pragmaRuleClasses) {
|
||||
WikiParser.prototype.pragmaRuleClasses = $tw.modules.createClassesFromModules("wikirule","pragma",$tw.WikiRuleBase);
|
||||
this.setupRules(WikiParser.prototype.pragmaRuleClasses,"$:/config/WikiParserRules/Pragmas/");
|
||||
}
|
||||
if(!this.blockRuleClasses) {
|
||||
WikiParser.prototype.blockRuleClasses = $tw.modules.createClassesFromModules("wikirule","block",$tw.WikiRuleBase);
|
||||
this.setupRules(WikiParser.prototype.blockRuleClasses,"$:/config/WikiParserRules/Block/");
|
||||
}
|
||||
if(!this.inlineRuleClasses) {
|
||||
WikiParser.prototype.inlineRuleClasses = $tw.modules.createClassesFromModules("wikirule","inline",$tw.WikiRuleBase);
|
||||
this.setupRules(WikiParser.prototype.inlineRuleClasses,"$:/config/WikiParserRules/Inline/");
|
||||
}
|
||||
// Save the parse text
|
||||
this.type = type || "text/vnd.tiddlywiki";
|
||||
@ -59,6 +62,18 @@ var WikiParser = function(type,text,options) {
|
||||
// Return the parse tree
|
||||
};
|
||||
|
||||
/*
|
||||
*/
|
||||
WikiParser.prototype.setupRules = function(proto,configPrefix) {
|
||||
var self = this;
|
||||
$tw.utils.each(proto,function(object,name) {
|
||||
if(self.wiki.getTiddlerText(configPrefix + name,"enable") !== "enable") {
|
||||
delete proto[name];
|
||||
console.log("deleting",name)
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/*
|
||||
Instantiate an array of parse rules
|
||||
*/
|
||||
|
29
core/ui/ControlPanel/Parsing.tid
Normal file
29
core/ui/ControlPanel/Parsing.tid
Normal file
@ -0,0 +1,29 @@
|
||||
title: $:/core/ui/ControlPanel/Parsing
|
||||
tags: $:/tags/ControlPanel
|
||||
caption: Parsing
|
||||
|
||||
\define parsing-inner(typeCap)
|
||||
<li>
|
||||
<$checkbox tiddler="""$:/config/WikiParserRules/$typeCap$/$(currentTiddler)$""" field="text" checked="enable" unchecked="disable" default="enable"> ''<$text text=<<currentTiddler>>/>'': </$checkbox>
|
||||
</li>
|
||||
\end
|
||||
|
||||
\define parsing-outer(typeLower,typeCap)
|
||||
<ul>
|
||||
<$list filter="[wikiparserrules[$typeLower$]]">
|
||||
<<parsing-inner typeCap:"$typeCap$">>
|
||||
</$list>
|
||||
</ul>
|
||||
\end
|
||||
|
||||
! Pragma Parse Rules
|
||||
|
||||
<<parsing-outer typeLower:"pragma" typeCap:"Pragma">>
|
||||
|
||||
! Inline Parse Rules
|
||||
|
||||
<<parsing-outer typeLower:"inline" typeCap:"Inline">>
|
||||
|
||||
! Block Parse Rules
|
||||
|
||||
<<parsing-outer typeLower:"block" typeCap:"Block">>
|
3
core/wiki/config/wikilink.tid
Normal file
3
core/wiki/config/wikilink.tid
Normal file
@ -0,0 +1,3 @@
|
||||
title: $:/config/WikiParserRules/Inline/wikilink
|
||||
|
||||
enable
|
Loading…
Reference in New Issue
Block a user