Пример #1
0
 def format_section(self, section):
     if self.notes:
         with self._tag('h%d' % section.level):
             self.out.write(to_html(section.text))
         if section.synopsis:
             with self._tag('span', classes=['h%d-synopsis' % section.level]):
                 self.out.write(to_html(plain(section.synopsis)))
Пример #2
0
 def format_slug(self, slug):
     num = slug.scene_number
     with self._tag('div', classes=['slug']):
         if num and self.shooting:
             with self._tag('span', classes=['scnuml']):
                 self.out.write(to_html(slug.scene_number))
         self.out.write(to_html(slug.line))
         if num and self.shooting:
             with self._tag('span', classes=['scnumr']):
                 self.out.write(to_html(slug.scene_number))
     if slug.synopsis and self.notes:
         with self._tag('span', classes=['h6-synopsis']):
             self.out.write(to_html(plain(slug.synopsis)))
Пример #3
0
    def append_slug(self, paragraphs):
        if len(self.lines) != 1:
            return False

        elif self.lines[0].startswith("!"):
            return False

        match = scene_re.match(self.lines[0])
        if not match:
            match = slug_re.match(self.lines[0])
            if not match:
                return False

            else:
                period, text = match.groups()
                text = text.upper()
                if not period and not any(regex.match(text) for regex in slug_regexes):
                    return False

                match = scene_number_re.match(text)
                if match:
                    text, scene_number = match.groups()
                    paragraphs.append(Slug(_string_to_rich(text), plain(scene_number)))
                else:
                    paragraphs.append(Slug(_string_to_rich(text)))
                return True

        elif match.group(2) == "#" and match.group(4) == "#":
            paragraphs.append(Slug(_string_to_rich(match.group(1) +
                " " + match.group(3)), plain(match.group(3))))
            return True

        else:
            paragraphs.append(Slug(_string_to_rich(match.group(1) +
                " " + (match.group(2) or "") + match.group(3) +
                (match.group(4) or ""))))
            return True
Пример #4
0
def convert_full(screenplay, out, css_file, strong, notes, shooting):
    """Convert the screenplay into a complete HTML document,
    written to the file-like object `out`.

    """
    title = 'Screenplay'
    if 'Title' in screenplay.title_page:
        title = ' - '.join(screenplay.title_page['Title'])

    with open(css_file, 'r') as stream:
        css = stream.read()
    out.write(
        '<!DOCTYPE html>\n'
        '<html>'
        '<head>'
        '<meta charset="UTF-8">'
        '<title>' + to_html(plain(title)) + '</title>'
        '<style type="text/css">'
    )
    out.write(css.replace("\n"," "))
    out.write(
        '</style>'
    )
    if notes:
        out.write(
        '<style type="text/css">' +
        """h1:before,h2:before,h3:before,h4:before,h5:before {
        content: "\\25e6\\00a0";
        margin-left:-9pt;
        }
        h1,h2,h3,h4,h5{
        font-family:'Gill Sans','Helvetiva Neue',Helvetica,sans-serif;
        margin-top: 1em;
        font-weight: 400;
        color: #6e6e6e;
        border-top: dotted 1px #c7c7c7;
        background-image: -webkit-linear-gradient(top, #fafafa, #fff);
        font-size: 11pt;
        }
        h1,.h1-synopsis {
        margin-left:-71pt;
        }
        h2,.h2-synopsis {
        margin-left:-61pt;
        }
        h3,.h3-synopsis {
        margin-left:-41pt;
        }
        h4,.h4-synopsis {
        margin-left:-21pt;
        }
        h5,.h5-synopsis {
        margin-left:-1pt;
        }
        .h1-synopsis,.h2-synopsis,.h3-synopsis,.h4-synopsis,.h5-synopsis,.h6-synopsis{
        font-family:'Gill Sans','Helvetiva Neue',Helvetica,sans-serif;
        font-size: 10pt;
        font-style: italic;
        color: rgb(145, 145, 145);
        display: block;
        margin-bottom: .5em;
        }""".replace('\n', "") +
        '</style>'
        )
    if strong:
        out.write(
        '<style type="text/css">div.act,div.slug{font-weight: bold;}</style>'
        )
    out.write(
        '</head>'
        '<body>'
        '<div class="play">\n'
    )
    convert_bare(screenplay, out, notes, shooting)
    out.write(
        '</div>'
        '</body>'
        '</html>\n'
    )
Пример #5
0
 def format_act(self, act):
     with self._tag('div', classes=['act']):
         self.out.write(to_html(act.line))
     if isinstance(act, NewAct) and act.synopsis and self.notes:
         with self._tag('span', classes=['h6-synopsis']):
             self.out.write(to_html(plain(act.synopsis)))