mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-06-13 09:09:25 +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
|
* List item one
|
||||||
*{{active}} List item two has the class `active`
|
*.active List item two has the class `active`
|
||||||
* List item three
|
* 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) {
|
WikiTextRenderer.prototype.parseClassedRun = function(terminatorRegExp) {
|
||||||
var classRegExp = /\{\{([^\}]*)\}\}/mg,
|
var classRegExp = /\.([^\s\.]+)/mg,
|
||||||
className;
|
classNames = [];
|
||||||
classRegExp.lastIndex = this.pos;
|
classRegExp.lastIndex = this.pos;
|
||||||
var match = classRegExp.exec(this.source);
|
var match = classRegExp.exec(this.source);
|
||||||
if(match && match.index === this.pos) {
|
while(match && match.index === this.pos) {
|
||||||
className = match[1];
|
|
||||||
this.pos = match.index + match[0].length;
|
this.pos = match.index + match[0].length;
|
||||||
|
classNames.push(match[1]);
|
||||||
|
var match = classRegExp.exec(this.source);
|
||||||
}
|
}
|
||||||
var tree = this.parseRun(terminatorRegExp);
|
var tree = this.parseRun(terminatorRegExp);
|
||||||
return {
|
return {
|
||||||
"class": className,
|
"class": classNames.join(" "),
|
||||||
tree: tree
|
tree: tree
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -13,7 +13,7 @@ title: $:/templates/PageTemplate
|
||||||
<!-- Navigation menu -->
|
<!-- Navigation menu -->
|
||||||
* HelloThere
|
* HelloThere
|
||||||
* [[Docs]]
|
* [[Docs]]
|
||||||
*{{divider-vertical}}
|
*.divider-vertical
|
||||||
|
|
||||||
<!-- Search box -->
|
<!-- Search box -->
|
||||||
<form class="form-search">
|
<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
|
* List One
|
||||||
*{{MyClass}} List Two
|
*.MyClass List Two
|
||||||
* List Three
|
* List Three
|
||||||
}}}
|
}}}
|
||||||
|
|
||||||
|
@ -186,7 +186,7 @@ The resulting HTML looks like this:
|
||||||
The same syntax can be used with headings:
|
The same syntax can be used with headings:
|
||||||
|
|
||||||
{{{
|
{{{
|
||||||
!{{myStyle}} This heading has the class `myStyle`
|
!.myStyle This heading has the class `myStyle`
|
||||||
}}}
|
}}}
|
||||||
|
|
||||||
! Typographic Features
|
! Typographic Features
|
||||||
|
@ -288,4 +288,4 @@ Generates the results:
|
||||||
This is in red!
|
This is in red!
|
||||||
@@
|
@@
|
||||||
|
|
||||||
See StyleBlockWikiText for more details.
|
See StyleBlockWikiText for more details.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user