Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
html-template-parser
Readme
The is an HTML template parser. It is a modified version of Python's HTMLParse library, expanded to handle template tags.
pip install html-template-parser
# or
poetry add html-template-parser
A basic usage example is remarkably similar to Python's HTMLParser:
from HtmlTemplateParser import Htp
from HtmlTemplateParser import AttributeParser
class MyAttributeParser(AttributeParser):
def handle_starttag_curly_perc(self, tag, attrs, props):
print("starttag_curly_perc", tag, attrs, props)
# get the position of the element relative to the original html
print(self.getpos())
# get the original html text
print(self.get_element_text())
def handle_endtag_curly_perc(self, tag, attrs, props):
print("endtag_curly_perc", tag, attrs, props)
def handle_value(self, value):
print("value", value)
class MyHTMLParser(Htp):
def handle_starttag(self, tag, attrs):
print("Encountered a start tag:", tag)
print(self.getpos())
MyAttributeParser(attrs).parse()
def handle_endtag(self, tag):
print("Encountered an end tag :", tag)
def handle_data(self, data):
print("Encountered some data :", data)
parser = MyHTMLParser()
parser.feed('<html><head><title>Test</title></head>'
'<body {% if this %}ok{% endif %}><h1>Parse me!</h1></body></html>')
<!-- -->
{# data #}
{{! data }}
{% comment "attrs" %}
{% endcomment %}
@* data *@
startendtag < />
starttag <
starttag_curly_perc {% ... %}
starttag_curly_two_hash {{#...}}
starttag_curly_four {{{{...}}}}
endtag <.../>
endtag_curly_perc {% end.. %}
endtag_curly_two_slash {{/...}}
endtag_curly_four_slash {{{{/...}}}}
{{ ... }}
\{{ ... }}
{{{ ... }}}
Modifiers such as ~
, !--
, -
, +
, >
will show up as props on the tags.
Attributes are passed from the Htp as a complete string to be parsed with the attribute parser.
FAQs
A parser for HTML templates.
We found that html-template-parser 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.