Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Markdown Parsing | ContentDev Tools
Test UI Features
course content

Course Content

Test UI Features

Test UI Features

1. Buttons
2. ContentDev Tools
3. Image Tools
4. Links
5. Other
7. Tables
8. Developers

book
Markdown Parsing

12345678910111213141516171819202122232425262728293031
docstring = """ **This** is a **bold** text. *This* is an *italic* text. *`This`* is a *`code`* snippet. List: - 123 - 123 Numbered List: 1. Item 1.; 2. Item 2 """ docstring = docstring.strip() import re def format_docstring(docstring): docstring = re.sub(r'\*\*(.*?)\*\*', r'<b>\1</b>', docstring) # Π—Π°ΠΌΡ–Π½Π° '**' Π½Π° <b> Ρ– </b> docstring = re.sub(r'\*(.*?)\*', r'<i>\1</i>', docstring) # Π—Π°ΠΌΡ–Π½Π° '*' Π½Π° <i> Ρ– </i> docstring = re.sub(r'`(.*?)`', r'<code>\1</code>', docstring) # Π—Π°ΠΌΡ–Π½Π° '*`' Π½Π° <code> Ρ– </code> # ΠŸΠ°Ρ€ΡΠΈΠ½Π³ списку ΠΌΠ°Ρ€ΠΊΠ΄Π°ΡƒΠ½ Π· Π½ΡƒΠΌΠ΅Ρ€Π°Ρ†Ρ–Ρ”ΡŽ docstring = re.sub(r'^\d+\. (.*)$', r'<li>\1</li>', docstring, flags=re.M) # ΠŸΠ°Ρ€ΡΠΈΠ½Π³ списку Ρ‡Π΅Ρ€Π΅Π· "-" docstring = re.sub(r'\n- (.*)', r'\n<li>\1</li>', docstring) # ΠŸΠ°Ρ€ΡΠΈΠ½Π³ відступів docstring = docstring.split("\n") docstring = "<br>\n".join(docstring) docstring = docstring.replace("</li><br>", "</li>") return docstring print(format_docstring(docstring) + "\n")
copy

Note

Π”ΠΎ списків Ρ‚Ρ€Π΅Π±Π° Π΄ΠΎΠ΄Π°Π²Π°Ρ‚ΠΈ Ρ‚Π΅Π³ΠΈ <ul> </ul> (unordered list) Π°Π±ΠΎ <ol> </ol> (ordered list) для створСння Π·Π²ΠΈΡ‡Π°ΠΉΠ½ΠΎΠ³ΠΎ (ul), Ρ‚Π° Π½ΡƒΠΌΠ΅Ρ€ΠΎΠ²Π°Π½ΠΎΠ³ΠΎ (ol) списків.

Reversed Parsing

12345678910111213141516171819202122232425262728
docstring = """ <b>This</b> is a <b>bold</b> text. <i>This</i> is an <i>italic</i> text.<br> <i><code>This</code></i> is a <i><code>code</code></i> snippet.<br> <br> List:<br> <ol> <li>123</li> <li>123</li> </ol> <br> Numbered List:<br> <ul> <ul><li>Item 1.;</li> <li>Item 2</li> </ul> """ docstring = docstring.replace("<br>", "") docstring = docstring.replace("<code>", "`").replace("</code>", "`") docstring = docstring.replace("<b>", "**").replace("</b>", "**") docstring = docstring.replace("<i>", "*").replace("</i>", "*") docstring = docstring.replace("<li>", "- ").replace("</li>", "") docstring = docstring.replace("<ul>\n", "").replace("</ul>\n", "") docstring = docstring.replace("<ol>\n", "").replace("</ol>\n", "") docstring = docstring.replace("<ul>", "").replace("</ul>", "") docstring = docstring.replace("<ol>", "").replace("</ol>", "") print(docstring)
copy

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 2. ChapterΒ 1

Ask AI

expand
ChatGPT

