On Sep 12, 8:07 pm, Yakov <[email protected]> wrote:
> There's a header formatter. And a user can write smth like
>
> !!some header with a [[link|linkTarget]]
>
> Now, either the formatter of headers or the wikifier behaves so that
> there's not just a header
>
> <h2>some header with a [[link|linkTarget]]</h2>
>
> is created, but rather the tw-code the header is passed for further
> wikification.
It's the wikifier. Have a look at the Wikifier.prototype.subWikifyTerm
code.
In line 120 you'll see a while(terminatorMatch || formatterMatch)
Inside the while you'll see some if's for terminator match and
formatter match, that decide, if there is some text left to be checked
against the TW formatters. They also calculate the new "start to match
here" indexes, if needed.
If terminator is found, it jumps out and goes on with the text, until
all tiddler.text is matched.
The whole matching thingy is defined at line 117, 119 _and_ 154,155
the same code.
To understand these lines, you have to have a look at js regexp
handling.
Especially the regexpDeffinition.exec(source) and the resulting array
elements
> The header of the formatter is the following [1]:
>
> {
> name: "heading",
> match: "^!{1,6}",
> termRegExp: /(\n)/mg,
> handler: function(w)
> {
> w.subWikifyTerm(createTiddlyElement(w.output,"h" +
> w.matchLength),this.termRegExp);
> }
>
> }
>
> I guess subWikifyTerm somehow continue within the wikification.
see above
> ..But
> what the createTiddlyElement returns and how subWikifyTerm deals with
> that?
createTiddlyElement creates a DOM element. eg: <div>, <span>,
<pre> ....
see: http://tiddlywiki.org/#createTiddlyElement
function createTiddlyElement(parent, element, id, className, text,
attribs)
If an element is created inside the inner functions (subWikify...),
there is no further dealing with it.
> ... By the way, there are subWikifyTerm and subWikifyUnterm methods
> in [2]. Can anyone explain what do these "term" and "unterm" mean?
According to the comment at "Wikifier.prototype.subWikify" it is there
for speed reasons.
https://github.com/TiddlyWiki/tiddlywiki/blob/master/js/Wikifier.js#L61
subWikifyUnterm seems to be called only once (L66) in the whole source
code. Inside subWikify(), which is called by the global wikify()
function. wikify() is used all over the place (15x).
subWikify() is only used in Formatters.js, Wikifier.js and once in
Macros.js (may be an accident :)
So you just need to understand subWikifyTerm, and expect Unterm to be
faster :)
> PS one of the most important formatters that I'd like to create and
> that I keep in mind is the following: instead of treating *** as a
> start of a list item, I'd like to have TW treat ***s where "s" is a
> symbol (or an html-entity) as a start of list item with "s" as a
> marker (imagine "?" or "!" instead of standart • -- very useful
> for mobile TW).
Why is this usefull for mobile TW?
You could just use CSS for this. See [2][3]
hope this helps
-mario
[1] https://github.com/TiddlyWiki/tiddlywiki/blob/master/js/Wikifier.js#L110
[2] https://developer.mozilla.org/en/CSS/list-style
[3] http://www.mediacollege.com/internet/css/ul-list.html
--
You received this message because you are subscribed to the Google Groups
"TiddlyWikiDev" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/tiddlywikidev?hl=en.