Package: quickhtml
QuickHTMLA simple Markdown to HTML preprocessor that doesn't require any third-party modules.Quickly generate HTML from Markdown, using Python.Technologies usedPythonRegExTable of contentsQuickHTMLTechnologies usedTable of contentsFile treeInstallationUsageSupported syntaxHeadingsAlternate heading syntaxParagraphsLine breaksEmphasisBoldItalicBold and italicBlockquotesListsOrdered listsUnordered listsCodeEscaping backticksCode blocksHorizontal RulesLinksAdding titles to linksEmails and URLsReference-style linksFormatting the referenceFormatting the definitionImagesAdding links to imagesEscaping charactersEscape sequencesContributingFile treeQuickHTML
├ LICENSE                   Project license.
├ quickhtml/                Main module directory.
│ ├ __init__.py             Executed when running the module directly.
│ ├ __main__.py             Ensures Python treats this directory as a package.
│ └ quickhtml.py            Main module file.
├ README.md                 Project README.
├ setup.py                  Module setup file.
└ tests/                    Contains tests.
  ├ integration_tests.py    Integration tests.
  └ unit_tests.py           Unit tests.InstallationQuickHTML is a Python module, if Python is not already installed in your system, you can get the latest versionhereor using a package manager. pip should be installed with Python by default, if not, you can get ithere.QuickHTML can then be installed using pip, by runningpip install quickhtmlon the command line.UsageTo see how to use QuickHTML directly from the terminal, runpython -m quickhtml -h.To import QuickHTML in Python files, use:>>> import quickhtml
