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 linestylefilter = {};
var _ = require('./underscore');
var AttributeManager = require('./AttributeManager');
linestylefilter.ATTRIB_CLASSES = {
'bold': 'tag:b',
@ -40,6 +42,9 @@ linestylefilter.ATTRIB_CLASSES = {
'strikethrough': 'tag:s'
};
var lineAttributeMarker = 'lineAttribMarker';
exports.lineAttributeMarker = lineAttributeMarker;
linestylefilter.getAuthorClassName = function(author)
{
return "author-" + author.replace(/[^a-y0-9]/g, function(c)
@ -68,14 +73,19 @@ linestylefilter.getLineStyleFilter = function(lineLength, aline, textAndClassFun
function attribsToClasses(attribs)
{
var classes = '';
var isLineAttribMarker = false;
Changeset.eachAttribNumber(attribs, function(n)
{
var key = apool.getAttribKey(n);
var key = apool.getAttribKey(n);
if (key)
{
var value = apool.getAttribValue(n);
if (value)
{
if (!isLineAttribMarker && _.indexOf(AttributeManager.lineAttributes, key) >= 0){
isLineAttribMarker = true;
}
if (key == 'author')
{
classes += ' ' + linestylefilter.getAuthorClassName(value);
@ -99,10 +109,12 @@ linestylefilter.getLineStyleFilter = function(lineLength, aline, textAndClassFun
key: key,
value: value
}, " ", " ", "");
}
}
}
}
});
if(isLineAttribMarker) classes += ' ' + lineAttributeMarker;
return classes.substring(1);
}