diff --git a/core/modules/widgets/blockmark.js b/core/modules/widgets/blockmark.js index 833e5227c..75b08d3a0 100644 --- a/core/modules/widgets/blockmark.js +++ b/core/modules/widgets/blockmark.js @@ -3,7 +3,7 @@ title: $:/core/modules/widgets/block-mark.js type: application/javascript module-type: widget -An invisible element with block mark id metadata. Marking a block level element, so that it can be jumped to. +An invisible element with block mark id metadata. Marking a block level element, so that it can be jumped to or transcluded. \*/ var Widget = require("$:/core/modules/widgets/widget.js").widget; var BlockMarkWidget = function(parseTreeNode,options) { @@ -21,9 +21,13 @@ BlockMarkWidget.prototype.render = function(parent,nextSibling) { // Create an invisible DOM element with data that can be accessed from JS or CSS this.idNode = this.document.createElement("span"); this.idNode.setAttribute("data-block-mark-id",this.blockMarkId); - this.idNode.setAttribute("data-block-mark-title",this.tiddlerTitle); - // id for anchor jumping in static site - this.idNode.setAttribute("id",this.tiddlerTitle + "-" + this.blockMarkId); + if(this.tiddlerTitle) { + this.idNode.setAttribute("data-block-mark-title",this.tiddlerTitle); + // id for anchor jumping in static site + this.idNode.setAttribute("id",this.tiddlerTitle + "-" + this.blockMarkId); + } else { + this.idNode.setAttribute("id",this.blockMarkId); + } // if the actual block is before this node, we need to add a flag to the node if(this.previousSibling) { this.idNode.setAttribute("data-block-mark-previous-sibling","true"); @@ -39,7 +43,7 @@ Compute the internal state of the widget BlockMarkWidget.prototype.execute = function() { // Get the id from the parse tree node or manually assigned attributes this.blockMarkId = this.getAttribute("id"); - this.tiddlerTitle = this.getVariable("currentTiddler"); + this.tiddlerTitle = this.getVariable("currentTiddler", ""); this.previousSibling = this.getAttribute("previousSibling") === "yes"; // Make the child widgets this.makeChildWidgets();