>>> ...Theconvert()function accepts a string, and returns it formatted as HTML:>>> string = "# This is a level 1 heading."
>>> quickhtml.convert(string)
'<h1>This is a level 1 heading.</h1>'
>>> ...Theconvert_file()function accepts a file path, and returns the file content formatted as HTML:>>> file_path = "./markdown_documents/example_document.md"
>>> quickhtml.convert_file(file_path)
'<p>This is an example document.</p>'
>>> ...Supported syntaxHeadingsTo create a heading, add a number of pound signs (#) before a word or phrase. The number of signs corresponds to the heading level, up to six levels. For example, to create a level three heading, use three pound signs (### This is a level three heading.).MarkdownHTMLOutput# This is a level 1 heading.<h1>This is a level 1 heading.</h1>This is a level 1 heading.## This is a level 2 heading.<h2>This is a level 2 heading.</h2>This is a level 2 heading.### This is a level 3 heading.<h3>This is a level 3 heading.</h3>This is a level 3 heading.#### This is a level 4 heading.<h4>This is a level 4 heading.</h4>This is a level 4 heading.##### This is a level 5 heading.<h5>This is a level 5 heading.</h5>This is a level 5 heading.###### This is a level 6 heading.<h6>This is a level 6 heading.</h6>This is a level 6 heading.Alternate heading syntaxAlternatively, add two or more equal (=) or minus signs (-) to the line after the text to create level 1 and level 2 headings, respectively.MarkdownHTMLOutputThis is a level 1 heading.====================<h1>This is a level 1 heading.</h1>This is a level 1 heading.This is a level 2 heading.--------------------<h2>This is a level 2 heading.</h2>This is a level 2 heading.ParagraphsUse a blank line to separate paragraphs.MarkdownHTMLOutputThisisaparagraph.<p>This is a paragraph.</p>This is a paragraph.This is a paragraph.This is another paragraph.<p>This is a paragraph.</p><p>This is another paragraph.</p>This is a paragraph.This is another paragraph.Line breaksEnd a line with two or more spaces to create a line break (<br>).MarkdownHTMLOutputThis is a paragraph.This is still the same paragraph.<p>This is a paragraph.<br>This is still the same paragraph.</p>This is a paragraph.This is still the same paragraph.Alternatively, the<br>tag can also be used directly to create line breaks, this is especially useful for adding line breaks in list and blockquote items.EmphasisEmphasis can be added by making text bold, italic, or both.BoldTo make text bold, add two asterisks (**) or underscores (__) before and after a word, phrase, or letter.MarkdownHTMLOutput**This is some bold text.**<p><strong>This is some bold text.</strong></p>This is some bold text.This is a __bold__ word.<p>This is a <strong>bold</strong> word.</p>This is aboldword.These are some **b**__o__**l**__d__ letters.<p>These are some <strong>b</strong><strong>o</strong><strong>l</strong><strong>d</strong> letters.</p>These are someboldletters.ItalicTo make text italic, add an asterisk (*) or underscore (_) before and after a word, phrase, or letter.MarkdownHTMLOutput*This is some italic text.*<p><em>This is some italic text.</em></p>This is some italic text.This is an _italic_ word.<p>This is an <em>italic</em> word.</p>This is anitalicword.These are some *i*_t_*a*_l_*i*_c_ letters.<p>These are some <em>i</em><em>t</em><em>a</em><em>l</em><em>i</em><em>c</em> letters.</p>These are someitalicletters.Bold and italicTo make text bold and italic, add three asterisks (***) or underscores (___) before and after a word, phrase, or letter.MarkdownHTMLOutput***This is some bold and italic text.***<p><em><strong>This is some bold and italic text.</strong></em></p>This is some bold and italic text.These are some ___bold and italic___ words.<p>These are some <em><strong>bold and italic</strong></em> words.</p>These are somebold and italicwords.These are some ***b***___o___***l***___d___ ***a***___n___***d*** ___i___***t***___a___***l***___i___***c*** letters.<p>These are some <em><strong>b</strong></em><em><strong>o</strong></em><em><strong>l</strong></em><em><strong>d</strong></em> <em><strong>a</strong></em><em><strong>n</strong></em><em><strong>d</strong></em> <em><strong>i</strong></em><em><strong>t</strong></em><em><strong>a</strong></em><em><strong>l</strong></em><em><strong>i</strong></em><em><strong>c</strong></em> letters.</p>These are someboldanditalicletters.BlockquotesTo create a blockquote, add a number of greater than signs (>) before a paragraph. To nest blockquotes, add a number of signs that is greater or lesser than the last one. For example, a level 1 blockquote (>) followed by a level 2 blockquote (>>).MarkdownHTMLOutput> This is a level 1 blockquote.<blockquote><p>This is a level 1 blockquote.</p></blockquote>This is a level 1 blockquote.> This is a level 1 blockquote.> This is another level 1 blockquote.> This is the third level 1 blockquote.<blockquote><p>This is a level 1 blockquote.</p><p>This is another level 1 blockquote.</p><p>This is the third level 1 blockquote.</p></blockquote>This is a level 1 blockquote.This is another level 1 blockquote.This is the third level 1 blockquote.>> This is a level 1 blockquote.>> This is a level 2 blockquote.>>> This is a level 3 blockquote.<blockquote><p>This is a level 1 blockquote.</p><blockquote><p>This is a level 2 blockquote.</p><blockquote><p>This is a level 3 blockquote.</p></blockquote></blockquote></blockquote>This is a level 1 blockquote.This is a level 2 blockquote.This is a level 3 blockquote.> This is a level 1 blockquote.>> This is a level 2 blockquote.>>> This is a level 3 blockquote.>> This is a level 2 blockquote.> This is a level 1 blockquote.<blockquote><p>This is a level 1 blockquote.</p><blockquote><p>This is a level 2 blockquote.</p><blockquote><p>This is a level 3 blockquote.</p></blockquote><p>This is a level 2 blockquote.</p></blockquote><p>This is a level 1 blockquote.</p></blockquote>This is a level 1 blockquote.This is a level 2 blockquote.This is a level 3 blockquote.This is a level 2 blockquote.This is a level 1 blockquote.> This is a level 1 blockquote.>> This is a level 2 blockquote.>>> This is a level 3 blockquote.> This is a level 1 blockquote.<blockquote><p>This is a level 1 blockquote.</p><blockquote><p>This is a level 2 blockquote.</p><blockquote><p>This is a level 3 blockquote.</p></blockquote></blockquote><p>This is a level 1 blockquote.</p></blockquote>This is a level 1 blockquote.This is a level 2 blockquote.This is a level 3 blockquote.This is a level 1 blockquote.At the moment, multiline items, such as multiline paragraphs, are not supported inside blockquotes. This means each line is a new item. To add line breaks in blockquote elements, use<br>tags directly.ListsItems can be organized into ordered and unordered lists.Ordered listsTo create an ordered list, add a number, followed by a period (.) or closing parenthesis ()), followed by a space before a paragraph. The numbers do not have to be in numerical order. To nest ordered lists, add a number of spaces before the number that is greater or lesser than the last number of spaces. For example, a level 1 ordered list (1.) followed by a level 2 ordered list. (1.)MarkdownHTMLOutput1. This is a level 1 ordered list item.2. This is another level 1 ordered list item.3. This is the third level 1 ordered list item.<ol><li>This is a level 1 ordered list item.</li><li>This is another level 1 ordered list item.</li><li>This is the third level 1 ordered list item.</li></ol>This is a level 1 ordered list item.This is another level 1 ordered list item.This is the third level 1 ordered list item.1) This is a level 1 ordered list item.2) This is another level 1 ordered list item.3) This is the third level 1 ordered list item.<ol><li>This is a level 1 ordered list item.</li><li>This is another level 1 ordered list item.</li><li>This is the third level 1 ordered list item.</li></ol>This is a level 1 ordered list item.This is another level 1 ordered list item.This is the third level 1 ordered list item.1. This is a level 1 ordered list item.1. This is another level 1 ordered list item.1. This is the third level 1 ordered list item.<ol><li>This is a level 1 ordered list item.</li><li>This is another level 1 ordered list item.</li><li>This is the third level 1 ordered list item.</li></ol>This is a level 1 ordered list item.This is another level 1 ordered list item.This is the third level 1 ordered list item.82. This is a level 1 ordered list item.6. This is another level 1 ordered list item.14. This is the third level 1 ordered list item.<ol><li>This is a level 1 ordered list item.</li><li>This is another level 1 ordered list item.</li><li>This is the third level 1 ordered list item.</li></ol>This is a level 1 ordered list item.This is another level 1 ordered list item.This is the third level 1 ordered list item.1. This is a level 1 ordered list item.2. This is another level 1 ordered list item.1. This is a level 2 ordered list item.2. This is another level 2 ordered list item.3. This is the third level 1 ordered list item.<ol><li>This is a level 1 ordered list item.</li><li>This is another level 1 ordered list item.</li><ol><li>This is a level 2 ordered list item.</li><li>This is another level 2 ordered list item.</li></ol><li>This is the third level 1 ordered list item.</li></ol>This is a level 1 ordered list item.This is another level 1 ordered list item.This is a level 2 ordered list item.This is another level 2 ordered list item.This is the third level 1 ordered list item.1. This is a level 1 ordered list item.2. This is another level 1 ordered list item.1. This is a level 2 ordered list item.1. This is a level 3 ordered list item.3. This is the third level 1 ordered list item.<ol><li>This is a level 1 ordered list item.</li><li>This is another level 1 ordered list item.</li><ol><li>This is a level 2 ordered list item.</li><ol><li>This is a level 3 ordered list item.</li></ol></ol><li>This is the third level 1 ordered list item.</li></ol>This is a level 1 ordered list item.This is another level 1 ordered list item.This is a level 2 ordered list item.This is a level 3 ordered list item.This is the third level 1 ordered list item.Unordered listsTo create an unordered list, add a minus sign (-), asterisk (*), or plus sign (+), followed by a space before a paragraph. To nest unordered lists, add a number of spaces before the minus sign (-), asterisk (*), or plus sign (+) that is greater or lesser than the last number of spaces. For example, a level 1 unordered list (-) followed by a level 2 unordered list. (-)MarkdownHTMLOutput- This is a level 1 unordered list item.- This is another level 1 unordered list item.- This is the third level 1 unordered list item.<ul><li>This is a level 1 unordered list item.</li><li>This is another level 1 unordered list item.</li><li>This is the third level 1 unordered list item.</li></ul>This is a level 1 unordered list item.This is another level 1 unordered list item.This is the third level 1 unordered list item.- This is a level 1 unordered list item.* This is another level 1 unordered list item.+ This is the third level 1 unordered list item.<ul><li>This is a level 1 unordered list item.</li><li>This is another level 1 unordered list item.</li><li>This is the third level 1 unordered list item.</li></ul>This is a level 1 unordered list item.This is another level 1 unordered list item.This is the third level 1 unordered list item.- This is a level 1 unordered list item.- This is another level 1 unordered list item.- This is a level 2 unordered list item.- This is another level 2 unordered list item.- This is the third level 1 unordered list item.<ul><li>This is a level 1 unordered list item.</li><li>This is another level 1 unordered list item.</li><ul><li>This is a level 2 unordered list item.</li><li>This is another level 2 unordered list item.</li></ul><li>This is the third level 1 unordered list item.</li></ul>This is a level 1 unordered list item.This is another level 1 unordered list item.This is a level 2 unordered list item.This is another level 2 unordered list item.This is the third level 1 unordered list item.- This is a level 1 unordered list item.- This is another level 1 unordered list item.- This is a level 2 unordered list item.- This is a level 3 unordered list item.- This is the third level 1 unordered list item.<ul><li>This is a level 1 unordered list item.</li><li>This is another level 1 unordered list item.</li><ul><li>This is a level 2 unordered list item.</li><ul><li>This is a level 3 unordered list item.</li></ul></ul><li>This is the third level 1 unordered list item.</li></ul>This is a level 1 unordered list item.This is another level 1 unordered list item.This is a level 2 unordered list item.This is a level 3 unordered list item.This is the third level 1 unordered list item.At the moment, multiline items, such as multiline paragraphs, are not supported inside lists. This means each line is a new item. To add line breaks in list elements, use<br>tags directly.CodeTo denote text as code, add backticks (`) before and after a word or phrase.MarkdownHTMLOutput`This is some text denoted as code.`<code>This is some text denoted as code.</code>This is some text denoted as code.This is a `word` denoted as code.<p>This is a <code>word</code> denoted as code.</p>This is aworddenoted as code.Escaping backticksIf the word or phrase you want to denote as code includes one or more backticks, you can escape it by using double backticks (``) instead.MarkdownHTMLOutput``This is some text denoted as code.``<code>This is some text denoted as code.</code>This is some text denoted as code.This is a ``word`` denoted as code.<p>This is a <code>word</code> denoted as code.</p>This is aworddenoted as code.``This code contains `backticks`.``<code>This code contains `backticks`.</code>This code contains `backticks`.Backticks can also be escaped using a backslash (seeescaping characters).Code blocksAdd at least four spaces at the start of each line to denote a section as a code block.MarkdownHTMLOutputThisissometextdenotedascode.<pre><code>Thisissometextdenotedascode.</code></pre>Thisissometextdenotedascode.Horizontal RulesTo create a horizontal rule, add three or more asterisks (***), minus signs (---), or underscores (___) by themselves on a line.MarkdownHTMLOutput***<hr>---<hr>___<hr>****<hr>-----<hr>______<hr>LinksTo create a link, enclose the link name in square brackets ([]), followed by the URL enclosed in parentheses (()).MarkdownHTMLOutput[Click me!](https://github.com/ckc-dev/QuickHTML)<a href="https://github.com/ckc-dev/QuickHTML">Click me!</a>Click me!Go to [GitHub](https://github.com/)'s main page.<p>Go to <a href="https://github.com/">GitHub</a>'s main page.</p>Go toGitHub's main page.Adding titles to linksA title can optionally be added to a link, it will appear as a tooltip when the link is hovered. To add a title, enclose it in either single (') or double (") quotes after the URL.MarkdownHTMLOutput[Click me!](https://github.com/ckc-dev/QuickHTML "Go to the main page of this repository.")<a href="https://github.com/ckc-dev/QuickHTML" title="Go to the main page of this repository.">Click me!</a>Click me!Go to [GitHub](https://github.com/ 'Click here to go to the main page of GitHub.<p>Go to <a href="https://github.com/" title="Click here to go to the main page of GitHub.">GitHub</a>'s main page.</p>Go toGitHub's main page.Emails and URLsEmails and URLs can be quickly turned into links by being enclosed in angle brackets (<>).MarkdownHTMLOutput<https://github.com><a href="https://github.com">https://github.com</a>https://github.com<example@email.address><a href="mailto:example@email.address">example@email.address</a>example@email.addressReference-style linksReference-style links are made up of two parts: the first part is the link reference, which is used inline with the text, and the second is the link definition, which is stored somewhere else in the document. This makes the document easier to read, especially when containing multiple long links.Formatting the referenceThe link reference is formatted using two sets of brackets ([]). The first set encloses the text which should appear as a link, and the second set encloses the label of a link definition.Formatting the definitionThe link definition is formatted using a set of brackets ([]) which encloses the label to this definition, immediately followed by a colon (:), followed by the link URL, which can optionally be enclosed in angle brackets (<>), and finally, optionally followed by a title, which must be enclosed in single quotes (''), double quotes ("") or parentheses (()).MarkdownHTMLOutput[Click me!][repository-url][repository-url]:https://github.com/ckc-dev/QuickHTML<a href="https://github.com/ckc-dev/QuickHTML">Click me!</a>Click me!Go to [GitHub][github-url]'s main page.[github-url]:<https://github.com/><p>Go to <a href="https://github.com/">GitHub</a>'s main page.</p>Go toGitHub's main page.[Click me!][repository-url][repository-url]: https://github.com/ckc-dev/QuickHTML "Go to the main page of this repository."<a href="https://github.com/ckc-dev/QuickHTML" title="Go to the main page of this repository.">Click me!</a>Click me!Go to [GitHub][github-url]'s main page.[github-url]: <https://github.com/> (Click here to go to the main page of GitHub.)<p>Go to <a href="https://github.com/" title="Click here to go to the main page of GitHub.">GitHub</a>'s main page.</p>Go toGitHub's main page.ImagesTo add an image, use an exclamation mark (!), followed by the imagealttext enclosed in square brackets ([]), followed by the image's path or URL enclosed in parentheses (()). Titles can be optionally added to images, to add a title, enclose it in either single (') or double (") quotes after the URL.MarkdownHTMLOutput![Tux](https://upload.wikimedia.org/wikipedia/commons/thumb/3/35/Tux.svg/256px-Tux.svg.png)<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/3/35/Tux.svg/256px-Tux.svg.png" alt="Tux">![Tux](https://upload.wikimedia.org/wikipedia/commons/thumb/3/35/Tux.svg/256px-Tux.svg.png "lewing@isc.tamu.edu Larry Ewing and The GIMP, CC0, via Wikimedia Commons")<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/3/35/Tux.svg/256px-Tux.svg.png" alt="Tux" title="lewing@isc.tamu.edu Larry Ewing and The GIMP, CC0, via Wikimedia Commons">Adding links to imagesTo add a link to an image, enclose the Markdown for the image in square brackets ([]), then follow with the link enclosed in parentheses (()).MarkdownHTMLOutput[![Tux](https://upload.wikimedia.org/wikipedia/commons/thumb/3/35/Tux.svg/256px-Tux.svg.png)](https://commons.wikimedia.org/wiki/File:Tux.svg)<a href="https://commons.wikimedia.org/wiki/File:Tux.svg"><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/3/35/Tux.svg/256px-Tux.svg.png" alt="Tux"></a>[![Tux](https://upload.wikimedia.org/wikipedia/commons/thumb/3/35/Tux.svg/256px-Tux.svg.png)](https://commons.wikimedia.org/wiki/File:Tux.svg "lewing@isc.tamu.edu Larry Ewing and The GIMP, CC0, via Wikimedia Commons")<a href="https://commons.wikimedia.org/wiki/File:Tux.svg" title="lewing@isc.tamu.edu Larry Ewing and The GIMP, CC0, via Wikimedia Commons"><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/3/35/Tux.svg/256px-Tux.svg.png" alt="Tux"></a>Escaping charactersAdd a backslash (\) before a character to escape it, this is often used to display literal characters that would otherwise be used in Markdown syntax.MarkdownHTMLOutput\# Without the backslash, this would be a heading.<p># Without the backslash, this would be a heading</p># Without the backslash, this would be a heading\- Without the backslash, this would be an unordered list item.<p>- Without the backslash, this would be an unordered list item.</p>- Without the backslash, this would be an unordered list item.Escape sequencesYou can useescape sequenceswhen passing strings directly to theconvert()function.ContributingPull requests are welcome.Please open an issue to discuss what you'd like to change before making major changes.Please make sure to update and/or add appropriate tests when applicable.This project is licensed under theGPL-3.0 License.