1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-06-25 23:03:15 +00:00

Added wikitext for m- and n-dashes

This commit is contained in:
Jeremy Ruston 2012-06-05 16:33:35 +01:00
parent ca8cf1a386
commit 03da553c3b
3 changed files with 31 additions and 1 deletions

View File

@ -0,0 +1,28 @@
/*\
title: $:/core/modules/parsers/newwikitextparser/rules/dash.js
type: application/javascript
module-type: wikitextrule
Wiki text run rule for HTML entities
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
exports.name = "dash";
exports.runParser = true;
exports.regExpString = "-{2,3}(?=\\s)";
exports.parse = function(match,isBlock) {
this.pos = match.index + match[0].length;
match = /(-{2,3})/mg.exec(match[0]);
var dash = match[0].length === 2 ? "–" : "—";
return [$tw.Tree.Entity(dash)];
};
})();

View File

@ -12,7 +12,7 @@ store.addTiddler(new Tiddler(storyTiddler,{text: navigateTo + "\n" + s
dependentAll: false
}</pre><p>The <code>tiddlers</code> field is a hashmap of the title of each tiddler that is linked or included in the current one. The value is <code>true</code> if the tiddler is a <em>'fat'</em> dependency (ie the text is included in some way) or <code>false</code> if the tiddler is a <em><code>skinny</code></em> dependency.</p><p>The <code>dependentAll</code> field is used to indicate that the tiddler contains a macro that scans the entire pool of tiddlers (for example the <code>&lt;&lt;list&gt;&gt;</code> macro), and is potentially dependent on any of them. The effect is that the tiddler should be rerendered whenever any other tiddler changes.</p><h1> Rendering</h1><p>The <code>parseTree.compile(type)</code> method returns a renderer object that contains a <a class='tw-tiddlylink tw-tiddlylink-internal tw-tiddlylink-missing' href='JavaScript'>JavaScript</a> function that generates the new representation of the original parsed text.</p><p>The renderer is invoked as follows:</p><pre class='javascript-source'><span class='javascript-keyword'>var</span> <span class='javascript-identifier'>renderer</span> <span class='javascript-punctuator'>=</span> <span class='javascript-identifier'>parseTree</span><span class='javascript-punctuator'>.</span><span class='javascript-identifier'>compile</span><span class='javascript-punctuator'>(</span><span class='javascript-string'>&quot;text/html&quot;</span><span class='javascript-punctuator'>)</span><span class='javascript-punctuator'>;</span>
<span class='javascript-keyword'>var</span> <span class='javascript-identifier'>html</span> <span class='javascript-punctuator'>=</span> <span class='javascript-identifier'>renderer</span><span class='javascript-punctuator'>.</span><span class='javascript-identifier'>render</span><span class='javascript-punctuator'>(</span><span class='javascript-identifier'>tiddler</span><span class='javascript-punctuator'>,</span><span class='javascript-identifier'>store</span><span class='javascript-punctuator'>)</span><span class='javascript-punctuator'>;</span>
</pre><p>The <code>tiddler</code> parameter to the <code>render</code> method identifies the tiddler that is acting as the context for this rendering -- for example, it provides the fields displayed by the <code>&lt;&lt;view&gt;&gt;</code> macro. The <code>store</code> parameter is used to resolve any references to other tiddlers.</p><h1> Rerendering</h1><p>When rendering to the HTML/SVG DOM in the browser, <a class='tw-tiddlylink tw-tiddlylink-internal tw-tiddlylink-missing' href='TiddlyWiki5'>TiddlyWiki5</a> also allows a previous rendering to be selectively updated in response to changes in dependent tiddlers. At the moment, only the <a class='tw-tiddlylink tw-tiddlylink-internal tw-tiddlylink-missing' href='WikiTextRenderer'>WikiTextRenderer</a> supports rerendering.</p><p>The rerender method on the renderer is called as follows:</p><pre>var node = document.getElementById(&quot;myNode&quot;);
</pre><p>The <code>tiddler</code> parameter to the <code>render</code> method identifies the tiddler that is acting as the context for this rendering &ndash; for example, it provides the fields displayed by the <code>&lt;&lt;view&gt;&gt;</code> macro. The <code>store</code> parameter is used to resolve any references to other tiddlers.</p><h1> Rerendering</h1><p>When rendering to the HTML/SVG DOM in the browser, <a class='tw-tiddlylink tw-tiddlylink-internal tw-tiddlylink-missing' href='TiddlyWiki5'>TiddlyWiki5</a> also allows a previous rendering to be selectively updated in response to changes in dependent tiddlers. At the moment, only the <a class='tw-tiddlylink tw-tiddlylink-internal tw-tiddlylink-missing' href='WikiTextRenderer'>WikiTextRenderer</a> supports rerendering.</p><p>The rerender method on the renderer is called as follows:</p><pre>var node = document.getElementById(&quot;myNode&quot;);
var renderer = parseTree.compile(&quot;text/html&quot;);
myNode.innerHTML = renderer.render(tiddler,store);
// And then, later:

View File

@ -9,6 +9,8 @@ One two three four. With a link to HelloThere. And a link to TiddlyWiki and Tidd
Here's an http link: http://www.google.com/, and a suppressed link: ~http://www.apple.com/.
This is a series -- of dashes --- that are of different ---- sizes!
Here's a paragraph with an embedded macro <<image "Motovun Jack.jpg">> and that was it.
{{{