-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4950 from mkslanc/bibtex-mode
BibTeX mode
- Loading branch information
Showing
11 changed files
with
247 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
@Comment{ | ||
@Book{tes03, | ||
author = {John Smith}, | ||
title = {Cooking}, | ||
publisher = {Culinary Expert}, | ||
year = 1890 | ||
} | ||
} | ||
@String(mar = "march") | ||
|
||
@Book{sweig-42, | ||
Author = { Stefan Sweig }, | ||
title = { The impossible book }, | ||
publisher = { Dead Poet Society}, | ||
year = 1942, | ||
month = mar | ||
} | ||
|
||
@String {firstname = "John"} | ||
@String {lastname = "Smith"} | ||
@String {email = firstname # "." # lastname # "@imag.en"} | ||
|
||
@Article{key01, | ||
title = { The history of @ sign } | ||
} | ||
|
||
Everything " " outside {entries} is treated as comment in BibTeX. | ||
@Article{key03, | ||
title = "A {bunch {of} braces {in}} title" | ||
} | ||
|
||
@preamble {"This bibliography was generated on \today"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
"use strict"; | ||
|
||
var oop = require("../lib/oop"); | ||
var TextMode = require("./text").Mode; | ||
var BibTeXHighlightRules = require("./bibtex_highlight_rules").BibTeXHighlightRules; | ||
var FoldMode = require("./folding/cstyle").FoldMode; | ||
|
||
var Mode = function() { | ||
this.HighlightRules = BibTeXHighlightRules; | ||
this.foldingRules = new FoldMode(); | ||
}; | ||
oop.inherits(Mode, TextMode); | ||
|
||
(function() { | ||
this.$id = "ace/mode/bibtex"; | ||
}).call(Mode.prototype); | ||
|
||
exports.Mode = Mode; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,184 @@ | ||
"use strict"; | ||
|
||
var oop = require("../lib/oop"); | ||
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; | ||
|
||
var BibTeXHighlightRules = function() { | ||
// regexp must not have capturing parentheses. Use (?:) instead. | ||
// regexps are ordered -> the first match is used | ||
|
||
this.$rules = { | ||
start: [ | ||
{ | ||
token: "comment", | ||
regex: /@Comment\{/, | ||
stateName: "bibtexComment", | ||
push: [ | ||
{ | ||
token: "comment", | ||
regex: /}/, | ||
next: "pop" | ||
}, { | ||
token: "comment", | ||
regex: /\{/, | ||
push: "bibtexComment" | ||
}, { | ||
defaultToken: "comment" | ||
} | ||
] | ||
}, { | ||
token: [ | ||
"keyword", "text", "paren.lparen", "text", "variable", "text", "keyword.operator" | ||
], | ||
regex: /(@String)(\s*)(\{)(\s*)([a-zA-Z]*)(\s*)(=)/, | ||
push: [ | ||
{ | ||
token: "paren.rparen", | ||
regex: /\}/, | ||
next: "pop" | ||
}, { | ||
include: "#misc" | ||
}, { | ||
defaultToken: "text" | ||
} | ||
] | ||
}, { | ||
token: [ | ||
"keyword", "text", "paren.lparen", "text", "variable", "text", "keyword.operator" | ||
], | ||
regex: /(@String)(\s*)(\()(\s*)([a-zA-Z]*)(\s*)(=)/, | ||
push: [ | ||
{ | ||
token: "paren.rparen", | ||
regex: /\)/, | ||
next: "pop" | ||
}, { | ||
include: "#misc" | ||
}, { | ||
defaultToken: "text" | ||
} | ||
] | ||
}, { | ||
token: [ | ||
"keyword", "text", "paren.lparen" | ||
], | ||
regex: /(@preamble)(\s*)(\()/, | ||
push: [ | ||
{ | ||
token: "paren.rparen", | ||
regex: /\)/, | ||
next: "pop" | ||
}, { | ||
include: "#misc" | ||
}, { | ||
defaultToken: "text" | ||
} | ||
] | ||
}, { | ||
token: [ | ||
"keyword", "text", "paren.lparen" | ||
], | ||
regex: /(@preamble)(\s*)(\{)/, | ||
push: [ | ||
{ | ||
token: "paren.rparen", | ||
regex: /\}/, | ||
next: "pop" | ||
}, { | ||
include: "#misc" | ||
}, { | ||
defaultToken: "text" | ||
} | ||
] | ||
}, { | ||
token: [ | ||
"keyword", "text", "paren.lparen", "text", "support.class" | ||
], | ||
regex: /(@[a-zA-Z]+)(\s*)(\{)(\s*)([\w-]+)/, | ||
push: [ | ||
{ | ||
token: "paren.rparen", | ||
regex: /\}/, | ||
next: "pop" | ||
}, { | ||
token: [ | ||
"variable", "text", "keyword.operator" | ||
], | ||
regex: /([a-zA-Z0-9\!\$\&\*\+\-\.\/\:\;\<\>\?\[\]\^\_\`\|]+)(\s*)(=)/, | ||
push: [ | ||
{ | ||
token: "text", | ||
regex: /(?=[,}])/, | ||
next: "pop" | ||
}, { | ||
include: "#misc" | ||
}, { | ||
include: "#integer" | ||
}, { | ||
defaultToken: "text" | ||
} | ||
] | ||
}, { | ||
token: "punctuation", | ||
regex: /,/ | ||
}, { | ||
defaultToken: "text" | ||
} | ||
] | ||
}, { | ||
defaultToken: "comment" | ||
} | ||
], | ||
"#integer": [ | ||
{ | ||
token: "constant.numeric.bibtex", | ||
regex: /\d+/ | ||
} | ||
], | ||
"#misc": [ | ||
{ | ||
token: "string", | ||
regex: /"/, | ||
push: "#string_quotes" | ||
}, { | ||
token: "paren.lparen", | ||
regex: /\{/, | ||
push: "#string_braces" | ||
}, { | ||
token: "keyword.operator", | ||
regex: /#/ | ||
} | ||
], | ||
"#string_braces": [ | ||
{ | ||
token: "paren.rparen", | ||
regex: /\}/, | ||
next: "pop" | ||
}, { | ||
token: "invalid.illegal", | ||
regex: /@/ | ||
}, { | ||
include: "#misc" | ||
}, { | ||
defaultToken: "string" | ||
} | ||
], | ||
"#string_quotes": [ | ||
{ | ||
token: "string", | ||
regex: /"/, | ||
next: "pop" | ||
}, { | ||
include: "#misc" | ||
}, { | ||
defaultToken: "string" | ||
} | ||
] | ||
}; | ||
|
||
this.normalizeRules(); | ||
}; | ||
|
||
oop.inherits(BibTeXHighlightRules, TextHighlightRules); | ||
|
||
exports.BibTeXHighlightRules = BibTeXHighlightRules; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,4 @@ | ||
define(function(require, exports, module) { | ||
"use strict"; | ||
|
||
exports.snippetText = require("../requirejs/text!./%modeName%.snippets"); | ||
exports.scope = "%modeName%"; | ||
|
||
}); | ||
exports.scope = "%modeName%"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters