2015-10-08 20:16:45 +03:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
import {Pipe} from 'angular2/angular2';
|
|
|
|
import {JsonPointer} from './JsonPointer';
|
2015-10-23 12:03:47 +03:00
|
|
|
import marked from 'marked';
|
|
|
|
|
|
|
|
marked.setOptions({
|
|
|
|
renderer: new marked.Renderer(),
|
|
|
|
gfm: true,
|
|
|
|
tables: true,
|
|
|
|
breaks: false,
|
|
|
|
pedantic: false,
|
|
|
|
smartLists: true,
|
|
|
|
smartypants: false
|
|
|
|
});
|
|
|
|
|
2015-10-08 20:16:45 +03:00
|
|
|
|
|
|
|
@Pipe({
|
|
|
|
name: 'keys'
|
|
|
|
})
|
|
|
|
export class KeysPipe {
|
|
|
|
transform(obj) {
|
|
|
|
return Object.keys(obj);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Pipe({
|
|
|
|
name: 'values'
|
|
|
|
})
|
|
|
|
export class ValuesPipe {
|
|
|
|
transform(obj) {
|
|
|
|
return Object.keys(obj).map(key => obj[key]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Pipe({
|
|
|
|
name: 'jsonPointerEscape'
|
|
|
|
})
|
|
|
|
export class JsonPointerEscapePipe {
|
|
|
|
transform(str) {
|
|
|
|
return JsonPointer.escape(str);
|
|
|
|
}
|
|
|
|
}
|
2015-10-23 12:03:47 +03:00
|
|
|
|
|
|
|
@Pipe({
|
|
|
|
name: 'marked'
|
|
|
|
})
|
|
|
|
export class MarkedPipe {
|
|
|
|
transform(str) {
|
|
|
|
if (!str) return str;
|
|
|
|
return marked(str);
|
|
|
|
}
|
|
|
|
}
|