Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Python 3 tools for creating markup documents.
The project is listed on the Python Package Index, it can be installed simply by executing pip install markyp
.
Element creation in markyp
and its derivates usually works as follows:
**kwargs
) are turned into element attributes.The markup defined by the created elements can be obtained by converting to root element to string (str()
) or by using the root element's markup
property.
Creating new markyp
element types is typically as simple as deriving new classes with the right name from the base elements that are provided by the project. The following example shows the creation of some HTML elements:
from markyp import ElementType
from markyp.elements import Element, StringElement
class html(Element):
__slots__ = ()
def __str__(self) -> str:
return f"<!DOCTYPE html>\n{(super().__str__())}"
class head(Element):
__slots__ = ()
class body(Element):
__slots__ = ()
class title(StringElement):
__slots__ = ()
class p(Element):
__slots__ = ()
@property
def inline_children(self) -> bool:
return True
class code(StringElement):
__slots__ = ()
class ul(Element):
__slots__ = ()
class li(Element):
__slots__ = ()
Once you have defined the basic components that are required by your project, you can make document creation easier by creating higher order functions that convert your data into markup elements.
def create_unordered_list(*items: ElementType) -> ul:
"""Creates an unordered list from the received arguments."""
return ul(
*(li(item, class_="fancy-list-item", style="color:blue;") for item in items),
class_="fancy-list"
)
When everything is in place, a document can be created simply by instantiating the elements that make up the document. Notice that during element construction, positional arguments are treated as children elements and keyword arguments are treated as element attributes, allowing you to create documents using a markup-like syntax.
document = html(
head(title("Hello World!")),
body(
p(code("markyp"), "HTML example.", style="font-weight:bold;"),
p("Creating lists is easy as", style="color:blue;"),
create_unordered_list("One", p("Two", style="font-style:italic;"), "Three"),
style="font-size:20px"
)
)
At this point, you have a Python object representing your document. The actual markup is created only when you convert this object into a string using either the str()
method or the markup
property of the element.
print(document)
markyp
extensionsmarkyp
extensions should follow the markyp-{domain-or-extension-name}
naming convention. Here is a list of domain-specific extensions:
markyp-rss
: RSS 2 implementation at https://github.com/volfpeter/markyp-rss, contribution is welcome.markyp-html
: HTML implementation at https://github.com/volfpeter/markyp-html, contribution is welcome.markyp-highlightjs
: HTML code highlighting using highlight.js
at https://github.com/volfpeter/markyp-highlightjs, contribution is welcome.markyp-bootstrap4
: Bootstrap 4 implementation at https://github.com/volfpeter/markyp-bootstrap4, contribution is welcome.markyp-fontawesome
: Font Awesome icons for markyp-html
-based web pages at https://github.com/volfpeter/markyp-fontawesome, contribution is welcome.If you have created an open source markyp
extension, please let us know and we will include your project in this list.
In general, please treat each other with respect and follow the below guidelines to interact with the project:
[Question] <issue-title>
title.[Bug] <issue-title>
title, an adequate description of the bug, and a code snippet that reproduces the issue if possible.[Enhancement] <issue-title>
title and a clear description of the enhancement proposal.Every form of contribution is welcome, including documentation improvements, tests, bug fixes, and feature implementations.
Please follow these guidelines to contribute to the project:
mypy
is used to type-check the codebase, submitted code should not produce typing errors. See this page for more information on mypy
.#refs <issue-id>
to the end of commit messages).If you have any questions about contributing to the project, please contact the project owner.
As mentioned in the contribution guidelines, the project is type-checked using mypy
, so first of all, the project must pass mypy
's static code analysis.
The project is tested using pytest
. The chosen test layout is that tests are outside the application code, see this page for details on what it means in practice.
If pytest
is installed, the test set can be executed using the pytest test
command from within the project directory.
If pytest-cov
is also installed, a test coverage report can be generated by executing pytest test --cov markyp
from the root directory of the project.
The library is open-sourced under the conditions of the MIT license.
FAQs
Python 3 tools for creating markup documents.
We found that markyp demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.