How to use html - 10 common examples

To help you get started, we’ve selected a few html examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mozilla / amo-validator / validator / testcases / markup / markuptester.py View on Github external
UNSAFE_THEME_TAGS = ("implementation", "browser", "xul:browser", "xul:script")
SELF_CLOSING_TAGS = ("area", "base", "basefont", "br", "col", "frame", "hr",
                     "img", "input", "li", "link", "meta", "p", "param", )
SAFE_IFRAME_TYPES = ("content", "content-primary", "content-targetable", )
TAG_NOT_OPENED = "Tag (%s) being closed before it is opened."

DOM_MUTATION_HANDLERS = (
        "ondomattrmodified", "ondomattributenamechanged",
        "ondomcharacterdatamodified", "ondomelementnamechanged",
        "ondomnodeinserted", "ondomnodeinsertedintodocument", "ondomnoderemoved",
        "ondomnoderemovedfromdocument", "ondomsubtreemodified", )
UNSAFE_THEME_XBL = ("constructor", "destructor", "field", "getter",
                    "implementation", "setter", )


class MarkupParser(htmlparser.HTMLParser):
    """Parse and analyze the versious components of markup files."""

    def __init__(self, err, strict=True, debug=False):
        htmlparser.HTMLParser.__init__(self)
        self.err = err
        self.line = 0
        self.strict = strict
        self.debug = debug

        self.context = None

        self.xml_state = []
        self.xml_line_stack = []
        self.xml_buffer = []
        self.xbl = False
