Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: Better way to auto-inject bibliography heading #639

Merged
merged 3 commits into from May 20, 2022

Conversation

kaushalmodi
Copy link
Owner

@kaushalmodi kaushalmodi commented May 20, 2022

Earlier method wasn't elegant because it relied on an empirically
derived regexp. The reason for this change was that this regexp was
falsely matching a <style> elsewhere in one of my blog posts (Nim
notes), and it caused a regex out of stack error 😒

By advising org-cite-export-bibliography directly, we will always be
able to perfectly inject the heading before the bibliography.

As a side-effect,

  1. This approach now is able to inject the heading for non-CSS i.e. basic style bibliography as well.
  2. ❗ but! now the auto heading insertion will stop for org-ref citations.

Earlier method wasn't elegant because it relied on an empirically
derived regexp. The reason for this change was that this regexp was
falsely matching a <style> elsewhere in one of my blog posts (Nim
notes), and it caused a regex out of stack error :|

By advising `org-cite-export-bibliography` directly, we will always be
able to perfectly inject the heading before the bibliography. As a
side-effect, this approach now is able to inject the heading for
non-CSS i.e. basic style bibliography as well.
Adding this feature for org-ref is a bit painful because:

1. `org-ref` uses `citeproc-render-bib` in `org-ref-export.el`., while
   the heading insertion feature is advised to
   `org-cite-export-bibliography`.
2. `org-ref-process-buffer` calls `citeproc-render-bib` internally in
   the function and assigns the rendered bibliography to
   `rendered-bib` variable after manually prefixing some CSS style
   elements. So it's not easy to advise that internal variable.

If a user wants this auto bibliography heading insertion for org-ref
citations, they can use `org-export-before-parsing-hook` to
post-process the Org buffer and I can help out with that.
@kaushalmodi kaushalmodi merged commit e63bb09 into main May 20, 2022
@kaushalmodi kaushalmodi deleted the improve-bibliography-heading-injection branch May 20, 2022 03:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant