Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ep.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"eejsBlock_editbarMenuLeft": "ep_headings2/index",
"collectContentPre": "ep_headings2/static/js/shared",
"collectContentPost": "ep_headings2/static/js/shared",
"ccRegisterBlockElements": "ep_headings2/static/js/shared",
"getLineHTMLForExport": "ep_headings2/index",
"stylesForExport" : "ep_headings2/index"
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"url": "https://github.com/ether/ep_headings2/issues"
},
"dependencies": {
"ep_plugin_helpers": "^0.3.2"
"ep_plugin_helpers": "^0.5.2"
},
"devDependencies": {
"eslint": "^8.57.1",
Expand Down
1 change: 1 addition & 0 deletions static/js/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ const headings = lineAttribute({attr: 'heading', tags});

exports.collectContentPre = headings.collectContentPre;
exports.collectContentPost = headings.collectContentPost;
exports.ccRegisterBlockElements = headings.ccRegisterBlockElements;
31 changes: 31 additions & 0 deletions static/tests/backend/specs/exportHTML.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,35 @@ describe('ep_headings2 - export headings to HTML', function () {
}
});
});

context('when pad has adjacent <h1> and <h2> with no separator', function () {
// Regression for ether/etherpad#7568 round-trip. Without server-side
// ccRegisterBlockElements registered for the heading tags,
// contentcollector treats <h1>/<h2> as inline and adjacent ones
// merge into a single pad line.
before(async function () {
html = () => buildHTML('<h1>Alpha</h1><h2>Beta</h2>');
});

it('keeps each heading on its own line', function (done) {
const expected = /<h1>\s*Alpha\s*<\/h1>[\s\S]*<h2>\s*Beta\s*<\/h2>/;
generateJWTToken().then((token) => {
agent.get(getHTMLEndPointFor(padID))
.set('Authorization', token)
.end((err, res) => {
if (err) return done(err);
const out = res.body.data.html;
if (out.search(expected) === -1) {
return done(new Error(
`Adjacent headings merged or missing in: ${out}`));
}
if (out.search(/AlphaBeta/) !== -1) {
return done(new Error(
`Headings merged into one line: ${out}`));
}
done();
});
}).catch(done);
});
});
});
Loading