kopia lustrzana https://github.com/miklobit/TiddlyWiki5
Add better control over whether tiddlers are transcluded in block or inline mode
rodzic
f67e216b3a
commit
ecad2bf7a8
|
@ -41,6 +41,7 @@ TranscludeWidget.prototype.execute = function() {
|
|||
this.transcludeTitle = this.getAttribute("tiddler",this.getVariable("currentTiddler"));
|
||||
this.transcludeField = this.getAttribute("field");
|
||||
this.transcludeIndex = this.getAttribute("index");
|
||||
this.transcludeMode = this.getAttribute("mode");
|
||||
// Check for recursion
|
||||
var recursionMarker = this.makeRecursionMarker();;
|
||||
if(this.parentWidget && this.parentWidget.hasVariable("transclusion",recursionMarker)) {
|
||||
|
@ -50,11 +51,17 @@ TranscludeWidget.prototype.execute = function() {
|
|||
// Set context variables for recursion detection
|
||||
this.setVariable("transclusion",recursionMarker);
|
||||
// Parse the text reference
|
||||
var parseAsInline = !this.parseTreeNode.isBlock;
|
||||
if(this.transcludeMode === "inline") {
|
||||
parseAsInline = true;
|
||||
} else if(this.transcludeMode === "block") {
|
||||
parseAsInline = false;
|
||||
}
|
||||
var parser = this.wiki.parseTextReference(
|
||||
this.transcludeTitle,
|
||||
this.transcludeField,
|
||||
this.transcludeIndex,
|
||||
{parseAsInline: !this.parseTreeNode.isBlock}),
|
||||
{parseAsInline: parseAsInline}),
|
||||
parseTreeNodes = parser ? parser.tree : [];
|
||||
// Construct the child widgets
|
||||
this.makeChildWidgets(parseTreeNodes);
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
created: 201308241425
|
||||
modified: 201310301349
|
||||
created: 20130824142500000
|
||||
modified: 20140212175900970
|
||||
tags: widget
|
||||
title: TranscludeWidget
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
! Introduction
|
||||
|
||||
|
@ -16,6 +17,44 @@ The TranscludeWidget dynamically imports content from another tiddler.
|
|||
|class |CSS classes to added to the generated elements |
|
||||
|style |CSS styles to be added to the generated elements |
|
||||
|tooltip |Tooltip to be added to the generated elements |
|
||||
|mode |Override the default parsing mode for the transcluded text to "block" or "inline" |
|
||||
|
||||
The TranscludeWidget ignores any contained content.
|
||||
|
||||
! Parsing modes
|
||||
|
||||
TiddlyWiki parses text in two modes:
|
||||
|
||||
* ''inline'' mode recognises character formatting such as emphasis, links
|
||||
* ''block'' mode recognises all the ''inline'' formatting, and adds block formatting such as tables, headings and lists
|
||||
|
||||
Usually, the mode is determined by whether the transclude widget itself has been parsed in block or inline mode. This can be overridden with the `mode` attribute.
|
||||
|
||||
For example, consider tiddler "A" with this content:
|
||||
|
||||
```
|
||||
# Item one
|
||||
#<$transclude tiddler="B"/>
|
||||
# Item two
|
||||
```
|
||||
|
||||
And a tiddler "B" with this content:
|
||||
|
||||
```
|
||||
# Item one - a
|
||||
# Item one - b
|
||||
```
|
||||
|
||||
The result will be something like this:
|
||||
|
||||
# Item one
|
||||
# # Item one - a # Item one - b
|
||||
# Item two
|
||||
|
||||
This can be fixed by amending tiddler "A":
|
||||
|
||||
```
|
||||
# Item one
|
||||
#<$transclude tiddler="B" mode="block"/>
|
||||
# Item two
|
||||
```
|
||||
|
|
File diff suppressed because one or more lines are too long
Ładowanie…
Reference in New Issue