Skip to content

Commit dbd185c

Browse files
authored
Merge pull request #59 from RegioneER/improve_blocks_convertion
improve block conversion
2 parents 7653373 + b306ae7 commit dbd185c

File tree

4 files changed

+22
-9
lines changed

4 files changed

+22
-9
lines changed

CHANGES.rst

+4-1
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@ Changelog
55
3.1.3 (unreleased)
66
------------------
77

8+
- Handle text-larger class in slate2html.
9+
[cekk]
10+
- Do not pretty slate2html output to avoid not needed spaces between tags.
11+
[cekk]
812
- Changed label from Parametro to Dato.
913
[eikichi18]
1014

11-
1215
3.1.2 (2024-12-05)
1316
------------------
1417

src/rer/newsletter/blocks_converter/__init__.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@ def __call__(self, context, blocks, blocks_layout):
3030
if value:
3131
html.append(value)
3232
root = "".join(html)
33-
soup = bs(root, "html.parser") # make BeautifulSoup
34-
return soup.prettify() # prettify the html
33+
34+
# soup = bs(root, "html.parser") # make BeautifulSoup
35+
# return soup.prettify() # prettify the html
36+
return root
3537

3638
def get_blocks(self, context, blocks, blocks_layout):
3739
"""

src/rer/newsletter/blocks_converter/slate2html.py

+11-6
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,21 @@ def serialize(self, element):
3434
:param element:
3535
"""
3636
if "text" in element:
37-
if "\n" not in element["text"]:
38-
return [element["text"]]
39-
40-
return join(E.BR, element["text"].split("\n"))
37+
text_elements = element["text"].split("\n")
38+
if element.get("style-text-larger", False):
39+
text_elements = [
40+
E.SPAN(
41+
x,
42+
**{"class": "text-larger"},
43+
)
44+
for x in text_elements
45+
]
46+
47+
return join(E.BR, text_elements)
4148

4249
if element["type"] == "paragraph":
4350
element["type"] = "p"
4451
tagname = element["type"]
45-
4652
if element.get("data") and tagname not in SLATE_ACCEPTED_TAGS:
4753
handler = self.handle_slate_data_element
4854
else:
@@ -73,7 +79,6 @@ def handle_tag_link(self, element):
7379
children = []
7480
for child in element["children"]:
7581
children += self.serialize(child)
76-
7782
return el(*children, **attributes)
7883

7984
def handle_slate_data_element(self, element):

src/rer/newsletter/browser/message/messagepreview.py

+3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
#footer {
2323
clear: both;
2424
}
25+
.text-larger {
26+
font-size: 1.75em;
27+
}
2528
"""
2629

2730

0 commit comments

Comments
 (0)