Skip to content

Commit

Permalink
Skips replacement for fences inside list_blocks
Browse files Browse the repository at this point in the history
Affects both markdown v1 and v2.
Skips template replacement for elements that are nested inside list_blocks,
which break parsing and compiling step.

Example:
1. List
   1. ```
      code
      ```
  • Loading branch information
Jason authored and Jason committed Nov 14, 2017
1 parent c9dfcd4 commit fb2428e
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 2 deletions.
2 changes: 1 addition & 1 deletion openformats/formats/github_markdown.py
Expand Up @@ -215,7 +215,7 @@ def parse(self, content, **kwargs):
curr_pos = 0
for string in (yaml_stringset + block.md_stringset):
string = string_handler(string, template)
if string:
if string and string in template[curr_pos:]:
string_object = OpenString(str(order), string, order=order)
order += 1
stringset.append(string_object)
Expand Down
2 changes: 1 addition & 1 deletion openformats/formats/github_markdown_v2.py
Expand Up @@ -117,7 +117,7 @@ def parse(self, content, **kwargs):
curr_pos = 0
for string in block.md_stringset:
string = string_handler(string, md_template)
if string:
if string and string in template[curr_pos:]:
string_object = OpenString(str(order), string, order=order)
order += 1
stringset.append(string_object)
Expand Down
6 changes: 6 additions & 0 deletions openformats/tests/formats/github_markdown/files/1_el.md
Expand Up @@ -38,6 +38,9 @@ el:_You **can** combine bold and italic_
* el:Item 2
* el:Item 2a
* el:Item 2b
* ```
Item 2c
```

### el:Ordered

Expand All @@ -46,6 +49,9 @@ el:_You **can** combine bold and italic_
1. el:Item 3
1. el:Item 3a
1. el:Item 3b
1. ```
Item 3c
```


## el:Images
Expand Down
6 changes: 6 additions & 0 deletions openformats/tests/formats/github_markdown/files/1_en.md
Expand Up @@ -38,6 +38,9 @@ _You **can** combine bold and italic_
* Item 2
* Item 2a
* Item 2b
* ```
Item 2c
```

### Ordered

Expand All @@ -46,6 +49,9 @@ _You **can** combine bold and italic_
1. Item 3
1. Item 3a
1. Item 3b
1. ```
Item 3c
```


## Images
Expand Down
6 changes: 6 additions & 0 deletions openformats/tests/formats/github_markdown/files/1_tpl.md
Expand Up @@ -34,6 +34,9 @@ custom_vars:
* 26101031d5115f57d3e8c34f2ac1f741_tr
* ac435aa88d7932bc7c26dbe0277119a3_tr
* 311a0516b1c6eb11a28e8deaa5c64c78_tr
* ```
Item 2c
```

### a3575631fc76819748da773b5b0087a4_tr

Expand All @@ -42,6 +45,9 @@ custom_vars:
1. 867da7e2af8e6b2f3aa7213a4080edb3_tr
1. a6c1243676462dae35ed0c9122125d4e_tr
1. 6994d1415b92982eb7cf57740b15b949_tr
1. ```
Item 3c
```


## 061c16448aee6be07e20ab574ef27ea4_tr
Expand Down
6 changes: 6 additions & 0 deletions openformats/tests/formats/github_markdown_v2/files/1_el.md
Expand Up @@ -57,6 +57,9 @@ el:_You **can** combine bold and italic_
* el:Item 2
* el:Item 2a
* el:Item 2b
* ```
Item 2c
```

### el:Ordered

Expand All @@ -65,6 +68,9 @@ el:_You **can** combine bold and italic_
1. el:Item 3
1. el:Item 3a
1. el:Item 3b
1. ```
Item 3c
```


## el:Images
Expand Down
6 changes: 6 additions & 0 deletions openformats/tests/formats/github_markdown_v2/files/1_en.md
Expand Up @@ -60,6 +60,9 @@ _You **can** combine bold and italic_
* Item 2
* Item 2a
* Item 2b
* ```
Item 2c
```

### Ordered

Expand All @@ -68,6 +71,9 @@ _You **can** combine bold and italic_
1. Item 3
1. Item 3a
1. Item 3b
1. ```
Item 3c
```


## Images
Expand Down
Expand Up @@ -56,6 +56,9 @@ _You **can** combine bold and italic_
* Item 2
* Item 2a
* Item 2b
* ```
Item 2c
```

### Ordered

Expand All @@ -64,6 +67,9 @@ _You **can** combine bold and italic_
1. Item 3
1. Item 3a
1. Item 3b
1. ```
Item 3c
```


## Images
Expand Down
6 changes: 6 additions & 0 deletions openformats/tests/formats/github_markdown_v2/files/1_tpl.md
Expand Up @@ -51,6 +51,9 @@ a3575631fc76819748da773b5b0087a4_tr
* 061c16448aee6be07e20ab574ef27ea4_tr
* ea8a5a340cab600d88eea120273c4022_tr
* 944024165d37855a16b48158a491e0a5_tr
* ```
Item 2c
```

### d51c2a7526e97b2e9ba2d86ac075af7c_tr

Expand All @@ -59,6 +62,9 @@ a3575631fc76819748da773b5b0087a4_tr
1. f1c3d12b026ece333653621093d9abe3_tr
1. bb74ac206332955a7b4f5076f55b2e26_tr
1. bc3bd100ff8a56464a05d8f7f8bb7a6d_tr
1. ```
Item 3c
```


## 28e677da01f23106bbe6f32634edae27_tr
Expand Down

0 comments on commit fb2428e

Please sign in to comment.