diff options
author | John McLear <john@mclear.co.uk> | 2015-01-24 02:24:10 +0000 |
---|---|---|
committer | John McLear <john@mclear.co.uk> | 2015-01-24 02:24:10 +0000 |
commit | 4ecf0dfad2636a7d4d73dcda1bb51d1ad1a7eec7 (patch) | |
tree | c0749b7ad9815fb225d9fe5dcee4a54962898eb0 | |
parent | 4fa47ea969c0fbcef45d450b41613c4f3a263dac (diff) | |
download | etherpad-lite-4ecf0dfad2636a7d4d73dcda1bb51d1ad1a7eec7.zip |
docs for export HTML
-rw-r--r-- | doc/api/hooks_server-side.md | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/doc/api/hooks_server-side.md b/doc/api/hooks_server-side.md index 32e76ae7..c7e7a43a 100644 --- a/doc/api/hooks_server-side.md +++ b/doc/api/hooks_server-side.md @@ -247,6 +247,30 @@ Things in context: This hook will allow a plug-in developer to re-write each line when exporting to HTML. +Example: +``` +var Changeset = require("ep_etherpad-lite/static/js/Changeset"); + +exports.getLineHTMLForExport = function (hook, context) { + var header = _analyzeLine(context.attribLine, context.apool); + if (header) { + return "<" + header + ">" + context.lineContents + "</" + header + ">"; + } +} + +function _analyzeLine(alineAttrs, apool) { + var header = null; + if (alineAttrs) { + var opIter = Changeset.opIterator(alineAttrs); + if (opIter.hasNext()) { + var op = opIter.next(); + header = Changeset.opAttributeValue(op, 'heading', apool); + } + } + return header; +} +``` + ## stylesForExport Called from: src/node/utils/ExportHtml.js |