Skip to content

Commit 3bf5284

Browse files
Fixed a bug with an insufficient number of new lines.
1 parent 19ff3a7 commit 3bf5284

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

elementOfHtml.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export class ElementOfHtml {
9292
for (let innerElement of this.innerElements ?? []) {
9393
this.#string += innerElement.string
9494

95-
if (!innerElement.textAfter) {
95+
if (!innerElement.string?.match(/\n *$/gm)) {
9696
this.#string += '\n'
9797
}
9898
}

tests/text.test.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,21 @@ import { CssToHtml } from '../cssToHtml.js'
22
import assert from 'assert'
33
import test from 'node:test'
44

5+
test('New lines are placed correctly', () => {
6+
assert.equal(
7+
new CssToHtml({
8+
css: `
9+
div { /* {{ text inside }} */ }
10+
div i { /* {{ text of i }} after */ }
11+
`,
12+
})
13+
.outputHTML,
14+
15+
`<div> text inside
16+
<i> text of i </i> after
17+
</div>`
18+
)
19+
})
520
test('The text inside the tag must be processed', () => {
621
assert.equal(
722
new CssToHtml({
@@ -64,7 +79,6 @@ test('The text with additional spaces should keep them.', () => {
6479
</div> after text`,
6580
)
6681
})
67-
6882
test('The text should be processed along with the new lines.', () => {
6983
assert.equal(
7084
new CssToHtml({

0 commit comments

Comments
 (0)