Skip to content

Commit

Permalink
fix_too_many_endif_buggy_43 (#35)
Browse files Browse the repository at this point in the history
fix_too_many_endif_buggy : issue 43
  • Loading branch information
philippe-levan authored Apr 12, 2024
1 parent d6ec113 commit 76e31a6
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 3 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,9 @@ For trying to fix these problems, you can try:

<a name="versions"></a>Versions
-------------------------------

- v1.6.1 : 2024-04-12 : bugfix
- fix the issue https://github.com/Probesys/lotemplate/issues/34 : too many endif buggy
- v1.6.0 : 2024-04-11
- allow put variables inside headers and footers
- fix a bug when a variable is both inside the text content and inside a table (it should not arrive, but it is fixed)
Expand Down
8 changes: 5 additions & 3 deletions lotemplate/Statement/IfStatement.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,11 @@ class IfStatement:
end_regex = r'\[\s*endif\s*\]'

start_regex_light = r"""
\[\s*if\s* # [if detection
(?:(?:.*?)\[\s*for(?:.*?)\])? # [foritem xxx] et [forindex] detection
(?:.*?) # anything but not too greedy
\[\s*if\s* # [if detection
(?:[^\[\]]*) # anything before the foritem or forindex
# ex: [if $foo.[forindex] == PP]
(?:\[\s*for(?:.*?)\])? # [foritem xxx] et [forindex] detection
(?:[^\]]*) # anything but not too greedy
\]
"""
# remove comments, spaces and newlines
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Test SAS

nom= nom1, titre=titre1 ;


21 changes: 21 additions & 0 deletions lotemplate/unittest/files/content/too_many_endif_strange.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"odoo(coop_forme_juridique)": {
"type": "text",
"value": "SAS"
},
"odoo(mandataires_sas)": {
"type": "array",
"value": [
{
"type": "PP",
"nom": "nom1",
"titre": "titre1"
},
{
"type": "type2",
"nom": "nom2",
"titre": "titre2"
}
]
}
}
Binary file not shown.
3 changes: 3 additions & 0 deletions lotemplate/unittest/test_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,5 +131,8 @@ def test_counter(self):
def test_text_var_in_header(self):
self.assertTrue(compare_files('text_var_in_header', 'pdf'))

def test_too_many_endif_strange(self):
self.assertTrue(compare_files('too_many_endif_strange'))

def test_debug(self):
self.assertTrue(compare_files('debug'))

0 comments on commit 76e31a6

Please sign in to comment.