It looks like you're new here. If you want to get involved, click one of these buttons!
macros.add("hublinks", { version: {major: 1, minor: 0, revision: 0 }, handler: function (place, macroName, params, parser) { if (this.args.length < 1) { return "Enter the hub variable"; } var tab = document.createElement("table"); tab.id = "hubtable"; var row = tab.insertRow(0); var cell1 = row.insertCell(0); var cell2 = row.insertCell(1); cell1.innerHTML = "Wikifier who now?"; cell2.innerHTML = "I'd appreciate a link in here."; this.output.appendChild(tab); } });
Comments
Had to change the macros.add("macroname", { to macros.macroname = {, though I don't know why Wikifier works with one and not the other. Deprecated syntax?
Then had to make sure I was using outerHTML to get the properly formatted table
Also, I am a bit puzzled as to why you felt the need to use a macro for this—more on that at the bottom.
The Wikifier works with either, you simply were not using it within your first example.
And, yes, one of those syntaxes is deprecated—its macros.macroname. See the SugarCube v1's Macros API documentation.
Because innerHTML yields the contents of the element, not the element itself—which is why outerHTML exists. Beyond that, creating the element nodes and then converting them to HTML markup to feed into the Wikifier is… less than optimal.
You wanted something like the following: TIP: If you're simply appending rows and cells, you may use -1 as the index.
I am a bit puzzled as to why you felt the need to use a macro for this when simply using <table> markup, wrapped within a widget for reuse if necessary, would work just as well. For example, the equivalent <table> markup: As a <<hublinks>> widget: (goes in a separate widget-tagged passage)