diff options
author | Alexander Sulfrian <alex@spline.inf.fu-berlin.de> | 2016-01-11 04:26:42 +0100 |
---|---|---|
committer | Alexander Sulfrian <alex@spline.inf.fu-berlin.de> | 2016-01-11 04:26:42 +0100 |
commit | 735a3379c508a9fed2af68d41d1204d6a31061db (patch) | |
tree | 00592723f76e15dfee1e7f057ab2bcd033bc4447 /index.js | |
parent | 33b97da914105927bc5800224b9bab0ad1d312c6 (diff) | |
download | ep_headline_buttons-master.tar.gz ep_headline_buttons-master.tar.bz2 ep_headline_buttons-master.zip |
Diffstat (limited to 'index.js')
-rw-r--r-- | index.js | 35 |
1 files changed, 35 insertions, 0 deletions
@@ -11,4 +11,39 @@ exports.eejsBlock_styles = function (hook_name, args, cb) { return cb(); } +exports.getLineHTMLForExport = function (hook, ctx) { + function _analyzeLine(lineAttrs, pool) { + if (lineAttrs) { + var opIter = Changeset.opIterator(lineAttrs); + if (opIter.hasNext()) { + var op = opIter.next(); + return Changeset.opAttributeValue(op, 'headline_buttons', pool); + } + } + } + function _getStyle(tag) { + switch (tag) { + case 'h1': + return 'margin: 0; line-height: 1.5em; font-size: 2em'; + case 'h2': + return 'margin: 0; line-height: 1.5em; font-size: 1.5em'; + case 'h3': + return 'margin: 0; line-height: 1.5em; font-size: 1.17em'; + case 'h4': + return 'margin: 0; line-height: 1.5em'; + case 'h5': + return 'margin: 0; line-height: 1.5em; font-size: 0.83em'; + case 'h6': + return 'margin: 0; line-height: 1.5em; font-size: 0.75em'; + } + + return ''; + } + + var tag = _analyzeLine(ctx.attribLine, ctx.apool); + if (tag) { + var style = _getStyle(tag); + return "<" + tag + " style=\"" + style + "\">" + ctx.text.substring(1) + "</" + tag + ">"; + } +} |