Sha256: d3c53a9811b77ae2384b49a2dc68df43d678c3903cb90a1fb1b4d299c2ce7bdd

Contents?: true

Size: 1.67 KB

Versions: 37

Compression:

Stored size: 1.67 KB

Contents

define(function(require, exports, module) {
"use strict";

var oop = require("../lib/oop");
var TextMode = require("./text").Mode;
var Tokenizer = require("../tokenizer").Tokenizer;
var LatexHighlightRules = require("./latex_highlight_rules").LatexHighlightRules;
var Range = require("../range").Range;

var Mode = function()
{
    this.$tokenizer = new Tokenizer(new LatexHighlightRules().getRules());
};
oop.inherits(Mode, TextMode);

(function() {
    this.toggleCommentLines = function(state, doc, startRow, endRow) {
        // This code is adapted from ruby.js
        var outdent = true;
        
        // LaTeX comments begin with % and go to the end of the line
        var commentRegEx = /^(\s*)\%/;

        for (var i = startRow; i <= endRow; i++) {
            if (!commentRegEx.test(doc.getLine(i))) {
                outdent = false;
                break;
            }
        }

        if (outdent) {
            var deleteRange = new Range(0, 0, 0, 0);
            for (var i = startRow; i <= endRow; i++) {
                var line = doc.getLine(i);
                var m = line.match(commentRegEx);
                deleteRange.start.row = i;
                deleteRange.end.row = i;
                deleteRange.end.column = m[0].length;
                doc.replace(deleteRange, m[1]);
            }
        }
        else {
            doc.indentRows(startRow, endRow, "%");
        }
    };
    
    // There is no universally accepted way of indenting a tex document
    // so just maintain the indentation of the previous line
    this.getNextLineIndent = function(state, line, tab) {
        return this.$getIndent(line);
    };
    
}).call(Mode.prototype);

exports.Mode = Mode;

});

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
gollum-2.4.4 lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/latex.js
gollum-2.4.3 lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/latex.js
gollum-2.4.2 lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/latex.js
gollum-2.4.1 lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/latex.js
gollum-2.4.0 lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/latex.js
gollum-2.3.12 lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/latex.js
gollum-2.3.11 lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/latex.js
gollum-2.3.10 lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/latex.js
gollum-2.3.9 lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/latex.js
gollum-2.3.8 lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/latex.js
gollum-2.3.7 lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/latex.js
gollum-2.3.6 lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/latex.js
gollum-2.3.5 lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/latex.js
gollum-2.3.4 lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/latex.js
gollum-2.3.3 lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/latex.js
gollum-2.3.2 lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/latex.js
gollum-2.3.1 lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/latex.js
gollum-2.3.0 lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/latex.js
gollum-2.2.9 lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/latex.js
gollum-2.2.8 lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/latex.js