Ejemplo n.º 1
0
def prepare_manuscript(args):
    """
    Compile manuscript, creating manuscript.md and references.json as inputs
    for pandoc.
    """
    text = get_text(args.content_directory)
    citation_df = get_citation_df(args, text)

    generate_csl_items(args, citation_df)

    citation_string_to_id = collections.OrderedDict(
        zip(citation_df.string, citation_df.citation_id))
    text = replace_citations_strings_with_ids(text, citation_string_to_id)

    metadata, variables = get_metadata_and_variables(args)
    variables['manuscript_stats'] = get_manuscript_stats(text, citation_df)
    with args.variables_path.open('w') as write_file:
        json.dump(variables, write_file, indent=2)
        write_file.write('\n')

    text = template_with_jinja2(text, variables)

    # Write manuscript for pandoc
    with args.manuscript_path.open('w') as write_file:
        yaml.dump(metadata,
                  write_file,
                  default_flow_style=False,
                  explicit_start=True,
                  explicit_end=True)
        write_file.write('\n')
        write_file.write(text)
Ejemplo n.º 2
0
def prepare_manuscript(args):
    """
    Compile manuscript, creating manuscript.md and references.json as inputs
    for pandoc.
    """
    text = get_text(args.content_directory)
    assert args.skip_citations

    variables = load_variables(args)
    variables["manubot"]["manuscript_stats"] = get_manuscript_stats(text)
    with args.variables_path.open("w", encoding="utf-8") as write_file:
        json.dump(variables, write_file, ensure_ascii=False, indent=2)
        write_file.write("\n")

    text = template_with_jinja2(text, variables)

    # Write manuscript for pandoc
    yaml = get_configured_yaml()
    with args.manuscript_path.open("w", encoding="utf-8") as write_file:
        yaml.dump(
            variables["pandoc"],
            write_file,
            default_flow_style=False,
            explicit_start=True,
            explicit_end=True,
            width=float("inf"),
            allow_unicode=True,
            sort_keys=False,
        )
        write_file.write("\n")
        write_file.write(text)
Ejemplo n.º 3
0
def prepare_manuscript(args):
    """
    Compile manuscript, creating manuscript.md and references.json as inputs
    for pandoc.
    """
    text = get_text(args.content_directory)
    citekeys_df = get_citekeys_df(args, text)

    generate_csl_items(args, citekeys_df)

    citekey_mapping = collections.OrderedDict(
        zip(citekeys_df.manuscript_citekey, citekeys_df.short_citekey)
    )
    text = update_manuscript_citekeys(text, citekey_mapping)

    metadata, variables = get_metadata_and_variables(args)
    variables["manuscript_stats"] = get_manuscript_stats(text, citekeys_df)
    with args.variables_path.open("w", encoding="utf-8") as write_file:
        json.dump(variables, write_file, ensure_ascii=False, indent=2)
        write_file.write("\n")

    text = template_with_jinja2(text, variables)

    # Write manuscript for pandoc
    with args.manuscript_path.open("w", encoding="utf-8") as write_file:
        yaml.dump(
            metadata,
            write_file,
            default_flow_style=False,
            explicit_start=True,
            explicit_end=True,
        )
        write_file.write("\n")
        write_file.write(text)