Skip to content

Commit

Permalink
bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
István Bozsó committed Feb 17, 2020
1 parent 49779a4 commit 4cb8666
Showing 1 changed file with 60 additions and 56 deletions.
116 changes: 60 additions & 56 deletions utils/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,62 +13,6 @@
"jslibs",
]

########
# TAGS #
########

def make_tag(name):
def inner(self, *args, **kwargs):
return self.__class__.Tag(self, name, _attributes(args, kwargs))

return inner

tags = {
"div", "head", "header", "body", "html", "center", "ul", "ol",
"script", "style", "section", "video", "table", "tr"
}

for tag in tags:
setattr(SimpleDoc, tag, make_tag(tag))

#########
# STAGS #
#########

def make_stag(name):
def inner(self, *args, **kwargs):
return self.stag(name, *args, **kwargs)

return inner

stags = {
"meta", "link", "iframe",
}

for stag in stags:
setattr(SimpleDoc, stag, make_stag(stag))


#########
# LINES #
#########


def make_line(name):
def inner(self, text_contents, *args, **kwargs):
return self.line(name, text_contents, *args, **kwargs)

return inner

lines = {
"h1", "h2", "h3", "h4", "p", "li", "bold", "q", "u", "em",
"it", "del", "strong", "th", "td", "font",
}

for line in lines:
setattr(SimpleDoc, line, make_line(line))


class Encoder(object):
__slots__ = (
"encoder",
Expand Down Expand Up @@ -202,6 +146,10 @@ def __init__(self, *args, **kwargs):
def presentation(*args, **kwargs):
return Presentation(*args, **kwargs)

def line(self, tag_name, text_content, *args, **kwargs):
with self.tag(tag_name, *args, **kwargs):
self.asis(text_content)

def use(self, lib):
lib.add(self)

Expand Down Expand Up @@ -253,6 +201,62 @@ def inner(self, *args, **kwargs):
for enc, mode in encodable.items():
setattr(HTML, enc, make_encodable(enc, mode))


########
# TAGS #
########

def make_tag(name):
def inner(self, *args, **kwargs):
return self.__class__.Tag(self, name, _attributes(args, kwargs))

return inner

tags = {
"div", "head", "header", "body", "html", "center", "ul", "ol",
"script", "style", "section", "video", "table", "tr"
}

for tag in tags:
setattr(HTML, tag, make_tag(tag))

#########
# STAGS #
#########

def make_stag(name):
def inner(self, *args, **kwargs):
return self.stag(name, *args, **kwargs)

return inner

stags = {
"meta", "link", "iframe",
}

for stag in stags:
setattr(HTML, stag, make_stag(stag))


#########
# LINES #
#########


def make_line(name):
def inner(self, text_contents, *args, **kwargs):
return self.line(name, text_contents, *args, **kwargs)

return inner

lines = {
"h1", "h2", "h3", "h4", "p", "li", "b", "q", "u", "em",
"it", "del", "strong", "th", "td", "font",
}

for line in lines:
setattr(HTML, line, make_line(line))


yt_opts = {
"autoplay": False,
Expand Down

0 comments on commit 4cb8666

Please sign in to comment.