// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE
if (typeof exports == "object" && typeof module == "object")
mod(require("../../lib/codemirror"));
else if (typeof define == "function" && define.amd)
define(["../../lib/codemirror"], mod);
})(function(CodeMirror) {
CodeMirror.defineMode('troff', function() {
function tokenBase(stream) {
if (stream.eatSpace()) return null;
if (stream.match('fB') || stream.match('fR') || stream.match('fI') ||
stream.match('u') || stream.match('d') ||
stream.match('%') || stream.match('&')) {
if (stream.match('m[')) {
if (stream.match('s+') || stream.match('s-')) {
stream.eatWhile(/[\d-]/);
if (stream.match('\(') || stream.match('*\(')) {
stream.eatWhile(/[\w-]/);
if (sol && (ch === '.' || ch === '\'')) {
if (stream.eat('\\') && stream.eat('\"')) {
if (stream.match('B ') || stream.match('I ') || stream.match('R ')) {
if (stream.match('TH ') || stream.match('SH ') || stream.match('SS ') || stream.match('HP ')) {
if ((stream.match(/[A-Z]/) && stream.match(/[A-Z]/)) || (stream.match(/[a-z]/) && stream.match(/[a-z]/))) {
stream.eatWhile(/[\w-]/);
var cur = stream.current();
return words.hasOwnProperty(cur) ? words[cur] : null;
function tokenize(stream, state) {
return (state.tokens[0] || tokenBase) (stream, state);
startState: function() {return {tokens:[]};},
token: function(stream, state) {
return tokenize(stream, state);
CodeMirror.defineMIME('text/troff', 'troff');
CodeMirror.defineMIME('text/x-troff', 'troff');
CodeMirror.defineMIME('application/x-troff', 'troff');