Skip to content

Commit

Permalink
Externalized XHTML detection, fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeche committed Nov 19, 2012
1 parent bfb1e5c commit fa4042d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
11 changes: 10 additions & 1 deletion javascript/actionUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,13 +278,22 @@ emmet.define('actionUtils', function(require, _) {
var profile = require('resources').getVariable('profile');
if (!profile) { // no forced profile, guess from content
// html or xhtml?
profile = editor.getContent().search(/<!DOCTYPE[^>]+XHTML/i) != -1 ? 'xhtml': 'html';
profile = this.isXHTML(editor) ? 'xhtml': 'html';
}

return profile;
}

return 'xhtml';
},

/**
* Tries to detect if current document is XHTML one.
* @param {IEmmetEditor} editor
* @returns {Boolean}
*/
isXHTML: function(editor) {
return editor.getContent().search(/<!DOCTYPE[^>]+XHTML/i) != -1;
}
};
});
2 changes: 1 addition & 1 deletion javascript/unittest/tests/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@
test('Wrap With Abbreviation', function() {
var wrap = function(abbr, content) {
content = emmet.require('utils').escapeText(content);
return emmet.require('wrapWithAbbreviation').wrap(abbr, content);
return emmet.require('wrapWithAbbreviation').wrap(abbr, content, 'html', 'plain');
};

editorStub.replaceContent('<br${0} />');
Expand Down
7 changes: 6 additions & 1 deletion javascript/unittest/tests/expandAbbreviation.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@

function runTest() {
var args = _.toArray(arguments);
var result = emmet.expandAbbreviation.apply(emmet, _.initial(args));
var params = _.initial(args);
if (!params[2]) {
params[2] = 'plain';
}

var result = emmet.expandAbbreviation.apply(emmet, params);
result = emmet.require('tabStops').processText(result, {
escape: function(ch) {
return ch;
Expand Down

0 comments on commit fa4042d

Please sign in to comment.