summaryrefslogtreecommitdiff
path: root/doc/api
diff options
context:
space:
mode:
authorJohn McLear <john@mclear.co.uk>2015-01-24 02:24:10 +0000
committerJohn McLear <john@mclear.co.uk>2015-01-24 02:24:10 +0000
commit4ecf0dfad2636a7d4d73dcda1bb51d1ad1a7eec7 (patch)
treec0749b7ad9815fb225d9fe5dcee4a54962898eb0 /doc/api
parent4fa47ea969c0fbcef45d450b41613c4f3a263dac (diff)
downloadetherpad-lite-4ecf0dfad2636a7d4d73dcda1bb51d1ad1a7eec7.zip
docs for export HTML
Diffstat (limited to 'doc/api')
-rw-r--r--doc/api/hooks_server-side.md24
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