2012-05-26 17:30:32 +00:00
|
|
|
/*\
|
2012-06-02 08:54:00 +00:00
|
|
|
title: $:/core/modules/parsers/newwikitextparser/rules/heading.js
|
2012-05-26 17:30:32 +00:00
|
|
|
type: application/javascript
|
2012-05-27 08:19:37 +00:00
|
|
|
module-type: wikitextrule
|
2012-05-26 17:30:32 +00:00
|
|
|
|
2012-06-05 21:54:36 +00:00
|
|
|
Wiki text block rule for headings. For example:
|
|
|
|
|
|
|
|
{{{
|
|
|
|
! Level one heading
|
|
|
|
|
|
|
|
A paragraph in level 1.
|
|
|
|
|
|
|
|
!! Level two heading
|
|
|
|
|
|
|
|
A paragraph in level 2.
|
|
|
|
}}}
|
|
|
|
|
|
|
|
The bang `!` must be the first thing on the line. Any white space before the text of the heading is ignored.
|
2012-05-26 17:30:32 +00:00
|
|
|
|
2012-06-06 09:15:20 +00:00
|
|
|
A CSS can be applied to the heading as follows:
|
|
|
|
|
|
|
|
{{{
|
|
|
|
!{{myClass}} This heading will have the class `myClass`
|
|
|
|
}}}
|
|
|
|
|
2012-05-26 17:30:32 +00:00
|
|
|
\*/
|
|
|
|
(function(){
|
|
|
|
|
|
|
|
/*jslint node: true, browser: true */
|
|
|
|
/*global $tw: false */
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
exports.name = "heading";
|
|
|
|
|
2012-05-26 23:22:58 +00:00
|
|
|
exports.blockParser = true;
|
|
|
|
|
2012-05-26 17:30:32 +00:00
|
|
|
exports.regExpString = "!{1,6}";
|
|
|
|
|
2012-05-28 14:51:52 +00:00
|
|
|
exports.parse = function(match,isBlock) {
|
2012-05-26 17:30:32 +00:00
|
|
|
this.pos = match.index + match[0].length;
|
|
|
|
var classedRun = this.parseClassedRun(/(\r?\n)/mg);
|
|
|
|
return [$tw.Tree.Element("h1",{"class": classedRun["class"]},classedRun.tree)];
|
|
|
|
};
|
|
|
|
|
|
|
|
})();
|