From d13de81c7ac916b0ae57ee0841377713ff43705f Mon Sep 17 00:00:00 2001 From: buggyj Date: Tue, 17 Jun 2014 18:56:31 +0200 Subject: [PATCH 01/11] checkin of updates to latest version of widget tree format, includes tiddler, slider and tabs macros --- .../tiddlywiki/tw2parser/classictransclude.js | 184 ++++++++++++ plugins/tiddlywiki/tw2parser/entry.js | 30 ++ plugins/tiddlywiki/tw2parser/macrodefs.tid | 34 +++ .../tiddlywiki/tw2parser/parameteradapter.js | 97 +++++++ plugins/tiddlywiki/tw2parser/plugin.info | 8 + .../tiddlywiki/tw2parser/wikitextparser.js | 35 ++- plugins/tiddlywiki/tw2parser/wikitextrules.js | 262 ++++++++++++------ 7 files changed, 550 insertions(+), 100 deletions(-) create mode 100644 plugins/tiddlywiki/tw2parser/classictransclude.js create mode 100644 plugins/tiddlywiki/tw2parser/entry.js create mode 100644 plugins/tiddlywiki/tw2parser/macrodefs.tid create mode 100644 plugins/tiddlywiki/tw2parser/parameteradapter.js create mode 100644 plugins/tiddlywiki/tw2parser/plugin.info diff --git a/plugins/tiddlywiki/tw2parser/classictransclude.js b/plugins/tiddlywiki/tw2parser/classictransclude.js new file mode 100644 index 000000000..7c9fa5016 --- /dev/null +++ b/plugins/tiddlywiki/tw2parser/classictransclude.js @@ -0,0 +1,184 @@ +/*\ +title: $:/core/modules/widgets/classictransclude.js +type: application/javascript +module-type: widget + +Transclude widget + +\*/ +(function(){ + +/*jslint node: true, browser: true */ +/*global $tw: false */ +"use strict"; +var sliceSeparator = "::"; +var sectionSeparator = "##"; + +function getsectionname(title) { + if(!title) + return ""; + var pos = title.indexOf(sectionSeparator); + if(pos != -1) { + return title.substr(pos + sectionSeparator.length); + } + return ""; +} +function getslicename(title) { + if(!title) + return ""; + var pos = title.indexOf(sliceSeparator); + if(pos != -1) { + return title.substr(pos + sliceSeparator.length); + } + return ""; +}; +function gettiddlername(title) { + if(!title) + return ""; + var pos = title.indexOf(sectionSeparator); + + if(pos != -1) { + return title.substr(0,pos); + } + pos = title.indexOf(sliceSeparator); + if(pos != -1) { + return title.substr(0,pos); + } + return title; +} +var Widget = require("$:/core/modules/widgets/widget.js").widget; + +var TranscludeWidget = function(parseTreeNode,options) { + this.initialise(parseTreeNode,options); +}; + +/* +Inherit from the base widget class +*/ +TranscludeWidget.prototype = new Widget(); + +/* +Render this widget into the DOM +*/ +TranscludeWidget.prototype.render = function(parent,nextSibling) { + this.parentDomNode = parent; + this.computeAttributes(); + this.execute(); + this.renderChildren(parent,nextSibling); +}; + +/* +Compute the internal state of the widget +*/ +TranscludeWidget.prototype.execute = function() { + // Get our parameters + this.rawTitle = this.getAttribute("tiddler",this.getVariable("currentTiddler")); + this.transcludeTitle = gettiddlername(this.rawTitle); + this.section = getsectionname(this.rawTitle); + this.slice = getslicename(this.rawTitle); + // Check for recursion + var recursionMarker = this.makeRecursionMarker(); + if(this.parentWidget && this.parentWidget.hasVariable("transclusion",recursionMarker)) { + this.makeChildWidgets([{type: "text", text: "Recursive transclusion error in transclude widget"}]); + return; + } + // Set context variables for recursion detection + this.setVariable("transclusion",recursionMarker); + // Parse + var text = this.wiki.getTiddlerText(this.transcludeTitle); + if (!!this.section||!!this.slice) { + text =this.refineTiddlerText(text, this.section, this.slice); + } + + this.options ={}; + this.options.parseAsInline = false; + var parser = this.wiki.parseText("text/x-tiddlywiki",text,{}); + var parseTreeNodes = parser ? parser.tree : this.parseTreeNode.children; + // Construct the child widgets + this.makeChildWidgets(parseTreeNodes); +}; +/* +Compose a string comprising the title, field and/or index to identify this transclusion for recursion detection +*/ +TranscludeWidget.prototype.makeRecursionMarker = function() { + var output = []; + output.push("{"); + output.push(this.getVariable("currentTiddler",{defaultValue: ""})); + output.push("|"); + output.push(this.transcludeTitle || ""); + output.push("|"); + output.push(this.transcludeField || ""); + output.push("|"); + output.push(this.transcludeIndex || ""); + output.push("|"); + output.push(this.section || ""); + output.push("|"); + output.push(this.slice || ""); + output.push("}"); + return output.join(""); +}; + +TranscludeWidget.prototype.slicesRE = /(?:^([\'\/]{0,2})~?([\.\w]+)\:\1[\t\x20]*([^\n]*)[\t\x20]*$)|(?:^\|([\'\/]{0,2})~?([\.\w]+)\:?\4\|[\t\x20]*([^\|\n]*)[\t\x20]*\|$)/gm; + +TranscludeWidget.prototype.calcAllSlices = function(text) +{ + var slices = {}; + this.slicesRE.lastIndex = 0; + var m = this.slicesRE.exec(text); + while(m) { + if(m[2]) + slices[m[2]] = m[3]; + else + slices[m[5]] = m[6]; + m = this.slicesRE.exec(text); + } + return slices; +}; + +// Returns the slice of text of the given name +TranscludeWidget.prototype.getTextSlice = function(text,sliceName) +{ + return (this.calcAllSlices(text))[sliceName]; +}; + +TranscludeWidget.prototype.refineTiddlerText = function(text,section,slice) +{ + var textsection = null; + if (slice) { + var textslice = this.getTextSlice(text,slice); + if(textslice) + return textslice; + } + if(!section) + return text; + var re = new RegExp("(^!{1,6}[ \t]*" + $tw.utils.escapeRegExp(section) + "[ \t]*\n)","mg"); + re.lastIndex = 0; + var match = re.exec(text); + if(match) { + var t = text.substr(match.index+match[1].length); + var re2 = /^!/mg; + re2.lastIndex = 0; + match = re2.exec(t); //# search for the next heading + if(match) + t = t.substr(0,match.index-1);//# don't include final \n + return t; + } + return ""; +} + +/* +Selectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering +*/ +TranscludeWidget.prototype.refresh = function(changedTiddlers) { + var changedAttributes = this.computeAttributes(); + if(changedAttributes.tiddler ||changedTiddlers[this.transcludeTitle]) { + this.refreshSelf(); + return true; + } else { + return this.refreshChildren(changedTiddlers); + } +}; + +exports.classictransclude = TranscludeWidget; + +})(); diff --git a/plugins/tiddlywiki/tw2parser/entry.js b/plugins/tiddlywiki/tw2parser/entry.js new file mode 100644 index 000000000..f97cf4cdc --- /dev/null +++ b/plugins/tiddlywiki/tw2parser/entry.js @@ -0,0 +1,30 @@ +/*\ +title: $:/macros/tiddlywiki/entry.js +type: application/javascript +module-type: macro +\*/ +(function(){ +/*jslint node: true, browser: true */ +/*global $tw: false */ +"use strict"; +/* +Information about this macro +returns value of key in a data json tiddler +note that macros are not connected with the refresh mechanism -use with caution. +*/ +exports.name = "entryof"; + +exports.params = [ + { name: "key" }, { name: "map" } +]; +/* +Run the macro +*/ +exports.run = function(key,map) { + try{ + return JSON.parse(map)[key]; + } catch(e) { + return ""; + } +} +})(); diff --git a/plugins/tiddlywiki/tw2parser/macrodefs.tid b/plugins/tiddlywiki/tw2parser/macrodefs.tid new file mode 100644 index 000000000..8edc585d5 --- /dev/null +++ b/plugins/tiddlywiki/tw2parser/macrodefs.tid @@ -0,0 +1,34 @@ +title: $:/plugins/tiddlywiki/tw2parser/macrodefs + +\define tiddler(tiddler) +<$classictransclude tiddler = "$tiddler$"/> +\end + +\define slider(chkUniqueCookieName tiddler label tooltip) +<$button popup="$chkUniqueCookieName$" class="btn-invisible tw-slider">$label$ +<$reveal type="nomatch" text="" default="" state="$chkUniqueCookieName$" animate="yes"> +<$classictransclude tiddler = "$tiddler$"/> + +\end + +\define __system_tabinstance(state, currentTab, prompts, labels) + > ><$button set=<> setTo="$currentTab$" selectedClass="tw-tab-selected"> + <> + +\end + +\define __system_tabs(tabsList,prompts,labels,state:"$:/state/tab") +
+ <$list filter="$tabsList$" variable="currentTab"> + <$macrocall $name="__system_tabinstance" state="$state$" prompts='$prompts$' labels='$labels$'currentTab=<>/> + +
+
+
+ <$list filter="$tabsList$" variable="currentTab"> + <$reveal type="match" state=<> text=<> default="$default$"> + <$classictransclude tiddler=<> /> + + +
+\end diff --git a/plugins/tiddlywiki/tw2parser/parameteradapter.js b/plugins/tiddlywiki/tw2parser/parameteradapter.js new file mode 100644 index 000000000..2f0eb335d --- /dev/null +++ b/plugins/tiddlywiki/tw2parser/parameteradapter.js @@ -0,0 +1,97 @@ +/*\ +title: $:/macros/classic/macroadapter.js +type: application/javascript +module-type: module +\*/ +(function(){ + +/*jslint node: true, browser: true */ +/*global $tw: false */ +"use strict"; +/* +Information about this module: +rename macros and +re-jig macro params from tw2 to tw5 style +new macros created as a result of adapting tw2 should be +prepended "__system" to distinguish them from the actual used name +*/ +var sliceSeparator = "::"; +var sectionSeparator = "##"; + +function getsectionname(title) { + if(!title) + return ""; + var pos = title.indexOf(sectionSeparator); + if(pos != -1) { + return title.substr(pos + sectionSeparator.length); + } + return ""; +} +function getslicename(title) { + if(!title) + return ""; + var pos = title.indexOf(sliceSeparator); + if(pos != -1) { + return title.substr(pos + sliceSeparator.length); + } + return ""; +}; +function gettiddlername(title) { + if(!title) + return ""; + var pos = title.indexOf(sectionSeparator); + + if(pos != -1) { + return title.substr(0,pos); + } + pos = title.indexOf(sliceSeparator); + if(pos != -1) { + return title.substr(0,pos); + } + return title; +} + +var parserparams = function(paramString) { + var params = [], + reParam = /\s*(?:([A-Za-z0-9\-_]+)\s*:)?(?:\s*(?:"([^"]*)"|'([^']*)'|\[\[([^\]]*)\]\]|([^"'\s]+)))/mg, + paramMatch = reParam.exec(paramString); + while(paramMatch) { + // Process this parameter + var paramInfo = { + value: paramMatch[2] || paramMatch[3] || paramMatch[4] || paramMatch[5] + }; + if(paramMatch[1]) { + paramInfo.name = paramMatch[1]; + } + params.push(paramInfo); + // Find the next match + paramMatch = reParam.exec(paramString); + } + return params; +} +var tabshandler = function(paramstring) { + var params = parserparams(paramstring); + var cookie = params[0].value; + var numTabs = (params.length-1)/3; + var t; + var tabslist = ""; + var labelarray = {}; + var promptarray = {}; + for(t=0; t label and name -> prompt + //Use json to implement maps + return "'"+tabslist +"' '"+JSON.stringify(promptarray)+"' '"+JSON.stringify(labelarray)+"' '"+cookie+"'"; +}; +var namedapter = {tabs:'__system_tabs'}; +var paramadapter = { + tabs: tabshandler +} +exports.name = 'macroadapter'; +exports.namedapter = namedapter; +exports.paramadapter = paramadapter; +})(); diff --git a/plugins/tiddlywiki/tw2parser/plugin.info b/plugins/tiddlywiki/tw2parser/plugin.info new file mode 100644 index 000000000..27f2f29ed --- /dev/null +++ b/plugins/tiddlywiki/tw2parser/plugin.info @@ -0,0 +1,8 @@ +{ + "title": "$:/plugins/bj/tw2parser", + "description": "legacy parser", + "author": "JeremyRuston, JeffreyWilkinson", + "version": "0.0.2-alpha-tw2parser", + "core-version": ">=5.0.0", + "plugin-type": "plugin" +} diff --git a/plugins/tiddlywiki/tw2parser/wikitextparser.js b/plugins/tiddlywiki/tw2parser/wikitextparser.js index a78c22717..96393eb95 100644 --- a/plugins/tiddlywiki/tw2parser/wikitextparser.js +++ b/plugins/tiddlywiki/tw2parser/wikitextparser.js @@ -48,11 +48,29 @@ Planned: extraMacros: An array of additional macro handlers to add */ -var WikiTextParser = function(options) { +var WikiTextParser = function(type,text,options) { this.wiki = options.wiki; this.autoLinkWikiWords = true; + this.installRules(); + text = text || "no text"; + this.source = text; + this.nextMatch = 0; + this.children = []; + //this.children.push({type: "text",text:"hello to the queen"}); + this.tree =[]; + this.output = null; + this.subWikify(this.children); + var parser = $tw.wiki.old_parseTiddler("$:/plugins/tiddlywiki/tw2parser/macrodefs",{parseAsInline:false}); + this.tree = [{ + type: "element", + tag: "div", + children:this.children + }]; + Array.prototype.push.apply(parser.tree,this.tree); + this.tree = parser.tree; }; + WikiTextParser.prototype.installRules = function() { var rules = require("./wikitextrules.js").rules, pattern = []; @@ -63,23 +81,10 @@ WikiTextParser.prototype.installRules = function() { this.rulesRegExp = new RegExp(pattern.join("|"),"mg"); }; -WikiTextParser.prototype.parse = function(type,text) { - text = text || ""; - this.source = text; - this.nextMatch = 0; - this.children = []; - this.dependencies = new $tw.Dependencies(); - this.output = null; - this.subWikify(this.children); - var tree = new $tw.Renderer(this.children,this.dependencies); - this.source = null; - this.children = null; - return tree; -}; WikiTextParser.prototype.outputText = function(place,startPos,endPos) { if(startPos < endPos) { - place.push($tw.Tree.Text(this.source.substring(startPos,endPos))); + place.push({type: "text",text:this.source.substring(startPos,endPos)}); } }; diff --git a/plugins/tiddlywiki/tw2parser/wikitextrules.js b/plugins/tiddlywiki/tw2parser/wikitextrules.js index d32c145fa..f9e78c7d5 100755 --- a/plugins/tiddlywiki/tw2parser/wikitextrules.js +++ b/plugins/tiddlywiki/tw2parser/wikitextrules.js @@ -11,7 +11,7 @@ Rule modules for the wikitext parser /*jslint node: true, browser: true */ /*global $tw: false */ "use strict"; - +var macroadapter = require("$:/macros/classic/macroadapter.js"); var textPrimitives = { upperLetter: "[A-Z\u00c0-\u00de\u0150\u0170]", lowerLetter: "[a-z0-9_\\-\u00df-\u00ff\u0151\u0171]", @@ -51,7 +51,7 @@ var setAttr = function(node,attr,value) { if(!node.attributes) { node.attributes = {}; } - node.attributes[attr] = value; + node.attributes[attr] ={type: "string", value:value} ; }; var inlineCssHelper = function(w) { @@ -80,17 +80,14 @@ var inlineCssHelper = function(w) { }; var applyCssHelper = function(e,styles) { + if(styles.length > 0) { - if(!e.attributes) { - e.attributes = {}; - } - if(!e.attributes.style) { - e.attributes.style = {}; - } + for(var t=0; t< styles.length; t++) { - e.attributes.style[styles[t].style] = styles[t].value; + $tw.utils.addStyleToParseTreeNode(e,$tw.utils.roundTripPropertyName(styles[t].style),styles[t].value); } } + }; var enclosedTextHelper = function(w) { @@ -98,23 +95,41 @@ var enclosedTextHelper = function(w) { var lookaheadMatch = this.lookaheadRegExp.exec(w.source); if(lookaheadMatch && lookaheadMatch.index == w.matchStart) { var text = lookaheadMatch[1]; - w.output.push($tw.Tree.Element(this.element,null,[$tw.Tree.Text(text)])); + w.output.push({type:"element",tag:this.element, + children:[{type: "text",text: lookaheadMatch[1]}]}); w.nextMatch = lookaheadMatch.index + lookaheadMatch[0].length; } }; -var insertMacroCall = function(w,output,name,params,content) { - if(name in w.wiki.macros) { - var macroNode = $tw.Tree.Macro(name,{ - srcParams: params, - content: content, - wiki: w.wiki - }); - w.dependencies.mergeDependencies(macroNode.dependencies); - output.push(macroNode); +var insertMacroCall = function(w,output,macroName,paramString) { + var params = [], + reParam = /\s*(?:([A-Za-z0-9\-_]+)\s*:)?(?:\s*(?:"([^"]*)"|'([^']*)'|\[\[([^\]]*)\]\]|([^"'\s]+)))/mg, + paramMatch = reParam.exec(paramString); + while(paramMatch) { + // Process this parameter + var paramInfo = { + value: paramMatch[2] || paramMatch[3] || paramMatch[4] || paramMatch[5] + }; + if(paramMatch[1]) { + paramInfo.name = paramMatch[1]; + } + params.push(paramInfo); + // Find the next match + paramMatch = reParam.exec(paramString); } -}; + output.push({ + type: "macrocall", + name: macroName, + params: params, + isBlock: true + }); +} + +var isLinkExternal = function(to) { + var externalRegExp = /(?:file|http|https|mailto|ftp|irc|news|data|skype):[^\s'"]+(?:\/|\b)/i; + return externalRegExp.test(to); +}; var rules = [ { name: "table", @@ -126,7 +141,9 @@ var rules = [ rowTypes: {"c":"caption", "h":"thead", "":"tbody", "f":"tfoot"}, handler: function(w) { - var table = $tw.Tree.Element("table",{"class": "table"},[]); + var table = {type:"element",tag:"table",attributes: {"class": {type: "string", value:"table"}}, + children: []}; + w.output.push(table); var prevColumns = []; var currRowType = null; @@ -142,7 +159,7 @@ var rules = [ w.nextMatch += lookaheadMatch[0].length+1; } else { if(nextRowType != currRowType) { - rowContainer = $tw.Tree.Element(this.rowTypes[nextRowType],{},[]); + rowContainer = {type:"element",tag:this.rowTypes[nextRowType],children: []}; table.children.push(rowContainer); currRowType = nextRowType; } @@ -154,11 +171,14 @@ var rules = [ table.children.pop(); // Take rowContainer out of the children array table.children.splice(0,0,rowContainer); // Insert it at the bottom } + rowContainer.attributes={}; rowContainer.attributes.align = rowCount === 0 ? "top" : "bottom"; w.subWikifyTerm(rowContainer.children,this.rowTermRegExp); } else { - var theRow = $tw.Tree.Element("tr",{},[]); - theRow.attributes["class"] = rowCount%2 ? "oddRow" : "evenRow"; + var theRow = {type:"element",tag:"tr", + attributes: {"class": {type: "string", value:rowCount%2 ? "oddRow" : "evenRow"}}, + children: []}; + rowContainer.children.push(theRow); this.rowHandler(w,theRow.children,prevColumns); rowCount++; @@ -179,15 +199,16 @@ var rules = [ if(cellMatch[1] == "~") { // Rowspan var last = prevColumns[col]; - if(last) { - last.rowSpanCount++; - last.element.attributes.rowspan = last.rowSpanCount; - last.element.attributes.valign = "center"; - if(colSpanCount > 1) { - last.element.attributes.colspan = colSpanCount; - colSpanCount = 1; - } + if(last) { + last.rowSpanCount++; + $tw.utils.addAttributeToParseTreeNode(last.element,"rowspan",last.rowSpanCount); + var vAlign = $tw.utils.getAttributeValueFromParseTreeNode(last.element,"valign","center"); + $tw.utils.addAttributeToParseTreeNode(last.element,"valign",vAlign); + if(colSpanCount > 1) { + $tw.utils.addAttributeToParseTreeNode(last.element,"colspan",colSpanCount); + colSpanCount = 1; } + } w.nextMatch = this.cellRegExp.lastIndex-1; } else if(cellMatch[1] == ">") { // Colspan @@ -213,25 +234,26 @@ var rules = [ } var cell; if(chr == "!") { - cell = $tw.Tree.Element("th",{},[]); + cell = {type:"element",tag:"th",children: []}; e.push(cell); w.nextMatch++; } else { - cell = $tw.Tree.Element("td",{},[]); + cell = {type:"element",tag:"td",children: []}; e.push(cell); } prevCell = cell; prevColumns[col] = {rowSpanCount:1,element:cell}; if(colSpanCount > 1) { - cell.attributes.colspan = colSpanCount; + $tw.utils.addAttributeToParseTreeNode(cell,"colspan",colSpanCount); colSpanCount = 1; } applyCssHelper(cell,styles); w.subWikifyTerm(cell.children,this.cellTermRegExp); + if (!cell.attributes) cell.attributes ={}; if(w.matchText.substr(w.matchText.length-2,1) == " ") // spaceRight - cell.attributes.align = spaceLeft ? "center" : "left"; + $tw.utils.addAttributeToParseTreeNode(cell,"align",spaceLeft ? "center" : "left"); else if(spaceLeft) - cell.attributes.align = "right"; + $tw.utils.addAttributeToParseTreeNode(cell,"align","right"); w.nextMatch--; } col++; @@ -247,7 +269,7 @@ var rules = [ termRegExp: /(\n)/mg, handler: function(w) { - var e = $tw.Tree.Element("h" + w.matchLength,{},[]); + var e = {type:"element",tag:"h" + w.matchLength,children: []}; w.output.push(e); w.subWikifyTerm(e.children,this.termRegExp); } @@ -291,7 +313,7 @@ var rules = [ if(currLevel !== 0 && target.children) { target = target.children[target.children.length-1]; } - e = $tw.Tree.Element(listType,{},[]); + e = {type:"element",tag:listType,children: []}; target.push(e); stack.push(e.children); } @@ -303,13 +325,13 @@ var rules = [ stack.pop(); } else if(listLevel == currLevel && listType != currType) { stack.pop(); - e = $tw.Tree.Element(listType,{},[]); + e = {type:"element",tag:listType,children: []}; stack[stack.length-1].push(e); stack.push(e.children); } currLevel = listLevel; currType = listType; - e = $tw.Tree.Element(itemType,{},[]); + e = {type:"element",tag:itemType,children: []}; stack[stack.length-1].push(e); w.subWikifyTerm(e.children,this.termRegExp); this.lookaheadRegExp.lastIndex = w.nextMatch; @@ -324,7 +346,7 @@ var rules = [ termRegExp: /(^<<<(\n|$))/mg, element: "blockquote", handler: function(w) { - var e = $tw.Tree.Element(this.element,{},[]); + var e = {type:"element",tag:this.element,children: []}; w.output.push(e); w.subWikifyTerm(e.children,this.termRegExp); } @@ -338,23 +360,32 @@ var rules = [ element: "blockquote", handler: function(w) { - var stack = [w.output]; + var stack = []; var currLevel = 0; var newLevel = w.matchLength; var t,matched,e; do { if(newLevel > currLevel) { for(t=currLevel; tnewLevel; t--) stack.pop(); } currLevel = newLevel; - w.subWikifyTerm(stack[stack.length-1],this.termRegExp); - stack[stack.length-1].push($tw.Tree.Element("br")); + w.subWikifyTerm(stack[stack.length-1].children,this.termRegExp); + stack[stack.length-1].children.push({type:"element",tag:"br"}); + //e.push({type:"element",tag:"br"}); + this.lookaheadRegExp.lastIndex = w.nextMatch; var lookaheadMatch = this.lookaheadRegExp.exec(w.source); matched = lookaheadMatch && lookaheadMatch.index == w.nextMatch; @@ -371,7 +402,7 @@ var rules = [ match: "^----+$\\n?|
\\n?", handler: function(w) { - w.output.push($tw.Tree.Element("hr")); + w.output.push({type:"element",tag:"hr"}); } }, @@ -403,28 +434,33 @@ var rules = [ { name: "typedBlock", - match: "^\\$\\$\\$(?:.*)\\n", - lookaheadRegExp: /^\$\$\$(.*)\n((?:^[^\n]*\n)+?)(^\f*\$\$\$$\n?)/mg, + match: "^\\$\\$\\$(?:[^ >\\r\\n]*)\\r?\\n", + lookaheadRegExp: /^\$\$\$([^ >\r\n]*)\n((?:^[^\n]*\r?\n)+?)(^\f*\$\$\$\r?\n?)/mg, + //match: "^\\$\\$\\$(?:[^ >\\r\\n]*)(?: *> *([^ \\r\\n]+))?\\r?\\n", + //lookaheadRegExp: /^\$\$\$([^ >\r\n]*)(?: *> *([^ \r\n]+))\n((?:^[^\n]*\n)+?)(^\f*\$\$\$$\n?)/mg, handler: function(w) { this.lookaheadRegExp.lastIndex = w.matchStart; var lookaheadMatch = this.lookaheadRegExp.exec(w.source); if(lookaheadMatch && lookaheadMatch.index == w.matchStart) { // The wikitext parsing infrastructure is horribly unre-entrant - var mimeType = lookaheadMatch[1], - content = lookaheadMatch[2], + var parseType = lookaheadMatch[1], + renderType ,//= this.match[2], + text = lookaheadMatch[2], oldOutput = w.output, oldSource = w.source, oldNextMatch = w.nextMatch, - oldChildren = w.children, - oldDependencies = w.dependencies, - parseTree = w.wiki.parseText(mimeType,content,{defaultType: "text/plain"}).tree; + oldChildren = w.children; + // Parse the block according to the specified type + var parser = $tw.wiki.parseText(parseType,text.toString(),{defaultType: "text/plain"}); + w.output = oldOutput; w.source = oldSource; w.nextMatch = oldNextMatch; w.children = oldChildren; - w.dependencies = oldDependencies; - w.output.push.apply(w.output,parseTree); + for (var i=0; i]?[Ii][Mm][Gg]\\[", @@ -545,7 +636,7 @@ var rules = [ } } }, - +*/ { name: "html", match: "<[Hh][Tt][Mm][Ll]>", @@ -555,7 +646,7 @@ var rules = [ this.lookaheadRegExp.lastIndex = w.matchStart; var lookaheadMatch = this.lookaheadRegExp.exec(w.source); if(lookaheadMatch && lookaheadMatch.index == w.matchStart) { - w.output.push($tw.Tree.Element("html",{},[$tw.Tree.Raw(lookaheadMatch[1])])); + w.output.push({ type:"raw", html:lookaheadMatch[1]}); w.nextMatch = this.lookaheadRegExp.lastIndex; } } @@ -582,32 +673,32 @@ var rules = [ var e,lookaheadRegExp,lookaheadMatch; switch(w.matchText) { case "''": - e = $tw.Tree.Element("strong",null,[]); + e = {type:"element",tag:"strong",children: []}; w.output.push(e); w.subWikifyTerm(e.children,/('')/mg); break; case "//": - e = $tw.Tree.Element("em",null,[]); + e = {type:"element",tag:"em",children: []}; w.output.push(e); w.subWikifyTerm(e.children,/(\/\/)/mg); break; case "__": - e = $tw.Tree.Element("u",null,[]); + e = {type:"element",tag:"u",children: []}; w.output.push(e); w.subWikifyTerm(e.children,/(__)/mg); break; case "^^": - e = $tw.Tree.Element("sup",null,[]); + e = {type:"element",tag:"sup",children: []}; w.output.push(e); w.subWikifyTerm(e.children,/(\^\^)/mg); break; case "~~": - e = $tw.Tree.Element("sub",null,[]); + e = {type:"element",tag:"sub",children: []}; w.output.push(e); w.subWikifyTerm(e.children,/(~~)/mg); break; case "--": - e = $tw.Tree.Element("strike",null,[]); + e = {type:"element",tag:"strike",children: []}; w.output.push(e); w.subWikifyTerm(e.children,/(--)/mg); break; @@ -616,8 +707,8 @@ var rules = [ lookaheadRegExp.lastIndex = w.matchStart; lookaheadMatch = lookaheadRegExp.exec(w.source); if(lookaheadMatch && lookaheadMatch.index == w.matchStart) { - w.output.push($tw.Tree.Element("code",null,[$tw.Tree.Text(lookaheadMatch[1])])); - w.nextMatch = lookaheadRegExp.lastIndex; + w.output.push({type:"element",tag:"code", + children:[{type: "text",text: lookaheadMatch[1]}]}); } break; case "{{{": @@ -625,7 +716,8 @@ var rules = [ lookaheadRegExp.lastIndex = w.matchStart; lookaheadMatch = lookaheadRegExp.exec(w.source); if(lookaheadMatch && lookaheadMatch.index == w.matchStart) { - w.output.push($tw.Tree.Element("code",null,[$tw.Tree.Text(lookaheadMatch[1])])); + w.output.push({type:"element",tag:"code", + children:[{type: "text",text: lookaheadMatch[1]}]}); w.nextMatch = lookaheadRegExp.lastIndex; } break; @@ -640,7 +732,7 @@ var rules = [ { switch(w.matchText) { case "@@": - var e = $tw.Tree.Element("span",null,[]); + var e = {type:"element",tag:"span",children: []}; w.output.push(e); var styles = inlineCssHelper(w); if(styles.length === 0) @@ -655,9 +747,8 @@ var rules = [ var lookaheadMatch = lookaheadRegExp.exec(w.source); if(lookaheadMatch) { w.nextMatch = lookaheadRegExp.lastIndex; - e = $tw.Tree.Element(lookaheadMatch[2] == "\n" ? "div" : "span",{ - "class": lookaheadMatch[1] - },[]); + e = {type:"element",tag:lookaheadMatch[2] == "\n" ? "div" : "span", + attributes: {"class": {type: "string", value:lookaheadMatch[1]}},children: []}; w.output.push(e); w.subWikifyTerm(e.children,/(\}\}\})/mg); } @@ -671,7 +762,7 @@ var rules = [ match: "--", handler: function(w) { - w.output.push($tw.Tree.Entity("—")); + w.output.push({type: "entity", entity: "—"}); } }, @@ -680,7 +771,7 @@ var rules = [ match: "\\n|
", handler: function(w) { - w.output.push($tw.Tree.Element("br")); + w.output.push({type:"element",tag:"br"}); } }, @@ -693,7 +784,8 @@ var rules = [ this.lookaheadRegExp.lastIndex = w.matchStart; var lookaheadMatch = this.lookaheadRegExp.exec(w.source); if(lookaheadMatch && lookaheadMatch.index == w.matchStart) { - w.output.push($tw.Tree.Text(lookaheadMatch[1])); + w.output.push({type: "text",text: lookaheadMatch[1] + }); w.nextMatch = this.lookaheadRegExp.lastIndex; } } @@ -704,7 +796,7 @@ var rules = [ match: "&#?[a-zA-Z0-9]{2,8};", handler: function(w) { - w.output.push($tw.Tree.Entity(w.matchText)); + w.output.push({type: "entity", entity: w.matchText}); } } From 9992b542a35b32423a8d5537bd3409d6a24988e6 Mon Sep 17 00:00:00 2001 From: buggyj Date: Fri, 20 Jun 2014 09:52:37 +0200 Subject: [PATCH 02/11] added update for triple double-quotes macro params --- plugins/tiddlywiki/tw2parser/macrodefs.tid | 6 +++--- plugins/tiddlywiki/tw2parser/parameteradapter.js | 6 +++--- plugins/tiddlywiki/tw2parser/wikitextrules.js | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/plugins/tiddlywiki/tw2parser/macrodefs.tid b/plugins/tiddlywiki/tw2parser/macrodefs.tid index 8edc585d5..2b6f9eb24 100644 --- a/plugins/tiddlywiki/tw2parser/macrodefs.tid +++ b/plugins/tiddlywiki/tw2parser/macrodefs.tid @@ -12,15 +12,15 @@ title: $:/plugins/tiddlywiki/tw2parser/macrodefs \end \define __system_tabinstance(state, currentTab, prompts, labels) - > ><$button set=<> setTo="$currentTab$" selectedClass="tw-tab-selected"> - <> + > ><$button set=<> setTo="$currentTab$" selectedClass="tw-tab-selected"> + <> \end \define __system_tabs(tabsList,prompts,labels,state:"$:/state/tab")
<$list filter="$tabsList$" variable="currentTab"> - <$macrocall $name="__system_tabinstance" state="$state$" prompts='$prompts$' labels='$labels$'currentTab=<>/> + <$macrocall $name="__system_tabinstance" state="$state$" prompts="""$prompts$""" labels="""$labels$""" currentTab=<>/>
diff --git a/plugins/tiddlywiki/tw2parser/parameteradapter.js b/plugins/tiddlywiki/tw2parser/parameteradapter.js index 2f0eb335d..7dc8e751d 100644 --- a/plugins/tiddlywiki/tw2parser/parameteradapter.js +++ b/plugins/tiddlywiki/tw2parser/parameteradapter.js @@ -53,12 +53,12 @@ function gettiddlername(title) { var parserparams = function(paramString) { var params = [], - reParam = /\s*(?:([A-Za-z0-9\-_]+)\s*:)?(?:\s*(?:"([^"]*)"|'([^']*)'|\[\[([^\]]*)\]\]|([^"'\s]+)))/mg, + reParam = /\s*(?:([A-Za-z0-9\-_]+)\s*:)?(?:\s*(?:"""([\s\S]*?)"""|"([^"]*)"|'([^']*)'|\[\[([^\]]*)\]\]|([^"'\s]+)))/mg, paramMatch = reParam.exec(paramString); while(paramMatch) { // Process this parameter var paramInfo = { - value: paramMatch[2] || paramMatch[3] || paramMatch[4] || paramMatch[5] + value: paramMatch[2] || paramMatch[3] || paramMatch[4] || paramMatch[5] || paramMatch[6] }; if(paramMatch[1]) { paramInfo.name = paramMatch[1]; @@ -85,7 +85,7 @@ var tabshandler = function(paramstring) { } //Create a list of names (tiddlers, tiddler/sections, tiddler/slices), and create maps from name -> label and name -> prompt //Use json to implement maps - return "'"+tabslist +"' '"+JSON.stringify(promptarray)+"' '"+JSON.stringify(labelarray)+"' '"+cookie+"'"; + return '"""'+tabslist +'""" """'+JSON.stringify(promptarray)+'""" """'+JSON.stringify(labelarray)+'""" """'+cookie+'"""'; }; var namedapter = {tabs:'__system_tabs'}; var paramadapter = { diff --git a/plugins/tiddlywiki/tw2parser/wikitextrules.js b/plugins/tiddlywiki/tw2parser/wikitextrules.js index f9e78c7d5..7618d873b 100755 --- a/plugins/tiddlywiki/tw2parser/wikitextrules.js +++ b/plugins/tiddlywiki/tw2parser/wikitextrules.js @@ -103,12 +103,12 @@ var enclosedTextHelper = function(w) { var insertMacroCall = function(w,output,macroName,paramString) { var params = [], - reParam = /\s*(?:([A-Za-z0-9\-_]+)\s*:)?(?:\s*(?:"([^"]*)"|'([^']*)'|\[\[([^\]]*)\]\]|([^"'\s]+)))/mg, + reParam = /\s*(?:([A-Za-z0-9\-_]+)\s*:)?(?:\s*(?:"""([\s\S]*?)"""|"([^"]*)"|'([^']*)'|\[\[([^\]]*)\]\]|([^"'\s]+)))/mg, paramMatch = reParam.exec(paramString); while(paramMatch) { // Process this parameter var paramInfo = { - value: paramMatch[2] || paramMatch[3] || paramMatch[4] || paramMatch[5] + value: paramMatch[2] || paramMatch[3] || paramMatch[4] || paramMatch[5] || paramMatch[6] }; if(paramMatch[1]) { paramInfo.name = paramMatch[1]; From 9a49c2a99e7f29615d926e49268a89216b1f76a6 Mon Sep 17 00:00:00 2001 From: buggyj Date: Thu, 26 Jun 2014 15:46:45 +0200 Subject: [PATCH 03/11] removed version info --- plugins/tiddlywiki/tw2parser/plugin.info | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/plugins/tiddlywiki/tw2parser/plugin.info b/plugins/tiddlywiki/tw2parser/plugin.info index 27f2f29ed..3da96ea7b 100644 --- a/plugins/tiddlywiki/tw2parser/plugin.info +++ b/plugins/tiddlywiki/tw2parser/plugin.info @@ -1,8 +1,5 @@ { "title": "$:/plugins/bj/tw2parser", "description": "legacy parser", - "author": "JeremyRuston, JeffreyWilkinson", - "version": "0.0.2-alpha-tw2parser", - "core-version": ">=5.0.0", - "plugin-type": "plugin" + "authors": "JeremyRuston, JeffreyWilkinson" } From c8d9ceaf2df7f661c60b551136af70baaa7f81ee Mon Sep 17 00:00:00 2001 From: buggyj Date: Thu, 28 Aug 2014 18:49:40 +0200 Subject: [PATCH 04/11] added image handling to tw2parser --- plugins/tiddlywiki/tw2parser/image-css.tid | 11 +++++ plugins/tiddlywiki/tw2parser/plugin.info | 6 ++- plugins/tiddlywiki/tw2parser/wikitextrules.js | 43 ++++++++++++++----- 3 files changed, 47 insertions(+), 13 deletions(-) create mode 100644 plugins/tiddlywiki/tw2parser/image-css.tid diff --git a/plugins/tiddlywiki/tw2parser/image-css.tid b/plugins/tiddlywiki/tw2parser/image-css.tid new file mode 100644 index 000000000..b408bea40 --- /dev/null +++ b/plugins/tiddlywiki/tw2parser/image-css.tid @@ -0,0 +1,11 @@ +tags: $:/tags/stylesheet +title: $:/plugins/tiddlywiki/tw2parser/image-css +type: text/plain + +.classic-image-left{ + float: left; +} + +.classic-image-right{ + float: right; +} diff --git a/plugins/tiddlywiki/tw2parser/plugin.info b/plugins/tiddlywiki/tw2parser/plugin.info index 3b9d10719..5c5fe493c 100644 --- a/plugins/tiddlywiki/tw2parser/plugin.info +++ b/plugins/tiddlywiki/tw2parser/plugin.info @@ -1,6 +1,8 @@ { "title": "$:/plugins/tiddlywiki/tw2parser", "description": "TiddlyWiki Classic-compatible wikitext parser", - "authors": "JeremyRuston, JeffreyWilkinson" - "core-version": ">=5.0.0" + "authors": "JeremyRuston, JeffreyWilkinson", + "version": "0.0.2-alpha-tw2parser", + "core-version": ">=5.0.15", + "plugin-type": "plugin" } diff --git a/plugins/tiddlywiki/tw2parser/wikitextrules.js b/plugins/tiddlywiki/tw2parser/wikitextrules.js index 7618d873b..d0ad4757d 100755 --- a/plugins/tiddlywiki/tw2parser/wikitextrules.js +++ b/plugins/tiddlywiki/tw2parser/wikitextrules.js @@ -491,6 +491,7 @@ var rules = [ if (name) { if (!!macroadapter.paramadapter[name]) { params=macroadapter.paramadapter[name](params); + //alert("going out as "+params); } if (!!macroadapter.namedapter[name]) { name=macroadapter.namedapter[name]; @@ -602,7 +603,7 @@ var rules = [ } }, -/* + { name: "image", match: "\\[[<>]?[Ii][Mm][Gg]\\[", @@ -610,33 +611,53 @@ var rules = [ lookaheadRegExp: /\[([<]?)(>?)[Ii][Mm][Gg]\[(?:([^\|\]]+)\|)?([^\[\]\|]+)\](?:\[([^\]]*)\])?\]/mg, handler: function(w) { + var node = { + type: "image", + attributes: {} + }; this.lookaheadRegExp.lastIndex = w.matchStart; var lookaheadMatch = this.lookaheadRegExp.exec(w.source), imageParams = {}, linkParams = {}; if(lookaheadMatch && lookaheadMatch.index == w.matchStart) { if(lookaheadMatch[1]) { - imageParams.alignment = "left"; + node.attributes.class = {type: "string", value: "classic-image-left"}; } else if(lookaheadMatch[2]) { - imageParams.alignment = "right"; + node.attributes.class = {type: "string", value: "classic-image-right"}; } if(lookaheadMatch[3]) { - imageParams.text = lookaheadMatch[3]; + node.attributes.tooltip = {type: "string", value: lookaheadMatch[3]}; } - imageParams.src = lookaheadMatch[4]; + node.attributes.source = {type: "string", value: lookaheadMatch[4]}; if(lookaheadMatch[5]) { - linkParams.target = lookaheadMatch[5]; - var linkChildren = []; - insertMacroCall(w,w.output,"link",linkParams,linkChildren); - insertMacroCall(w,linkChildren,"image",imageParams); + if(isLinkExternal(lookaheadMatch[5])) { + w.output.push({ + type: "element", + tag: "a", + attributes: { + href: {type: "string", value:lookaheadMatch[5]}, + "class": {type: "string", value: "tw-tiddlylink-external"}, + target: {type: "string", value: "_blank"} + }, + children: [node] + }); + } else { + w.output.push({ + type: "link", + attributes: { + to: {type: "string", value: lookaheadMatch[5]} + }, + children: [node] + }); + } } else { - insertMacroCall(w,w.output,"image",imageParams); + w.output.push(node); } w.nextMatch = this.lookaheadRegExp.lastIndex; } } }, -*/ + { name: "html", match: "<[Hh][Tt][Mm][Ll]>", From 322c04da53582645ae320fb7a703bb658d538261 Mon Sep 17 00:00:00 2001 From: buggyj Date: Sat, 30 Aug 2014 16:46:47 +0200 Subject: [PATCH 05/11] remove incorrect version info --- plugins/tiddlywiki/tw2parser/plugin.info | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/tiddlywiki/tw2parser/plugin.info b/plugins/tiddlywiki/tw2parser/plugin.info index 5c5fe493c..05cfdfe99 100644 --- a/plugins/tiddlywiki/tw2parser/plugin.info +++ b/plugins/tiddlywiki/tw2parser/plugin.info @@ -2,7 +2,6 @@ "title": "$:/plugins/tiddlywiki/tw2parser", "description": "TiddlyWiki Classic-compatible wikitext parser", "authors": "JeremyRuston, JeffreyWilkinson", - "version": "0.0.2-alpha-tw2parser", "core-version": ">=5.0.15", "plugin-type": "plugin" } From 59244fba91cc87c0aa6954a23c86e51e66e30d86 Mon Sep 17 00:00:00 2001 From: buggyj Date: Sun, 31 Aug 2014 17:48:14 +0200 Subject: [PATCH 06/11] remove newlines around macros --- plugins/tiddlywiki/tw2parser/wikitextrules.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/tiddlywiki/tw2parser/wikitextrules.js b/plugins/tiddlywiki/tw2parser/wikitextrules.js index d0ad4757d..4305227fb 100755 --- a/plugins/tiddlywiki/tw2parser/wikitextrules.js +++ b/plugins/tiddlywiki/tw2parser/wikitextrules.js @@ -121,7 +121,7 @@ var insertMacroCall = function(w,output,macroName,paramString) { type: "macrocall", name: macroName, params: params, - isBlock: true + isBlock: false }); } From 053929db3fd9b967ab5fb0c63bfde22efd779cf1 Mon Sep 17 00:00:00 2001 From: buggyj Date: Sun, 31 Aug 2014 17:51:03 +0200 Subject: [PATCH 07/11] remove upgrade nagging --- plugins/tiddlywiki/tw2parser/BlankViewTemplate_classic.tid | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 plugins/tiddlywiki/tw2parser/BlankViewTemplate_classic.tid diff --git a/plugins/tiddlywiki/tw2parser/BlankViewTemplate_classic.tid b/plugins/tiddlywiki/tw2parser/BlankViewTemplate_classic.tid new file mode 100644 index 000000000..c5834a9f8 --- /dev/null +++ b/plugins/tiddlywiki/tw2parser/BlankViewTemplate_classic.tid @@ -0,0 +1,6 @@ +tags: $:/tags/ViewTemplate $:/tags/EditTemplate +title: $:/core/ui/ViewTemplate/classic +type: text/vnd.tiddlywiki + + + From 3cc702faa0d50151c5f3daf060cba026dba33cce Mon Sep 17 00:00:00 2001 From: buggyj Date: Mon, 1 Sep 2014 11:11:44 +0200 Subject: [PATCH 08/11] additions for the classicparserdemo edition --- bld.cmd | 8 ++ bld.sh | 9 ++ .../tiddlers/$__DefaultTiddlers.tid | 12 ++ .../tiddlers/$__ShowEditPreview.tid | 6 + .../tiddlers/$__SiteSubtitle.tid | 5 + .../tiddlers/$__SiteTitle.tid | 6 + .../tiddlers/$__plugins_bj_Calendar.tid | 31 +++++ .../tiddlers/Basic Formatting.tid | 36 +++++ .../tiddlers/Blockquotes.tid | 55 ++++++++ .../tiddlers/CSS Formatting.tid | 51 +++++++ .../tiddlers/Classic Parser Plugin Demo.tid | 14 ++ .../tiddlers/Classic Slider Demo.tid | 13 ++ .../tiddlers/Classic Transclusion.tid | 12 ++ .../tiddlers/ClassicTabsDemo.tid | 39 ++++++ editions/classicparserdemo/tiddlers/Code.tid | 42 ++++++ .../tiddlers/Comment Formatting.tid | 41 ++++++ .../tiddlers/Developers Notes.tid | 26 ++++ .../tiddlers/ExtendableCalendar.tid | 12 ++ .../tiddlers/HTML Entities.tid | 62 +++++++++ .../tiddlers/HTML Formatting.tid | 40 ++++++ .../classicparserdemo/tiddlers/Headings.tid | 38 ++++++ .../tiddlers/Horizontal Rules.tid | 37 +++++ .../classicparserdemo/tiddlers/Images.tid | 61 +++++++++ .../classicparserdemo/tiddlers/Issues.tid | 9 ++ .../tiddlers/Line Breaks.tid | 36 +++++ editions/classicparserdemo/tiddlers/Links.tid | 63 +++++++++ editions/classicparserdemo/tiddlers/Lists.tid | 55 ++++++++ .../classicparserdemo/tiddlers/Markup.tid | 112 +++++++++++++++ .../tiddlers/Monospaced Text.tid | 21 +++ .../tiddlers/Suppressing Formatting.tid | 41 ++++++ .../classicparserdemo/tiddlers/Tables.tid | 129 ++++++++++++++++++ .../classicparserdemo/tiddlers/slidertest.tid | 8 ++ .../tiddlers/text_x-tiddlywiki typeblock.tid | 25 ++++ editions/classicparserdemo/tiddlywiki.info | 15 ++ editions/tw5.com/tiddlers/Features.tid | 1 + 35 files changed, 1171 insertions(+) create mode 100644 editions/classicparserdemo/tiddlers/$__DefaultTiddlers.tid create mode 100644 editions/classicparserdemo/tiddlers/$__ShowEditPreview.tid create mode 100644 editions/classicparserdemo/tiddlers/$__SiteSubtitle.tid create mode 100644 editions/classicparserdemo/tiddlers/$__SiteTitle.tid create mode 100644 editions/classicparserdemo/tiddlers/$__plugins_bj_Calendar.tid create mode 100644 editions/classicparserdemo/tiddlers/Basic Formatting.tid create mode 100644 editions/classicparserdemo/tiddlers/Blockquotes.tid create mode 100644 editions/classicparserdemo/tiddlers/CSS Formatting.tid create mode 100644 editions/classicparserdemo/tiddlers/Classic Parser Plugin Demo.tid create mode 100644 editions/classicparserdemo/tiddlers/Classic Slider Demo.tid create mode 100644 editions/classicparserdemo/tiddlers/Classic Transclusion.tid create mode 100644 editions/classicparserdemo/tiddlers/ClassicTabsDemo.tid create mode 100644 editions/classicparserdemo/tiddlers/Code.tid create mode 100644 editions/classicparserdemo/tiddlers/Comment Formatting.tid create mode 100644 editions/classicparserdemo/tiddlers/Developers Notes.tid create mode 100644 editions/classicparserdemo/tiddlers/ExtendableCalendar.tid create mode 100644 editions/classicparserdemo/tiddlers/HTML Entities.tid create mode 100644 editions/classicparserdemo/tiddlers/HTML Formatting.tid create mode 100644 editions/classicparserdemo/tiddlers/Headings.tid create mode 100644 editions/classicparserdemo/tiddlers/Horizontal Rules.tid create mode 100644 editions/classicparserdemo/tiddlers/Images.tid create mode 100644 editions/classicparserdemo/tiddlers/Issues.tid create mode 100644 editions/classicparserdemo/tiddlers/Line Breaks.tid create mode 100644 editions/classicparserdemo/tiddlers/Links.tid create mode 100644 editions/classicparserdemo/tiddlers/Lists.tid create mode 100644 editions/classicparserdemo/tiddlers/Markup.tid create mode 100644 editions/classicparserdemo/tiddlers/Monospaced Text.tid create mode 100644 editions/classicparserdemo/tiddlers/Suppressing Formatting.tid create mode 100644 editions/classicparserdemo/tiddlers/Tables.tid create mode 100644 editions/classicparserdemo/tiddlers/slidertest.tid create mode 100644 editions/classicparserdemo/tiddlers/text_x-tiddlywiki typeblock.tid create mode 100644 editions/classicparserdemo/tiddlywiki.info diff --git a/bld.cmd b/bld.cmd index 9d803d2b0..0b988676a 100644 --- a/bld.cmd +++ b/bld.cmd @@ -94,6 +94,14 @@ node .\tiddlywiki.js ^ --rendertiddler $:/core/save/all markdowndemo.html text/plain ^ || exit 1 +rem classicparserdemo.html: wiki to demo classicparser plugin + +node .\tiddlywiki.js ^ + .\editions\classicparserdemo ^ + --verbose ^ + --output %TW5_BUILD_OUTPUT% ^ + --rendertiddler $:/core/save/all classicparserdemo.html text/plain ^ + || exit 1 rem highlightdemo.html: wiki to demo highlight plugin diff --git a/bld.sh b/bld.sh index ad707acd9..50ad509b9 100755 --- a/bld.sh +++ b/bld.sh @@ -95,6 +95,15 @@ node ./tiddlywiki.js \ --rendertiddler $:/core/save/all markdowndemo.html text/plain \ || exit 1 +# classicparserdemo.html: wiki to demo classicparser plugin + +node ./tiddlywiki.js \ + ./editions/classicparserdemo \ + --verbose \ + --output $TW5_BUILD_OUTPUT \ + --rendertiddler $:/core/save/all classicparserdemo.html text/plain \ + || exit 1 + # highlightdemo.html: wiki to demo highlight plugin node ./tiddlywiki.js \ diff --git a/editions/classicparserdemo/tiddlers/$__DefaultTiddlers.tid b/editions/classicparserdemo/tiddlers/$__DefaultTiddlers.tid new file mode 100644 index 000000000..2ea5805fa --- /dev/null +++ b/editions/classicparserdemo/tiddlers/$__DefaultTiddlers.tid @@ -0,0 +1,12 @@ +created: 20140417191319973 +modified: 20140901082708004 +title: $:/DefaultTiddlers +type: text/vnd.tiddlywiki + +[[Classic Parser Plugin Demo]] +[[Classic Slider Demo]] +[[ClassicTabsDemo]] +[[Classic Transclusion]] +[[text/x-tiddlywiki typeblock]] +[[Markup]] +[[Developers Notes]] \ No newline at end of file diff --git a/editions/classicparserdemo/tiddlers/$__ShowEditPreview.tid b/editions/classicparserdemo/tiddlers/$__ShowEditPreview.tid new file mode 100644 index 000000000..89d259d5f --- /dev/null +++ b/editions/classicparserdemo/tiddlers/$__ShowEditPreview.tid @@ -0,0 +1,6 @@ +created: 20140416191641926 +modified: 20140417181106838 +title: $:/ShowEditPreview +type: text/vnd.tiddlywiki + +yes \ No newline at end of file diff --git a/editions/classicparserdemo/tiddlers/$__SiteSubtitle.tid b/editions/classicparserdemo/tiddlers/$__SiteSubtitle.tid new file mode 100644 index 000000000..d73c44a5b --- /dev/null +++ b/editions/classicparserdemo/tiddlers/$__SiteSubtitle.tid @@ -0,0 +1,5 @@ +created: 20140417192155748 +modified: 20140417192155748 +title: $:/SiteSubtitle +type: text/vnd.tiddlywiki + diff --git a/editions/classicparserdemo/tiddlers/$__SiteTitle.tid b/editions/classicparserdemo/tiddlers/$__SiteTitle.tid new file mode 100644 index 000000000..a84e0d4bc --- /dev/null +++ b/editions/classicparserdemo/tiddlers/$__SiteTitle.tid @@ -0,0 +1,6 @@ +created: 20140417192135107 +modified: 20140417192152339 +title: $:/SiteTitle +type: text/vnd.tiddlywiki + +Classic Parser Demo \ No newline at end of file diff --git a/editions/classicparserdemo/tiddlers/$__plugins_bj_Calendar.tid b/editions/classicparserdemo/tiddlers/$__plugins_bj_Calendar.tid new file mode 100644 index 000000000..5620f4279 --- /dev/null +++ b/editions/classicparserdemo/tiddlers/$__plugins_bj_Calendar.tid @@ -0,0 +1,31 @@ +created: 20140322080900815 +dependents: +description: ckeditor adapter plugin +modified: 20140322080900815 +plugin-type: plugin +title: $:/plugins/bj/Calendar +type: application/json +version: 0.0.1 + +{ + "tiddlers": { + "$:/macros/buggyj/Calendar/entry.js": { + "text": "/*\\\ntitle: $:/macros/buggyj/Calendar/entry.js\ntype: application/javascript\nmodule-type: macro\n\n<>\n<> - year calendar\n<> - this month\n\nOptions:$:/macros/diary/options.json\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nInformation about this macro\nCAL demo\n*/\n\nexports.name = \"calendar\";\n\nexports.params = [\n\t{ name: \"year\" },{ name: \"month\" },{ name: \"opts\" }\n];\n/*\nRun the macro\n*/\n\nexports.run = function(year, month,opts) {\nif (!opts) opts=\"default\";\nvar options = $tw.wiki.getTiddlerData(\"$:/plugins/bj/Calendar/json/config.json\")[opts]||\n\t\t\t\t{lastDayOfWeek:\"6\",formatter:\"\",titlebold:\"\",highlightThisDay:\"\",highlightThisDate:\"\"};\nvar createMonth;\ntry {\n\tcreateMonth = require(options.formatter).createMonth;\n} catch (e) {\n\tcreateMonth= function(mnth,year){\n\t\tvar month=[];\n\t\tfor (var i=1;i < 1+daysInMonth(mnth,year);i++) month[i] = i;\n\t\treturn month;\n\t}\n} \nvar boldtitle=(options.titlebold=='yes')?'!':'';\nvar day_of_week = $tw.config.dateFormats.shortDays;\nvar month_of_year = $tw.config.dateFormats.months; \nvar Calendar = new Date();\nvar thisyear = Calendar.getFullYear(); // year (xxxx)\nvar thismonth = Calendar.getMonth();\t// month (0-11)\nvar thisday = Calendar.getDay(); // day (0-6)\nvar WEEKFIN = parseInt(options.lastDayOfWeek); \nvar MONTHS_IN_YEAR=12;\t\t\t\t\t\n \nvar lf ='\\n';\nvar cal='
'+lf+lf; \nvar ayear=thisyear;\nif (!!month) {\n\tif (!!year) {\n\t\tcal+=calendar (month-1,year,options);\n\t} else {\n\t\tcal+=calendar (month-1,thisyear,options);\n\t}\n} else {\n\toptions.seperateYearHeading = 'yes';\n\tcal+=titleOfYear(year); \n\tif (!!year) ayear=year; \n\tfor(var i=0; i';\n\nfunction calendar (mnth,year,options){\n var month =\tcreateMonth(mnth,year,options);\n var blankdays = (firstDayInMonth(mnth,year)+13-WEEKFIN)%7;\n\treturn titleOfMonth(mnth,year)+createWeekHeading()+\n\t formatAsMonth(month,blankdays);\n}\nfunction titleOfMonth(mth,year) {\n\tif (!!options.seperateYearHeading ) {\n\t\treturn '|>|>|>|'+ centre(boldtitle+ month_of_year[mth]) +'|<|<|<|'+lf;\n\t} else {\n\t\treturn '|>|>|>|'+ centre(boldtitle+ month_of_year[mth] + ' ' + year) +'|<|<|<|'+lf;\n\t}\n}\n\nfunction titleOfYear(year) {\n\t\treturn '|>|>|>|>|>|>|>|'+ centre('!'+year) +'|<|<|<|<|<|<|<|'+lf;\n}\nfunction centre (x){ return ' '+x+' ';}\n\nfunction formatAsMonth(month,blankdays){\t\n\tvar theday,blank=['','|','||','|||','||||','|||||','||||||','|||||||'];\t\n\tvar cal=blank[blankdays];//pad out before first day of month\n\tfor(var i=1; i < month.length;i++){//first '0' month element is not used\n\t\tcal+='|'+month[i];\n\t\ttheday=(i+blankdays-1)%7;\n\t\tif (theday== 6) cal +='|'+lf; \n\t}\n\tcal+=blank[7-theday]+(7-theday>1?lf:'');//pad out rest of week, if no blanks then lf was added in loop\n\treturn cal ;\n}\nfunction createWeekHeading(){\n\t\tvar daystitle=[],weekdays= day_of_week.slice(0);\n\t\t// highlight today's day of week\n\t\tif (options.highlightThisDay=='yes')weekdays[thisday] ='!'+weekdays[thisday];\n\t\tfor (var i=0;i < weekdays.length; i++) daystitle[i] =centre(weekdays[(i+1+WEEKFIN)%7]);\n\t\treturn '|'+daystitle.join('|')+'|'+lf; \n}\nfunction daysInMonth(iMonth, iYear){\n\t\treturn 32 - new Date(iYear, iMonth, 32).getDate();\n\t}\nfunction firstDayInMonth(iMonth, iYear){\n\t\treturn new Date(iYear, iMonth, 1).getDay();\n\t} \nfunction splicetable (a,b) {\n\tvar i,cal='',taba =a.split('\\n'),tabb=b.split('|\\n');\n\tvar limit=(taba.lengthbold|{{{''bold''}}} -- two single-quotes| +|//italics//|{{{//italics//}}}| +|bold italics|{{{''//bold italics//''}}}| +|__underline__|{{{__underline__}}}| +|--strikethrough--|{{{--Strikethrough--}}}| +|super^^script^^|{{{super^^script^^}}}| +|sub~~script~~|{{{sub~~script~~}}}| +|@@Highlight@@|{{{@@Highlight@@}}}| +|{{{plain text}}}|{{{PlainText No ''Formatting''}}}| +|/%this text will be invisible%/hidden text|{{{/%this text will be invisible%/}}}| +|foo -- bar|{{{use two dashes -- between two words to create an Em dash}}}| diff --git a/editions/classicparserdemo/tiddlers/Blockquotes.tid b/editions/classicparserdemo/tiddlers/Blockquotes.tid new file mode 100644 index 000000000..ffdda5432 --- /dev/null +++ b/editions/classicparserdemo/tiddlers/Blockquotes.tid @@ -0,0 +1,55 @@ +_hash: 816bced1fe527175bcf3be0fdf7dd2419989ea5e +created: 20110215174227000 +creator: pmario +modified: 20140415164659711 +modifier: andrewstern +more: [[TiddlyWiki Markup]] +server.bag: tiddlywiki_public +server.content-type: +server.etag: "tiddlywiki_public/Blockquotes/1335259:2fe415fcc19e5d77f9ae8d000b8d37107c34a8c6" +server.host: http://tiddlywiki.org +server.page.revision: 1335259 +server.permissions: read +server.recipe: tiddlywiki_public +server.title: Blockquotes +server.type: tiddlyweb +server.workspace: bags/tiddlywiki_public +tags: Formatting +title: Blockquotes +type: text/x-tiddlywiki + +!Summary +Use quotations to cite other sources or simply indent content. +!!Blockquotes +Text can be displayed as quotations using three less-than signs: +{{{ +<<< +Steve Jobs: "computers are like a bicycle for our minds" +<<< +}}} +<<< +Steve Jobs: "computers are like a bicycle for our minds" +<<< +!Nested Blockquotes +Quotes can be displayed with multi-levels: +{{{ +> blockquote, level 1 +>> blockquote, level 2 +>>> blockquote, level 3 +}}} +> blockquote, level 1 +>> blockquote, level 2 +>>> blockquote, level 3 +!!Mixed Blockquotes +{{{ +<<< +Steve Jobs: "computers are like a bicycle for our minds" +> blockquote, level 1 +Some more text. +<<< +}}} +<<< +Steve Jobs: "computers are like a bicycle for our minds" +> blockquote, level 1 +Some more text. +<<< diff --git a/editions/classicparserdemo/tiddlers/CSS Formatting.tid b/editions/classicparserdemo/tiddlers/CSS Formatting.tid new file mode 100644 index 000000000..7d8279c7f --- /dev/null +++ b/editions/classicparserdemo/tiddlers/CSS Formatting.tid @@ -0,0 +1,51 @@ +_hash: 8e82a50e4e8f727c56f450b0b9a5b935c2d9535f +created: 20130211145116000 +creator: tobibeer +modified: 20140415164516606 +modifier: andrewstern +more: [[TiddlyWiki Markup]] +server.bag: tiddlywiki_public +server.content-type: +server.etag: "tiddlywiki_public/CSS%20Formatting/1335261:a084d915f3bc4e548b5616c5c3e8d8d70712e625" +server.host: http://tiddlywiki.org +server.page.revision: 1335261 +server.permissions: read +server.recipe: tiddlywiki_public +server.title: CSS Formatting +server.type: tiddlyweb +server.workspace: bags/tiddlywiki_public +tags: Formatting +title: CSS Formatting +type: text/x-tiddlywiki + + +!Summary +You can directly apply CSS rules inline or use custom classes. +!Markup +!!!Inline Styles +Enclose text using two double @ signs and let the first two follow by your CSS rules. +{{{ +@@color:#4bbbbb;Some random text@@ +}}} +''Displays as:'' +@@color:red;Some random text@@ + +!!!CSS Classes +CSS classes can be applied to text blocks. + +To wrap your text inline in a HTML {{{}}} element use... +{{{ +before » {{customClassName{inline content}}} « after +}}} +''Displays as:'' +before » {{customClassName{inline content}}} « after + +To wrap your text as a block level element -- a HTML {{{
}}} -- use line-breaks... +
+before » {{customClassName{
+box content
+}}} « after
+
''Displays as:'' +before » {{customClassName{ +box content +}}} « after diff --git a/editions/classicparserdemo/tiddlers/Classic Parser Plugin Demo.tid b/editions/classicparserdemo/tiddlers/Classic Parser Plugin Demo.tid new file mode 100644 index 000000000..a35f261d4 --- /dev/null +++ b/editions/classicparserdemo/tiddlers/Classic Parser Plugin Demo.tid @@ -0,0 +1,14 @@ +created: 20140416201128370 +modified: 20140901082657977 +title: Classic Parser Plugin Demo +type: text/x-tiddlywiki + +This is a demo of the Tiddlywiki Classic parser for Tiddlywiki5 (the tw2parser plugin). +Below is a [[Test card|Markup]] from [[http://tiddlywiki.org]] showing examples of all Classic markup. + +Tiddlers that are given the type 'text/x-tiddlywiki' will be interpreted as containing Classic Tiddlywiki markup. In addition Classic Tiddlywiki markup can be embedded in a tiddlywiki5 tiddler by the use of a type block - see [[text/x-tiddlywiki typeblock]] below. +!!Support for Classic macros +At present there is limited support for Classic macros. See below for examples of the [[slider|Classic Slider Demo]], [[tabs|ClassicTabsDemo]] and [[tiddler|Classic Transclusion]] macros. +!!Status +See here for <> +!!See also [[Developers Notes]] diff --git a/editions/classicparserdemo/tiddlers/Classic Slider Demo.tid b/editions/classicparserdemo/tiddlers/Classic Slider Demo.tid new file mode 100644 index 000000000..6010f9744 --- /dev/null +++ b/editions/classicparserdemo/tiddlers/Classic Slider Demo.tid @@ -0,0 +1,13 @@ +created: 20140831105412236 +modified: 20140901072049425 +title: Classic Slider Demo +type: text/x-tiddlywiki + +!!Demo text: +{{{ +<> +}}} +!!Demo results: + +<> + \ No newline at end of file diff --git a/editions/classicparserdemo/tiddlers/Classic Transclusion.tid b/editions/classicparserdemo/tiddlers/Classic Transclusion.tid new file mode 100644 index 000000000..139d8dc1f --- /dev/null +++ b/editions/classicparserdemo/tiddlers/Classic Transclusion.tid @@ -0,0 +1,12 @@ +created: 20140831105630157 +modified: 20140901082725277 +title: Classic Transclusion +type: text/x-tiddlywiki + +!!Demo text: +{{{ +<> +}}} +!!Demo results: + +<> diff --git a/editions/classicparserdemo/tiddlers/ClassicTabsDemo.tid b/editions/classicparserdemo/tiddlers/ClassicTabsDemo.tid new file mode 100644 index 000000000..76e1dbbdc --- /dev/null +++ b/editions/classicparserdemo/tiddlers/ClassicTabsDemo.tid @@ -0,0 +1,39 @@ +created: 20140603181004793 +modified: 20140901071957024 +title: ClassicTabsDemo +type: text/x-tiddlywiki + +!!Demo text: +{{{ +<> + +/% +!Do1 +first section: this is a hidden section below +!Do2 +another hidden section of this tiddler +!end +|~slice| a hidden slice of this tiddler| +!end +%/ +}}} +!!Demo results: +<> + +/% +!Do1 +first section: this is a hidden section below +!Do2 +another hidden section of this tiddler +!end +|~slice| a hidden slice of this tiddler| +!end +%/ diff --git a/editions/classicparserdemo/tiddlers/Code.tid b/editions/classicparserdemo/tiddlers/Code.tid new file mode 100644 index 000000000..cd3740b46 --- /dev/null +++ b/editions/classicparserdemo/tiddlers/Code.tid @@ -0,0 +1,42 @@ +_hash: 63711c725b9bd23b197b1569670088ce26dbd898 +created: 20130211142734000 +creator: tobibeer +modified: 20140901061201603 +modifier: andrewstern +more: [[TiddlyWiki Markup]] +server.bag: tiddlywiki_public +server.content-type: +server.etag: "tiddlywiki_public/Code/1335258:2e39d9422863168f6a71f2b09941cb4261414092" +server.host: http://tiddlywiki.org +server.page.revision: 1335258 +server.permissions: read +server.recipe: tiddlywiki_public +server.title: Code +server.type: tiddlyweb +server.workspace: bags/tiddlywiki_public +tags: Formatting +title: Code +type: text/x-tiddlywiki + +!Summary +You can render text monospaced text, e.g. using the font //Courier//, while preserving line breaks and not applying WikiText formating or turning WikiWords into links. +!!"""Monospaced Text Block""" +
+{{{
+Some plain text including WikiLinks
+}}}
+
''Displays as:'' a HTML
 element
+{{{
+Some plain text including WikiLinks
+}}}
+<<<
+''Note:'' Code blocks are displayed using a white-space 'as-is', fixed-width font without no word-wrapping -- displayed in a box.
+<<<
+!!"""Monospaced Inline Text"""
+Alternatively, you can also display monospaced text __inline__ by wrapping the text in three braces {{{...}}}:
+
{{{inline //code//}}}
''Displays as:'' a HTML element +{{{inline //code//}}} +<<< +''Note:'' Inline code uses a white-space 'collapsed', word-wrapped, fixed-width font. + + diff --git a/editions/classicparserdemo/tiddlers/Comment Formatting.tid b/editions/classicparserdemo/tiddlers/Comment Formatting.tid new file mode 100644 index 000000000..27798ce92 --- /dev/null +++ b/editions/classicparserdemo/tiddlers/Comment Formatting.tid @@ -0,0 +1,41 @@ +_hash: 78b7216cae18ec47008a6948d404deee68257058 +created: 20130213001758000 +creator: tobibeer +modified: 20140901061006864 +modifier: andrewstern +more: [[TiddlyWiki Markup]] +server.bag: tiddlywiki_public +server.content-type: +server.etag: "tiddlywiki_public/Comment%20Formatting/1335257:dfac9b4ac6526e0a1625ecf4796601565b189fb7" +server.host: http://tiddlywiki.org +server.page.revision: 1335257 +server.permissions: read +server.recipe: tiddlywiki_public +server.title: Comment Formatting +server.type: tiddlyweb +server.workspace: bags/tiddlywiki_public +tags: Formatting +title: Comment Formatting +type: text/x-tiddlywiki + +!Summary +Occasionally you want to add notes to your tiddler markup yet don't want it displayed when the tiddler is rendered. To achieve this, wrap the text using {{{/% hidden %/}}}. +!Example +{{{ +text before .../% +!HIDDEN SECTION +This is content of a hidden section. +!END%/ text after +}}} +''Display as:'' +<<< +text before /% +!HIDDEN SECTION +This is content of a hidden section. +!END%/... text after +<<< +!Also see... +;[[Suppressing Formatting]] +:» when you just don't want that text to be TiddlyWiki markup +:» when you want to prevent WikiWords +:» when you copy & paste from other sources diff --git a/editions/classicparserdemo/tiddlers/Developers Notes.tid b/editions/classicparserdemo/tiddlers/Developers Notes.tid new file mode 100644 index 000000000..73d3015af --- /dev/null +++ b/editions/classicparserdemo/tiddlers/Developers Notes.tid @@ -0,0 +1,26 @@ +created: 20140831112438405 +modified: 20140901080739956 +title: Developers Notes +type: text/x-tiddlywiki + +The includes handling of namespace conflicts between Classic and Tw5 macros. + +One of the goals of the Tw2parser plugin is to hide the Classic macros from tiddlers of types other than text/x-tiddlywiki. This is achieved by having the parser prepend the macro definitions to the 'local' parse tree (see around line 60 wikitextparser.js), making them only visible in text/x-tiddlywiki tiddlers and typed-blocks. At present all text based Classic macros are in the same file. + +As all global Tw5 macros are visible in all tiddlers (including text/x-tiddlywiki tiddlers), there is a name-space conflict between Classic and tw5 macros. For macros that are defined using tiddlytext (ie /define() /end blocks) the local defined Classic definition will override the global Tw5 macros (which is what we want). + +For cases where simple overriding is not sufficient, the tw2parser plugin also has a 'macro name adapter' module (macroadapter.js) to move the Classic macros names to a new names - +(in wikitextrules.js around line 490) + +{{{tw2on5-name=macroadapter.namedapter[tw2name];}}} + +This is invisible to the user. + +An example is the {{{tabs()}}} macro which is mapped to {{{__system_tabs()}}} +so the user still types {{{tabs()}}} but this is mapped to {{{__system_tabs()}}} in the parser which is what appears in the file macrodefs.tids + +There is also the facility to manipulate the parameters via {{{params=macroadapter.paramadaptername}}} +This is used in the 'tabs' macro where there is a variable number of parameters that must be mapped into fixed number of tw5 macro parameters. + +The implementation of the tabs macro is rather sophisticated, the parameters are put into maps from tab-tiddername to tab-property (properties are cookies, prompts and labels) implemented as jsons. + diff --git a/editions/classicparserdemo/tiddlers/ExtendableCalendar.tid b/editions/classicparserdemo/tiddlers/ExtendableCalendar.tid new file mode 100644 index 000000000..0d8acf1a1 --- /dev/null +++ b/editions/classicparserdemo/tiddlers/ExtendableCalendar.tid @@ -0,0 +1,12 @@ +created: 20140218170942002 +modified: 20140415153433659 +title: ExtendableCalendar +type: text/vnd.tiddlywiki + +The Calendar macro is configurable via the file [[$:/plugins/bj/Calendar/json/config.json]], and is extendable by plug-in formatter modules, it enable it use with different applications. + + +!!Default Calendar Format +<> +!!Calendar Formatter by Journals Extension +<> \ No newline at end of file diff --git a/editions/classicparserdemo/tiddlers/HTML Entities.tid b/editions/classicparserdemo/tiddlers/HTML Entities.tid new file mode 100644 index 000000000..b08db8ee5 --- /dev/null +++ b/editions/classicparserdemo/tiddlers/HTML Entities.tid @@ -0,0 +1,62 @@ +_hash: 32b1f260d97f45ce425e8bcff9a7647972b7a80e +created: 20130204165019000 +creator: tobibeer +modified: 20140415164150742 +modifier: andrewstern +more: [[TiddlyWiki Markup]] +server.bag: tiddlywiki_public +server.content-type: +server.etag: "tiddlywiki_public/HTML%20Entities/1335264:117f829031adc20106ce49a71687b123ec65bb7f" +server.host: http://tiddlywiki.org +server.page.revision: 1335264 +server.permissions: read +server.recipe: tiddlywiki_public +server.title: HTML Entities +server.type: tiddlyweb +server.workspace: bags/tiddlywiki_public +tags: Formatting +title: HTML Entities +type: text/x-tiddlywiki + +!Summary +Use HTML entities to enter characters that can't easily be typed on an ordinary keyboard. They take the form of an ampersand ({{{&}}}), an identifying string, and a terminating semi-colon ({{{;}}}), e.g. {{{&}}}. +!Markup +{{{ +The value of Tiddlers™ cannot even be expressed in £, € or $. +}}} +''Displays as:'' +The value of Tiddlers™ cannot even be expressed in £, € or $. + +!"""Entity References""" +Comprehensive lists of html entities can be found at... +* [[w3schools.com|http://www.w3schools.com/tags/ref_entities.asp]] +* [[htmlhelp.com|http://www.htmlhelp.com/reference/html40/entities]] + +!"""Examples Of Common And Eseful Entities""" +|>|>|>|>|>|>| !HTML Entities | +| &nbsp; |   | no-break space |    | &apos; | ' | single quote, apostrophe | +| &ndash; | – | en dash |~| &quot; | " | quotation mark | +| &mdash; | — | em dash |~| &prime; | ′ | prime; minutes; feet | +| &hellip; | … | horizontal ellipsis |~| &Prime; | ″ | double prime; seconds; inches | +| &copy; | © | Copyright symbol |~| &lsquo; | ‘ | left single quote | +| &reg; | ® | Registered symbol |~| &rsquo; | ’ | right single quote | +| &trade; | ™ | Trademark symbol |~| &ldquo; | “ | left double quote | +| &dagger; | † | dagger |~| &rdquo; | ” | right double quote | +| &Dagger; | ‡ | double dagger |~| &laquo; | « | left angle quote | +| &para; | ¶ | paragraph sign |~| &raquo; | » | right angle quote | +| &sect; | § | section sign |~| &times; | × | multiplication symbol | +| &uarr; | ↑ | up arrow |~| &darr; | ↓ | down arrow | +| &larr; | ← | left arrow |~| &rarr; | → | right arrow | +| &lArr; | ⇐ | double left arrow |~| &rArr; | ⇒ | double right arrow | +| &harr; | ↔ | left right arrow |~| &hArr; | ⇔ | double left right arrow | +!"""Accented Characters""" +The table below shows how accented characters can be built up by subsituting the underscore (_) into the corresponding character: +|>|>|>|>|>|>|>|>|>|>|>|>|>|>|>|>|>| !Accented Characters | +| grave accent | &_grave; | À | à | È | è | Ì | ì | Ò | ò | Ù | ù |   |   |   |   |   |   | +| acute accent | &_acute; | Á | á | É | é | Í | í | Ó | ó | Ú | ú |   |   | Ý | ý |   |   | +| circumflex accent | &_circ; | Â | â | Ê | ê | Î | î | Ô | ô | Û | û |   |   |   |   |   |   | +| umlaut mark | &_uml; | Ä | ä | Ë | ë | Ï | ï | Ö | ö | Ü | ü |   |   | Ÿ | ÿ |   |   | +| tilde | &_tilde; | Ã | ã |   |   |   |   | Õ | õ |   |   | Ñ | ñ |   |   |   |   | +| ring | &_ring; | Å | å |   |   |   |   |   |   |   |   |   |   |   |   |   |   | +| slash | &_slash; |   |   |   |   |   |   | Ø | ø |   |   |   |   |   |   |   |   | +| cedilla | &_cedil; |   |   |   |   |   |   |   |   |   |   |   |   |   |   | Ç | ç | diff --git a/editions/classicparserdemo/tiddlers/HTML Formatting.tid b/editions/classicparserdemo/tiddlers/HTML Formatting.tid new file mode 100644 index 000000000..8cd4aafc8 --- /dev/null +++ b/editions/classicparserdemo/tiddlers/HTML Formatting.tid @@ -0,0 +1,40 @@ +_hash: 1738085855a64048d0d8bb2d3eda1d7f7527e0b5 +created: 20130212225913000 +creator: tobibeer +modified: 20140415163847476 +modifier: andrewstern +server.bag: tiddlywiki_public +server.content-type: +server.etag: "tiddlywiki_public/HTML%20Formatting/1335265:8840437d314e281d82669c312d1129b933760b5a" +server.host: http://tiddlywiki.org +server.page.revision: 1335265 +server.permissions: read +server.recipe: tiddlywiki_public +server.title: HTML Formatting +server.type: tiddlyweb +server.workspace: bags/tiddlywiki_public +tags: Formatting +title: HTML Formatting +type: text/x-tiddlywiki + +!Summary +TiddlyWiki provides support for rendering pure HTML markup. To do this, simply wrap your HTML code in {{{your html markup goes here}}}. This way you are able to use embed code using iFrames often suggested by popular media sites like ~YouTube. +!!"""Embedded HTML""" +{{{ + +any
+valid xhtml + +}}} +any
valid xhtml +!!"""Embedded iFrame""" +{{{ + +