5
if (typeof exports == "object" && typeof module == "object")
6
mod(require("../../lib/codemirror"));
7
else if (typeof define == "function" && define.amd)
8
define(["../../lib/codemirror"], mod);
11
})(function(CodeMirror) {
14
CodeMirror.defineMode('troff', function() {
18
function tokenBase(stream) {
19
if (stream.eatSpace()) return null;
21
var sol = stream.sol();
22
var ch = stream.next();
25
if (stream.match('fB') || stream.match('fR') || stream.match('fI') ||
26
stream.match('u') || stream.match('d') ||
27
stream.match('%') || stream.match('&')) {
30
if (stream.match('m[')) {
35
if (stream.match('s+') || stream.match('s-')) {
36
stream.eatWhile(/[\d-]/);
39
if (stream.match('\(') || stream.match('*\(')) {
40
stream.eatWhile(/[\w-]/);
45
if (sol && (ch === '.' || ch === '\'')) {
46
if (stream.eat('\\') && stream.eat('\"')) {
51
if (sol && ch === '.') {
52
if (stream.match('B ') || stream.match('I ') || stream.match('R ')) {
55
if (stream.match('TH ') || stream.match('SH ') || stream.match('SS ') || stream.match('HP ')) {
59
if ((stream.match(/[A-Z]/) && stream.match(/[A-Z]/)) || (stream.match(/[a-z]/) && stream.match(/[a-z]/))) {
63
stream.eatWhile(/[\w-]/);
64
var cur = stream.current();
65
return words.hasOwnProperty(cur) ? words[cur] : null;
68
function tokenize(stream, state) {
69
return (state.tokens[0] || tokenBase) (stream, state);
73
startState: function() {return {tokens:[]};},
74
token: function(stream, state) {
75
return tokenize(stream, state);
80
CodeMirror.defineMIME('text/troff', 'troff');
81
CodeMirror.defineMIME('text/x-troff', 'troff');
82
CodeMirror.defineMIME('application/x-troff', 'troff');