linestylefilter now uses attributemanager to find lineattributemarkers

This commit is contained in:
Matthias Bartelmeß 2012-04-07 02:14:19 +02:00
parent a0235126e4
commit 2db74150ee
1 changed files with 14 additions and 2 deletions

View File

@ -32,6 +32,8 @@ var Changeset = require('./Changeset');
var hooks = require('./pluginfw/hooks'); var hooks = require('./pluginfw/hooks');
var linestylefilter = {}; var linestylefilter = {};
var _ = require('./underscore'); var _ = require('./underscore');
var AttributeManager = require('./AttributeManager');
linestylefilter.ATTRIB_CLASSES = { linestylefilter.ATTRIB_CLASSES = {
'bold': 'tag:b', 'bold': 'tag:b',
@ -40,6 +42,9 @@ linestylefilter.ATTRIB_CLASSES = {
'strikethrough': 'tag:s' 'strikethrough': 'tag:s'
}; };
var lineAttributeMarker = 'lineAttribMarker';
exports.lineAttributeMarker = lineAttributeMarker;
linestylefilter.getAuthorClassName = function(author) linestylefilter.getAuthorClassName = function(author)
{ {
return "author-" + author.replace(/[^a-y0-9]/g, function(c) return "author-" + author.replace(/[^a-y0-9]/g, function(c)
@ -68,6 +73,8 @@ linestylefilter.getLineStyleFilter = function(lineLength, aline, textAndClassFun
function attribsToClasses(attribs) function attribsToClasses(attribs)
{ {
var classes = ''; var classes = '';
var isLineAttribMarker = false;
Changeset.eachAttribNumber(attribs, function(n) Changeset.eachAttribNumber(attribs, function(n)
{ {
var key = apool.getAttribKey(n); var key = apool.getAttribKey(n);
@ -76,6 +83,9 @@ linestylefilter.getLineStyleFilter = function(lineLength, aline, textAndClassFun
var value = apool.getAttribValue(n); var value = apool.getAttribValue(n);
if (value) if (value)
{ {
if (!isLineAttribMarker && _.indexOf(AttributeManager.lineAttributes, key) >= 0){
isLineAttribMarker = true;
}
if (key == 'author') if (key == 'author')
{ {
classes += ' ' + linestylefilter.getAuthorClassName(value); classes += ' ' + linestylefilter.getAuthorClassName(value);
@ -103,6 +113,8 @@ linestylefilter.getLineStyleFilter = function(lineLength, aline, textAndClassFun
} }
} }
}); });
if(isLineAttribMarker) classes += ' ' + lineAttributeMarker;
return classes.substring(1); return classes.substring(1);
} }