Improve syntax for classed runs

This commit is contained in:
Jeremy Ruston 2012-11-29 17:23:46 +00:00
parent 97f6314dbb
commit 6d09b2fb9c
5 changed files with 14 additions and 13 deletions

View File

@ -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
}}}

View File

@ -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
};
};

View File

@ -13,7 +13,7 @@ title: $:/templates/PageTemplate
<!-- Navigation menu -->
* HelloThere
* [[Docs]]
*{{divider-vertical}}
*.divider-vertical
<!-- Search box -->
<form class="form-search">

View File

@ -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.

File diff suppressed because one or more lines are too long