Ask anything or try one of the suggested questions to begin our chat

course content

Course Content

Test UI Features

Test UI Features

1. Buttons
2. ContentDev Tools
3. Image Tools
4. Links
5. Other
7. Tables
8. Developers

book
Markdown Parsing

12345678910111213141516171819202122232425262728293031
docstring = """ **This** is a **bold** text. *This* is an *italic* text. *`This`* is a *`code`* snippet. List: - 123 - 123 Numbered List: 1. Item 1.; 2. Item 2 """ docstring = docstring.strip() import re def format_docstring(docstring): docstring = re.sub(r'\*\*(.*?)\*\*', r'<b>\1</b>', docstring) # Π—Π°ΠΌΡ–Π½Π° '**' Π½Π° <b> Ρ– </b> docstring = re.sub(r'\*(.*?)\*', r'<i>\1</i>', docstring) # Π—Π°ΠΌΡ–Π½Π° '*' Π½Π° <i> Ρ– </i> docstring = re.sub(r'`(.*?)`', r'<code>\1</code>', docstring) # Π—Π°ΠΌΡ–Π½Π° '*`' Π½Π° <code> Ρ– </code> # ΠŸΠ°Ρ€ΡΠΈΠ½Π³ списку ΠΌΠ°Ρ€ΠΊΠ΄Π°ΡƒΠ½ Π· Π½ΡƒΠΌΠ΅Ρ€Π°Ρ†Ρ–Ρ”ΡŽ docstring = re.sub(r'^\d+\. (.*)$', r'<li>\1</li>', docstring, flags=re.M) # ΠŸΠ°Ρ€ΡΠΈΠ½Π³ списку Ρ‡Π΅Ρ€Π΅Π· "-" docstring = re.sub(r'\n- (.*)', r'\n<li>\1</li>', docstring) # ΠŸΠ°Ρ€ΡΠΈΠ½Π³ відступів docstring = docstring.split("\n") docstring = "<br>\n".join(docstring) docstring = docstring.replace("</li><br>", "</li>") return docstring print(format_docstring(docstring) + "\n")
copy

Note

Π”ΠΎ списків Ρ‚Ρ€Π΅Π±Π° Π΄ΠΎΠ΄Π°Π²Π°Ρ‚ΠΈ Ρ‚Π΅Π³ΠΈ <ul> </ul> (unordered list) Π°Π±ΠΎ <ol> </ol> (ordered list) для створСння Π·Π²ΠΈΡ‡Π°ΠΉΠ½ΠΎΠ³ΠΎ (ul), Ρ‚Π° Π½ΡƒΠΌΠ΅Ρ€ΠΎΠ²Π°Π½ΠΎΠ³ΠΎ (ol) списків.

Reversed Parsing

12345678910111213141516171819202122232425262728
docstring = """ <b>This</b> is a <b>bold</b> text. <i>This</i> is an <i>italic</i> text.<br> <i><code>This</code></i> is a <i><code>code</code></i> snippet.<br> <br> List:<br> <ol> <li>123</li> <li>123</li> </ol> <br> Numbered List:<br> <ul> <ul><li>Item 1.;</li> <li>Item 2</li> </ul> """ docstring = docstring.replace("<br>", "") docstring = docstring.replace("<code>", "`").replace("</code>", "`") docstring = docstring.replace("<b>", "**").replace("</b>", "**") docstring = docstring.replace("<i>", "*").replace("</i>", "*") docstring = docstring.replace("<li>", "- ").replace("</li>", "") docstring = docstring.replace("<ul>\n", "").replace("</ul>\n", "") docstring = docstring.replace("<ol>\n", "").replace("</ol>\n", "") docstring = docstring.replace("<ul>", "").replace("</ul>", "") docstring = docstring.replace("<ol>", "").replace("</ol>", "") print(docstring)
copy

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 2. ChapterΒ 1
We're sorry to hear that something went wrong. What happened?
some-alt