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

ebib-create-org-description does not clean the entry's title #310

Open
mcookly opened this issue Oct 23, 2024 · 5 comments
Open

ebib-create-org-description does not clean the entry's title #310

mcookly opened this issue Oct 23, 2024 · 5 comments

Comments

@mcookly
Copy link

mcookly commented Oct 23, 2024

Making notes with %T as an identifier results in a title with TeX markup. On the other hand, ebib-create-org-title cleans the TeX. If this is a bug, I think it can be fixed quite easily. Here is what I use in my own code:

(defun ebib-create-org-description (key db)
  "Return a description for an Org mode note for KEY in DB.
The title is formed from the author(s) or editor(s) of the entry,
its year and its title.  Newlines are removed from the resulting
string."
  (let ((author (or (ebib-get-field-value "author" key db 'noerror 'unbraced 'xref)
                    (ebib-get-field-value "editor" key db 'noerror 'unbraced 'xref)
                    "(No Author)"))
        (year (ebib-get-year-for-display key db))
-        (title (or (ebib-get-field-value "title" key db 'noerror 'unbraced 'xref)
+        (title (or (parsebib-clean-TeX-markup
+                    (ebib-get-field-value "title" key db 'noerror 'unbraced 'xref))
                   "(No Title)")))
    (remove ?\n (format "%s (%s): %s" author year title))))

Just as a disclaimer, I've configured Ebib to use markdown instead of org-mode, so perhaps %T would be cleaned if I used org-mode.

Thank you for the wonderful program!

@joostkremers
Copy link
Owner

Hmm, that does look like a bug, given the fact that org-create-title does clean TeX markup. Your modification will cause an error, though, for entries that do not have a title. That's probably unlikely to occur, but better safe than sorry. I'll push a fix for this in a minute.

@joostkremers
Copy link
Owner

On second thought, cleaning all TeX markup may not be a good idea... Things like \textit{word} are converted to #("word" 0 4 (face italic)), but the text property does not show up in an Org buffer, and even if it did, it would be gone once the file is closed.

Ideally, font commands such as \textit are converted to the equivalent Org markup (and in your case, the equivalent Markdown), but that would be more work...

@mcookly
Copy link
Author

mcookly commented Oct 24, 2024

Good points. It's pretty trivial for the user to create a custom identifier that converts the title to another markup format if he or she wants a clean title (using Pandoc e.g.). Since you've made Ebib quite flexible on the user-end, maybe this can be considered a feature, not a bug. 😉

@joostkremers
Copy link
Owner

In any case, I think it doesn't make sense that ebib-create-org-title and ebib-create-org-description behave differently in this respect. Furthermore, it wouldn't be too difficult to provide ready-made functions that can transform TeX markup into Org or Markdown. After all, most of what parsebib-clean-TeX-markup does is format-agnostic. All that's needed would be four small functions that handle \text{it|bf|sc} and \emph. I won't promise anything, but I'll try to come up with something in the next few days.

@joostkremers
Copy link
Owner

I just pushed updates to parsebib.el and Ebib that should improve things. Ebib now comes with a set of functions for creating Markdown notes. These are intended to be used as template specifiers in ebib-notes-template-specifiers instead of the Org-specific functions of the default value.

I would appreciate it if you could update your configuration to use the new functions, at least for the specifiers that you use in your template, and let me know if you run into any issues. The names of the functions are identical to the Org-specific ones, with markdown instead of org. (So e.g. ebib-create-markdown-description instead of ebib-create-org-description.)

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

No branches or pull requests

2 participants