chapisha/helpers/pages.py
def create_titlepage_xhtml(metadata: WorkMetadata) -> str:
    """
    Load the default `titlepage.xhtml` file, and generate the required terms for the creative work. Return xhtml as a string.
    
    Parameters
    ----------
    metadata: WorkMetadata
        All the terms for updating the work, not all compulsory

    Returns
    -------
    str: svg response for `titlepage.xhtml` as a str.
    """
    with open(DATA_PATH / "xhtml" / DEFAULT_TITLEPAGE, "r+", encoding="utf-8") as xhtml_file:
        xml_txt = xhtml_file.read()
        # Title
        title_xml = ""
        y = TITLEPAGE_TITLE_START
        for row in formats.get_text_rows(metadata.title):
            y += TITLEPAGE_TITLE_HEIGHT
            title_xml += F'\t<text class="title" x="700" y="{y}">{row}</text>\n'
            y += TITLEPAGE_ROW_MARGIN
        xml_txt = xml_txt.replace('\t<text class="title" x="700" y="130">WORK_TITLE</text>\n', title_xml)
        # Author/s
        creator = metadata.creator
        if isinstance(creator, list):
            if len(creator) > 1:
                creator = " &amp; ".join([", ".join(creator[:-1]), creator[-1]])
            else:
                creator = creator[0]
        y += SECTION_SPACER - TITLEPAGE_ROW_MARGIN
        author_xml = ""
        for row in formats.get_text_rows(creator, font_size=formats.AUTHOR_SIZE):
            y += TITLEPAGE_AUTHOR_HEIGHT
            author_xml += F'\t<text class="author" x="700" y="{y}">{row}</text>\n'
            y += TITLEPAGE_ROW_MARGIN
        xml_txt = xml_txt.replace('\t<text class="author" x="700" y="290">WORK_AUTHOR</text>\n', author_xml)
        # Chapisha boilerplate
        y += SECTION_SPACER * 2 + TITLEPAGE_AUTHOR_HEIGHT - TITLEPAGE_ROW_MARGIN
        xml_txt = xml_txt.replace('<text class="contributor-descriptor" x="700" y="480">Generated by Chapisha</text>',
                                  F'<text class="contributor-descriptor" x="700" y="{y}">Generated by Chapisha</text>')
        y += SECTION_SPACER - TITLEPAGE_ROW_MARGIN * 2
        xml_txt = xml_txt.replace('<image x="650" y="540" width="100" height="100" xlink:href="../images/logo.svg" />',
                                  F'<image x="650" y="{y}" width="140" height="140" xlink:href="../images/logo.svg" />')
        y += 150
        xml_txt = xml_txt.replace(F'viewBox="0 0 1400 700"',
                                F'viewBox="0 0 1400 {y}"')
    return xml_txt

    Load the default `titlepage.xhtml` file, and generate the required terms for the creative work. Return xhtml as a string.
    
    Parameters
    ----------
    metadata: WorkMetadata
        All the terms for updating the work, not all compulsory

    Returns
    -------
    str: svg response for `titlepage.xhtml` as a str.
    
Load the default `titlepage.xhtml` file, and generate the required terms for the creative work. Return xhtml as a string.
Parameters

WorkMetadata
All the terms for updating the work, not all compulsory

Returns

