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
5 changes: 3 additions & 2 deletions src/convert/divOrPTagsHandler.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
module.exports = {
name: 'dirOrPTagsHandler',
checkIsAllowed: (context, {tag}) => ['div', 'p'].includes(tag),
checkIsAllowed: (context, {tag}) => ['div', 'p', 'section'].includes(tag),
after: (context) => {
context.commands.push({name: 'newLine'});
return context;
},
sanitizeHtml: {
allowedTags: [ 'div', 'p' ],
allowedTags: [ 'div', 'p', 'section' ],
allowedAttributes: {
p: [ 'style' ],
div: [ 'style' ],
section: [ 'style' ],
},
},
};
21 changes: 21 additions & 0 deletions test/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,27 @@ me</p>

assert.deepStrictEqual(await convert(template), exptectedResult);
});

it('section tag works like div tag', async () => {
const template = `
<section>section content</section>
<div>div content</div>
<section style="font-weight: bold">bold section</section>
`;

const exptectedResult = [
{name: 'print', data: 'section content'},
{name: 'newLine'},
{name: 'print', data: 'div content'},
{name: 'newLine'},
{name: 'bold', data: true},
{name: 'print', data: 'bold section'},
{name: 'bold', data: false},
{name: 'newLine'},
];

assert.deepStrictEqual(await convert(template), exptectedResult);
});


it('has special treatment for simple table', async () => {
Expand Down