diff --git a/tests/data/html/audio.html b/tests/data/html/audio.html index a344dca..f1372d3 100644 --- a/tests/data/html/audio.html +++ b/tests/data/html/audio.html @@ -1,4 +1,4 @@ -
+
diff --git a/tests/data/html/code_block.html b/tests/data/html/code_block.html index b5aaefd..9d48b41 100644 --- a/tests/data/html/code_block.html +++ b/tests/data/html/code_block.html @@ -1,4 +1,4 @@ -
# Python Program to find the L.C.M. of two input number
+
# Python Program to find the L.C.M. of two input number
 
 def compute_lcm(x, y):
 
diff --git a/tests/data/html/data_attributes.html b/tests/data/html/data_attributes.html
index ed202d1..f389900 100644
--- a/tests/data/html/data_attributes.html
+++ b/tests/data/html/data_attributes.html
@@ -1 +1 @@
-
Sleepy Kitten
Cute Kitty
Happy Kitten
New Kitty
\ No newline at end of file +
Sleepy Kitten
Cute Kitty
Happy Kitten
New Kitty
\ No newline at end of file diff --git a/tests/data/html/document-pdf.html b/tests/data/html/document-pdf.html index 566846d..9b7b052 100644 --- a/tests/data/html/document-pdf.html +++ b/tests/data/html/document-pdf.html @@ -1,4 +1,4 @@ -
+
pdf diff --git a/tests/data/html/embed.html b/tests/data/html/embed.html index 92983f2..e458d48 100644 --- a/tests/data/html/embed.html +++ b/tests/data/html/embed.html @@ -1 +1 @@ -
Extraction
\ No newline at end of file +
Extraction
\ No newline at end of file diff --git a/tests/data/html/heading.html b/tests/data/html/heading.html index e1ef8d9..ecc7505 100644 --- a/tests/data/html/heading.html +++ b/tests/data/html/heading.html @@ -1 +1 @@ -

This is a
word

\ No newline at end of file +

This is a
word

\ No newline at end of file diff --git a/tests/data/html/horizontal_rule.html b/tests/data/html/horizontal_rule.html index b5055ee..396384c 100644 --- a/tests/data/html/horizontal_rule.html +++ b/tests/data/html/horizontal_rule.html @@ -1 +1 @@ -
\ No newline at end of file +

\ No newline at end of file diff --git a/tests/data/html/image.html b/tests/data/html/image.html index f0adfa1..0132e42 100644 --- a/tests/data/html/image.html +++ b/tests/data/html/image.html @@ -1 +1 @@ -
Sleepy Kitten
<script>alert(23)</script>Cute Kitty
\ No newline at end of file +
Sleepy Kitten
<script>alert(23)</script>Cute Kitty
\ No newline at end of file diff --git a/tests/data/html/paragraph.html b/tests/data/html/paragraph.html index 9930c14..bcd000c 100644 --- a/tests/data/html/paragraph.html +++ b/tests/data/html/paragraph.html @@ -1 +1 @@ -

Quick brown fox jumps over the lazy dog.

In Penny Lane, there is a barber showing photographs..

\ No newline at end of file +

Quick brown fox jumps over the lazy dog.

In Penny Lane, there is a barber showing photographs..

