@ecency/render-helper 2.3.17 → 2.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +171 -17
- package/dist/browser/index.d.ts +32 -0
- package/dist/browser/index.js +1556 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/node/index.cjs +1575 -0
- package/dist/node/index.cjs.map +1 -0
- package/dist/node/index.mjs +1559 -0
- package/dist/node/index.mjs.map +1 -0
- package/package.json +49 -47
- package/lib/cache.d.ts +0 -3
- package/lib/cache.js +0 -21
- package/lib/cache.js.map +0 -1
- package/lib/catch-post-image.d.ts +0 -2
- package/lib/catch-post-image.js +0 -76
- package/lib/catch-post-image.js.map +0 -1
- package/lib/consts/allowed-attributes.const.d.ts +0 -2
- package/lib/consts/allowed-attributes.const.js +0 -71
- package/lib/consts/allowed-attributes.const.js.map +0 -1
- package/lib/consts/dom-parser.const.d.ts +0 -2
- package/lib/consts/dom-parser.const.js +0 -12
- package/lib/consts/dom-parser.const.js.map +0 -1
- package/lib/consts/index.d.ts +0 -5
- package/lib/consts/index.js +0 -22
- package/lib/consts/index.js.map +0 -1
- package/lib/consts/regexes.const.d.ts +0 -44
- package/lib/consts/regexes.const.js +0 -49
- package/lib/consts/regexes.const.js.map +0 -1
- package/lib/consts/section-list.const.d.ts +0 -1
- package/lib/consts/section-list.const.js +0 -24
- package/lib/consts/section-list.const.js.map +0 -1
- package/lib/consts/white-list.const.d.ts +0 -2
- package/lib/consts/white-list.const.js +0 -37
- package/lib/consts/white-list.const.js.map +0 -1
- package/lib/helper.d.ts +0 -6
- package/lib/helper.js +0 -72
- package/lib/helper.js.map +0 -1
- package/lib/index.d.ts +0 -8
- package/lib/index.js +0 -19
- package/lib/index.js.map +0 -1
- package/lib/markdown-2-html.d.ts +0 -2
- package/lib/markdown-2-html.js +0 -25
- package/lib/markdown-2-html.js.map +0 -1
- package/lib/methods/a.method.d.ts +0 -1
- package/lib/methods/a.method.js +0 -647
- package/lib/methods/a.method.js.map +0 -1
- package/lib/methods/clean-reply.method.d.ts +0 -1
- package/lib/methods/clean-reply.method.js +0 -37
- package/lib/methods/clean-reply.method.js.map +0 -1
- package/lib/methods/get-inner-html.method.d.ts +0 -1
- package/lib/methods/get-inner-html.method.js +0 -16
- package/lib/methods/get-inner-html.method.js.map +0 -1
- package/lib/methods/iframe.method.d.ts +0 -1
- package/lib/methods/iframe.method.js +0 -159
- package/lib/methods/iframe.method.js.map +0 -1
- package/lib/methods/img.method.d.ts +0 -4
- package/lib/methods/img.method.js +0 -50
- package/lib/methods/img.method.js.map +0 -1
- package/lib/methods/index.d.ts +0 -7
- package/lib/methods/index.js +0 -24
- package/lib/methods/index.js.map +0 -1
- package/lib/methods/linkify.method.d.ts +0 -1
- package/lib/methods/linkify.method.js +0 -56
- package/lib/methods/linkify.method.js.map +0 -1
- package/lib/methods/markdown-to-html.method.d.ts +0 -1
- package/lib/methods/markdown-to-html.method.js +0 -98
- package/lib/methods/markdown-to-html.method.js.map +0 -1
- package/lib/methods/noop.method.d.ts +0 -1
- package/lib/methods/noop.method.js +0 -6
- package/lib/methods/noop.method.js.map +0 -1
- package/lib/methods/p.method.d.ts +0 -1
- package/lib/methods/p.method.js +0 -11
- package/lib/methods/p.method.js.map +0 -1
- package/lib/methods/remove-child-nodes.method.d.ts +0 -1
- package/lib/methods/remove-child-nodes.method.js +0 -10
- package/lib/methods/remove-child-nodes.method.js.map +0 -1
- package/lib/methods/sanitize-html.method.d.ts +0 -1
- package/lib/methods/sanitize-html.method.js +0 -42
- package/lib/methods/sanitize-html.method.js.map +0 -1
- package/lib/methods/text.method.d.ts +0 -1
- package/lib/methods/text.method.js +0 -69
- package/lib/methods/text.method.js.map +0 -1
- package/lib/methods/traverse.method.d.ts +0 -3
- package/lib/methods/traverse.method.js +0 -38
- package/lib/methods/traverse.method.js.map +0 -1
- package/lib/post-body-summary.d.ts +0 -2
- package/lib/post-body-summary.js +0 -123
- package/lib/post-body-summary.js.map +0 -1
- package/lib/proxify-image-src.d.ts +0 -5
- package/lib/proxify-image-src.js +0 -86
- package/lib/proxify-image-src.js.map +0 -1
- package/lib/render-helper.js +0 -1
- package/lib/types/entry.interface.d.ts +0 -7
- package/lib/types/entry.interface.js +0 -3
- package/lib/types/entry.interface.js.map +0 -1
- package/lib/types/index.d.ts +0 -2
- package/lib/types/index.js +0 -19
- package/lib/types/index.js.map +0 -1
- package/lib/types/xss-white-list.interface.d.ts +0 -6
- package/lib/types/xss-white-list.interface.js +0 -3
- package/lib/types/xss-white-list.interface.js.map +0 -1
- package/src/cache.ts +0 -15
- package/src/catch-post-image.spec.ts +0 -144
- package/src/catch-post-image.ts +0 -78
- package/src/consts/allowed-attributes.const.ts +0 -69
- package/src/consts/dom-parser.const.ts +0 -6
- package/src/consts/index.ts +0 -5
- package/src/consts/regexes.const.ts +0 -46
- package/src/consts/section-list.const.ts +0 -20
- package/src/consts/white-list.const.ts +0 -33
- package/src/external-types/multihashes.d.ts +0 -3
- package/src/helper.spec.ts +0 -16
- package/src/helper.ts +0 -77
- package/src/index.ts +0 -18
- package/src/markdown-2-html.spec.ts +0 -1251
- package/src/markdown-2-html.ts +0 -25
- package/src/methods/a.method.ts +0 -791
- package/src/methods/clean-reply.method.ts +0 -32
- package/src/methods/get-inner-html.method.ts +0 -11
- package/src/methods/iframe.method.ts +0 -176
- package/src/methods/img.method.ts +0 -62
- package/src/methods/index.ts +0 -7
- package/src/methods/linkify.method.ts +0 -61
- package/src/methods/markdown-to-html.method.ts +0 -104
- package/src/methods/noop.method.ts +0 -1
- package/src/methods/p.method.ts +0 -6
- package/src/methods/remove-child-nodes.method.ts +0 -5
- package/src/methods/sanitize-html.method.ts +0 -32
- package/src/methods/text.method.ts +0 -77
- package/src/methods/traverse.method.ts +0 -33
- package/src/post-body-summary.spec.ts +0 -150
- package/src/post-body-summary.ts +0 -130
- package/src/proxify-image-src.spec.ts +0 -76
- package/src/proxify-image-src.ts +0 -77
- package/src/sanitize-html.spec.ts +0 -15
- package/src/test/data/index.ts +0 -12
- package/src/test/data/json/muratkbesiroglu____sci-fi-novel-underground-city-part-13.json +0 -2120
- package/src/test/data/json/steemitboard____steemitboard-notify-dunsky-20181210t153450000z.json +0 -47
- package/src/test/data/legacy/10.json +0 -5
- package/src/test/data/legacy/20.json +0 -5
- package/src/test/data/legacy/21.json +0 -5
- package/src/test/data/legacy/2112524.json +0 -5
- package/src/test/data/legacy/22.json +0 -5
- package/src/test/data/legacy/23.json +0 -5
- package/src/test/data/legacy/24.json +0 -5
- package/src/test/data/legacy/25.json +0 -5
- package/src/test/data/legacy/26.json +0 -5
- package/src/test/data/legacy/27.JSON +0 -5
- package/src/test/data/legacy/28.json +0 -5
- package/src/test/data/legacy/29.json +0 -5
- package/src/test/data/legacy/31.json +0 -5
- package/src/test/snaps.json +0 -8
- package/src/types/entry.interface.ts +0 -7
- package/src/types/index.ts +0 -2
- package/src/types/xss-white-list.interface.ts +0 -7
|
@@ -1,1251 +0,0 @@
|
|
|
1
|
-
import { getTestData } from './test/data'
|
|
2
|
-
import { markdown2Html } from './markdown-2-html'
|
|
3
|
-
|
|
4
|
-
const fs = require('fs')
|
|
5
|
-
const path = require('path')
|
|
6
|
-
const SNAPSHOT_JSON = {
|
|
7
|
-
"markdown_2_html_test_files_1_should_catch_images_in_table": "<p dir=\"auto\"><span>Congratulations <a class=\"markdown-author-link\" data-author=\"dunsky\">@dunsky</a>! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :</span></p>\n<table><tr><td><span><img class=\"markdown-img-link\" src=\"https://images.ecency.com/p/9RTqgyyu8sX2kxvHt3ueNhDJEActwvqfV9wXt7pGKpjnWxBVz6r6Lv5n7t2RYBogkr5EjvnLjk.png?format=match&mode=fit\" loading=\"eager\" fetchpriority=\"high\" itemprop=\"image\" /></span></td><td>You made more than 6000 upvotes. Your next target is to reach 7000 upvotes.</td></tr>\n<tr><td><span><img class=\"markdown-img-link\" src=\"https://images.ecency.com/p/9RTqgyyu8sX2kxvHt3ueNhDJEActwvqfV9wXt7pGKpjnVKjKxTD5Xwi6jJqBW9PAmtMWvTCvPF.png?format=match&mode=fit\" loading=\"eager\" fetchpriority=\"high\" itemprop=\"image\" /></span></td><td>You published more than 250 posts. Your next target is to reach 300 posts.</td></tr>\n</table>\n<p dir=\"auto\"><sub><em><a class=\"markdown-external-link\" data-href=\"https://steemitboard.com/@dunsky\">Click here to view your Board of Honor</a></em></sub><br />\n<sub><em>If you no longer want to receive notifications, reply to this comment with the word</em> <code>STOP</code></sub></p>\n<p dir=\"auto\">To support your work, I also upvoted your post!</p>\n<blockquote>\n<p dir=\"auto\">Support <a class=\"markdown-external-link\" data-href=\"https://steemit.com/@steemitboard\">SteemitBoard's project</a>! <strong><a class=\"markdown-external-link\" data-href=\"https://v2.steemconnect.com/sign/account-witness-vote?witness=steemitboard&approve=1\">Vote for its witness</a></strong> and <strong>get one more award</strong>!</p>\n</blockquote>",
|
|
8
|
-
"markdown_2_html_test_files_3_should_replace_busy_links_properly": "<p dir=\"auto\"><img src=\"https://.esteem.app/0x0/https://ipfs.busy.org/ipfs/QmPziJCkx8w62UZCz1TNxAMsgf1uTnPZdVKAYjLBWvMzeD\" alt=\"image.png\" /></p>\n<p dir=\"auto\"><a class=\"markdown-post-link\" data-tag=\"post\" data-author=\"muratkbesiroglu\" data-permlink=\"sci-fi-novel-underground-city-part-1-2\">Part 1 - 2</a><br />\n<a class=\"markdown-post-link\" data-tag=\"post\" data-author=\"muratkbesiroglu\" data-permlink=\"sci-fi-novel-underground-city-part-3\">Part 3</a><br />\n<a class=\"markdown-post-link\" data-tag=\"post\" data-author=\"muratkbesiroglu\" data-permlink=\"sci-fi-novel-underground-city-part-4\">Part 4</a><br />\n<a class=\"markdown-post-link\" data-tag=\"post\" data-author=\"muratkbesiroglu\" data-permlink=\"sci-fi-novel-underground-city-part-5\">Part 5</a><br />\n<a class=\"markdown-post-link\" data-tag=\"post\" data-author=\"muratkbesiroglu\" data-permlink=\"sci-fi-novel-underground-city-part-6\">Part 6</a><br />\n<a class=\"markdown-post-link\" data-tag=\"post\" data-author=\"muratkbesiroglu\" data-permlink=\"sci-fi-novel-underground-city-part-7\">Part 7</a><br />\n<a class=\"markdown-post-link\" data-tag=\"post\" data-author=\"muratkbesiroglu\" data-permlink=\"sci-fi-novel-underground-city-part-8\">Part 8</a><br />\n<a class=\"markdown-post-link\" data-tag=\"post\" data-author=\"muratkbesiroglu\" data-permlink=\"sci-fi-novel-underground-city-part-9\">Part 9</a><br />\n<a class=\"markdown-post-link\" data-tag=\"post\" data-author=\"muratkbesiroglu\" data-permlink=\"sci-fi-novel-underground-city-part-10\">Part 10</a><br />\n<a class=\"markdown-post-link\" data-tag=\"post\" data-author=\"muratkbesiroglu\" data-permlink=\"sci-fi-novel-underground-city-part-11\">Part 11</a><br />\n<a class=\"markdown-post-link\" data-tag=\"post\" data-author=\"muratkbesiroglu\" data-permlink=\"sci-fi-novel-underground-city-part-12\">Part 12</a></p>\n<p dir=\"auto\"><strong>Part 13</strong></p>\n<p dir=\"auto\">Members of the Yerşehir caravan have surrendered their weapons to imperial soldiers at the entrance of Istanbul by the agreement provided earlier. The imperial soldiers arrested them immediately after the surrender of the weapons, and they entered the city with their hands chained.</p>\n<p dir=\"auto\">“The Yerşehir administration will ask you the account of this disrespect,” said Tamra to the proud Commander Timor on the pony. Tamra was angry because an ordinary soldier pushed her.</p>\n<p dir=\"auto\">\"You should be thankful we didn't strip you naked and had you wandering the streets of the city,\" said Commander Timor.</p>\n<p dir=\"auto\">Doma turned to the commander and said, “That's not how we dealt with you. Still, I assume you're doing your duty. I ask you to inform your superiors as soon as possible.”</p>\n<p dir=\"auto\">”You may be executed for armed entry into the Imperial lands,\" said the commander.</p>\n<p dir=\"auto\">“You like to dramatize things,” Akman said. Although Commander Timor was angry with Akman's happy face, he chose to keep the sarcastic look on his face.</p>\n<p dir=\"auto\">When he was taken to the dungeon, Akman was watching the buildings on the road, the squares adorned with sculptures, statues, and facades reflecting the beauty of East Roman stone craftsmanship.</p>\n<p dir=\"auto\">After passing the Hippodrome, which is one of the rare works of the ancient world, they entered a narrow tunnel and went down a ladder descending by turning. The soldiers locked them in a large gallery and returned. The water was dripping from the high ceiling of the dungeon, and the air they breathed was quite damp. Akman saw two rats with the size of cats running to their holes, terrified by the sound of footsteps.</p>\n<p dir=\"auto\">”I don't think they're gonna keep us here for long,\" Akman said.</p>\n<p dir=\"auto\">Akman was wrong; they told stories to each other in the first few days while there was no authority to call and ask for them. One of the dungeon guards came once a day and left a cup of water and a disgusting wheat porridge in the cell. The amount of oatmeal brought by the guard was so small that it was even possible for them to starve if the situation went on like this.</p>\n<p dir=\"auto\">Akman was cheerful as if he was at the banquet table, not at the dungeon. His joy was so bizarre that the team members began to think he was out of his mind. As the days passed, he was weakened by malnutrition; his clothes were stained, and his face was blackened. Still, he didn't lose anything from his joy. When asked how it can be so enjoyable, he said, “peace and light are within us. Just let's call and find out.\"</p>\n<p dir=\"auto\">Days later, an officer finally appeared at the door of the dungeon. Now, even the sparkle in the eyes of Akman has been lost, and Doma was unable to get up from where he was sleeping because of his illness. “The emperor will meet with the two representatives of your choice in two days,” said Chlorus, who brought plenty of food with him. Chlorus was handling his business with care. He brought water and ash to the cell to make sure they didn't smell bad, and he arranged a basin for their clothes. After washing, a barber would cut off their hair and beard. When they talk to the emperor, they should not extend the word and that they should give satisfying answers to the questions asked.</p>\n<p dir=\"auto\">Akman and Doma were taken from prison by the guards to be brought to the emperor. They agreed to hold a reasonable discourse during the interview. They were ready to suffer the maltreatment for the well-being of their country. The Imperial Palace adjacent to the Hippodrome was quite magnificent. They couldn't retrieve their eyes from the mosaics on the floor, the tiles on the walls and the stained glass windows. They passed through the large gate of the palace and entered the inner courtyard, where they waited for a while and then came to the emperor's presence.</p>\n<p dir=\"auto\">Since Doma's disease has not passed yet, Akman was holding his arm. As a matter of fact, he hasn't been able to speak; he agreed to join the meeting to show The Emperor what a terrible treatment they had.</p>\n<p dir=\"auto\">As soon as Emperor Valens saw Doma, he noticed his discomfort and told the servants to bring him a chair to sit down.</p>\n<p dir=\"auto\">“You wanted to see me,” said the Emperor, sitting on a plain throne compared to the splendor of the palace.</p>\n<p dir=\"auto\">”In the name of my people, I share your sorrow,\" said Akman.</p>\n<p dir=\"auto\">The emperor looked at Akman with the eyes asking, \"what is it about?”</p>\n<p dir=\"auto\">“I think robots attack your stables,” Akman said. Doma, who saw the environment as blurry due to high fever, turned and looked at Akman with amazement.</p>\n<p dir=\"auto\">”Few people know that yet, \" said Emperor Valens. Akman heard the news from the two soldiers they encountered on the way to the dungeon; the soldiers thought others did not understand them because they were whispering. As the security of his country is concerned, Akman chose to transfer the incident to the emperor in a different manner.</p>\n<p dir=\"auto\">\"We came to Istanbul to warn you about this. When the imperial authorities said in the dungeon that we could finally come to your peace, I understood that the attack has occurred,” Akman said.</p>\n<p dir=\"auto\">“You speak our language very well,” said the emperor.</p>\n<p dir=\"auto\">“Master Doma is much better than me, I hoped he'd be able to talk, but I was wrong,\" Akman said.</p>\n<p dir=\"auto\">\"I give you my regards and my gratitude for showing us the grace of acceptance. Because of my illness, I beg forgiveness for the imperfections that I can handle,” Doma said.</p>\n<p dir=\"auto\">“I will ask without hesitation: what could we have done to draw the wrath of God upon us, and what should we do to be merciful to his forgiveness?”</p>\n<p dir=\"auto\">Akman did not tell the emperor that events had begun with Ordin rising to Earth. He didn't want him to think they were in charge of the activities. Moreover, there was no evidence that the attacks on the stables in Yerşehir and Istanbul were related to Ordin's action. It was more than three months ago, and it could have been a coincidence.</p>\n<p dir=\"auto\">“I do not think that what happened is related to any sin.”</p>\n<p dir=\"auto\">“Foreigners come to our city with magical weapons, and ten days later, such an attack is taking place. Is that a coincidence?”</p>\n<p dir=\"auto\">\"I suspect that your scientists have already studied our weapons and have partially solved their operational principles. I assure you, our weapons work in accordance with scientific rules. I don't know why we're being treated so hard in your country.”</p>\n<p dir=\"auto\">“Could it be because you closed your doors to our country with a unilateral decision you made two centuries ago? According to historical records, despite the insistence of our empire, we have not even been able to negotiate the matter.”</p>\n<p dir=\"auto\">“It was a great travesty that half of our people died because of the plague. But that's not a valid excuse. I think the decision we made on time was wrong. During the past, we have been deprived of the benefits that we can achieve mutually. Given that the tunnel system makes wars almost impossible, it is not reasonable for us to continue such a mistake,\" Akman said.</p>\n<p dir=\"auto\">“I haven't received a satisfactory answer to my questions yet?\" the emperor said, despite the tone of his voice, his eyes were warm to Akman.</p>\n<p dir=\"auto\">\"I have to admit I don't know the answer to your questions, even if it's embarrassing for a philosopher. We came to Istanbul to find the answer to this question together.”</p>\n<p dir=\"auto\">\"I want to learn the working principles and how to produce the weapons you bring with you. This is the only way we can initiate an equality-based relationship.”</p>\n<p dir=\"auto\">\"I am not authorized to make such a decision. But I don't think your offer will be rejected at a time when we need cooperation to defend our cities,\" Akman said.</p>\n<p dir=\"auto\">After the meeting with Emperor Valens, the Yerşehir delegation was removed from prison, their belongings were returned, and they were sent from Istanbul with a ceremony in accordance with diplomatic traditions.</p>\n<p dir=\"auto\">Image Source: pixabay.com</p>",
|
|
9
|
-
"markdown_2_html_test_files_4_should_not_convert_markdown_links": "<p dir=\"auto\">lorem <a class=\"markdown-external-link\" data-href=\"https://images.ecency.com/0x0/https://d1vof77qrk4l5q.cloudfront.net/img/5752638e6965247789bc20cef34727263aaa41e1.png\">this error</a> ipsum</p>",
|
|
10
|
-
"markdown_2_html_traversing_20_should_not_convert_markdown_links": "<p dir=\"auto\">lorem <a class=\"markdown-external-link\" data-href=\"https://images.ecency.com/0x0/https://d1vof77qrk4l5q.cloudfront.net/img/5752638e6965247789bc20cef34727263aaa41e1.png\">this error</a> ipsum</p>",
|
|
11
|
-
"markdown_2_html_traversing_22_should_replace_busy_links_properly": "<p dir=\"auto\"><img src=\"https://images.ecency.com/p/7ohP4GDMGPrUMp8dW6yuJTR9MKNu8P8DCXDU9qmmhgT2GEFsgcwp6r41v9wnLUULgcVqE59AhpBJjFXHVP6KTGZbAszsNTZrVUY3.png?format=match&mode=fit\" alt=\"image.png\" /></p>\n<p dir=\"auto\"><a class=\"markdown-post-link\" data-tag=\"post\" data-author=\"muratkbesiroglu\" data-permlink=\"sci-fi-novel-underground-city-part-1-2\">Part 1 - 2</a><br />\n<a class=\"markdown-post-link\" data-tag=\"post\" data-author=\"muratkbesiroglu\" data-permlink=\"sci-fi-novel-underground-city-part-3\">Part 3</a><br />\n<a class=\"markdown-post-link\" data-tag=\"post\" data-author=\"muratkbesiroglu\" data-permlink=\"sci-fi-novel-underground-city-part-4\">Part 4</a><br />\n<a class=\"markdown-post-link\" data-tag=\"post\" data-author=\"muratkbesiroglu\" data-permlink=\"sci-fi-novel-underground-city-part-5\">Part 5</a><br />\n<a class=\"markdown-post-link\" data-tag=\"post\" data-author=\"muratkbesiroglu\" data-permlink=\"sci-fi-novel-underground-city-part-6\">Part 6</a><br />\n<a class=\"markdown-post-link\" data-tag=\"post\" data-author=\"muratkbesiroglu\" data-permlink=\"sci-fi-novel-underground-city-part-7\">Part 7</a><br />\n<a class=\"markdown-post-link\" data-tag=\"post\" data-author=\"muratkbesiroglu\" data-permlink=\"sci-fi-novel-underground-city-part-8\">Part 8</a><br />\n<a class=\"markdown-post-link\" data-tag=\"post\" data-author=\"muratkbesiroglu\" data-permlink=\"sci-fi-novel-underground-city-part-9\">Part 9</a><br />\n<a class=\"markdown-post-link\" data-tag=\"post\" data-author=\"muratkbesiroglu\" data-permlink=\"sci-fi-novel-underground-city-part-10\">Part 10</a><br />\n<a class=\"markdown-post-link\" data-tag=\"post\" data-author=\"muratkbesiroglu\" data-permlink=\"sci-fi-novel-underground-city-part-11\">Part 11</a><br />\n<a class=\"markdown-post-link\" data-tag=\"post\" data-author=\"muratkbesiroglu\" data-permlink=\"sci-fi-novel-underground-city-part-12\">Part 12</a></p>\n<p dir=\"auto\"><strong>Part 13</strong></p>\n<p dir=\"auto\">Members of the Yerşehir caravan have surrendered their weapons to imperial soldiers at the entrance of Istanbul by the agreement provided earlier. The imperial soldiers arrested them immediately after the surrender of the weapons, and they entered the city with their hands chained.</p>\n<p dir=\"auto\">“The Yerşehir administration will ask you the account of this disrespect,” said Tamra to the proud Commander Timor on the pony. Tamra was angry because an ordinary soldier pushed her.</p>\n<p dir=\"auto\">\"You should be thankful we didn't strip you naked and had you wandering the streets of the city,\" said Commander Timor.</p>\n<p dir=\"auto\">Doma turned to the commander and said, “That's not how we dealt with you. Still, I assume you're doing your duty. I ask you to inform your superiors as soon as possible.”</p>\n<p dir=\"auto\">”You may be executed for armed entry into the Imperial lands,\" said the commander.</p>\n<p dir=\"auto\">“You like to dramatize things,” Akman said. Although Commander Timor was angry with Akman's happy face, he chose to keep the sarcastic look on his face.</p>\n<p dir=\"auto\">When he was taken to the dungeon, Akman was watching the buildings on the road, the squares adorned with sculptures, statues, and facades reflecting the beauty of East Roman stone craftsmanship.</p>\n<p dir=\"auto\">After passing the Hippodrome, which is one of the rare works of the ancient world, they entered a narrow tunnel and went down a ladder descending by turning. The soldiers locked them in a large gallery and returned. The water was dripping from the high ceiling of the dungeon, and the air they breathed was quite damp. Akman saw two rats with the size of cats running to their holes, terrified by the sound of footsteps.</p>\n<p dir=\"auto\">”I don't think they're gonna keep us here for long,\" Akman said.</p>\n<p dir=\"auto\">Akman was wrong; they told stories to each other in the first few days while there was no authority to call and ask for them. One of the dungeon guards came once a day and left a cup of water and a disgusting wheat porridge in the cell. The amount of oatmeal brought by the guard was so small that it was even possible for them to starve if the situation went on like this.</p>\n<p dir=\"auto\">Akman was cheerful as if he was at the banquet table, not at the dungeon. His joy was so bizarre that the team members began to think he was out of his mind. As the days passed, he was weakened by malnutrition; his clothes were stained, and his face was blackened. Still, he didn't lose anything from his joy. When asked how it can be so enjoyable, he said, “peace and light are within us. Just let's call and find out.\"</p>\n<p dir=\"auto\">Days later, an officer finally appeared at the door of the dungeon. Now, even the sparkle in the eyes of Akman has been lost, and Doma was unable to get up from where he was sleeping because of his illness. “The emperor will meet with the two representatives of your choice in two days,” said Chlorus, who brought plenty of food with him. Chlorus was handling his business with care. He brought water and ash to the cell to make sure they didn't smell bad, and he arranged a basin for their clothes. After washing, a barber would cut off their hair and beard. When they talk to the emperor, they should not extend the word and that they should give satisfying answers to the questions asked.</p>\n<p dir=\"auto\">Akman and Doma were taken from prison by the guards to be brought to the emperor. They agreed to hold a reasonable discourse during the interview. They were ready to suffer the maltreatment for the well-being of their country. The Imperial Palace adjacent to the Hippodrome was quite magnificent. They couldn't retrieve their eyes from the mosaics on the floor, the tiles on the walls and the stained glass windows. They passed through the large gate of the palace and entered the inner courtyard, where they waited for a while and then came to the emperor's presence.</p>\n<p dir=\"auto\">Since Doma's disease has not passed yet, Akman was holding his arm. As a matter of fact, he hasn't been able to speak; he agreed to join the meeting to show The Emperor what a terrible treatment they had.</p>\n<p dir=\"auto\">As soon as Emperor Valens saw Doma, he noticed his discomfort and told the servants to bring him a chair to sit down.</p>\n<p dir=\"auto\">“You wanted to see me,” said the Emperor, sitting on a plain throne compared to the splendor of the palace.</p>\n<p dir=\"auto\">”In the name of my people, I share your sorrow,\" said Akman.</p>\n<p dir=\"auto\">The emperor looked at Akman with the eyes asking, \"what is it about?”</p>\n<p dir=\"auto\">“I think robots attack your stables,” Akman said. Doma, who saw the environment as blurry due to high fever, turned and looked at Akman with amazement.</p>\n<p dir=\"auto\">”Few people know that yet, \" said Emperor Valens. Akman heard the news from the two soldiers they encountered on the way to the dungeon; the soldiers thought others did not understand them because they were whispering. As the security of his country is concerned, Akman chose to transfer the incident to the emperor in a different manner.</p>\n<p dir=\"auto\">\"We came to Istanbul to warn you about this. When the imperial authorities said in the dungeon that we could finally come to your peace, I understood that the attack has occurred,” Akman said.</p>\n<p dir=\"auto\">“You speak our language very well,” said the emperor.</p>\n<p dir=\"auto\">“Master Doma is much better than me, I hoped he'd be able to talk, but I was wrong,\" Akman said.</p>\n<p dir=\"auto\">\"I give you my regards and my gratitude for showing us the grace of acceptance. Because of my illness, I beg forgiveness for the imperfections that I can handle,” Doma said.</p>\n<p dir=\"auto\">“I will ask without hesitation: what could we have done to draw the wrath of God upon us, and what should we do to be merciful to his forgiveness?”</p>\n<p dir=\"auto\">Akman did not tell the emperor that events had begun with Ordin rising to Earth. He didn't want him to think they were in charge of the activities. Moreover, there was no evidence that the attacks on the stables in Yerşehir and Istanbul were related to Ordin's action. It was more than three months ago, and it could have been a coincidence.</p>\n<p dir=\"auto\">“I do not think that what happened is related to any sin.”</p>\n<p dir=\"auto\">“Foreigners come to our city with magical weapons, and ten days later, such an attack is taking place. Is that a coincidence?”</p>\n<p dir=\"auto\">\"I suspect that your scientists have already studied our weapons and have partially solved their operational principles. I assure you, our weapons work in accordance with scientific rules. I don't know why we're being treated so hard in your country.”</p>\n<p dir=\"auto\">“Could it be because you closed your doors to our country with a unilateral decision you made two centuries ago? According to historical records, despite the insistence of our empire, we have not even been able to negotiate the matter.”</p>\n<p dir=\"auto\">“It was a great travesty that half of our people died because of the plague. But that's not a valid excuse. I think the decision we made on time was wrong. During the past, we have been deprived of the benefits that we can achieve mutually. Given that the tunnel system makes wars almost impossible, it is not reasonable for us to continue such a mistake,\" Akman said.</p>\n<p dir=\"auto\">“I haven't received a satisfactory answer to my questions yet?\" the emperor said, despite the tone of his voice, his eyes were warm to Akman.</p>\n<p dir=\"auto\">\"I have to admit I don't know the answer to your questions, even if it's embarrassing for a philosopher. We came to Istanbul to find the answer to this question together.”</p>\n<p dir=\"auto\">\"I want to learn the working principles and how to produce the weapons you bring with you. This is the only way we can initiate an equality-based relationship.”</p>\n<p dir=\"auto\">\"I am not authorized to make such a decision. But I don't think your offer will be rejected at a time when we need cooperation to defend our cities,\" Akman said.</p>\n<p dir=\"auto\">After the meeting with Emperor Valens, the Yerşehir delegation was removed from prison, their belongings were returned, and they were sent from Istanbul with a ceremony in accordance with diplomatic traditions.</p>\n<p dir=\"auto\">Image Source: pixabay.com</p>",
|
|
12
|
-
"markdown_2_html_traversing_54_should_highlight_code": "<pre><code><span class=\"ll-spc\"> </span><span class=\"ll-key\">def</span><span class=\"ll-spc\"> </span><span class=\"ll-nam\">factorial</span><span class=\"ll-pct\">(</span><span class=\"ll-nam\">n</span><span class=\"ll-pct\">)</span><span class=\"ll-pct\">:</span><span class=\"ll-spc\">\n </span><span class=\"ll-com\"># a comment</span><span class=\"ll-spc\">\n </span><span class=\"ll-key\">return</span><span class=\"ll-spc\"> </span><span class=\"ll-num\">1</span><span class=\"ll-spc\"> </span><span class=\"ll-key\">if</span><span class=\"ll-spc\"> </span><span class=\"ll-pct\">(</span><span class=\"ll-nam\">n</span><span class=\"ll-pct\">=</span><span class=\"ll-pct\">=</span><span class=\"ll-num\">1</span><span class=\"ll-spc\"> </span><span class=\"ll-key\">or</span><span class=\"ll-spc\"> </span><span class=\"ll-nam\">n</span><span class=\"ll-pct\">=</span><span class=\"ll-pct\">=</span><span class=\"ll-num\">0</span><span class=\"ll-pct\">)</span><span class=\"ll-spc\"> </span><span class=\"ll-key\">else</span><span class=\"ll-spc\"> </span><span class=\"ll-nam\">n</span><span class=\"ll-spc\"> </span><span class=\"ll-pct\">*</span><span class=\"ll-spc\"> </span><span class=\"ll-nam\">factorial</span><span class=\"ll-pct\">(</span><span class=\"ll-nam\">n</span><span class=\"ll-spc\"> </span><span class=\"ll-pct\">-</span><span class=\"ll-spc\"> </span><span class=\"ll-num\">1</span><span class=\"ll-pct\">)</span><span class=\"ll-spc\">\n </span><span class=\"ll-str\">``</span><span class=\"ll-unk\">`</span><span class=\"ll-spc\">\n</span></code></pre>",
|
|
13
|
-
"markdown_2_html_webp_support_should_render_images_in_webp_format": `<p dir=\"auto\">lorem ipsum <img class=\"markdown-img-link\" src=\"https://images.ecency.com/p/2BCfkBRHmbhyg7yeHaumxJq2oMZjKUDK5rv2tmGQzQHxPvTmaiv6Ar.webp?format=webp&mode=fit\" loading=\"lazy\" decoding=\"async\" itemprop=\"image\" /> dolor sit amet</p>`
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
describe('Markdown2Html', () => {
|
|
17
|
-
describe('Traversing', () => {
|
|
18
|
-
it('1- Should convert image links to img tag', () => {
|
|
19
|
-
const input = {
|
|
20
|
-
author: 'foo11',
|
|
21
|
-
permlink: 'bar11',
|
|
22
|
-
last_update: '2019-05-10T09:15:21',
|
|
23
|
-
body: 'https://img.esteem.ws/bbq3ob1idy.png'
|
|
24
|
-
}
|
|
25
|
-
const expected = '<p dir=\"auto\"><img class="markdown-img-link" src="https://images.ecency.com/p/o1AJ9qDyyJNSpZWhUgGYc3MngFqoAMwgbeMkkd8SVxyfRVjiN.png?format=match&mode=fit" loading="lazy" decoding="async" itemprop="image" /></p>'
|
|
26
|
-
|
|
27
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
it('2- Should handle steemit links', () => {
|
|
31
|
-
const input = {
|
|
32
|
-
author: 'foo22',
|
|
33
|
-
permlink: 'bar22',
|
|
34
|
-
last_update: '2019-05-10T09:15:21',
|
|
35
|
-
body: '<a href=\'https://steemit.com/esteem/@esteemapp/esteem-monthly-guest-curation-program-4\'>click here</a>'
|
|
36
|
-
}
|
|
37
|
-
const expected = '<p dir=\"auto\"><a class="markdown-external-link" data-href="https://steemit.com/esteem/@esteemapp/esteem-monthly-guest-curation-program-4">click here</a></p>'
|
|
38
|
-
|
|
39
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
it('3- Should handle copied links', () => {
|
|
43
|
-
const input = {
|
|
44
|
-
author: 'foo33',
|
|
45
|
-
permlink: 'bar33',
|
|
46
|
-
last_update: '2019-05-10T09:15:21',
|
|
47
|
-
body: '<a href=\'/esteem/@esteemapp/esteem-monthly-guest-curation-program-4\'>click here</a>'
|
|
48
|
-
}
|
|
49
|
-
const expected = '<p dir=\"auto\"><a class=\"markdown-post-link\" data-href=\"/esteem/@esteemapp/esteem-monthly-guest-curation-program-4\" data-is-inline=\"true\" data-tag=\"esteem\" data-author=\"esteemapp\" data-permlink=\"esteem-monthly-guest-curation-program-4\">click here</a></p>'
|
|
50
|
-
|
|
51
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
it('4- Should handle copied links', () => {
|
|
55
|
-
const input = {
|
|
56
|
-
author: 'foo34',
|
|
57
|
-
permlink: 'bar34',
|
|
58
|
-
last_update: '2019-05-10T09:15:21',
|
|
59
|
-
body: '[click here](/esteem/@esteemapp/esteem-monthly-guest-curation-program-4)'
|
|
60
|
-
}
|
|
61
|
-
const expected = '<p dir=\"auto\"><a class=\"markdown-post-link\" data-href=\"/esteem/@esteemapp/esteem-monthly-guest-curation-program-4\" data-is-inline=\"true\" data-tag=\"esteem\" data-author=\"esteemapp\" data-permlink=\"esteem-monthly-guest-curation-program-4\">click here</a></p>'
|
|
62
|
-
|
|
63
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
64
|
-
})
|
|
65
|
-
|
|
66
|
-
it('5- Should handle youtube videos', () => {
|
|
67
|
-
const input = {
|
|
68
|
-
author: 'foo35',
|
|
69
|
-
permlink: 'bar35',
|
|
70
|
-
last_update: '2019-05-10T09:15:21',
|
|
71
|
-
body: 'https://www.youtube.com/watch?v=qK3d1eoH-Qs'
|
|
72
|
-
}
|
|
73
|
-
const expected = '<p dir=\"auto\"><a class="markdown-video-link markdown-video-link-youtube" data-embed-src="https://www.youtube.com/embed/qK3d1eoH-Qs?autoplay=1" data-youtube="qK3d1eoH-Qs"><img class="no-replace video-thumbnail" itemprop="image" src="https://images.ecency.com/p/S5Eokt4BcQdk7EHeT1aYjzebg2hC7hkthT45eMZRVYW6mkGBWKemLWWzXbRhNG7Z3h1qjGS.png?format=match&mode=fit" loading="eager" fetchpriority="high" /><span class="markdown-video-play"></span></a></p>'
|
|
74
|
-
|
|
75
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
76
|
-
})
|
|
77
|
-
|
|
78
|
-
it('6- Should handle vimeo videos', () => {
|
|
79
|
-
const input = {
|
|
80
|
-
author: 'foo36',
|
|
81
|
-
permlink: 'bar36',
|
|
82
|
-
last_update: '2019-05-10T09:15:21',
|
|
83
|
-
body: 'https://vimeo.com/311983548'
|
|
84
|
-
}
|
|
85
|
-
const expected = '<p dir=\"auto\"><a class="markdown-video-link markdown-video-link-vimeo"><iframe frameborder="0" allowfullscreen="true" src="https://player.vimeo.com/video/311983548"></iframe></a></p>'
|
|
86
|
-
|
|
87
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
88
|
-
})
|
|
89
|
-
|
|
90
|
-
it('7- Should handle d.tube videos', () => {
|
|
91
|
-
const input = {
|
|
92
|
-
author: 'foo37',
|
|
93
|
-
permlink: 'bar37',
|
|
94
|
-
last_update: '2019-05-10T09:15:21',
|
|
95
|
-
body: '<a href="https://d.tube/#!/v/scottcbusiness/g04n2bbp" title="This link will take you away from steemit.com"><img src="https://images.ecency.com/640x0/https://ipfs.io/ipfs/QmPhb9HA1gASFiNAUPFqMdSidTAj17L5SSoV3zbXUx8M7t"></a>'
|
|
96
|
-
}
|
|
97
|
-
const expected = '<p dir=\"auto\"><a title="This link will take you away from steemit.com" class="markdown-video-link markdown-video-link-dtube" data-embed-src="https://emb.d.tube/#!/scottcbusiness/g04n2bbp"><img class="no-replace video-thumbnail" itemprop="image" src="https://images.ecency.com/p/46aP2QbqUqBqwzwxM6L1P6uLNceBDDCM6xyDJFx6ANhENRd3gJWJH7TiVR91QZ1KBcdAdZruQE35PBpQ3jUvkNK4mJqZ.png?format=match&mode=fit" loading="eager" fetchpriority="high" /><span class="markdown-video-play"></span></a></p>'
|
|
98
|
-
|
|
99
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
100
|
-
})
|
|
101
|
-
|
|
102
|
-
it('7.1- Should handle raw d.tube videos without thumbnail', () => {
|
|
103
|
-
const input = {
|
|
104
|
-
author: 'foo37.1',
|
|
105
|
-
permlink: 'bar37.1',
|
|
106
|
-
last_update: '2020-05-10T09:15:21',
|
|
107
|
-
body: 'https://d.tube/#!/v/techcoderx/QmVdEYicJwiTxSk2U9ER1Yc8Rumb1Nek4KynqAYGyQs7ga'
|
|
108
|
-
}
|
|
109
|
-
const expected = '<p dir=\"auto\"><a class="markdown-video-link markdown-video-link-dtube" data-embed-src="https://emb.d.tube/#!/techcoderx/QmVdEYicJwiTxSk2U9ER1Yc8Rumb1Nek4KynqAYGyQs7ga"><span class="markdown-video-play"></span></a></p>'
|
|
110
|
-
|
|
111
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
112
|
-
})
|
|
113
|
-
|
|
114
|
-
it('7.2- Should handle raw d.tube videos different format', () => {
|
|
115
|
-
const input = {
|
|
116
|
-
author: 'foo37.2',
|
|
117
|
-
permlink: 'bar37.2',
|
|
118
|
-
last_update: '2020-05-10T09:15:21',
|
|
119
|
-
body: 'https://d.tube/v/techcoderx/QmVdEYicJwiTxSk2U9ER1Yc8Rumb1Nek4KynqAYGyQs7ga'
|
|
120
|
-
}
|
|
121
|
-
const expected = '<p dir=\"auto\"><a class="markdown-video-link markdown-video-link-dtube" data-embed-src="https://emb.d.tube/#!/techcoderx/QmVdEYicJwiTxSk2U9ER1Yc8Rumb1Nek4KynqAYGyQs7ga"><span class="markdown-video-play"></span></a></p>'
|
|
122
|
-
|
|
123
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
124
|
-
})
|
|
125
|
-
|
|
126
|
-
it('9- Should handle witnesses links', () => {
|
|
127
|
-
const input = {
|
|
128
|
-
author: 'foo39',
|
|
129
|
-
permlink: 'bar39',
|
|
130
|
-
last_update: '2019-05-10T09:15:21',
|
|
131
|
-
body: '<a href=\'https://hivesigner.com/sign/account-witness-vote?witness=talhasch\'>vote @talhasch</a>'
|
|
132
|
-
}
|
|
133
|
-
const expected = '<p dir=\"auto\"><a class="markdown-witnesses-link" data-href="https://hivesigner.com/sign/account-witness-vote?witness=talhasch">vote @talhasch</a></p>'
|
|
134
|
-
|
|
135
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
136
|
-
})
|
|
137
|
-
|
|
138
|
-
it('10- External link', () => {
|
|
139
|
-
const input = {
|
|
140
|
-
author: 'foo40',
|
|
141
|
-
permlink: 'bar40',
|
|
142
|
-
last_update: '2019-05-10T09:15:21',
|
|
143
|
-
body: 'click <a href=\'https://loremipsum.com/foo/bar.html\'>here</a> to visit'
|
|
144
|
-
}
|
|
145
|
-
const expected = '<p dir=\"auto\">click <a class="markdown-external-link" data-href="https://loremipsum.com/foo/bar.html">here</a> to visit</p>'
|
|
146
|
-
|
|
147
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
148
|
-
})
|
|
149
|
-
|
|
150
|
-
it('11- Should remove empty iframes', () => {
|
|
151
|
-
const input = {
|
|
152
|
-
author: 'foo41',
|
|
153
|
-
permlink: 'bar41',
|
|
154
|
-
last_update: '2019-05-10T09:15:21',
|
|
155
|
-
body: '<iframe></iframe> <code>some content</code>'
|
|
156
|
-
}
|
|
157
|
-
const expected = '<code>some content</code>'
|
|
158
|
-
|
|
159
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
160
|
-
})
|
|
161
|
-
|
|
162
|
-
it('12- Should handle youtube iframe embeds', () => {
|
|
163
|
-
const input = {
|
|
164
|
-
author: 'foo42',
|
|
165
|
-
permlink: 'bar42',
|
|
166
|
-
last_update: '2019-05-10T09:15:21',
|
|
167
|
-
body: '<iframe width="560" height="315" src="https://www.youtube.com/embed/I3f9ixg59no?foo=bar&baz=000" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>'
|
|
168
|
-
}
|
|
169
|
-
const expected = '<iframe src=\"https://www.youtube.com/embed/I3f9ixg59no\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"></iframe>'
|
|
170
|
-
|
|
171
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
172
|
-
})
|
|
173
|
-
|
|
174
|
-
it('13- Should handle vimeo iframe embeds', () => {
|
|
175
|
-
const input = {
|
|
176
|
-
author: 'foo43',
|
|
177
|
-
permlink: 'bar43',
|
|
178
|
-
last_update: '2019-05-10T09:15:21',
|
|
179
|
-
body: '<iframe src="https://player.vimeo.com/video/311983548" width="640" height="360" frameborder="0" allow="autoplay; fullscreen" allowfullscreen></iframe>'
|
|
180
|
-
}
|
|
181
|
-
const expected = '<iframe src="https://player.vimeo.com/video/311983548" frameborder="0" allowfullscreen="allowfullscreen"></iframe>'
|
|
182
|
-
|
|
183
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
184
|
-
})
|
|
185
|
-
|
|
186
|
-
it('14- Should handle twitch iframe embeds', () => {
|
|
187
|
-
const input = {
|
|
188
|
-
author: 'foo44',
|
|
189
|
-
permlink: 'bar44',
|
|
190
|
-
last_update: '2019-05-10T09:15:21',
|
|
191
|
-
body: '<iframe src="https://player.twitch.tv/?channel=esl_csgo" frameborder="0" allowfullscreen="true" scrolling="no" height="378" width="620"></iframe>'
|
|
192
|
-
}
|
|
193
|
-
const expected = '<iframe src="https://player.twitch.tv/?channel=esl_csgo&parent=ecency.com&autoplay=false" frameborder="0" allowfullscreen="true"></iframe>'
|
|
194
|
-
|
|
195
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
196
|
-
})
|
|
197
|
-
|
|
198
|
-
it('15- Should handle soundcloud iframe embeds', () => {
|
|
199
|
-
const input = {
|
|
200
|
-
author: 'foo45',
|
|
201
|
-
permlink: 'bar45',
|
|
202
|
-
last_update: '2019-05-10T09:15:21',
|
|
203
|
-
body: '<iframe width="100%" height="300" scrolling="no" frameborder="no" allow="autoplay" src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/558749283&color=%23ff5500&auto_play=true&hide_related=false&show_comments=true&show_user=true&show_reposts=false&show_teaser=true&visual=true"></iframe>'
|
|
204
|
-
}
|
|
205
|
-
const expected = '<iframe frameborder="no" src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/558749283&auto_play=false&hide_related=false&show_comments=true&show_user=true&show_reposts=false&visual=true"></iframe>'
|
|
206
|
-
|
|
207
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
208
|
-
})
|
|
209
|
-
|
|
210
|
-
it('16- Should replace placeholder for unsopported iframe sources', () => {
|
|
211
|
-
const input = {
|
|
212
|
-
author: 'foo46',
|
|
213
|
-
permlink: 'bar46',
|
|
214
|
-
last_update: '2019-05-10T09:15:21',
|
|
215
|
-
body: '<iframe src="https://foobarbaz.com/132431212" ></iframe>'
|
|
216
|
-
}
|
|
217
|
-
const expected = '<div class="unsupported-iframe">(Unsupported https://foobarbaz.com/132431212)</div>'
|
|
218
|
-
|
|
219
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
220
|
-
})
|
|
221
|
-
|
|
222
|
-
it('17- Should replace author names with link for given string', () => {
|
|
223
|
-
let input = {
|
|
224
|
-
author: 'foo47',
|
|
225
|
-
permlink: 'bar47',
|
|
226
|
-
last_update: '2019-05-10T09:15:21',
|
|
227
|
-
body: 'lorem ipsum @dolor sit amet'
|
|
228
|
-
}
|
|
229
|
-
let expected =
|
|
230
|
-
'<p dir=\"auto\"><span>lorem ipsum <a class="markdown-author-link" data-author="dolor">@dolor</a> sit amet</span></p>'
|
|
231
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
232
|
-
|
|
233
|
-
input = {
|
|
234
|
-
author: 'foo48',
|
|
235
|
-
permlink: 'bar48',
|
|
236
|
-
last_update: '2019-05-10T09:15:21',
|
|
237
|
-
body: '@lorem ipsum @dolor sit amet'
|
|
238
|
-
}
|
|
239
|
-
expected =
|
|
240
|
-
'<p dir=\"auto\"><span><a class="markdown-author-link" data-author="lorem">@lorem</a> ipsum <a class="markdown-author-link" data-author="dolor">@dolor</a> sit amet</span></p>'
|
|
241
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
input = {
|
|
245
|
-
author: 'foo49',
|
|
246
|
-
permlink: 'bar49',
|
|
247
|
-
last_update: '2019-05-10T09:15:21',
|
|
248
|
-
body: '@lorem @ipsum @dolor sit amet'
|
|
249
|
-
}
|
|
250
|
-
expected =
|
|
251
|
-
'<p dir=\"auto\"><span><a class="markdown-author-link" data-author="lorem">@lorem</a> <a class="markdown-author-link" data-author="ipsum">@ipsum</a> <a class="markdown-author-link" data-author="dolor">@dolor</a> sit amet</span></p>'
|
|
252
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
input = {
|
|
256
|
-
author: 'foo50',
|
|
257
|
-
permlink: 'bar50',
|
|
258
|
-
last_update: '2019-05-10T09:15:21',
|
|
259
|
-
body: '@lorem @ipsum @dolor \n @sit amet'
|
|
260
|
-
}
|
|
261
|
-
expected =
|
|
262
|
-
'<p dir=\"auto\"><span><a class="markdown-author-link" data-author="lorem">@lorem</a> <a class="markdown-author-link" data-author="ipsum">@ipsum</a> <a class="markdown-author-link" data-author="dolor">@dolor</a></span><br /><span>\n<a class="markdown-author-link" data-author="sit">@sit</a> amet</span></p>'
|
|
263
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
input = {
|
|
267
|
-
author: 'foo51',
|
|
268
|
-
permlink: 'bar51',
|
|
269
|
-
last_update: '2019-05-10T09:15:21',
|
|
270
|
-
body: '@lorem @ipsum @dolor \n @Sit amet'
|
|
271
|
-
}
|
|
272
|
-
expected =
|
|
273
|
-
'<p dir=\"auto\"><span><a class="markdown-author-link" data-author="lorem">@lorem</a> <a class="markdown-author-link" data-author="ipsum">@ipsum</a> <a class="markdown-author-link" data-author="dolor">@dolor</a></span><br />\n@Sit amet</p>'
|
|
274
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
275
|
-
})
|
|
276
|
-
|
|
277
|
-
it('18- Should replace tags with link for given string', () => {
|
|
278
|
-
let input = {
|
|
279
|
-
author: 'foo52',
|
|
280
|
-
permlink: 'bar52',
|
|
281
|
-
last_update: '2019-05-10T09:15:21',
|
|
282
|
-
body: 'lorem ipsum #dolor sit amet'
|
|
283
|
-
}
|
|
284
|
-
let expected =
|
|
285
|
-
'<p dir=\"auto\"><span>lorem ipsum <a class="markdown-tag-link" data-tag="dolor">#dolor</a> sit amet</span></p>'
|
|
286
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
287
|
-
|
|
288
|
-
input = {
|
|
289
|
-
author: 'foo53',
|
|
290
|
-
permlink: 'bar53',
|
|
291
|
-
last_update: '2019-05-10T09:15:21',
|
|
292
|
-
body: '#lorem ipsum #dolor sit amet'
|
|
293
|
-
}
|
|
294
|
-
expected =
|
|
295
|
-
'<p dir=\"auto\"><span><a class="markdown-tag-link" data-tag="lorem">#lorem</a> ipsum <a class="markdown-tag-link" data-tag="dolor">#dolor</a> sit amet</span></p>'
|
|
296
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
297
|
-
|
|
298
|
-
input = {
|
|
299
|
-
author: 'foo54',
|
|
300
|
-
permlink: 'bar54',
|
|
301
|
-
last_update: '2019-05-10T09:15:21',
|
|
302
|
-
body: '#lorem #ipsum #dolor sit amet'
|
|
303
|
-
}
|
|
304
|
-
expected =
|
|
305
|
-
'<p dir=\"auto\"><span><a class="markdown-tag-link" data-tag="lorem">#lorem</a> <a class="markdown-tag-link" data-tag="ipsum">#ipsum</a> <a class="markdown-tag-link" data-tag="dolor">#dolor</a> sit amet</span></p>'
|
|
306
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
307
|
-
|
|
308
|
-
input = {
|
|
309
|
-
author: 'foo55',
|
|
310
|
-
permlink: 'bar55',
|
|
311
|
-
last_update: '2019-05-10T09:15:21',
|
|
312
|
-
body: '#lorem #ipsum #dolor \n #sit amet'
|
|
313
|
-
}
|
|
314
|
-
expected =
|
|
315
|
-
'<p dir=\"auto\"><span><a class="markdown-tag-link" data-tag="lorem">#lorem</a> <a class="markdown-tag-link" data-tag="ipsum">#ipsum</a> <a class="markdown-tag-link" data-tag="dolor">#dolor</a></span><br /><span>\n<a class="markdown-tag-link" data-tag="sit">#sit</a> amet</span></p>'
|
|
316
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
317
|
-
|
|
318
|
-
input = {
|
|
319
|
-
author: 'foo56',
|
|
320
|
-
permlink: 'bar56',
|
|
321
|
-
last_update: '2019-05-10T09:15:21',
|
|
322
|
-
body: '#lorem #ipsum #dolor \n #Sit amet'
|
|
323
|
-
}
|
|
324
|
-
expected =
|
|
325
|
-
'<p dir=\"auto\"><span><a class="markdown-tag-link" data-tag="lorem">#lorem</a> <a class="markdown-tag-link" data-tag="ipsum">#ipsum</a> <a class="markdown-tag-link" data-tag="dolor">#dolor</a></span><br /><span>\n<a class="markdown-tag-link" data-tag="sit">#Sit</a> amet</span></p>'
|
|
326
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
327
|
-
|
|
328
|
-
input = {
|
|
329
|
-
author: 'foo57',
|
|
330
|
-
permlink: 'bar57',
|
|
331
|
-
last_update: '2019-05-10T09:15:21',
|
|
332
|
-
body: 'you are #1'
|
|
333
|
-
}
|
|
334
|
-
expected = '<p dir=\"auto\">you are #1</p>'
|
|
335
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
336
|
-
|
|
337
|
-
input = {
|
|
338
|
-
author: 'foo58',
|
|
339
|
-
permlink: 'bar58',
|
|
340
|
-
last_update: '2019-05-10T09:15:21',
|
|
341
|
-
body: 'you are #1 #steemit-promo'
|
|
342
|
-
}
|
|
343
|
-
expected =
|
|
344
|
-
'<p dir=\"auto\"><span>you are #1 <a class="markdown-tag-link" data-tag="steemit-promo">#steemit-promo</a></span></p>'
|
|
345
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
346
|
-
})
|
|
347
|
-
|
|
348
|
-
it('19- Should replace both mentions and tags', () => {
|
|
349
|
-
let input = {
|
|
350
|
-
author: 'foo59',
|
|
351
|
-
permlink: 'bar59',
|
|
352
|
-
last_update: '2019-05-10T09:15:21',
|
|
353
|
-
body: 'lorem ipsum #dolor sit @amet'
|
|
354
|
-
}
|
|
355
|
-
let expected =
|
|
356
|
-
'<p dir=\"auto\"><span>lorem ipsum <a class="markdown-tag-link" data-tag="dolor">#dolor</a> sit <a class="markdown-author-link" data-author="amet">@amet</a></span></p>'
|
|
357
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
358
|
-
|
|
359
|
-
input = {
|
|
360
|
-
author: 'foo60',
|
|
361
|
-
permlink: 'bar60',
|
|
362
|
-
last_update: '2019-05-10T09:15:21',
|
|
363
|
-
body: 'lorem ipsum @#dolor sit amet'
|
|
364
|
-
}
|
|
365
|
-
expected = '<p dir=\"auto\">lorem ipsum @#dolor sit amet</p>'
|
|
366
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
367
|
-
})
|
|
368
|
-
|
|
369
|
-
it('20- Should not convert markdown links', () => {
|
|
370
|
-
const input = {
|
|
371
|
-
author: 'foo61',
|
|
372
|
-
permlink: 'bar61',
|
|
373
|
-
last_update: '2019-05-10T09:15:21',
|
|
374
|
-
body: 'lorem [this error](https://images.ecency.com/0x0/https://d1vof77qrk4l5q.cloudfront.net/img/5752638e6965247789bc20cef34727263aaa41e1.png) ipsum'
|
|
375
|
-
}
|
|
376
|
-
expect(markdown2Html(input)).toBe(SNAPSHOT_JSON.markdown_2_html_test_files_4_should_not_convert_markdown_links)
|
|
377
|
-
})
|
|
378
|
-
|
|
379
|
-
it('21- Should add https prefix', () => {
|
|
380
|
-
const input = {
|
|
381
|
-
author: 'foo62',
|
|
382
|
-
permlink: 'bar62',
|
|
383
|
-
last_update: '2019-05-10T09:15:21',
|
|
384
|
-
body: '<a href="foo">foo</a>'
|
|
385
|
-
}
|
|
386
|
-
expect(markdown2Html(input).trim()).toBe(
|
|
387
|
-
'<p dir=\"auto\"><a class="markdown-external-link" data-href="https://foo">foo</a></p>'
|
|
388
|
-
)
|
|
389
|
-
})
|
|
390
|
-
|
|
391
|
-
it('23- Test with not obj param', () => {
|
|
392
|
-
expect(markdown2Html('<a href="foo">foo</a> lorem ipsum **dolor** sit amet').trim()).toBe(
|
|
393
|
-
'<p dir=\"auto\"><a class="markdown-external-link" data-href="https://foo">foo</a> lorem ipsum <strong>dolor</strong> sit amet</p>'
|
|
394
|
-
)
|
|
395
|
-
})
|
|
396
|
-
|
|
397
|
-
it('24- Should handle proposal vote links', () => {
|
|
398
|
-
const input = {
|
|
399
|
-
author: 'foo358',
|
|
400
|
-
permlink: 'bar358',
|
|
401
|
-
last_update: '2019-05-10T09:15:21',
|
|
402
|
-
body: '[Approve](https://beta.hivesigner.com/sign/update-proposal-votes?proposal_ids=[39]&approve=true) [Unapprove](https://beta.hivesigner.com/sign/update-proposal-votes?proposal_ids=%5B41%5D&approve=false)'
|
|
403
|
-
}
|
|
404
|
-
const expected = '<p dir=\"auto\"><a class="markdown-proposal-link" data-href="https://beta.hivesigner.com/sign/update-proposal-votes?proposal_ids=[39]&approve=true" data-proposal="39">Approve</a> <a class="markdown-proposal-link" data-href="https://beta.hivesigner.com/sign/update-proposal-votes?proposal_ids=%5B41%5D&approve=false" data-proposal="41">Unapprove</a></p>'
|
|
405
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
406
|
-
})
|
|
407
|
-
|
|
408
|
-
it('25- Should handle twitch videos', () => {
|
|
409
|
-
const input = {
|
|
410
|
-
author: 'foo363',
|
|
411
|
-
permlink: 'bar363',
|
|
412
|
-
last_update: '2019-05-10T09:15:21',
|
|
413
|
-
body: 'https://www.twitch.tv/steemspacely'
|
|
414
|
-
}
|
|
415
|
-
const expected = '<p dir=\"auto\"><a class="markdown-video-link markdown-video-link-twitch"><iframe frameborder="0" allowfullscreen="true" src="https://player.twitch.tv/?channel=steemspacely&parent=ecency.com&autoplay=false"></iframe></a></p>'
|
|
416
|
-
|
|
417
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
418
|
-
})
|
|
419
|
-
|
|
420
|
-
it('26- Should handle speak videos', () => {
|
|
421
|
-
const input = {
|
|
422
|
-
author: 'foo326',
|
|
423
|
-
permlink: 'bar326',
|
|
424
|
-
last_update: '2019-05-10T09:15:21',
|
|
425
|
-
body: '[](https://3speak.online/watch?v=wehmoen/xrhjxocx)'
|
|
426
|
-
}
|
|
427
|
-
const expected = '<p dir=\"auto\"><a class="markdown-video-link markdown-video-link-speak" data-embed-src="https://3speak.tv/embed?v=wehmoen/xrhjxocx"><img class="no-replace video-thumbnail" itemprop="image" src="https://images.ecency.com/p/2ufhwNgM3qHKBGVeU2TMMqPBjdB17MRuf4Q7vGrmGMtTn6yFtvW3Lt9t5v1c3so7UFhWDYh9B.png?format=match&mode=fit" loading="eager" fetchpriority="high" /><span class="markdown-video-play"></span></a></p>'
|
|
428
|
-
|
|
429
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
430
|
-
})
|
|
431
|
-
|
|
432
|
-
it('27- Should handle speak videos with different tld', () => {
|
|
433
|
-
const input = {
|
|
434
|
-
author: 'foo33399',
|
|
435
|
-
permlink: 'bar32300',
|
|
436
|
-
last_update: '2029-05-10T09:15:21',
|
|
437
|
-
body: '[](https://3speak.co/watch?v=theycallmedan/blnmdkjt) [Watch on 3Speak](https://3speak.co/watch?v=theycallmedan/blnmdkjt)'
|
|
438
|
-
}
|
|
439
|
-
const expected = '<p dir=\"auto\"><a class="markdown-video-link markdown-video-link-speak" data-embed-src="https://3speak.tv/embed?v=theycallmedan/blnmdkjt"><img class="no-replace video-thumbnail" itemprop="image" src="https://images.ecency.com/p/CQdwDW6BZfWWtctopKyTJuDRdBH4KXwm9ijE6sZXe5MveWF3nUu4zXXBFUau8NS.png?format=match&mode=fit" loading="eager" fetchpriority="high" /><span class="markdown-video-play"></span></a> <a class="markdown-external-link" data-href="https://3speak.co/watch?v=theycallmedan/blnmdkjt">Watch on 3Speak</a></p>'
|
|
440
|
-
|
|
441
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
442
|
-
})
|
|
443
|
-
|
|
444
|
-
it('28 - Should handle peakd post links', () => {
|
|
445
|
-
const input = {
|
|
446
|
-
author: 'foo3343',
|
|
447
|
-
permlink: 'bar3243',
|
|
448
|
-
last_update: '2019-05-10T09:15:21',
|
|
449
|
-
body: 'https://peakd.com/@demo/tests'
|
|
450
|
-
}
|
|
451
|
-
const expected = '<p dir=\"auto\"><a class=\"markdown-post-link\" data-href=\"https://peakd.com/@demo/tests\" data-is-inline=\"false\" data-tag=\"post\" data-author=\"demo\" data-permlink=\"tests\">@demo/tests</a></p>'
|
|
452
|
-
|
|
453
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
454
|
-
})
|
|
455
|
-
|
|
456
|
-
it('29- Should handle youtu.be videos', () => {
|
|
457
|
-
const input = {
|
|
458
|
-
author: 'foo329',
|
|
459
|
-
permlink: 'bar329',
|
|
460
|
-
last_update: '2019-05-10T09:15:21',
|
|
461
|
-
body: 'https://youtu.be/UuyS7YAkECA?t=295s'
|
|
462
|
-
}
|
|
463
|
-
const expected = '<p dir=\"auto\"><a class="markdown-video-link markdown-video-link-youtube" data-embed-src="https://www.youtube.com/embed/UuyS7YAkECA?autoplay=1" data-youtube="UuyS7YAkECA" data-start-time="295"><img class="no-replace video-thumbnail" itemprop="image" src="https://images.ecency.com/p/S5Eokt4BcQdk7EHeT1aYjzebg2hC7hkthT45eAMp88bZ44hfAQDm6BtJw2H53aq1Tpn1cu4.png?format=match&mode=fit" loading="eager" fetchpriority="high" /><span class="markdown-video-play"></span></a></p>'
|
|
464
|
-
|
|
465
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
466
|
-
})
|
|
467
|
-
|
|
468
|
-
it('30- Should handle external similar post links', () => {
|
|
469
|
-
const input = {
|
|
470
|
-
author: 'foo300',
|
|
471
|
-
permlink: 'bar300',
|
|
472
|
-
last_update: '2019-05-10T09:15:21',
|
|
473
|
-
body: '[Voice: the criteria for success or failure](https://app.voice.com/post/@lukestokes/voice-the-criteria-for-success-or-failure-1597453134-597)'
|
|
474
|
-
}
|
|
475
|
-
const expected = '<p dir=\"auto\"><a class="markdown-external-link" data-href="https://app.voice.com/post/@lukestokes/voice-the-criteria-for-success-or-failure-1597453134-597">Voice: the criteria for success or failure</a></p>'
|
|
476
|
-
|
|
477
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
478
|
-
})
|
|
479
|
-
|
|
480
|
-
it('31- Should handle external similar post links', () => {
|
|
481
|
-
const input = {
|
|
482
|
-
author: 'foo331',
|
|
483
|
-
permlink: 'bar331',
|
|
484
|
-
last_update: '2019-05-10T09:15:21',
|
|
485
|
-
body: '[Voice: the criteria for success or failure](https://app.voice.com/@lukestokes/voice-the-criteria-for-success-or-failure-1597453134-597)'
|
|
486
|
-
}
|
|
487
|
-
const expected = '<p dir=\"auto\"><a class="markdown-external-link" data-href="https://app.voice.com/@lukestokes/voice-the-criteria-for-success-or-failure-1597453134-597">Voice: the criteria for success or failure</a></p>'
|
|
488
|
-
|
|
489
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
490
|
-
})
|
|
491
|
-
|
|
492
|
-
it('32 - Should handle whitelisted post links', () => {
|
|
493
|
-
const input = {
|
|
494
|
-
author: 'foo33435',
|
|
495
|
-
permlink: 'bar32435',
|
|
496
|
-
last_update: '2019-05-10T09:15:21',
|
|
497
|
-
body: 'https://peakd.com/tag/@demo/tests and https://steemit.com/test/@demo/post'
|
|
498
|
-
}
|
|
499
|
-
const expected = '<p dir=\"auto\"><a class=\"markdown-post-link\" data-href=\"https://peakd.com/tag/@demo/tests\" data-is-inline=\"false\" data-tag=\"tag\" data-author=\"demo\" data-permlink=\"tests\">@demo/tests</a> and <a class=\"markdown-external-link\" data-href=\"https://steemit.com/test/@demo/post\">https://steemit.com/test/@demo/post</a></p>'
|
|
500
|
-
|
|
501
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
502
|
-
})
|
|
503
|
-
|
|
504
|
-
it('32c - Should handle whitelisted post links with referral parameters', () => {
|
|
505
|
-
const input = {
|
|
506
|
-
author: 'foo33437',
|
|
507
|
-
permlink: 'bar32437',
|
|
508
|
-
last_update: '2019-05-10T09:15:21',
|
|
509
|
-
body: 'Read related post: [Weekly Sacrament of Confession? | 3 Misconducts to Avoid!](https://ecency.com/hive-148441/@artgirl/weekly-sacrament-of-confession-or?referral=artgirl)'
|
|
510
|
-
}
|
|
511
|
-
const expected = '<p dir=\"auto\">Read related post: <a class=\"markdown-post-link\" data-href=\"https://ecency.com/hive-148441/@artgirl/weekly-sacrament-of-confession-or?referral=artgirl\" data-is-inline=\"true\" data-tag=\"hive-148441\" data-author=\"artgirl\" data-permlink=\"weekly-sacrament-of-confession-or\">Weekly Sacrament of Confession? | 3 Misconducts to Avoid!</a></p>'
|
|
512
|
-
|
|
513
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
514
|
-
})
|
|
515
|
-
|
|
516
|
-
it('32b - Should treat titled Hive links as non-inline', () => {
|
|
517
|
-
const input = {
|
|
518
|
-
author: 'foo33436',
|
|
519
|
-
permlink: 'bar32436',
|
|
520
|
-
last_update: '2019-05-10T09:15:21',
|
|
521
|
-
body: '[Waves mobile app](https://ecency.com/hive-125125/@ecency/waves-mobile-app-update-explore "https://ecency.com/hive-125125/@ecency/waves-mobile-app-update-explore")'
|
|
522
|
-
}
|
|
523
|
-
const expected = '<p dir=\"auto\"><a title=\"https://ecency.com/hive-125125/@ecency/waves-mobile-app-update-explore\" class=\"markdown-post-link\" data-href=\"https://ecency.com/hive-125125/@ecency/waves-mobile-app-update-explore\" data-is-inline=\"false\" data-tag=\"hive-125125\" data-author=\"ecency\" data-permlink=\"waves-mobile-app-update-explore\">Waves mobile app</a></p>'
|
|
524
|
-
|
|
525
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
526
|
-
})
|
|
527
|
-
|
|
528
|
-
it('33- Should handle whitelisted user links', () => {
|
|
529
|
-
const input = {
|
|
530
|
-
author: 'foo334352',
|
|
531
|
-
permlink: 'bar324352',
|
|
532
|
-
last_update: '2019-05-10T09:15:21',
|
|
533
|
-
body: 'https://peakd.com/@demo and https://steemit.com/@demo123'
|
|
534
|
-
}
|
|
535
|
-
const expected = '<p dir=\"auto\"><a class="markdown-author-link" data-author="demo">@demo</a> and <a class="markdown-external-link" data-href="https://steemit.com/@demo123">https://steemit.com/@demo123</a></p>'
|
|
536
|
-
|
|
537
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
538
|
-
})
|
|
539
|
-
|
|
540
|
-
it('34- Should handle ipfs links', () => {
|
|
541
|
-
const input = {
|
|
542
|
-
author: 'foo3493',
|
|
543
|
-
permlink: 'bar3493',
|
|
544
|
-
last_update: '2019-05-10T09:15:21',
|
|
545
|
-
body: 'this is link https://ipfs.io/ipfs/bafybeihbqfrcrbr6jkf77rdve3nbxjzkfgmeneaw2x5s43qdgpe26cha6q'
|
|
546
|
-
}
|
|
547
|
-
const expected = '<p dir=\"auto\">this is link <a data-href="https://ipfs.io/ipfs/bafybeihbqfrcrbr6jkf77rdve3nbxjzkfgmeneaw2x5s43qdgpe26cha6q" class="markdown-img-link"><img src="https://images.ecency.com/p/2923mN3pnd7PiPXAMdj9UuE6SsjvQJDHj5VpTTCNs3tkJu9JC9Pu9qXSi5Ys5PYtkaRx6ErTnFVzh1WQxWS45rvr6Q4rfUooAM242oyKeihwnx.png?format=match&mode=fit" itemprop=\"image\" loading=\"eager\" fetchpriority=\"high\" /></a></p>'
|
|
548
|
-
|
|
549
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
550
|
-
})
|
|
551
|
-
|
|
552
|
-
it('34-1- Should detect # in ipfs links', () => {
|
|
553
|
-
const input = {
|
|
554
|
-
author: 'foo34936',
|
|
555
|
-
permlink: 'bar34936',
|
|
556
|
-
last_update: '2019-05-10T09:15:24',
|
|
557
|
-
body: 'this is a link https://ipfs.io/ipfs/bafybeihbqfrcrbr6jkf77rdve3nbxjzkfgmeneaw2x5s43qdgpe26cha6q/#home'
|
|
558
|
-
}
|
|
559
|
-
const expected = '<p dir=\"auto\">this is a link <a class="markdown-external-link" data-href="https://ipfs.io/ipfs/bafybeihbqfrcrbr6jkf77rdve3nbxjzkfgmeneaw2x5s43qdgpe26cha6q/#home">https://ipfs.io/ipfs/bafybeihbqfrcrbr6jkf77rdve3nbxjzkfgmeneaw2x5s43qdgpe26cha6q/#home</a></p>'
|
|
560
|
-
|
|
561
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
562
|
-
})
|
|
563
|
-
|
|
564
|
-
it('35- Should handle twitter links', () => {
|
|
565
|
-
const input = {
|
|
566
|
-
author: 'foo3321',
|
|
567
|
-
permlink: 'bar3321',
|
|
568
|
-
last_update: '2019-05-10T09:15:21',
|
|
569
|
-
body: 'this is link https://twitter.com/DeWaarheid_/status/1320603494836015105'
|
|
570
|
-
}
|
|
571
|
-
const expected = '<p dir=\"auto\">this is link <blockquote class="twitter-tweet"><p>https://twitter.com/DeWaarheid_/status/1320603494836015105</p>- <a href="https://twitter.com/DeWaarheid_/status/1320603494836015105">DeWaarheid_</a></blockquote></p>'
|
|
572
|
-
|
|
573
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
574
|
-
})
|
|
575
|
-
|
|
576
|
-
it('36- Should handle custom community links', () => {
|
|
577
|
-
const input = {
|
|
578
|
-
author: 'foo33210',
|
|
579
|
-
permlink: 'bar33210',
|
|
580
|
-
last_update: '2019-05-10T09:15:21',
|
|
581
|
-
body: 'this is link https://peakd.com/c/hive-106444/trending and markdown link [Manipulation Station](https://peakd.com/c/hive-122516/trending)'
|
|
582
|
-
}
|
|
583
|
-
const expected = '<p dir=\"auto\">this is link <a class="markdown-community-link" data-community="hive-106444" data-filter="trending">trending/hive-106444</a> and markdown link <a class="markdown-community-link" data-community="hive-122516" data-filter="trending">Manipulation Station</a></p>'
|
|
584
|
-
|
|
585
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
586
|
-
})
|
|
587
|
-
|
|
588
|
-
it('37- Should handle dapplr iframe', () => {
|
|
589
|
-
const input = {
|
|
590
|
-
author: 'foo332101',
|
|
591
|
-
permlink: 'bar332101',
|
|
592
|
-
last_update: '2019-05-10T09:15:21',
|
|
593
|
-
body: 'this is link <iframe src="https://cdn.dapplr.in/file/dapplr-videos/sandymeyer/pEm9SdqNYJ6vntQCAalWU6dNC9zegQVl.mp4" ></iframe>'
|
|
594
|
-
}
|
|
595
|
-
const expected = '<p dir=\"auto\">this is link <iframe src="https://cdn.dapplr.in/file/dapplr-videos/sandymeyer/pEm9SdqNYJ6vntQCAalWU6dNC9zegQVl.mp4" sandbox="allow-scripts allow-same-origin" frameborder="0" allowfullscreen="true"></iframe></p>'
|
|
596
|
-
|
|
597
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
598
|
-
})
|
|
599
|
-
|
|
600
|
-
it('38- Should handle lbry.tv iframe', () => {
|
|
601
|
-
const input = {
|
|
602
|
-
author: 'foo332102',
|
|
603
|
-
permlink: 'bar332102',
|
|
604
|
-
last_update: '2019-05-10T09:15:21',
|
|
605
|
-
body: 'this is link <iframe id="lbry-iframe" width="560" height="315" src="https://lbry.tv/$/embed/epic-drone-video-sunset-swiss/38f32ec6de375352512a01c37ec9ef5e7fc35958?r=4N4ga6kbnyKXLSUCHtyfF7zh57vvJwfu" allowfullscreen></iframe> '
|
|
606
|
-
}
|
|
607
|
-
const expected = '<p dir=\"auto\">this is link <iframe src="https://lbry.tv/$/embed/epic-drone-video-sunset-swiss/38f32ec6de375352512a01c37ec9ef5e7fc35958?r=4N4ga6kbnyKXLSUCHtyfF7zh57vvJwfu" allowfullscreen="allowfullscreen" frameborder="0"></iframe></p>'
|
|
608
|
-
|
|
609
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
610
|
-
})
|
|
611
|
-
|
|
612
|
-
it('39- Should form profile page sections with copied links', () => {
|
|
613
|
-
const input = {
|
|
614
|
-
author: 'foo054',
|
|
615
|
-
permlink: 'bar054',
|
|
616
|
-
last_update: '2019-05-21T09:19:21',
|
|
617
|
-
body: '<a href=\'https://ecency.com/@good-karma/wallet\'>click here</a>'
|
|
618
|
-
}
|
|
619
|
-
const expected = '<p dir=\"auto\"><a href="https://ecency.com/@good-karma/wallet" class="markdown-profile-link">click here</a></p>'
|
|
620
|
-
|
|
621
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
622
|
-
})
|
|
623
|
-
|
|
624
|
-
it('40- Should handle archive.org iframe', () => {
|
|
625
|
-
const input = {
|
|
626
|
-
author: 'foo040',
|
|
627
|
-
permlink: 'bar040',
|
|
628
|
-
last_update: '2019-05-10T09:15:21',
|
|
629
|
-
body: 'this is link <iframe src="https://archive.org/embed/VoyagetothePlanetofPrehistoricWomen" width="640" height="480" frameborder="0" webkitallowfullscreen="true" mozallowfullscreen="true" allowfullscreen></iframe>'
|
|
630
|
-
}
|
|
631
|
-
const expected = '<p dir=\"auto\">this is link <iframe src="https://archive.org/embed/VoyagetothePlanetofPrehistoricWomen" frameborder="0" webkitallowfullscreen="true" mozallowfullscreen="true" allowfullscreen="allowfullscreen"></iframe></p>'
|
|
632
|
-
|
|
633
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
634
|
-
})
|
|
635
|
-
|
|
636
|
-
it('41- Should handle spotify link', () => {
|
|
637
|
-
const input = {
|
|
638
|
-
author: 'foo041',
|
|
639
|
-
permlink: 'bar041',
|
|
640
|
-
last_update: '2019-05-10T09:15:21',
|
|
641
|
-
body: 'this is link https://open.spotify.com/playlist/7JG1cEnaIT6CSzloyNI6tU?si=7MCcmFEZQCebLvzqehq81Q '
|
|
642
|
-
}
|
|
643
|
-
const expected = '<p dir=\"auto\">this is link <a class=\"markdown-audio-link markdown-audio-link-spotify\"><iframe frameborder=\"0\" allowfullscreen=\"true\" src=\"https://open.spotify.com/embed/playlist/7JG1cEnaIT6CSzloyNI6tU?si=7MCcmFEZQCebLvzqehq81Q\" sandbox=\"allow-scripts allow-same-origin allow-popups\"></iframe></a></p>'
|
|
644
|
-
|
|
645
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
646
|
-
})
|
|
647
|
-
|
|
648
|
-
it('42- Should handle spotify embed', () => {
|
|
649
|
-
const input = {
|
|
650
|
-
author: 'foo042',
|
|
651
|
-
permlink: 'bar042',
|
|
652
|
-
last_update: '2019-05-10T09:15:21',
|
|
653
|
-
body: 'this is embed link <iframe src="https://open.spotify.com/embed/album/6AORtDjduMM3bupSWzbTSG" width="300" height="380" frameborder="0" allowtransparency="true" allow="encrypted-media"></iframe> '
|
|
654
|
-
}
|
|
655
|
-
const expected = '<p dir=\"auto\">this is embed link <iframe src=\"https://open.spotify.com/embed/album/6AORtDjduMM3bupSWzbTSG\" frameborder=\"0\" sandbox=\"allow-scripts allow-same-origin allow-popups\"></iframe></p>'
|
|
656
|
-
|
|
657
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
658
|
-
})
|
|
659
|
-
|
|
660
|
-
it('43 - Should handle dtube iframe', () => {
|
|
661
|
-
const input = {
|
|
662
|
-
author: 'foo343',
|
|
663
|
-
permlink: 'bar343',
|
|
664
|
-
last_update: '2019-05-10T09:15:21',
|
|
665
|
-
body: 'this is link <iframe width="560" height="315" src="https://emb.d.tube/#!/keepskating420/QmZyu5uPfm2wvEDJaSfCx9wwDBMEcDg5CoxbKKC2vjqubq" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>'
|
|
666
|
-
}
|
|
667
|
-
const expected = '<p dir=\"auto\">this is link <iframe src="https://emb.d.tube/#!/keepskating420/QmZyu5uPfm2wvEDJaSfCx9wwDBMEcDg5CoxbKKC2vjqubq" frameborder="0" allowfullscreen="true" sandbox="allow-scripts allow-same-origin"></iframe></p>'
|
|
668
|
-
|
|
669
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
670
|
-
})
|
|
671
|
-
|
|
672
|
-
it('44 - Should handle vimm iframe', () => {
|
|
673
|
-
const input = {
|
|
674
|
-
author: 'foo344',
|
|
675
|
-
permlink: 'bar344',
|
|
676
|
-
last_update: '2019-05-10T09:15:21',
|
|
677
|
-
body: 'this is link <iframe width="640px" height="360px" src="https://www.vimm.tv/vandalgame/embed?autoplay=0" frameborder=0></iframe>'
|
|
678
|
-
}
|
|
679
|
-
const expected = '<p dir=\"auto\">this is link <iframe src="https://www.vimm.tv/vandalgame/embed?autoplay=0" frameborder="0" sandbox="allow-scripts allow-same-origin allow-popups" allowfullscreen="true"></iframe></p>'
|
|
680
|
-
|
|
681
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
682
|
-
})
|
|
683
|
-
|
|
684
|
-
it('45 - Should handle collection linking', () => {
|
|
685
|
-
const input = {
|
|
686
|
-
author: 'foo345',
|
|
687
|
-
permlink: 'bar345',
|
|
688
|
-
last_update: '2019-05-10T09:15:21',
|
|
689
|
-
body: 'this is link https://peakd.com/ccc/jarvie/one-week-roadtrip-to-all-5-utah-national-parks-and-more'
|
|
690
|
-
}
|
|
691
|
-
const expected = '<p dir=\"auto\">this is link <a class=\"markdown-post-link\" data-href=\"https://peakd.com/ccc/jarvie/one-week-roadtrip-to-all-5-utah-national-parks-and-more\" data-is-inline=\"false\" data-tag=\"ccc\" data-author=\"jarvie\" data-permlink=\"one-week-roadtrip-to-all-5-utah-national-parks-and-more\">@jarvie/one-week-roadtrip-to-all-5-utah-national-parks-and-more</a></p>'
|
|
692
|
-
|
|
693
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
694
|
-
})
|
|
695
|
-
|
|
696
|
-
it('46 - Should handle copied md links', () => {
|
|
697
|
-
const input = {
|
|
698
|
-
author: 'foo346',
|
|
699
|
-
permlink: 'bar346',
|
|
700
|
-
last_update: '2019-05-10T09:15:21',
|
|
701
|
-
body: '[click here](https://peakd.com/@praetoria-cartel/wallet) direct link https://peakd.com/@praetoria-cartel/posts'
|
|
702
|
-
}
|
|
703
|
-
const expected = '<p dir=\"auto\"><a href=\"https://ecency.com/@praetoria-cartel/wallet\" class=\"markdown-profile-link\">click here</a> direct link <a href=\"https://ecency.com/@praetoria-cartel/posts\" class=\"markdown-profile-link\">@praetoria-cartel/posts</a></p>'
|
|
704
|
-
|
|
705
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
706
|
-
})
|
|
707
|
-
|
|
708
|
-
it('47 - Should handle internal links', () => {
|
|
709
|
-
const input = {
|
|
710
|
-
author: 'foo347',
|
|
711
|
-
permlink: 'bar347',
|
|
712
|
-
last_update: '2019-05-10T09:15:21',
|
|
713
|
-
body: 'for history refer to this fine post /@offgridlife/proofofbrain-golden-rule-do-to-others-what-you-want-them-to-do-to-you and while you are in the community'
|
|
714
|
-
}
|
|
715
|
-
const expected = '<p dir=\"auto\"><span>for history refer to this fine post <a class=\"markdown-post-link\" data-author=\"offgridlife\" data-tag=\"post\" data-permlink=\"proofofbrain-golden-rule-do-to-others-what-you-want-them-to-do-to-you\">@offgridlife/proofofbrain-golden-rule-do-to-others-what-you-want-them-to-do-to-you</a> and while you are in the community</span></p>'
|
|
716
|
-
|
|
717
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
718
|
-
})
|
|
719
|
-
|
|
720
|
-
it('48 - Should handle Bitchute links', () => {
|
|
721
|
-
const input = {
|
|
722
|
-
author: 'foo347',
|
|
723
|
-
permlink: 'bar347',
|
|
724
|
-
last_update: '2021-05-10T09:15:21',
|
|
725
|
-
body: 'https://www.bitchute.com/video/DJJvTZQxMaNK/'
|
|
726
|
-
}
|
|
727
|
-
const expected = '<p dir=\"auto\"><a class=\"markdown-video-link\" data-embed-src=\"https://www.bitchute.com/embed/DJJvTZQxMaNK/\"><span class=\"markdown-video-play\"></span></a></p>'
|
|
728
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
729
|
-
})
|
|
730
|
-
|
|
731
|
-
it('49 - Should handle Bitchute iframes', () => {
|
|
732
|
-
const input = {
|
|
733
|
-
author: 'foo349',
|
|
734
|
-
permlink: 'bar349',
|
|
735
|
-
last_update: '2021-05-10T09:15:49',
|
|
736
|
-
body: '<iframe width="640" height="360" scrolling="no" frameborder="0" style="border: none;" src="https://www.bitchute.com/embed/DJJvTZQxMaNK/"></iframe>'
|
|
737
|
-
}
|
|
738
|
-
const expected = '<iframe frameborder=\"0\" src=\"https://www.bitchute.com/embed/DJJvTZQxMaNK/\"></iframe>'
|
|
739
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
740
|
-
})
|
|
741
|
-
|
|
742
|
-
it('50 - Should handle user slash link', () => {
|
|
743
|
-
const input = {
|
|
744
|
-
author: 'foo350',
|
|
745
|
-
permlink: 'bar350',
|
|
746
|
-
last_update: '2021-05-10T09:15:49',
|
|
747
|
-
body: '<a href="/@hivesql"><img src="https://i.imgur.com/EPN8RW6.png"></a>'
|
|
748
|
-
}
|
|
749
|
-
const expected = '<p dir=\"auto\"><a class=\"markdown-author-link\" data-author=\"hivesql\"><img src=\"https://images.ecency.com/p/2bP4pJr4wVimqCWjYimXJe2cnCgn8gbL3c5wQPJF23G.png?format=match&mode=fit\" itemprop=\"image\" loading=\"eager\" fetchpriority=\"high\" /></a></p>'
|
|
750
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
751
|
-
})
|
|
752
|
-
|
|
753
|
-
it('51 - Should handle posts without tags internal link', () => {
|
|
754
|
-
const input = {
|
|
755
|
-
author: 'foo351',
|
|
756
|
-
permlink: 'bar351',
|
|
757
|
-
last_update: '2021-05-10T09:15:49',
|
|
758
|
-
body: '<a href="/@demo/test">test post</a>'
|
|
759
|
-
}
|
|
760
|
-
const expected = '<p dir=\"auto\"><a class=\"markdown-post-link\" data-href=\"/@demo/test\" data-is-inline=\"true\" data-tag=\"post\" data-author=\"demo\" data-permlink=\"test\">test post</a></p>'
|
|
761
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
762
|
-
})
|
|
763
|
-
|
|
764
|
-
it('52 - Should handle filtered tag link', () => {
|
|
765
|
-
const input = {
|
|
766
|
-
author: 'foo352',
|
|
767
|
-
permlink: 'bar352',
|
|
768
|
-
last_update: '2021-05-10T09:15:49',
|
|
769
|
-
body: 'https://hive.blog/trending/books'
|
|
770
|
-
}
|
|
771
|
-
const expected = '<p dir=\"auto\"><a class=\"markdown-tag-link\" data-filter=\"trending\" data-tag=\"books\">/trending/books</a></p>'
|
|
772
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
773
|
-
})
|
|
774
|
-
|
|
775
|
-
it('53 - Should handle filtered tag internal link', () => {
|
|
776
|
-
const input = {
|
|
777
|
-
author: 'foo353',
|
|
778
|
-
permlink: 'bar353',
|
|
779
|
-
last_update: '2021-05-10T09:15:49',
|
|
780
|
-
body: '<a href="/trending/books">trending books</a>'
|
|
781
|
-
}
|
|
782
|
-
const expected = '<p dir=\"auto\"><a class=\"markdown-tag-link\" data-filter=\"trending\" data-tag=\"books\">trending books</a></p>'
|
|
783
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
784
|
-
})
|
|
785
|
-
|
|
786
|
-
it('54 - Should highlight code', () => {
|
|
787
|
-
const input = {
|
|
788
|
-
author: 'foo354',
|
|
789
|
-
permlink: 'bar354',
|
|
790
|
-
last_update: '2021-08-18T09:15:49',
|
|
791
|
-
body: `\`\`\`
|
|
792
|
-
def factorial(n):
|
|
793
|
-
# a comment
|
|
794
|
-
return 1 if (n==1 or n==0) else n * factorial(n - 1)
|
|
795
|
-
\`\`\`
|
|
796
|
-
`
|
|
797
|
-
}
|
|
798
|
-
expect(markdown2Html(input)).toBe(SNAPSHOT_JSON.markdown_2_html_traversing_54_should_highlight_code)
|
|
799
|
-
})
|
|
800
|
-
|
|
801
|
-
it('55 - Should detect loom share', () => {
|
|
802
|
-
const input = {
|
|
803
|
-
author: 'foo355',
|
|
804
|
-
permlink: 'bar355',
|
|
805
|
-
last_update: '2021-08-18T09:15:49',
|
|
806
|
-
body: 'https://www.loom.com/share/5bbdeb480ba84e65b1b3de8c190e2003'
|
|
807
|
-
}
|
|
808
|
-
const expected = '<p dir=\"auto\"><a class=\"markdown-video-link markdown-video-link-loom\"><iframe frameborder=\"0\" allowfullscreen=\"true\" src=\"https://www.loom.com/embed/5bbdeb480ba84e65b1b3de8c190e2003\" sandbox=\"allow-scripts allow-same-origin allow-popups\"></iframe></a></p>'
|
|
809
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
810
|
-
})
|
|
811
|
-
|
|
812
|
-
it('56 - Should detect loom embed', () => {
|
|
813
|
-
const input = {
|
|
814
|
-
author: 'foo356',
|
|
815
|
-
permlink: 'bar356',
|
|
816
|
-
last_update: '2021-08-18T09:15:49',
|
|
817
|
-
body: '<iframe width="640" height="327" src="https://www.loom.com/embed/5bbdeb480ba84e65b1b3de8c190e2003" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>'
|
|
818
|
-
}
|
|
819
|
-
const expected = '<iframe src=\"https://www.loom.com/embed/5bbdeb480ba84e65b1b3de8c190e2003\" frameborder=\"0\" webkitallowfullscreen=\"webkitallowfullscreen\" mozallowfullscreen=\"mozallowfullscreen\" allowfullscreen=\"allowfullscreen\"></iframe>'
|
|
820
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
821
|
-
})
|
|
822
|
-
|
|
823
|
-
it('57 - Should post linkify failed links', () => {
|
|
824
|
-
const input = {
|
|
825
|
-
author: 'foo357',
|
|
826
|
-
permlink: 'bar357',
|
|
827
|
-
last_update: '2021-08-18T09:15:49',
|
|
828
|
-
body: '<p dir=\"auto\"><strong>THINGS WE CAN DO TO PREPARE FOR INDEFINITE LOCKDOWNS<br></strong>https://peakd.com/hive-123046/@ecotrain/ecotrain-question-of-the-week-5-2tie-up-post-things-we-can-do-to-prepare-for-indefinite-lockdowns </p>'
|
|
829
|
-
}
|
|
830
|
-
const expected = '<p dir=\"auto\"><strong>THINGS WE CAN DO TO PREPARE FOR INDEFINITE LOCKDOWNS<br /></strong><a data-tag=\"hive-123046\" data-author=\"ecotrain\" data-permlink=\"ecotrain-question-of-the-week-5-2tie-up-post-things-we-can-do-to-prepare-for-indefinite-lockdowns\" class=\"markdown-post-link\">/@ecotrain/ecotrain-question-of-the-week-5-2tie-up-post-things-we-can-do-to-prepare-for-indefinite-lockdowns</a></p>'
|
|
831
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
832
|
-
})
|
|
833
|
-
|
|
834
|
-
it('58 - Should post linkify failed, spaced links', () => {
|
|
835
|
-
const input = {
|
|
836
|
-
author: 'foo358',
|
|
837
|
-
permlink: 'bar358',
|
|
838
|
-
last_update: '2021-08-18T09:15:49',
|
|
839
|
-
body: `<p dir=\"auto\"><strong>It's a Secret, But is it good to have secrets?</strong><br>
|
|
840
|
-
https://peakd.com/hive-123046/@ecotrain/ecotrain-question-of-the-week-season-5-1tie-up-post-it-s-a-secret-but-is-it-good-to-have-secrets </p> `
|
|
841
|
-
}
|
|
842
|
-
const expected = '<p dir=\"auto\"><strong>It\'s a Secret, But is it good to have secrets?</strong><br /><a data-tag=\"hive-123046\" data-author=\"ecotrain\" data-permlink=\"ecotrain-question-of-the-week-season-5-1tie-up-post-it-s-a-secret-but-is-it-good-to-have-secrets\" class=\"markdown-post-link\">/@ecotrain/ecotrain-question-of-the-week-season-5-1tie-up-post-it-s-a-secret-but-is-it-good-to-have-secrets</a></p>'
|
|
843
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
844
|
-
})
|
|
845
|
-
|
|
846
|
-
it('59 - Should handle Aureal iframe', () => {
|
|
847
|
-
const input = {
|
|
848
|
-
author: 'foo359',
|
|
849
|
-
permlink: 'bar359',
|
|
850
|
-
last_update: '2021-10-23T09:15:21',
|
|
851
|
-
body: 'this is link <iframe loading="lazy" src="https://aureal-embed.web.app/535939" width="100%" height="200" frameborder="0" data-rocket-lazyload="fitvidscompatible" class="lazyloaded" data-ll-status="loaded"></iframe>'
|
|
852
|
-
}
|
|
853
|
-
const expected = '<p dir=\"auto\">this is link <iframe src=\"https://aureal-embed.web.app/535939\" frameborder=\"0\" class=\"lazyloaded\"></iframe></p>'
|
|
854
|
-
|
|
855
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
856
|
-
})
|
|
857
|
-
|
|
858
|
-
it('60 - Should username with permlink', () => {
|
|
859
|
-
const input = {
|
|
860
|
-
author: 'foo360',
|
|
861
|
-
permlink: 'bar360',
|
|
862
|
-
last_update: '2021-10-23T09:15:21',
|
|
863
|
-
body: 'this is link @demo/test for internal'
|
|
864
|
-
}
|
|
865
|
-
const expected = '<p dir=\"auto\"><span>this is link <a class=\"markdown-post-link\" data-author=\"demo\" data-tag=\"post\" data-permlink=\"test\">@demo/test</a> for internal</span></p>'
|
|
866
|
-
|
|
867
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
868
|
-
})
|
|
869
|
-
|
|
870
|
-
it('61 - Should username with permlink with slash', () => {
|
|
871
|
-
const input = {
|
|
872
|
-
author: 'foo361',
|
|
873
|
-
permlink: 'bar361',
|
|
874
|
-
last_update: '2021-10-23T09:15:21',
|
|
875
|
-
body: 'this is link /@demo/test for internal'
|
|
876
|
-
}
|
|
877
|
-
const expected = '<p dir=\"auto\"><span>this is link <a class=\"markdown-post-link\" data-author=\"demo\" data-tag=\"post\" data-permlink=\"test\">@demo/test</a> for internal</span></p>'
|
|
878
|
-
|
|
879
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
880
|
-
})
|
|
881
|
-
|
|
882
|
-
it('62 - Should username with permlink new line', () => {
|
|
883
|
-
const input = {
|
|
884
|
-
author: 'foo362',
|
|
885
|
-
permlink: 'bar362',
|
|
886
|
-
last_update: '2021-10-23T09:15:21',
|
|
887
|
-
body: '@demo/test for internal'
|
|
888
|
-
}
|
|
889
|
-
const expected = '<p dir=\"auto\"><span> <a class=\"markdown-post-link\" data-author=\"demo\" data-tag=\"post\" data-permlink=\"test\">@demo/test</a> for internal</span></p>'
|
|
890
|
-
|
|
891
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
892
|
-
})
|
|
893
|
-
|
|
894
|
-
it('63 - Should username with permlink with slash new line', () => {
|
|
895
|
-
const input = {
|
|
896
|
-
author: 'foo363',
|
|
897
|
-
permlink: 'bar363',
|
|
898
|
-
last_update: '2021-10-23T09:15:21',
|
|
899
|
-
body: '/@demo/test for internal'
|
|
900
|
-
}
|
|
901
|
-
const expected = '<p dir=\"auto\"><span> <a class=\"markdown-post-link\" data-author=\"demo\" data-tag=\"post\" data-permlink=\"test\">@demo/test</a> for internal</span></p>'
|
|
902
|
-
|
|
903
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
904
|
-
})
|
|
905
|
-
|
|
906
|
-
it('64 - Should username with section link', () => {
|
|
907
|
-
const input = {
|
|
908
|
-
author: 'foo364',
|
|
909
|
-
permlink: 'bar364',
|
|
910
|
-
last_update: '2021-10-23T09:15:21',
|
|
911
|
-
body: '@demo/wallet for internal'
|
|
912
|
-
}
|
|
913
|
-
const expected = '<p dir=\"auto\"><span> <a class=\"markdown-profile-link\" href=\"/@demo/wallet\">@demo/wallet</a> for internal</span></p>'
|
|
914
|
-
|
|
915
|
-
expect(markdown2Html(input, false)).toBe(expected)
|
|
916
|
-
})
|
|
917
|
-
|
|
918
|
-
it('65 - Should handle youtube.com/embed videos', () => {
|
|
919
|
-
const input = {
|
|
920
|
-
author: 'foo365',
|
|
921
|
-
permlink: 'bar365',
|
|
922
|
-
last_update: '2019-05-10T09:15:21',
|
|
923
|
-
body: 'https://www.youtube.com/embed/UuyS7YAkECA?start=295&autoplay=1'
|
|
924
|
-
}
|
|
925
|
-
const expected = '<p dir=\"auto\"><a class="markdown-video-link markdown-video-link-youtube" data-embed-src="https://www.youtube.com/embed/UuyS7YAkECA?autoplay=1" data-youtube="UuyS7YAkECA" data-start-time="295"><img class="no-replace video-thumbnail" itemprop="image" src="https://images.ecency.com/p/S5Eokt4BcQdk7EHeT1aYjzebg2hC7hkthT45eAMp88bZ44hfAQDm6BtJw2H53aq1Tpn1cu4.png?format=match&mode=fit" loading="eager" fetchpriority="high" /><span class="markdown-video-play"></span></a></p>'
|
|
926
|
-
|
|
927
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
928
|
-
})
|
|
929
|
-
|
|
930
|
-
it('66 - Should handle internal links with params', () => {
|
|
931
|
-
const input = {
|
|
932
|
-
author: 'foo366',
|
|
933
|
-
permlink: 'bar366',
|
|
934
|
-
last_update: '2019-05-10T09:15:21',
|
|
935
|
-
body: 'direct link https://ecency.com/@ecency/faq?history'
|
|
936
|
-
}
|
|
937
|
-
const expected = '<p dir=\"auto\">direct link <a class=\"markdown-post-link\" data-href=\"https://ecency.com/@ecency/faq?history\" data-is-inline=\"false\" data-tag=\"post\" data-author=\"ecency\" data-permlink=\"faq\">@ecency/faq</a></p>'
|
|
938
|
-
|
|
939
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
940
|
-
})
|
|
941
|
-
|
|
942
|
-
it('67 - Should handle section links with params', () => {
|
|
943
|
-
const input = {
|
|
944
|
-
author: 'foo367',
|
|
945
|
-
permlink: 'bar367',
|
|
946
|
-
last_update: '2019-05-10T09:15:21',
|
|
947
|
-
body: 'direct link https://ecency.com/@ecency/posts?q=games'
|
|
948
|
-
}
|
|
949
|
-
const expected = '<p dir=\"auto\">direct link <a href=\"https://ecency.com/@ecency/posts?q=games\" class=\"markdown-profile-link\">@ecency/posts?q=games</a></p>'
|
|
950
|
-
|
|
951
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
952
|
-
})
|
|
953
|
-
|
|
954
|
-
it('68 - Should handle section links', () => {
|
|
955
|
-
const input = {
|
|
956
|
-
author: 'foo368',
|
|
957
|
-
permlink: 'bar368',
|
|
958
|
-
last_update: '2019-05-10T09:15:21',
|
|
959
|
-
body: 'this is link [What is HIVE](#WhatHive) and locatino ## 1 <a data-id="WhatHive"></a>What is HIVE?'
|
|
960
|
-
}
|
|
961
|
-
const expected = '<p dir=\"auto\">this is link <a href=\"#WhatHive\" class=\"markdown-internal-link\">What is HIVE</a> and locatino ## 1 <a data-id=\"WhatHive\"></a>What is HIVE?</p>'
|
|
962
|
-
|
|
963
|
-
expect(markdown2Html(input, false)).toBe(expected)
|
|
964
|
-
})
|
|
965
|
-
|
|
966
|
-
it('69 - Should handle section links', () => {
|
|
967
|
-
const input = {
|
|
968
|
-
author: 'foo369',
|
|
969
|
-
permlink: 'bar369',
|
|
970
|
-
last_update: '2019-05-10T09:15:21',
|
|
971
|
-
body: 'this is link https://inleo.io/@godfish/close-range-reflections'
|
|
972
|
-
}
|
|
973
|
-
const expected = '<p dir=\"auto\">this is link <a href="/post/@godfish/close-range-reflections" class="markdown-post-link" data-is-inline="false">@godfish/close-range-reflections</a></p>'
|
|
974
|
-
|
|
975
|
-
expect(markdown2Html(input, false)).toBe(expected)
|
|
976
|
-
})
|
|
977
|
-
|
|
978
|
-
it('70- Should handle youtube shorts/videos', () => {
|
|
979
|
-
const input = {
|
|
980
|
-
author: 'foo370',
|
|
981
|
-
permlink: 'bar370',
|
|
982
|
-
last_update: '2019-05-10T09:15:21',
|
|
983
|
-
body: 'https://www.youtube.com/shorts/IaehbZnsi4w'
|
|
984
|
-
}
|
|
985
|
-
const expected = '<p dir=\"auto\"><a class="markdown-video-link markdown-video-link-youtube" data-embed-src="https://www.youtube.com/embed/IaehbZnsi4w?autoplay=1" data-youtube="IaehbZnsi4w"><img class="no-replace video-thumbnail" itemprop="image" src="https://images.ecency.com/p/S5Eokt4BcQdk7EHeT1aYjzebg2hC7hkthT45e5VviwaTq13pYBZesC7Hh3idYK26Q1RMUHU.png?format=match&mode=fit" loading="eager" fetchpriority="high" /><span class="markdown-video-play"></span></a></p>'
|
|
986
|
-
|
|
987
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
988
|
-
})
|
|
989
|
-
})
|
|
990
|
-
|
|
991
|
-
describe("Rumble support", () => {
|
|
992
|
-
|
|
993
|
-
it('Rumble iframes', () => {
|
|
994
|
-
let expected = '<iframe frameborder="0" src="https://rumble.com/embed/vhwsp4/?pub=4"></iframe>'
|
|
995
|
-
let input = {
|
|
996
|
-
author: 'foo350x',
|
|
997
|
-
permlink: 'bar350x',
|
|
998
|
-
last_update: '2021-05-10T09:15:50',
|
|
999
|
-
body: '<iframe width="640" height="360" scrolling="no" frameborder="0" style="border: none;" src="https://rumble.com/embed/vhwsp4/?pub=4"></iframe>'
|
|
1000
|
-
}
|
|
1001
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
1002
|
-
})
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
it('Rumble embed URL', () => {
|
|
1006
|
-
const expected = "<p dir=\"auto\"><a class=\"markdown-video-link\" data-embed-src=\"https://www.rumble.com/embed/vhwsp4/?pub=4\"><span class=\"markdown-video-play\"></span></a></p>"
|
|
1007
|
-
let input = {
|
|
1008
|
-
author: 'foo350y',
|
|
1009
|
-
permlink: 'bar350y',
|
|
1010
|
-
last_update: '2021-05-10T09:16:50',
|
|
1011
|
-
body: '<a href="https://rumble.com/embed/vhwsp4/?pub=4">https://rumble.com/embed/vhwsp4/?pub=4</a>'
|
|
1012
|
-
}
|
|
1013
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
1014
|
-
})
|
|
1015
|
-
|
|
1016
|
-
it('Rumble iframes 2', () => {
|
|
1017
|
-
let expected = '<iframe class="rumble" src="https://rumble.com/embed/v2mb4d6/?pub=1aoesn" frameborder="0" allowfullscreen="allowfullscreen"></iframe>'
|
|
1018
|
-
let input = {
|
|
1019
|
-
author: 'foo350xx',
|
|
1020
|
-
permlink: 'bar350xx',
|
|
1021
|
-
last_update: '2021-05-10T09:15:50',
|
|
1022
|
-
body: '<iframe class="rumble" width="640" height="360" src="https://rumble.com/embed/v2mb4d6/?pub=1aoesn" frameborder="0" allowfullscreen></iframe>'
|
|
1023
|
-
}
|
|
1024
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
1025
|
-
})
|
|
1026
|
-
|
|
1027
|
-
// The following cannot be done: Convert URLs to the video page like this one
|
|
1028
|
-
// (https://rumble.com/vkhkzl-helping-my-girls-to-cool-down-in-the-heat.html)
|
|
1029
|
-
// to its corresponding embedded URL (https://rumble.com/embed/vhveub/?pub=4).
|
|
1030
|
-
// The relationship seems to be governed by a table.
|
|
1031
|
-
|
|
1032
|
-
})
|
|
1033
|
-
|
|
1034
|
-
describe("Brightreon support", () => {
|
|
1035
|
-
|
|
1036
|
-
it('Brightreon iframes', () => {
|
|
1037
|
-
let expected = '<iframe src="https://www.brighteon.com/embed/5821540656001" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"></iframe>'
|
|
1038
|
-
let input = {
|
|
1039
|
-
author: 'foo351x',
|
|
1040
|
-
permlink: 'bar351x',
|
|
1041
|
-
last_update: '2021-05-10T09:15:50',
|
|
1042
|
-
body: "<iframe src='https://www.brighteon.com/embed/5821540656001' width='560' height='315' frameborder='0' allowfullscreen></iframe>"
|
|
1043
|
-
}
|
|
1044
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
1045
|
-
})
|
|
1046
|
-
|
|
1047
|
-
it('Brightreon embed URL', () => {
|
|
1048
|
-
const expected = "<p dir=\"auto\"><a class=\"markdown-video-link\" data-embed-src=\"https://www.brighteon.com/embed/5821540656001\"><span class=\"markdown-video-play\"></span></a></p>"
|
|
1049
|
-
let input = {
|
|
1050
|
-
author: 'foo351y',
|
|
1051
|
-
permlink: 'bar351y',
|
|
1052
|
-
last_update: '2021-05-10T09:16:50',
|
|
1053
|
-
body: '<a href="https://www.brighteon.com/embed/5821540656001">https://www.brighteon.com/embed/5821540656001</a>'
|
|
1054
|
-
}
|
|
1055
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
1056
|
-
})
|
|
1057
|
-
|
|
1058
|
-
it('Brightreon page URL', () => {
|
|
1059
|
-
const expected = "<p dir=\"auto\"><a class=\"markdown-video-link\" data-embed-src=\"https://www.brighteon.com/embed/5821540656001\"><span class=\"markdown-video-play\"></span></a></p>"
|
|
1060
|
-
let input = {
|
|
1061
|
-
author: 'foo351z',
|
|
1062
|
-
permlink: 'bar351z',
|
|
1063
|
-
last_update: '2021-05-10T09:16:50',
|
|
1064
|
-
body: '<a href="https://www.brighteon.com/5821540656001">https://www.brighteon.com/5821540656001</a>'
|
|
1065
|
-
}
|
|
1066
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
1067
|
-
})
|
|
1068
|
-
})
|
|
1069
|
-
|
|
1070
|
-
describe("Brand new tube support", () => {
|
|
1071
|
-
|
|
1072
|
-
it('Brand new tube iframes', () => {
|
|
1073
|
-
let expected = '<iframe src=\"https://brandnewtube.com/embed/BSqeH7nhg8I41rM\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"></iframe>'
|
|
1074
|
-
let input = {
|
|
1075
|
-
author: 'foo352x',
|
|
1076
|
-
permlink: 'bar352x',
|
|
1077
|
-
last_update: '2021-05-10T09:15:50',
|
|
1078
|
-
body: "<iframe src='https://brandnewtube.com/embed/BSqeH7nhg8I41rM' frameborder='0' width='700' height='400' allowfullscreen></iframe>"
|
|
1079
|
-
}
|
|
1080
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
1081
|
-
})
|
|
1082
|
-
|
|
1083
|
-
})
|
|
1084
|
-
|
|
1085
|
-
describe('Sanitization', () => {
|
|
1086
|
-
it('1- Should remove javascript links', () => {
|
|
1087
|
-
const input = {
|
|
1088
|
-
author: 'foo64',
|
|
1089
|
-
permlink: 'bar64',
|
|
1090
|
-
last_update: '2019-05-10T09:15:21',
|
|
1091
|
-
body: '<a href=\'javascript:void(0)\'>click here</a>'
|
|
1092
|
-
}
|
|
1093
|
-
const expected = '<p dir=\"auto\"><a>click here</a></p>'
|
|
1094
|
-
|
|
1095
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
1096
|
-
})
|
|
1097
|
-
|
|
1098
|
-
it('2- Should convert script tag to span', () => {
|
|
1099
|
-
const input = {
|
|
1100
|
-
author: 'foo65',
|
|
1101
|
-
permlink: 'bar65',
|
|
1102
|
-
last_update: '2019-05-10T09:15:21',
|
|
1103
|
-
body: `<script>document.getElementById('body').remove();</script>`
|
|
1104
|
-
}
|
|
1105
|
-
const expected = 'document.getElementById(\'body\').remove();'
|
|
1106
|
-
|
|
1107
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
1108
|
-
})
|
|
1109
|
-
|
|
1110
|
-
it('3- Should remove not allowed attributes', () => {
|
|
1111
|
-
const input = {
|
|
1112
|
-
author: 'foo66',
|
|
1113
|
-
permlink: 'bar66',
|
|
1114
|
-
last_update: '2019-05-10T09:15:21',
|
|
1115
|
-
body: `<a title="Foo" onclick="document.bar()">Click</a>`
|
|
1116
|
-
}
|
|
1117
|
-
const expected = '<p dir=\"auto\"><a title="Foo">Click</a></p>'
|
|
1118
|
-
|
|
1119
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
1120
|
-
})
|
|
1121
|
-
|
|
1122
|
-
it('4- Should remove javascript links', () => {
|
|
1123
|
-
const input = {
|
|
1124
|
-
author: 'foo67',
|
|
1125
|
-
permlink: 'bar67',
|
|
1126
|
-
last_update: '2019-05-10T09:15:21',
|
|
1127
|
-
body: `<a title="Foo" href="javascript:void(0)">Click</a>`
|
|
1128
|
-
}
|
|
1129
|
-
const expected = '<p dir=\"auto\"><a title="Foo">Click</a></p>'
|
|
1130
|
-
|
|
1131
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
1132
|
-
})
|
|
1133
|
-
})
|
|
1134
|
-
|
|
1135
|
-
describe('Test files', () => {
|
|
1136
|
-
it('1- Should catch images in table', () => {
|
|
1137
|
-
const data = getTestData(
|
|
1138
|
-
'steemitboard',
|
|
1139
|
-
'steemitboard-notify-dunsky-20181210t153450000z'
|
|
1140
|
-
)
|
|
1141
|
-
|
|
1142
|
-
data['author'] = 'foo68'
|
|
1143
|
-
data['permlink'] = 'foo68'
|
|
1144
|
-
data['last_update'] = '2019-05-10T09:15:21'
|
|
1145
|
-
expect(markdown2Html(data)).toBe(SNAPSHOT_JSON.markdown_2_html_test_files_1_should_catch_images_in_table)
|
|
1146
|
-
})
|
|
1147
|
-
})
|
|
1148
|
-
|
|
1149
|
-
describe('Test legacy files', () => {
|
|
1150
|
-
const dataDir = `${__dirname}/test/data/legacy`
|
|
1151
|
-
|
|
1152
|
-
const files = fs.readdirSync(dataDir)
|
|
1153
|
-
|
|
1154
|
-
let x = 150
|
|
1155
|
-
|
|
1156
|
-
for (const file of files) {
|
|
1157
|
-
if (file === '.DS_Store') {
|
|
1158
|
-
continue
|
|
1159
|
-
}
|
|
1160
|
-
const fileContents = fs.readFileSync(path.join(dataDir, file), 'utf8')
|
|
1161
|
-
const data = JSON.parse(fileContents)
|
|
1162
|
-
|
|
1163
|
-
const id = data['id']
|
|
1164
|
-
const input = {
|
|
1165
|
-
author: 'foo' + x,
|
|
1166
|
-
permlink: 'bar' + x,
|
|
1167
|
-
last_update: '2019-05-10T09:15:21',
|
|
1168
|
-
body: data['input']
|
|
1169
|
-
}
|
|
1170
|
-
const expected = data['result']
|
|
1171
|
-
|
|
1172
|
-
it('ID: ' + id, function () {
|
|
1173
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
1174
|
-
})
|
|
1175
|
-
|
|
1176
|
-
x += 1
|
|
1177
|
-
}
|
|
1178
|
-
})
|
|
1179
|
-
|
|
1180
|
-
describe('forApp = false', () => {
|
|
1181
|
-
it('1', () => {
|
|
1182
|
-
const input = {
|
|
1183
|
-
author: 'foo1123',
|
|
1184
|
-
permlink: 'bar1123',
|
|
1185
|
-
last_update: '2019-05-10T09:15:21',
|
|
1186
|
-
body: 'https://img.esteem.ws/bbq3ob1idy.png <a href="https://steemit.com/esteem/@esteemapp/esteem-monthly-guest-curation-program-4">fooo</a> <a href="/esteem/@esteemapp/esteem-monthly-guest-curation-program-4">bar</a> <a href="http://external.com/loromoro">baz</a> #lorem @ipsum <a href=\'https://steemit.com/~witnesses\'>vote me</a>'
|
|
1187
|
-
}
|
|
1188
|
-
const expected = '<p dir=\"auto\"><img class="markdown-img-link" src="https://images.ecency.com/p/o1AJ9qDyyJNSpZWhUgGYc3MngFqoAMwgbeMkkd8SVxyfRVjiN.png?format=match&mode=fit" loading="lazy" decoding="async" itemprop="image" /> <a href="https://steemit.com/esteem/@esteemapp/esteem-monthly-guest-curation-program-4" class="markdown-external-link" target="_blank" rel="noopener">fooo</a> <a href="/esteem/@esteemapp/esteem-monthly-guest-curation-program-4" class="markdown-post-link" data-is-inline="true">bar</a> <a href="http://external.com/loromoro" class="markdown-external-link" target="_blank" rel="noopener">baz</a><span> <a class="markdown-tag-link" href="/trending/lorem">#lorem</a> <a class="markdown-author-link" href="/@ipsum">@ipsum</a> </span><a href="https://steemit.com/~witnesses" class="markdown-external-link" target="_blank" rel="noopener">vote me</a></p>'
|
|
1189
|
-
|
|
1190
|
-
expect(markdown2Html(input, false)).toBe(expected)
|
|
1191
|
-
})
|
|
1192
|
-
|
|
1193
|
-
it('2- Should handle external similar post links', () => {
|
|
1194
|
-
const input = {
|
|
1195
|
-
author: 'foo32',
|
|
1196
|
-
permlink: 'bar32',
|
|
1197
|
-
last_update: '2019-05-10T09:15:21',
|
|
1198
|
-
body: '[Voice: the criteria for success or failure](https://app.voice.com/post/@lukestokes/voice-the-criteria-for-success-or-failure-1597453134-597)'
|
|
1199
|
-
}
|
|
1200
|
-
const expected = '<p dir=\"auto\"><a href="https://app.voice.com/post/@lukestokes/voice-the-criteria-for-success-or-failure-1597453134-597" class="markdown-external-link" target="_blank" rel="noopener">Voice: the criteria for success or failure</a></p>'
|
|
1201
|
-
|
|
1202
|
-
expect(markdown2Html(input, false)).toBe(expected)
|
|
1203
|
-
})
|
|
1204
|
-
|
|
1205
|
-
it('3- Should handle external similar post links', () => {
|
|
1206
|
-
const input = {
|
|
1207
|
-
author: 'foo33',
|
|
1208
|
-
permlink: 'bar33',
|
|
1209
|
-
last_update: '2019-05-10T09:15:21',
|
|
1210
|
-
body: '[Voice: the criteria for success or failure](https://app.voice.com/@lukestokes/voice-the-criteria-for-success-or-failure-1597453134-597)'
|
|
1211
|
-
}
|
|
1212
|
-
const expected = '<p dir=\"auto\"><a href="https://app.voice.com/@lukestokes/voice-the-criteria-for-success-or-failure-1597453134-597" class="markdown-external-link" target="_blank" rel="noopener">Voice: the criteria for success or failure</a></p>'
|
|
1213
|
-
|
|
1214
|
-
expect(markdown2Html(input, false)).toBe(expected)
|
|
1215
|
-
})
|
|
1216
|
-
|
|
1217
|
-
it('4 - Should handle filtered tag internal link', () => {
|
|
1218
|
-
const input = {
|
|
1219
|
-
author: 'foo34',
|
|
1220
|
-
permlink: 'bar34',
|
|
1221
|
-
last_update: '2021-05-10T09:15:49',
|
|
1222
|
-
body: '<a href="/trending/books">trending books</a>'
|
|
1223
|
-
}
|
|
1224
|
-
const expected = '<p dir=\"auto\"><a href=\"/trending/books\" class=\"markdown-tag-link\">trending books</a></p>'
|
|
1225
|
-
expect(markdown2Html(input, false)).toBe(expected)
|
|
1226
|
-
})
|
|
1227
|
-
})
|
|
1228
|
-
|
|
1229
|
-
describe('cleanReply', () => {
|
|
1230
|
-
it(' Should clean reply body', () => {
|
|
1231
|
-
const input = {
|
|
1232
|
-
parent_author: 'bar333',
|
|
1233
|
-
author: 'foo6401',
|
|
1234
|
-
permlink: 'bar6401',
|
|
1235
|
-
last_update: '2019-05-10T09:15:21',
|
|
1236
|
-
body: 'hello lorem ipsum \n Posted using [Partiko Android](https://partiko.app/referral/aftabkhan10) \n Posted using [Dapplr](https://app.dapplr.in/L55YHRuX4jKJ2SSk8) \n Posted Using [LeoFinance](https://leofinance.io/@taskmaster4450/is-defi-for-real) \n Posted with [STEMGeeks](https://stemgeeks.net) \n <center><sub>[Posted Using Aeneas.Blog](https://www.aeneas.blog/@rollie1212/sryptobrewmaster-weekend-rewards-3)</sub></center> \n <center><sub>Posted via [weedcash.network](https://www.weedcash.network/@cryptounicorn420/thc-and-nft-rising-star-hive-blockchain-game)</sub></center>'
|
|
1237
|
-
}
|
|
1238
|
-
const expected = '<p dir=\"auto\">hello lorem ipsum</p>'
|
|
1239
|
-
|
|
1240
|
-
expect(markdown2Html(input)).toBe(expected)
|
|
1241
|
-
})
|
|
1242
|
-
})
|
|
1243
|
-
|
|
1244
|
-
describe('Webp support', () => {
|
|
1245
|
-
it('Should render images in webp format', () => {
|
|
1246
|
-
const input = 'lorem ipsum https://images.ecency.com/foobarbaz.jpg dolor sit amet'
|
|
1247
|
-
|
|
1248
|
-
expect(markdown2Html(input, false, true)).toBe(SNAPSHOT_JSON.markdown_2_html_webp_support_should_render_images_in_webp_format)
|
|
1249
|
-
})
|
|
1250
|
-
})
|
|
1251
|
-
})
|