Skip to content

author name splitting fails in some cases when converting a bib-file with latexml #999

Description

@siegfriedzoetzsche

When a bib-File is converted with latexml, the name splitting of the author filed fails in some cases.

Converting the bib file example.bib:

@book{example0,
author = {
Ab Abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz and Xxxx Xxxxxxxxiiiii and Yyy Yyy
},}
@book{example1,
author = {
Ab Abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz and Xxxx Xxxxxxxxi and Yyy Yyy
},}
@book{example2,
author = {
Ab Abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz and Xxxx Xxxxxxxxii and Yyy Yyy
},}
@book{example3,
author = {
Ab Abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz and Xxxx Xxxxxxxx and Yyy Yyy
},}

with

latexml --destination=example.xml example.bib

produces a correct result only for entry example0.
For entry example1 the second author is messed up and the third is missing.
For entry example2 the second author is messed up.
For entry example3 the third author is messed up.

[...]
    <biblist>
      <bibentry key="example0" type="book" xml:id="bib.bib1">
        <bib-name role="author">
          <surname>Abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz</surname>
          <givenname>Ab</givenname>
        </bib-name>
        <bib-name role="author">
          <surname>Xxxxxxxxiiiii</surname>
          <givenname>Xxxx</givenname>
        </bib-name>
        <bib-name role="author">
          <surname>Yyy</surname>
          <givenname>Yyy</givenname>
        </bib-name>
        <bib-data role="self" type="BibTeX">@book{example0,
    author = {Ab Abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz and Xxxx Xxxxxxxxiiiii and Yyy Yyy}}
</bib-data>
      </bibentry>
      <bibentry key="example1" type="book" xml:id="bib.bib2">
        <bib-name role="author">
          <surname>Abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz</surname>
          <givenname>Ab</givenname>
        </bib-name>
        <bib-name role="author">
          <surname>and</surname>
          <givenname>Xxxx Xxxxxxxxi</givenname>
        </bib-name>
        <bib-data role="self" type="BibTeX">@book{example1,
    author = {Ab Abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz and Xxxx Xxxxxxxxi and Yyy Yyy}}
</bib-data>
      </bibentry>
      <bibentry key="example2" type="book" xml:id="bib.bib3">
        <bib-name role="author">
          <surname>Abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz</surname>
          <givenname>Ab</givenname>
        </bib-name>
        <bib-name role="author">
          <surname/>
          <givenname>Xxxx Xxxxxxxxii</givenname>
        </bib-name>
        <bib-name role="author">
          <surname>Yyy</surname>
          <givenname>Yyy</givenname>
        </bib-name>
        <bib-data role="self" type="BibTeX">@book{example2,
    author = {Ab Abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz and Xxxx Xxxxxxxxii and Yyy Yyy}}
</bib-data>
      </bibentry>
      <bibentry key="example3" type="book" xml:id="bib.bib4">
        <bib-name role="author">
          <surname>Abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz</surname>
          <givenname>Ab</givenname>
        </bib-name>
        <bib-name role="author">
          <surname>Xxxxxxxx</surname>
          <givenname>Xxxx</givenname>
        </bib-name>
        <bib-name role="author">
          <surname>Yyy</surname>
          <givenname/>
        </bib-name>
        <bib-data role="self" type="BibTeX">@book{example3,
    author = {Ab Abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz and Xxxx Xxxxxxxx and Yyy Yyy}}
</bib-data>
      </bibentry>
    </biblist>
[...]

I suspect this has something to do with the % inserted by sub UnTeX in Core/Token.pm after the 78th character (my $UNTEX_LINELENGTH = 78; # [CONSTANT]), similar to #884 .

A quick fix for me is to add $string =~ s/%\n//; in sub splitWords in Package/BibTeX.pool.ltxml like:

sub splitWords {
  my ($string) = @_;
  $string =~ s/\\~/####/g;    # Protect \~ so we can split on hard spaces (~) as well as regular ones.
  my @words = ();
  $string =~ s/^[\s~]+//;
  $string =~ s/%\n//;
[...]
  }

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions