def imageAlt(soup): if soup.imageAlt() > 0: images = soup.findAll('img', alt=False) return (htmlconv.makeHTML( 'h3', 'NO ALT FOUND ON THE FOLLOWING IMAGES (class)', 'text-danger') + listImages(images)) else: return (htmlconv.makeHTML('p', 'ALT found on all images ✔', 'text-success'))
def imageTitle(soup): if soup.imageTitle() > 0: images = soup.findAll('img', title=False) listImages(images) return (htmlconv.makeHTML( 'h3', 'NO TITLE FOUND ON THE FOLLOWING IMAGES (class)', 'text-warning') + listImages(images)) else: return (htmlconv.makeHTML('p', 'TITLE found on all images ✔', 'text-success'))
def testArticle(soup): if soup.countArticle() == 0: return (htmlconv.makeHTML( 'p', 'You should have <code><article></code> tags in your HTML5', 'text-danger')) elif soup.countArticle() > 0: return (htmlconv.makeHTML( 'p', (str(len(soup.findAll('article'))) + ' HTML5 <code><article></code> tags found')))
def imageWidth(soup): if soup.imageWidth() > 0: images = soup.findAll('img', width=True) return (htmlconv.makeHTML( 'h3', 'WIDTH SET ON THE FOLLOWING IMAGES', 'text-danger') + listImages(images)) else: return (htmlconv.makeHTML('p', 'Width not set on any images ✔', 'text-success'))
def imageHeight(soup): if soup.imageHeight() > 0: images = soup.findAll('img', height=True) return (htmlconv.makeHTML( 'h3', 'HEIGHT SET ON THE FOLLOWING IMAGES', 'text-danger') + listImages(images)) else: return (htmlconv.makeHTML('p', 'Height not set on any images ✔', 'text-success'))
def imageSource(soup): if soup.imageSource() > 0: images = soup.findAll('img', src=False) return (htmlconv.makeHTML( 'h3', 'NO SOURCE FOUND ON THE FOLLOWING IMAGES', 'text-danger') + listImages(images)) else: return (htmlconv.makeHTML('p', 'Source found on all images ✔', 'text-success'))
def testSection(soup): if soup.countSection() == 0: return (htmlconv.makeHTML( 'p', 'You should have <code><section></code> tags in your HTML5', 'text-danger')) elif soup.countSection() > 0 and soup.countArticle() == 0: return (htmlconv.makeHTML( 'p', 'You should not have <code><section></code> without <code><article></code>', 'text-danger')) else: return (htmlconv.makeHTML( 'p', (str(soup.countSection()) + ' HTML5 <code><section></code> tags found')))
def testNav(soup): if soup.countNav() == 0: return (htmlconv.makeHTML( 'p', 'You should have a nav section in your HTML5', 'text-danger')) elif soup.countNav() == 1: return (htmlconv.makeHTML( 'p', 'Single <code><nav></code> section found for page; ✔', 'text-success')) else: return (htmlconv.makeHTML( 'p', 'You should only have a single <code><nav></code> tag per page. You have used more than one on this page', 'text-danger'))