unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Roland Winkler <winkler@gnu.org>
To: Ihor Radchenko <yantar92@gmail.com>
Cc: 57712@debbugs.gnu.org, Lars Ingebrigtsen <larsi@gnus.org>
Subject: bug#57712: 29.0.50; bibtex.el: Should `bibtex-parse-entry' handle curly braces inside fields?
Date: Wed, 14 Sep 2022 12:02:24 -0500	[thread overview]
Message-ID: <87v8ppvqhr.fsf@gnu.org> (raw)
In-Reply-To: <87zgf2yai6.fsf@localhost> (Ihor Radchenko's message of "Wed, 14 Sep 2022 10:07:13 +0800")

On Wed, Sep 14 2022, Ihor Radchenko wrote:
> I am looking at this differently. Similar to BibTeX fields, text in the
> fields is a subject of a specific format. That format is _not_ exactly
> the same with TeX (e.g. see
> https://tex.stackexchange.com/questions/26338/how-to-code-%C3%9F-german-sharp-s-in-bibtex)

No, the problem discussed there exists exactly the same way within any
LaTeX document.  I deal with this frequently, both in the context of
LaTeX and in the context of BibTeX.  The content of BibTeX fields must
always be valid from LaTeX's perspective that will digest them.

(BibTeX never checks itself whether the user made an error from
LaTeX's perspective.  BibTeX generates bbl files that are then processed
by LaTeX.  LaTeX will choke over malformed BibTeX fields the same way it
will choke over invalid constructs in any LaTeX document.)

> I expect bibtex.el to handle all the peculiarities of BibTeX format, so
> that external packages do not need to perform extra parsing.

There are only two issues beyond the oddities of LaTeX itself

- BibTeX string constants

- BibTeX crossref'ed entries when a field is absent in an entry because
  it is present in a "parent" entry.

(There is also the odd behavior that standard BibTeX style files want to
downcase the content of the BibTeX "title" field, and this can be
suppressed by putting curly braces around the characters.  But the way
this works is that these braces are preserved in the bbl file generated
by BibTeX, and LaTeX will simply ignore them.  The braces do not violate
the rule that the content of BibTeX fields must always be valid from
LaTeX's perspective.)

> If you dislike modifying bibtex-parse-entry, bibtex-parse-field-text
> looks like a reasonable place to handle field text parsing.

Both BibTeX string constants and BibTeX crossref'ed entries are handled
by bibtex-text-in-field.  (As we discussed previously, expanding string
constants requires bibtex-expand-strings to be non-nil.)

Then bibtex-text-in-field always returns valid LaTeX code (provided the
user did not make any LaTeX mistakes in her fields, see above).

As I said before: if this doesn't fit your needs for org mode, I suggest
you develop a LaTeX parser that can process LaTeX code according to your
needs.  Then you can feed it with any valid LaTeX code including the
return values of bibtex-text-in-field.





  reply	other threads:[~2022-09-14 17:02 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-10  4:32 bug#57712: 29.0.50; bibtex.el: Should `bibtex-parse-entry' handle curly braces inside fields? Ihor Radchenko
2022-09-10  4:39 ` Lars Ingebrigtsen
2022-09-10 16:07   ` Roland Winkler
2022-09-11  5:11     ` Roland Winkler
2022-09-12  5:20       ` Ihor Radchenko
2022-09-12 13:50         ` Roland Winkler
2022-09-13  2:34           ` Ihor Radchenko
2022-09-13  4:08             ` Roland Winkler
2022-09-14  2:07               ` Ihor Radchenko
2022-09-14 17:02                 ` Roland Winkler [this message]
2022-12-30  6:39                   ` Roland Winkler
2022-09-12  5:06     ` Ihor Radchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87v8ppvqhr.fsf@gnu.org \
    --to=winkler@gnu.org \
    --cc=57712@debbugs.gnu.org \
    --cc=larsi@gnus.org \
    --cc=yantar92@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).