> lookaheadRegExp: /^(?:(?:(\*)|(#)|(;)|(:))+)/mg,
The "list" lookaheadRegExp is used to identify the "type" of a list.
eg: ol, ul, ...
Where
lookaheadMatch[1] is "ul"
lookaheadMatch[2] is "ol"
...
You can see this in formatters.js line 153ff inside the while().
lookaheadRegExp: /^(?:(?:(\*)|(#)|(;)|(:))+)/mg,
means:
^ // Assert position at the beginning of a line (at
beginning of the string or after a line break character)
(?: // Match the regular expression below
(?: // Match the regular expression below
// Match either the regular expression
below (attempting the next alternative only if this one fails)
( // Match the regular expression below and
capture its match into backreference number 1
\\* // Match the character “*” literally
)
| // Or match regular expression number 2 below
(attempting the next alternative only if this one fails)
( // Match the regular expression below and
capture its match into backreference number 2
# // Match the character “#” literally
)
| // Or match regular expression number 3 below
(attempting the next alternative only if this one fails)
( // Match the regular expression below and
capture its match into backreference number 3
; // Match the character “;” literally
)
| // Or match regular expression number 4 below
(the entire group fails if this one fails to match)
( // Match the regular expression below and
capture its match into backreference number 4
: // Match the character “:” literally
)
)+ // Between one and unlimited times, as many times
as possible, giving back as needed (greedy)
)
eg:
* list text .. lookaheadMatch[1] contains "*"
** list text .. lookaheadMatch[1] contains "**"
# list text .. lookaheadMatch[2] contains "#"
## list text .. "##"
; list text .. lookaheadMatch[3] -> ";"
: list text .. lookaheadMatch[4] -> ";"
=========
Now back to your needs :)
I did think a bit about the match. It doesn't need to change :)
because the start of a list is * or *? or *! It just has to identify
the "*" which it does allready.
The lookahead needs some tweaking:
*! some text
**? some text
* should work too :)
lookaheadMatch : "^(?:(?:(\\*)|(#)|(;)|(:))+([!?]?))"
([!?]?) .. see the new stuff near the end.
( ) ... creates a new array element in lookahead -> [5]
[ ] ... match one char, present in the list
[!?] .. ! and ? are identified
[!?]? .. second ? makes the list in front optional. which is needed,
because the "old list format" has to work too .)
([!?]?) sw created description.
the new stuff only:
( // Match the regular expression below and capture
its match into backreference number 5
[!?] // Match a single character present in the
list “!?”
? // Between zero and one times, as many
times as possible, giving back as needed (greedy)
)
*! list text .. lookaheadMatch[1] "*" [5] = "!"
##? list text .. lookaheadMatch[2] "##" [5] = "?"
Now lookaheadMatch[5] contains either ! or ? which can be used to
create a new eg: itemStyle variable inside the formatters.js - list -
while()
Depending on lookaheadMatch[5] the createTiddlyElement(..,
itemType, ...) should get a new parameter, that defines the class="xy"
and use a CSS to define the style using the StyleSheet mechanism
described at "a list appart" [1].
I hope, this isn't too much info. But it shows, a way, how I think it
could work, without actually writing the program.
For my general TW formatting thoughts, I'll start a new thread.
have fun!
mario
[1] http://www.alistapart.com/articles/taminglists/
--
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.