\ No newline at end of file diff --git a/tests/data/json/audio.json b/tests/data/json/audio.json index 7e0ce52..263b881 100644 --- a/tests/data/json/audio.json +++ b/tests/data/json/audio.json @@ -5,6 +5,7 @@ { "type": "audio", "attrs": { + "id": "b-NzgT2MAhuSTnpFyo-E3", "src": "https://getfoobar/audio/sohtdbcmxu-1581683086.mp3", "caption": "YetAnotherPodcaster" } diff --git a/tests/data/json/code_block.json b/tests/data/json/code_block.json index 893d245..9b72e12 100644 --- a/tests/data/json/code_block.json +++ b/tests/data/json/code_block.json @@ -4,7 +4,8 @@ { "type": "code_block", "attrs": { - "language": "python" + "language": "python", + "id": "b-NzgT2MAhuSTnpFyo-E4" }, "content": [ { diff --git a/tests/data/json/data_attributes.json b/tests/data/json/data_attributes.json index aa78142..ef26fa4 100644 --- a/tests/data/json/data_attributes.json +++ b/tests/data/json/data_attributes.json @@ -5,6 +5,7 @@ { "type": "image", "attrs": { + "id": "b-NzgT2MAhuSTnpFyo-E5", "src": { "image": "https://placekitten.com/200/301", "fallback": "https://placekitten.com/200/301" }, "alt": "Sleepy Kitten", "caption": "Cute Kitty", diff --git a/tests/data/json/document-pdf.json b/tests/data/json/document-pdf.json index 46f68d1..0f1ec45 100644 --- a/tests/data/json/document-pdf.json +++ b/tests/data/json/document-pdf.json @@ -5,6 +5,7 @@ { "type": "document", "attrs": { + "id": "b-NzgT2MAhuSTnpFyo-E6", "src": "http://www.africau.edu/images/default/sample.pdf", "caption": "This is pdf caption.", "name": "RE_40566006.pdf", diff --git a/tests/data/json/embed.json b/tests/data/json/embed.json index a3c38eb..a01a193 100644 --- a/tests/data/json/embed.json +++ b/tests/data/json/embed.json @@ -4,6 +4,7 @@ { "type": "embed", "attrs": { + "id": "b-NzgT2MAhuSTnpFyo-E7", "title": "Extraction | Chris Hemsworth | Official Trailer | Netflix India", "description": "A hardened mercenary's mission becomes a soul-searching race to survive when he's sent into Bangladesh to rescue a drug lord's kidnapped son.", "type": "video", diff --git a/tests/data/json/heading.json b/tests/data/json/heading.json index ab645de..602de8a 100644 --- a/tests/data/json/heading.json +++ b/tests/data/json/heading.json @@ -4,6 +4,7 @@ { "type": "heading", "attrs": { + "id": "b-NzgT2MAhuSTnpFyo-E8", "level": 2 }, "content": [ diff --git a/tests/data/json/horizontal_rule.json b/tests/data/json/horizontal_rule.json index 8497750..ddb4d3f 100644 --- a/tests/data/json/horizontal_rule.json +++ b/tests/data/json/horizontal_rule.json @@ -1,6 +1,12 @@ { "type": "doc", "content": [ + { + "type": "horizontal_rule", + "attrs": { + "id": "b-NzgT2MAhuSTnpFyo-E8" + } + }, { "type": "horizontal_rule" } diff --git a/tests/data/json/image.json b/tests/data/json/image.json index 5720172..d46329b 100644 --- a/tests/data/json/image.json +++ b/tests/data/json/image.json @@ -4,6 +4,7 @@ { "type": "image", "attrs": { + "id": "b-NzgT2MAhuSTnpFyo-E9", "src": { "image": "https://placekitten.com/200/301?text=\"escape me\"", "fallback": "https://placekitten.com/198/654" diff --git a/tests/data/json/paragraph.json b/tests/data/json/paragraph.json index db9c78b..30cfadb 100644 --- a/tests/data/json/paragraph.json +++ b/tests/data/json/paragraph.json @@ -18,7 +18,7 @@ { "type": "paragraph", "attrs": { - "id": "ayZCtf1xgGPZnCVimIUO" + "id": "b-NzgT3GpkPSdZL_VyV2f" }, "content": [ { diff --git a/tests/test_transform.py b/tests/test_transform.py index dff5d16..1decf32 100644 --- a/tests/test_transform.py +++ b/tests/test_transform.py @@ -6,45 +6,45 @@ import tiptapy tags_to_test = ( - # "simple", - # "blockquote", - # "bulletlist", - # "mark_tags", + "simple", + "blockquote", + "bulletlist", + "mark_tags", "ordered_list", "paragraph", "paragraph-is_renderable", "paragraph-codemark", "paragraph-escape", - # "image", - # "image-is_renderable", - # "image-missing_caption", - # "image-no_caption", - # "image-mime_type", - # "image-height_width", - # "featuredimage", - # "featuredimage-is_renderable", - # "featuredimage-missing_caption", - # "featuredimage-no_caption", - # "featuredimage-mime_type", - # "featuredimage-height_width", - # "horizontal_rule", - # "embed", - # "embed-missing_caption", - # "embed-no_caption", - # "embed-null_caption", - # "heading", - # "is_renderable", - # "code_block", - # "code_block-is_renderable", - # "audio", - # "audio-no_caption", - # "audio-is_renderable", - # "document-pdf", - # "document-is_renderable", - # "document-sketch", - # "camel-case", - # "data_attributes", - # "xss", + "image", + "image-is_renderable", + "image-missing_caption", + "image-no_caption", + "image-mime_type", + "image-height_width", + "featuredimage", + "featuredimage-is_renderable", + "featuredimage-missing_caption", + "featuredimage-no_caption", + "featuredimage-mime_type", + "featuredimage-height_width", + "horizontal_rule", + "embed", + "embed-missing_caption", + "embed-no_caption", + "embed-null_caption", + "heading", + "is_renderable", + "code_block", + "code_block-is_renderable", + "audio", + "audio-no_caption", + "audio-is_renderable", + "document-pdf", + "document-is_renderable", + "document-sketch", + "camel-case", + "data_attributes", + "xss", ) diff --git a/tiptapy/templates/codeBlock.html b/tiptapy/templates/codeBlock.html index 262db35..cab56e3 100644 --- a/tiptapy/templates/codeBlock.html +++ b/tiptapy/templates/codeBlock.html @@ -2,7 +2,7 @@ {%- if node.content -%} {%- set text = node.content[0].text -%} {%- if text -%} -
+    
       {%- if language -%}
         {{text}}
       {%- else -%}
diff --git a/tiptapy/templates/code_block.html b/tiptapy/templates/code_block.html
index 262db35..cab56e3 100644
--- a/tiptapy/templates/code_block.html
+++ b/tiptapy/templates/code_block.html
@@ -2,7 +2,7 @@
 {%- if node.content -%}
   {%- set text = node.content[0].text -%}
   {%- if text -%}
-    
+    
       {%- if language -%}
         {{text}}
       {%- else -%}
diff --git a/tiptapy/templates/embed.html b/tiptapy/templates/embed.html
index 05a0df0..ee4437a 100644
--- a/tiptapy/templates/embed.html
+++ b/tiptapy/templates/embed.html
@@ -1,7 +1,7 @@
 {%- set html = node.attrs.html -%}
 
 {%- set provider_name = node.attrs.provider|default('link')|lower -%}
-
+
{%- for item in node.content -%} {%- with template=item.type + '.html', node=item -%} {%- include template -%} diff --git a/tiptapy/templates/extras/audio.html b/tiptapy/templates/extras/audio.html index 787e7c0..e5ccbf2 100644 --- a/tiptapy/templates/extras/audio.html +++ b/tiptapy/templates/extras/audio.html @@ -3,7 +3,7 @@ {%- set audio_player_block = get_audio_player_block() -%} {%- set src = node.attrs.src|trim -%} -
+
{%- if caption -%}
{{audio_player_block}}
{{caption}}
{%- else -%} diff --git a/tiptapy/templates/extras/document.html b/tiptapy/templates/extras/document.html index c5fdeb9..495f440 100644 --- a/tiptapy/templates/extras/document.html +++ b/tiptapy/templates/extras/document.html @@ -5,7 +5,7 @@ {%- set ext = node.attrs.format|trim -%} {%- if src and size and fname and ext -%} {%- set doc_block = get_doc_block(ext, fname, size, src) -%} -
+
{%- if caption -%} {{doc_block}}
{{caption}}
{%- else -%} diff --git a/tiptapy/templates/heading.html b/tiptapy/templates/heading.html index 9fb255d..e07223b 100644 --- a/tiptapy/templates/heading.html +++ b/tiptapy/templates/heading.html @@ -1,4 +1,4 @@ - + {%- for item in node.content -%} {%- with template=item.type + '.html', node=item -%} {%- include template -%} diff --git a/tiptapy/templates/horizontalRule.html b/tiptapy/templates/horizontalRule.html index e123ba7..cd2fffa 100644 --- a/tiptapy/templates/horizontalRule.html +++ b/tiptapy/templates/horizontalRule.html @@ -1 +1 @@ -
+ diff --git a/tiptapy/templates/horizontal_rule.html b/tiptapy/templates/horizontal_rule.html index e123ba7..cd2fffa 100644 --- a/tiptapy/templates/horizontal_rule.html +++ b/tiptapy/templates/horizontal_rule.html @@ -1 +1 @@ -
+ diff --git a/tiptapy/templates/image.html b/tiptapy/templates/image.html index ac0f7d7..b8c2793 100644 --- a/tiptapy/templates/image.html +++ b/tiptapy/templates/image.html @@ -9,7 +9,7 @@ {%- set fallback_type = url2mime(fallback_url) -%} {%- if image_url or fallback_url -%} -
<{{ make_img_src(node.attrs) }}/> + <{{ make_img_src(node.attrs) }}/> {%- if caption -%}
{{ caption }}
{%- endif -%}