jabref icon indicating copy to clipboard operation
jabref copied to clipboard

Fix 11102 by allowing users to add local bst files to preview layout list

Open sahilsekr42 opened this issue 10 months ago • 10 comments

I've tried to fix #11102 by adding a button which may be used to add the selected bst files to the available styles and tested it to work although I think for preview to function well bstvm should be used not sure how. Would like some guidance . After it works as expected may be documentation can be modified.

Mandatory checks

  • [x] Change in CHANGELOG.md described in a way that is understandable for the average user (if applicable)
  • [ ] Tests created for changes (if applicable)
  • [x] Manually tested changed features in running JabRef (always required)
  • [ ] Screenshots added in PR description (for UI changes)
  • [ ] Checked developer's documentation: Is the information available and up to date? If not, I outlined it in this pull request.
  • [ ] Checked documentation: Is the information available and up to date? If not, I created an issue at https://github.com/JabRef/user-documentation/issues or, even better, I submitted a pull request to the documentation repository.

sahilsekr42 avatar Apr 21 '24 17:04 sahilsekr42

No need to close the PR and reopen. Just continue committing and pushing. The PR will be updated automatically

Siedlerchr avatar Apr 21 '24 17:04 Siedlerchr

think for preview to function well bstvm should be used not sure how

I am not quite sure I understand you correctly, but the BstPreviewLayout itself already handles the bstVm:, so it should work out of the box

https://github.com/JabRef/jabref/blob/94bc5c2c74adb7f034855bc4a362433bd2523294/src/main/java/org/jabref/logic/bst/BstPreviewLayout.java#L44-L54

Siedlerchr avatar Apr 21 '24 17:04 Siedlerchr

@Siedlerchr thanks I didn't really understand the mechanism of updating pull request (i.e. just committing to my branch automatically updates the pr and runs tests again.

sahilsekr42 avatar Apr 21 '24 17:04 sahilsekr42

Thanks for the PR! We refactored the code a bit and found an issue with the BST rendering itself, (not your fault, but we would like to continue here, so please leave the PR open).

Siedlerchr avatar Apr 22 '24 21:04 Siedlerchr

Intermediate result:

  • Running IEEEtran.bst with this branch leads to a failure
  • Running IEEEtran.bst with ANTLR4, works (see https://github.com/koppor/jabref/pull/685)
  • Thus, I assume that https://github.com/JabRef/jabref/pull/8934 broke our VM.

koppor avatar Apr 25 '24 17:04 koppor

Tested some other styles that work:

https://raw.githubusercontent.com/CarlOrff/apalike-german/master/apalike-german.bst https://ctan.org/pkg/alphanumb https://github.com/wacv-pcs/WACV-2023-Author-Kit/blob/main/ieee.bst https://www.ctan.org/tex-archive/biblio/bibtex/base/acm.bst Apalike: https://www.ctan.org/tex-archive/biblio/bibtex/base

interestingly, the IEEEtr.bst from the base style sworks as well https://mirrors.ctan.org/biblio/bibtex/base/ieeetr.bst

Siedlerchr avatar Apr 25 '24 18:04 Siedlerchr

Current state:

The t is a function which is "not found", but t seems to be string or a variable.

Maybe, the whole new interpretation mixes up parsing of the .bst file and the real execution.

Other than that, I find following code strange - this seems to mix parsing and execution

    @Override
    public Integer visitBstFunction(BstParser.BstFunctionContext ctx) {
        String name = ctx.getChild(0).getText();
        if (bstVMContext.functions().containsKey(name)) {
            LOGGER.trace("Function '{}' found", name);
            bstVMContext.functions().get(name).execute(this, ctx, selectedBstEntry);
        } else {
            LOGGER.trace("Function '{}' not found", name);
            visit(ctx.getChild(0));
        }

        return BstVM.TRUE;
    }

koppor avatar Apr 25 '24 19:04 koppor

Other than that, I find following code strange - this seems to mix parsing and execution

Parsing is all done in the constructor of the VM. Execution is done by the visitor.

calixtus avatar Apr 29 '24 20:04 calixtus

Parsing is all done in the constructor of the VM. Execution is done by the visitor.

I don't fully understand. The code above reads that visit is doing some semantic interpretation. First hit of a function: Visit it using the visitor. Second hit of a function: Execute it. This is what I meant with "mix". -- In other words: First, there is a "syntax analysis". Then, the visit function seems to do some semantic analysis and also a semantic execution.

(I found the article at https://medium.com/@shivanivikhar3775/know-more-about-compiler-phases-601680cf48fd a good overview)


Maybe, it's "just" about logging the steps in the ANTLR3 version and the steps at the ANTLR4 version and comparing them. When do they diverge for IEEE? (In other words: create traces and compare the traces). I hope, it will be "easy" to do so.

koppor avatar May 02 '24 23:05 koppor

If I recall correctly, the it just checks if a built-in function is present, otherwise it looks for custom functions.

calixtus avatar May 03 '24 11:05 calixtus

Strange git error:

error: Authentication error: Authentication required: You must have push access to verify locks
error: failed to push some refs to 'https://github.com/sahilsekr42/jabref.git'

Pushed to koppor.

koppor avatar May 19 '24 20:05 koppor

something with git lfs stuff

Siedlerchr avatar May 19 '24 21:05 Siedlerchr

We identified that there is an endless loop happening in following bst function

% Converts all single dashes "-" to double dashes "--".
FUNCTION {n.dashify}
{ large.number.separate
  't :=
  ""
    { t empty$ not }
    { t #1 #1 substring$ "-" =
        { t #1 #2 substring$ "--" = not
            { "--" *
              t #2 global.max$ substring$ 't :=
            }
            {   { t #1 #1 substring$ "-" = }
                { "-" *
                  t #2 global.max$ substring$ 't :=
                }
              while$
            }
          if$
        }
        { t #1 #1 substring$ *
          t #2 global.max$ substring$ 't :=
        }
      if$
    }
  while$
}

(And we fixed the lookup)

koppor avatar May 19 '24 21:05 koppor

Storing in the prefs now works as well

Siedlerchr avatar May 20 '24 09:05 Siedlerchr