diff --git a/core/modules/widgets/blockmark.js b/core/modules/widgets/blockmark.js index 962e944f8..833e5227c 100644 --- a/core/modules/widgets/blockmark.js +++ b/core/modules/widgets/blockmark.js @@ -3,12 +3,11 @@ title: $:/core/modules/widgets/block-mark.js type: application/javascript module-type: widget -An invisible element with block-mark id metadata. +An invisible element with block mark id metadata. Marking a block level element, so that it can be jumped to. \*/ var Widget = require("$:/core/modules/widgets/widget.js").widget; var BlockMarkWidget = function(parseTreeNode,options) { this.initialise(parseTreeNode,options); - // only this widget knows target info (if the block is before this node or not), so we need to hook the focus event, and process it here, instead of in the root widget. }; BlockMarkWidget.prototype = new Widget(); @@ -23,6 +22,8 @@ BlockMarkWidget.prototype.render = function(parent,nextSibling) { 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 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"); diff --git a/core/modules/widgets/link.js b/core/modules/widgets/link.js index ee1f31d81..79a2811e5 100755 --- a/core/modules/widgets/link.js +++ b/core/modules/widgets/link.js @@ -92,6 +92,7 @@ LinkWidget.prototype.renderLink = function(parent,nextSibling) { } // Set an href var wikilinkTransformFilter = this.getVariable("tv-filter-export-link"), + to = this.toBlockMark ? this.to + "-" + this.toBlockMark : this.to, wikiLinkText; if(wikilinkTransformFilter) { // Use the filter to construct the href @@ -102,8 +103,8 @@ LinkWidget.prototype.renderLink = function(parent,nextSibling) { // Expand the tv-wikilink-template variable to construct the href var wikiLinkTemplateMacro = this.getVariable("tv-wikilink-template"), wikiLinkTemplate = wikiLinkTemplateMacro ? wikiLinkTemplateMacro.trim() : "#$uri_encoded$"; - wikiLinkText = $tw.utils.replaceString(wikiLinkTemplate,"$uri_encoded$",$tw.utils.encodeURIComponentExtended(this.to)); - wikiLinkText = $tw.utils.replaceString(wikiLinkText,"$uri_doubleencoded$",$tw.utils.encodeURIComponentExtended($tw.utils.encodeURIComponentExtended(this.to))); + wikiLinkText = $tw.utils.replaceString(wikiLinkTemplate,"$uri_encoded$",$tw.utils.encodeURIComponentExtended(to)); + wikiLinkText = $tw.utils.replaceString(wikiLinkText,"$uri_doubleencoded$",$tw.utils.encodeURIComponentExtended($tw.utils.encodeURIComponentExtended(to))); } // Override with the value of tv-get-export-link if defined wikiLinkText = this.getVariable("tv-get-export-link",{params: [{name: "to",value: this.to}],defaultValue: wikiLinkText});