GetRD / academic-file-converter

📚 Import Bibtex publications and Jupyter Notebook blog posts into your Markdown website or book. 将Bibtex转换为Markdown网站
https://docs.hugoblox.com/reference/content-types/#automatically-import-publications-from-bibtex
MIT License
352 stars 102 forks source link

hugo-academic-cli bibtex import is broken with hugo v0.89.0 #104

Closed ostaadt closed 2 years ago

ostaadt commented 2 years ago

academic import --bibtex publications.bib is creating a malformed path for markown_path in parse_bibtex_entry, which is defined in academic/import_bibtex.py.

markdown_path starts with content/..., but the subprocess call to hugo new {markdown_path} --kind publication } already prepends the path with content automatically.

BibTeX entries are parsed correctly, and cite.bibis created in the correct directory (e.g., content/publication/some-publication-id/cite.bib). The markdown entry, however, is created in content/content/publication/some-publication-id/index.md. Subsequently, parse_bibtex_entry throws an error, because it cannot find index.md in content/publication/some-publication-id.

I don't know if this a bug in hugo new --publication or a change in archetypes behavior in the latest hugo

I was able to fix the problem in academic by changing markdown_path from

markdown_path = os.path.join(bundle_path, "index.md")

to

markdown_path = f"{pub_dir}/{slugify(entry['ID'])}/index.md"

This fix works for hugo v.0.89.0, but it might break older versions...

cornish commented 2 years ago

confirmed as having the same issue; haven't tried the fix yet

gcushen commented 2 years ago

Hugo v.0.89 is a new release with major changes. There are often bugs in the very latest major Hugo versions. Consider reporting Hugo bugs in the Hugo repo so that the relevant team are aware of them and can help address them...Or better yet, help contribute a Hugo fix since it's also an open source initiative that's driven by the community ;)

In this case, it appears the Hugo 0.89.0 CLI bugs were fixed in Hugo 0.89.4 (e.g. https://github.com/gohugoio/hugo/issues/9177).

With Hugo 0.89.4, the command you referred to, hugo new content/publication/test/index.md --kind publication, works fine.

gcushen commented 2 years ago

Also, if anyone wants to help submit a PR for #85 (removing the dependency on hugo new), that would be appreciated by a large number of users in the community who don't want to install Hugo locally or rely on Hugo to generate publications!