mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-23 10:07:19 +00:00
Improve syntax for classed runs
This commit is contained in:
parent
97f6314dbb
commit
6d09b2fb9c
@ -35,7 +35,7 @@ A CSS class can be applied to a list item as follows:
|
||||
|
||||
{{{
|
||||
* List item one
|
||||
*{{active}} List item two has the class `active`
|
||||
*.active List item two has the class `active`
|
||||
* List item three
|
||||
}}}
|
||||
|
||||
|
@ -238,20 +238,21 @@ WikiTextRenderer.prototype.parseRunTerminated = function(terminatorRegExp,option
|
||||
};
|
||||
|
||||
/*
|
||||
Parse a run of text preceded by an optional class specifier `{{class}}`
|
||||
Parse a run of text preceded by an optional class specifier `.classname`
|
||||
*/
|
||||
WikiTextRenderer.prototype.parseClassedRun = function(terminatorRegExp) {
|
||||
var classRegExp = /\{\{([^\}]*)\}\}/mg,
|
||||
className;
|
||||
var classRegExp = /\.([^\s\.]+)/mg,
|
||||
classNames = [];
|
||||
classRegExp.lastIndex = this.pos;
|
||||
var match = classRegExp.exec(this.source);
|
||||
if(match && match.index === this.pos) {
|
||||
className = match[1];
|
||||
while(match && match.index === this.pos) {
|
||||
this.pos = match.index + match[0].length;
|
||||
classNames.push(match[1]);
|
||||
var match = classRegExp.exec(this.source);
|
||||
}
|
||||
var tree = this.parseRun(terminatorRegExp);
|
||||
return {
|
||||
"class": className,
|
||||
"class": classNames.join(" "),
|
||||
tree: tree
|
||||
};
|
||||
};
|
||||
|
@ -13,7 +13,7 @@ title: $:/templates/PageTemplate
|
||||
<!-- Navigation menu -->
|
||||
* HelloThere
|
||||
* [[Docs]]
|
||||
*{{divider-vertical}}
|
||||
*.divider-vertical
|
||||
|
||||
<!-- Search box -->
|
||||
<form class="form-search">
|
||||
|
@ -169,7 +169,7 @@ You can also assign a CSS class to an individual member of a list with this nota
|
||||
|
||||
{{{
|
||||
* List One
|
||||
*{{MyClass}} List Two
|
||||
*.MyClass List Two
|
||||
* List Three
|
||||
}}}
|
||||
|
||||
@ -186,7 +186,7 @@ The resulting HTML looks like this:
|
||||
The same syntax can be used with headings:
|
||||
|
||||
{{{
|
||||
!{{myStyle}} This heading has the class `myStyle`
|
||||
!.myStyle This heading has the class `myStyle`
|
||||
}}}
|
||||
|
||||
! Typographic Features
|
||||
@ -288,4 +288,4 @@ Generates the results:
|
||||
This is in red!
|
||||
@@
|
||||
|
||||
See StyleBlockWikiText for more details.
|
||||
See StyleBlockWikiText for more details.
|
||||
|
Loading…
Reference in New Issue
Block a user