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) {
15
"From", "Sender", "Reply-To", "To", "Cc", "Bcc", "Message-ID",
16
"In-Reply-To", "References", "Resent-From", "Resent-Sender", "Resent-To",
17
"Resent-Cc", "Resent-Bcc", "Resent-Message-ID", "Return-Path", "Received"
20
"Date", "Subject", "Comments", "Keywords", "Resent-Date"
23
CodeMirror.registerHelper("hintWords", "mbox", rfc2822.concat(rfc2822NoEmail));
25
var whitespace = /^[ \t]/;
26
var separator = /^From /;
27
var rfc2822Header = new RegExp("^(" + rfc2822.join("|") + "): ");
28
var rfc2822HeaderNoEmail = new RegExp("^(" + rfc2822NoEmail.join("|") + "): ");
29
var header = /^[^:]+:/;
30
var email = /^[^ ]+@[^ ]+/;
31
var untilEmail = /^.*?(?=[^ ]+?@[^ ]+)/;
32
var bracketedEmail = /^<.*?>/;
33
var untilBracketedEmail = /^.*?(?=<.*>)/;
35
function styleForHeader(header) {
36
if (header === "Subject") return "header";
40
function readToken(stream, state) {
43
state.inSeparator = false;
44
if (state.inHeader && stream.match(whitespace)) {
48
state.inHeader = false;
52
if (stream.match(separator)) {
53
state.inHeaders = true;
54
state.inSeparator = true;
59
var emailPermitted = false;
60
if ((match = stream.match(rfc2822HeaderNoEmail)) ||
61
(emailPermitted = true) && (match = stream.match(rfc2822Header))) {
62
state.inHeaders = true;
63
state.inHeader = true;
64
state.emailPermitted = emailPermitted;
65
state.header = match[1];
71
if (state.inHeaders && (match = stream.match(header))) {
72
state.inHeader = true;
73
state.emailPermitted = true;
74
state.header = match[1];
78
state.inHeaders = false;
83
if (state.inSeparator) {
84
if (stream.match(email)) return "link";
85
if (stream.match(untilEmail)) return "atom";
91
var style = styleForHeader(state.header);
93
if (state.emailPermitted) {
94
if (stream.match(bracketedEmail)) return style + " link";
95
if (stream.match(untilBracketedEmail)) return style;
105
CodeMirror.defineMode("mbox", function() {
107
startState: function() {
114
emailPermitted: false,
122
blankLine: function(state) {
123
state.inHeaders = state.inSeparator = state.inHeader = false;
128
CodeMirror.defineMIME("application/mbox", "mbox");