# -*- coding: utf-8 -*-
# Copyright 2019 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Utilities for generating html."""
def GetPageHeader(page_title):
return """
%s
""" % page_title
def GetListHeader():
return ''
def GetListItem(text):
return '- %s
' % text
def GetListFooter():
return '
'
def GetList(items):
return '' % ''.join(['%s' % item for item in items])
def GetParagraph(text):
return '%s
' % text
def GetFooter():
return '\n'
def GetHeader(text, h=1):
return '%s' % (h, text, h)
def GetTableHeader(headers):
row = ''.join(['%s | ' % header for header in headers])
return '%s
' % row
def GetTableFooter():
return '
'
def FormatLineBreaks(text):
return text.replace('\n', '
')
def GetTableCell(text):
return '%s | ' % FormatLineBreaks(str(text))
def GetTableRow(columns):
return '%s
' % '\n'.join([GetTableCell(column) for column in columns])
def GetTable(headers, rows):
table = [GetTableHeader(headers)]
table.extend([GetTableRow(row) for row in rows])
table.append(GetTableFooter())
return '\n'.join(table)
def GetLink(link, text):
return "%s" % (link, text)