Skip to content

ec-intl/ecifl2html

Repository files navigation

ecifl2HTML

GitHub license GitHub release (latest by date) GitHub issues GitHub pull requests GitHub contributors GitHub last commit GitHub commit activity GitHub top language GitHub search hit counter GitHub stars GitHub watchers

ecifl2html is a Python package for converting formatted text to HTML. It is a simple package that provides a single class, FormattedTextToHTML, used to convert formatted text to HTML.

Project Status

Here's the current status of our workflows:

Workflow Status
Testing Suite Continuous-Integration
Deployment Suite Continuous-Deployment
Sphinx Documentation Sphinx-docs
Guard Main Branch Guard Main Branch
Code Quality Checker Lint Codebase

Components

The ecifl2HTML's codebase structure is as shown below:

.
├── LICENSE
├── MANIFEST.in
├── README.md
├── VERSION
├── build_docs
│   ├── __init__.py
│   └── src
│       ├── __init__.py
│       ├── conf.py
│       ├── index.rst
│       └── ecifl2html.rst
├── requirements
│   ├── production.txt
│   ├── staging.txt
│   └── testing.txt
├── requirements.txt
├── setup.py
└── src
    ├── ecifl2html
    │   ├── __init__.py
    │   └── ecifl2html.py
    └── tests
        ├── __init__.py
        └── test_ecifl2html.py

Usage

To use ecifl2HTML you first have your Markdown text in the following format:

Formatted Text HTML Equivalent
h., hh. etc. <h1>, <h2>, ...
p. <p>
#. <ol>
-. <ul>
... <pre><code>
i. <img>

Example Formatted Text

from src.ecifl2html import ecifl2html as hw

formatted_text = """
    h. Welcome to FormattedTextToHTML
    p. Convert formatted text into HTML effortlessly.

    hh. Features
    #. Supports headers (e.g., h., hh., hhh.)
    #. Paragraphs (e.g., p.)
    #. Ordered lists (#.)
    #. Unordered lists (-.)
    #. Code blocks (```...```)

    hh. Example
    p. Here's a code block:
    r```
    def example():
    return “Hello, FormattedTextToHTML!”
    r```
    """

converter = ht.MarkdownToHTML(formatted_text)
html_output = converter.convert()
print(html_output)

NB: the r in code block section is there for the sake of the formatted text, so in your formatted text omit the r.

The expected HTML output will be:

<h1>Welcome to FormattedTextToHTML</h1>
<p>Convert formatted text into HTML effortlessly.</p>

<h2>Features</h2>
<ol>
<li>Supports headers (e.g., h., hh., hhh.)</li>
<li>Paragraphs (e.g., p.)</li>
<li>Ordered lists (#.)</li>
<li>Unordered lists (-.)</li>
<li>Code blocks (```...```)</li>
</ol>

<h2>Example</h2>
<p>Here's a code block:</p>
<pre><code>
def example():
    return "Hello, FormattedTextToHTML!"
</code></pre>