svg response for `titlepage.xhtml` as a str.
Load the default ` titlepage . xhtml ` file and generate the required terms for the creative work . Return xhtml as a string . Parameters WorkMetadata All the terms for updating the work not all compulsory Returns svg response for ` titlepage . xhtml ` as a str .
def create_titlepage_xhtml(metadata: WorkMetadata) -> str:
    with open(DATA_PATH / "xhtml" / DEFAULT_TITLEPAGE, "r+", encoding="utf-8") as xhtml_file:
        xml_txt = xhtml_file.read()
        title_xml = ""
        y = TITLEPAGE_TITLE_START
        for row in formats.get_text_rows(metadata.title):
            y += TITLEPAGE_TITLE_HEIGHT
            title_xml += F'\t<text class="title" x="700" y="{y}">{row}</text>\n'
            y += TITLEPAGE_ROW_MARGIN
        xml_txt = xml_txt.replace('\t<text class="title" x="700" y="130">WORK_TITLE</text>\n', title_xml)
        creator = metadata.creator
        if isinstance(creator, list):
            if len(creator) > 1:
                creator = " &amp; ".join([", ".join(creator[:-1]), creator[-1]])
            else:
                creator = creator[0]
        y += SECTION_SPACER - TITLEPAGE_ROW_MARGIN
        author_xml = ""
        for row in formats.get_text_rows(creator, font_size=formats.AUTHOR_SIZE):
            y += TITLEPAGE_AUTHOR_HEIGHT
            author_xml += F'\t<text class="author" x="700" y="{y}">{row}</text>\n'
            y += TITLEPAGE_ROW_MARGIN
        xml_txt = xml_txt.replace('\t<text class="author" x="700" y="290">WORK_AUTHOR</text>\n', author_xml)
        y += SECTION_SPACER * 2 + TITLEPAGE_AUTHOR_HEIGHT - TITLEPAGE_ROW_MARGIN
        xml_txt = xml_txt.replace('<text class="contributor-descriptor" x="700" y="480">Generated by Chapisha</text>',
                                  F'<text class="contributor-descriptor" x="700" y="{y}">Generated by Chapisha</text>')
        y += SECTION_SPACER - TITLEPAGE_ROW_MARGIN * 2
        xml_txt = xml_txt.replace('<image x="650" y="540" width="100" height="100" xlink:href="../images/logo.svg" />',
                                  F'<image x="650" y="{y}" width="140" height="140" xlink:href="../images/logo.svg" />')
        y += 150
        xml_txt = xml_txt.replace(F'viewBox="0 0 1400 700"',
                                F'viewBox="0 0 1400 {y}"')
    return xml_txt
def create_titlepage_xhtml ( metadata : WorkMetadata ) -> str : with open ( DATA_PATH / "xhtml" / DEFAULT_TITLEPAGE , "r+" , encoding = "utf-8" ) as xhtml_file : xml_txt = xhtml_file . read ( ) title_xml = "" y = TITLEPAGE_TITLE_START for row in formats . get_text_rows ( metadata . title ) : y += TITLEPAGE_TITLE_HEIGHT title_xml += F'\t<text class="title" x="700" y="{y}">{row}</text>\n' y += TITLEPAGE_ROW_MARGIN xml_txt = xml_txt . replace ( '\t<text class="title" x="700" y="130">WORK_TITLE</text>\n' , title_xml ) creator = metadata . creator if isinstance ( creator , list ) : if len ( creator ) > 1 : creator = " &amp; " . join ( [ ", " . join ( creator [ : - 1 ] ) , creator [ - 1 ] ] ) else : creator = creator [ 0 ] y += SECTION_SPACER - TITLEPAGE_ROW_MARGIN author_xml = "" for row in formats . get_text_rows ( creator , font_size = formats . AUTHOR_SIZE ) : y += TITLEPAGE_AUTHOR_HEIGHT author_xml += F'\t<text class="author" x="700" y="{y}">{row}</text>\n' y += TITLEPAGE_ROW_MARGIN xml_txt = xml_txt . replace ( '\t<text class="author" x="700" y="290">WORK_AUTHOR</text>\n' , author_xml ) y += SECTION_SPACER * 2 + TITLEPAGE_AUTHOR_HEIGHT - TITLEPAGE_ROW_MARGIN xml_txt = xml_txt . replace ( '<text class="contributor-descriptor" x="700" y="480">Generated by Chapisha</text>' , F'<text class="contributor-descriptor" x="700" y="{y}">Generated by Chapisha</text>' ) y += SECTION_SPACER - TITLEPAGE_ROW_MARGIN * 2 xml_txt = xml_txt . replace ( '<image x="650" y="540" width="100" height="100" xlink:href="../images/logo.svg" />' , F'<image x="650" y="{y}" width="140" height="140" xlink:href="../images/logo.svg" />' ) y += 150 xml_txt = xml_txt . replace ( F'viewBox="0 0 1400 700"' , F'viewBox="0 0 1400 {y}"' ) return xml_txt
Load the default `titlepage.xhtml` file, and generate the required terms for the creative work.
Load the default ` titlepage . xhtml ` file and generate the required terms for the creative work .
"""
    Load the default `titlepage.xhtml` file, and generate the required terms for the creative work. Return xhtml as a string.
    
    Parameters
    ----------
    metadata: WorkMetadata
        All the terms for updating the work, not all compulsory

    Returns
    -------
    str: svg response for `titlepage.xhtml` as a str.
    """ # Title # Author/s # Chapisha boilerplate
metadata
WorkMetadata