github web2py / web2py / gluon / sqlhtml.py View on Github external
#================================================================

        console.append(search_actions)

        order = request.vars.order or ''
        if sortable:
            if order and not order=='None':
                tablename,fieldname = order.split('~')[-1].split('.',1)
                sort_field = db[tablename][fieldname]
                exception = sort_field.type in ('date','datetime','time')
                if exception:
                    orderby = (order[:1]=='~' and sort_field) or ~sort_field
                else:
                    orderby = (order[:1]=='~' and ~sort_field) or sort_field

        head = TR(_class=ui.get('header'))
        if selectable:
            head.append(TH(_class=ui.get('default')))
        for field in fields:
            if columns and not str(field) in columns: continue
            if not field.readable: continue
            key = str(field)
            header = headers.get(str(field),
                                 hasattr(field,'label') and field.label or key)
            if sortable:
                if key == order:
                    key, marker = '~'+order, sorter_icons[0]
                elif key == order[1:]:
                    marker = sorter_icons[1]
                else:
                    marker = ''
                header = A(header,marker,_href=url(vars=dict(
github web2py / pydal / gluon / sqlhtml.py View on Github external
#================================================================

        console.append(search_actions)

        order = request.vars.order or ''
        if sortable:
            if order and not order=='None':
                tablename,fieldname = order.split('~')[-1].split('.',1)
                sort_field = db[tablename][fieldname]
                exception = sort_field.type in ('date','datetime','time')
                if exception:
                    orderby = (order[:1]=='~' and sort_field) or ~sort_field
                else:
                    orderby = (order[:1]=='~' and ~sort_field) or sort_field

        head = TR(_class=ui.get('header'))
        if selectable:
            head.append(TH(_class=ui.get('default')))
        for field in fields:
            if columns and not str(field) in columns: continue
            if not field.readable: continue
            key = str(field)
            header = headers.get(str(field),
                                 hasattr(field,'label') and field.label or key)
            if sortable:
                if key == order:
                    key, marker = '~'+order, sorter_icons[0]
                elif key == order[1:]:
                    marker = sorter_icons[1]
                else:
                    marker = ''
                header = A(header,marker,_href=url(vars=dict(
github web2py / pydal / gluon / sqlhtml.py View on Github external
#                      vars=dict(keywords=request.vars.keywords or ''))))

        #================================================================
            options =[]
            for k,v in sorted(exportManager.items()):
                if hasattr(v, "__getitem__"):
                    label = v[1]
                else:
                    label = k
                options.append(OPTION(T(label),_value=k))
            ##FIXME ?
            mysignature = url(args=['export']).split('?', 1)
            mysignature = psq(mysignature[-1]).get('_signature', [None])[-1]
            f = FORM(BUTTON(SPAN(_class=ui.get('buttonexport')),
                            "Export", _type="submit", _class=ui.get('button')),
                     SELECT(options, _name="export_type"),
                     INPUT(_type="hidden", _name="order",
                           _value=request.vars.order),
                     INPUT(_type="hidden", _name="_signature",
                            _value=mysignature),
                     INPUT(_type="hidden", _name="keywords",
                           _value=request.vars.keywords or ''),
                     _method="GET", _action=url(args=['export']))
            search_actions.append(f)

        #================================================================

        console.append(search_actions)

        order = request.vars.order or ''
        if sortable:
            if order and not order=='None':
github web2py / web2py / gluon / sqlhtml.py View on Github external
#                      vars=dict(keywords=request.vars.keywords or ''))))

        #================================================================
            options =[]
            for k,v in sorted(exportManager.items()):
                if hasattr(v, "__getitem__"):
                    label = v[1]
                else:
                    label = k
                options.append(OPTION(T(label),_value=k))
            ##FIXME ?
            mysignature = url(args=['export']).split('?', 1)
            mysignature = psq(mysignature[-1]).get('_signature', [None])[-1]
            f = FORM(BUTTON(SPAN(_class=ui.get('buttonexport')),
                            "Export", _type="submit", _class=ui.get('button')),
                     SELECT(options, _name="export_type"),
                     INPUT(_type="hidden", _name="order",
                           _value=request.vars.order),
                     INPUT(_type="hidden", _name="_signature",
                            _value=mysignature),
                     INPUT(_type="hidden", _name="keywords",
                           _value=request.vars.keywords or ''),
                     _method="GET", _action=url(args=['export']))
            search_actions.append(f)

        #================================================================

        console.append(search_actions)

        order = request.vars.order or ''
        if sortable:
            if order and not order=='None':
github astrocatalogs / supernovae / supernova.py View on Github external
bibcodeauthor = ''
                        try:
                            response = urllib.request.urlopen(adsquery)
                            html = response.read().decode('utf-8')
                            hsplit = html.split("\n")
                            if len(hsplit) > 5:
                                bibcodeauthor = hsplit[5]
                        except:
                            pass

                        if not bibcodeauthor:
                            warnings.warn(
                                "Bibcode didn't return authors, not converting"
                                "this bibcode.")

                        self.catalog.bibauthor_dict[bibcode] = unescape(
                            bibcodeauthor).strip()

            for source in self[self._KEYS.SOURCES]:
                if (SOURCE.BIBCODE in source and
                        source[SOURCE.BIBCODE] in self.catalog.bibauthor_dict
                        and
                        self.catalog.bibauthor_dict[source[SOURCE.BIBCODE]]):
                    source[SOURCE.REFERENCE] = self.catalog.bibauthor_dict[
                        source[SOURCE.BIBCODE]]
                if (SOURCE.NAME not in source and SOURCE.BIBCODE in source and
                        source[SOURCE.BIBCODE]):
                    source[SOURCE.NAME] = source[SOURCE.BIBCODE]

        if self._KEYS.REDSHIFT in self:
            self[self._KEYS.REDSHIFT] = list(
                sorted(
github sx4-discord-bot / Sx4-Python / Sx4 / cogs / fun.py View on Github external
request = requests.get("http://localhost:8080/translate/{}?{}".format(language, urllib.parse.urlencode({"q": text.lower()})), timeout=3)
        try:
            await ctx.send(request.json()["message"].replace("'", "`") + " :no_entry:")
        except:
            input_text = request.json()["from"]["language"]["iso"]
            if "-" in input_text:
                input_text = input_text.split("-")[0]
            if input_text == "iw":
                input_text = "Hebrew"
            elif len(input_text) == 2:
                input_text = languages.get(part1=input_text).name
            elif len(input_text) == 3:
                input_text = languages.get(part3=input_text).name
            s=discord.Embed(colour=0x4285f4)
            s.set_author(name="Google Translate", icon_url="https://upload.wikimedia.org/wikipedia/commons/d/db/Google_Translate_Icon.png")
            s.add_field(name="Input Text ({})".format(input_text), value=html.unescape(request.json()["from"]["text"]["value"]) if request.json()["from"]["text"]["value"] else text, inline=False)
            s.add_field(name="Output Text ({})".format(language.title()), value=request.json()["text"])
            await ctx.send(embed=s)
github ExtensiveAutomation / extensiveautomation-server / app-plugins / client / hp-alm-qc / RestAPI.py View on Github external
data.append( "%s" % stepName )
        data.append( "%s" % self.__gethtml(stepDescription) )
        data.append( "%s" % self.__gethtml(stepExpected) )
        
        data.append( "" ) 
        data.append( "" )
        
        r = requests.post("%s/rest/domains/%s/projects/%s/design-steps" % (self.WsUrl, self.WsDomain, self.WsProject), 
                        cookies={ 'LWSSO_COOKIE_KEY': self.WsLwssoCookie, 'QCSession': self.WsQcSession } ,
                        headers = {'Content-Type': 'application/xml;charset=utf-8'},
                        data="\n".join(data).encode("utf8"),
                        proxies=self.WsProxies, verify=self.WsCheckSsl)
        if r.status_code != 201:
            errTitle = r.text.split("<title>")[1].split("</title>", 1)[0]
            errTitle = html.unescape(errTitle)
            raise Exception( "Unable to create step: %s - %s" % (r.status_code, errTitle) )
        return True
github GRASS-GIS / grass-ci / tools / g.html2man / ghtml.py View on Github external
allowed = omit(allowed, omit_start)

excluded = {
    "a": ["a"],
    "button": formctrl + ["a", "form", "isindex", "fieldset", "iframe"],
    "dir": block,
    "form": ["form"],
    "label": ["label"],
    "menu": block,
    "pre": pre_exclusion
}

excluded = setify(excluded)


class HTMLParser(base.HTMLParser):

    def __init__(self, entities=None):
        base.HTMLParser.__init__(self)
        self.tag_stack = []
        self.excluded = frozenset()
        self.excluded_stack = []
        self.data = []
        self.data_stack = []
        self.decls = []
        if entities:
            self.entities = entities
        else:
            self.entities = {}

    def top(self):
        if self.tag_stack == []:
github custom-components / youtube / custom_components / youtube / sensor.py View on Github external
async def async_setup_platform(
        hass, config, async_add_entities, discovery_info=None):  # pylint: disable=unused-argument
    """Setup sensor platform."""
    channel_id = config['channel_id']
    session = async_create_clientsession(hass)
    try:
        url = BASE_URL.format(channel_id)
        async with async_timeout.timeout(10, loop=hass.loop):
            response = await session.get(url)
            info = await response.text()
        name = html.parser.HTMLParser().unescape(
            info.split('<title>')[1].split('&lt;/')[0])
    except Exception:  # pylint: disable=broad-except

        name = None

    if name is not None:
        async_add_entities([YoutubeSensor(channel_id, name, session)], True)

</title>