Major updates to text-slicer plugin

* In the interests of performance and expressiveness, switched to using a Sax parser instead of a DOM implementation.
* Use extensible declarative rules to control the slicing process
* Added new optional set of rules for slicing by heading, where the paragraphs underneath a heading are packed into the same tiddler as the heading
* Added a modal dialogue for specifying parameters when slicing in the browser
This commit is contained in:
Jermolene
2017-12-14 14:16:54 +00:00
parent f128650c6e
commit e344c38349
39 changed files with 2943 additions and 713 deletions

View File

@@ -4,5 +4,18 @@ description: Slice a hierarchical document into individual tiddlers
Slices the specified tiddler
```
--slice <title>
--slice <source-title> [<dest-title>] [<slicer-rules>] [<output-mode>]
```
* ''source-title'': Title of the tiddler to be sliced
* ''dest-title'': Base title for the generated output tiddlers
* ''slicer-rules'': Name of the slicer rules to use for the operation (see below)
* ''output-mode'': "html" vs "wiki"
The plugin comes with several built-in sets of slicer rules:
* //html-by-paragraph//: Slice every paragraph into a separate tiddler, threaded by heading
* //html-by-heading//: Slice every heading into separate threaded tiddlers
* //html-plain-paragraphs//: Slice every paragraph into a separate tiddler, without formatting or headings
Advanced users can create or edit their own slicer rules for precise control over the conversion process

View File

@@ -34,13 +34,22 @@ Command.prototype.execute = function() {
wiki = this.commander.wiki,
sourceTitle = this.params[0],
destTitle = this.params[1],
slicerRules = this.params[2],
outputMode = this.params[3],
slicer = new textSlicer.Slicer({
sourceTiddlerTitle: sourceTitle,
baseTiddlerTitle: destTitle,
wiki: wiki
slicerRules: slicerRules,
outputMode: outputMode,
wiki: wiki,
callback: function(err,tiddlers) {
if(err) {
return self.callback(err);
}
wiki.addTiddlers(tiddlers);
self.callback();
}
});
wiki.addTiddlers(slicer.getTiddlers());
$tw.utils.nextTick(this.callback);
return null;
};