Exemple #1
0
    def take_action(self, parsed_args):
        dirname = os.path.join("build", parsed_args.name)
        if not os.path.exists(dirname):
            os.makedirs(dirname)

        self._build_style = parsed_args.style
        self._ext_priority = parsed_args.exts
        self._max_size = parsed_args.maxsize

        bbl_path = ".".join((os.path.splitext(self.app.options.master)[0],
                             'bbl'))

        with codecs.open(self.app.options.master, 'r', encoding='utf-8') as f:
            root_text = f.read()
        tex = inline(root_text)
        tex = remove_comments(tex)
        tex = self._process_figures(tex, dirname)
        if os.path.exists(bbl_path):
            with codecs.open(bbl_path, 'r', encoding='utf-8') as f:
                bbl_text = f.read()
            tex = inline_bbl(tex, bbl_text)
        else:
            self.log.debug("Skipping .bbl installation")

        if self._build_style == "aastex":
            output_tex_path = os.path.join(dirname, "ms.tex")
        else:
            output_tex_path = os.path.join(
                dirname,
                os.path.basename(self.app.options.master))
        self._write_tex(tex, output_tex_path)
Exemple #2
0
def inline_current(root_tex_path):
    """Inline the current manuscript."""
    base_dir = os.path.dirname(root_tex_path)
    with codecs.open(root_tex_path, 'r', encoding='utf-8') as f:
        root_text = f.read()
        root_text = remove_comments(root_text)
        root_text = inline(root_text, base_dir=base_dir)
    output_path = "_current.tex"
    if os.path.exists(output_path):
        os.remove(output_path)
    with codecs.open(output_path, 'w', encoding='utf-8') as f:
        f.write(root_text)
    return output_path
Exemple #3
0
def inline_current(root_tex_path):
    """Inline the current manuscript."""
    base_dir = os.path.dirname(root_tex_path)
    with codecs.open(root_tex_path, 'r', encoding='utf-8') as f:
        root_text = f.read()
        root_text = remove_comments(root_text)
        root_text = inline(root_text, base_dir=base_dir)
    output_path = "_current.tex"
    if os.path.exists(output_path):
        os.remove(output_path)
    with codecs.open(output_path, 'w', encoding='utf-8') as f:
        f.write(root_text)
    return output_path