Skip to content

Feat: Add definition links for TeX Files#14260

Merged
koppor merged 9 commits into
JabRef:mainfrom
palukku:add-tex-definiton
Nov 9, 2025
Merged

Feat: Add definition links for TeX Files#14260
koppor merged 9 commits into
JabRef:mainfrom
palukku:add-tex-definiton

Conversation

@palukku

@palukku palukku commented Nov 9, 2025

Copy link
Copy Markdown
Member

Closes palukku#53

Added ctrl + click and ctrl + hover for .tex files.

image image

Steps to test

Start the jabls server and after that checkout the last version of https://github.com/JabRef/lsp-vscode-extension and start it.

After that you should see that after opening your bibfile you can ctrl + click or hover to go to/see the definition.

Mandatory checks

  • I own the copyright of the code submitted and I license it under the MIT license
  • [/] I manually tested my changes in running JabRef (always required)
  • I added JUnit tests for changes (if applicable)
  • I added screenshots in the PR description (if change is visible to the user)
  • [/] I described the change in CHANGELOG.md in a way that is understandable for the average user (if change is visible to the user)
  • [/] I checked the user 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 updating file(s) in https://github.com/JabRef/user-documentation/tree/main/en.

@palukku palukku changed the title Add tex definiton Feat: Add definition links for TeX Files Nov 9, 2025
Comment on lines -58 to +65
Arguments.of(UNRESOLVED, "\\cite[pre][post]{UnresolvedKey}"),
Arguments.of(UNRESOLVED, "\\cite*{UnresolvedKey}"),
Arguments.of(UNRESOLVED, "\\parencite[post]{UnresolvedKey}"),
Arguments.of(EINSTEIN_C, "\\citep{Einstein1920c}"),
Arguments.of(EINSTEIN_C, "\\autocite{Einstein1920c}"),
Arguments.of(EINSTEIN_C, "\\Autocite{Einstein1920c}"),
Arguments.of(DARWIN, "\\blockcquote[p. 28]{Darwin1888}{some text}"),
Arguments.of(DARWIN, "\\textcquote[p. 18]{Darwin1888}{blablabla}")
Arguments.of(UNRESOLVED, 17, 30, "\\cite[pre][post]{UnresolvedKey}"),
Arguments.of(UNRESOLVED, 7, 20, "\\cite*{UnresolvedKey}"),
Arguments.of(UNRESOLVED, 17, 30, "\\parencite[post]{UnresolvedKey}"),
Arguments.of(EINSTEIN_C, 7, 20, "\\citep{Einstein1920c}"),
Arguments.of(EINSTEIN_C, 10, 23, "\\autocite{Einstein1920c}"),
Arguments.of(EINSTEIN_C, 10, 23, "\\Autocite{Einstein1920c}"),
Arguments.of(DARWIN, 20, 30, "\\blockcquote[p. 28]{Darwin1888}{some text}"),
Arguments.of(DARWIN, 19, 29, "\\textcquote[p. 18]{Darwin1888}{blablabla}")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Future work: rewrite to CsvSource

Path path = Path.of("");
LatexParserResult latexParserResult = new LatexParserResult(path);
matchCitation(path, 1, citeString, latexParserResult);
String[] citeStrings = citeString.split(System.lineSeparator());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment would be nice why this is necessary. I would have assumed that the code also can cover multiline \cite statements

@palukku palukku Nov 9, 2025

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm never thought of multiline citation, but this would neither work for both methods because \n is not included in the pattern as far as i understand and for the second method the parsing is done line by line.
Maybe futurework to make this better?

@koppor koppor left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to move fast here...

@koppor koppor added this pull request to the merge queue Nov 9, 2025
github-merge-queue Bot pushed a commit that referenced this pull request Nov 9, 2025
* add support for latex citation definitions and refactor citation handling logic

* enhance LSP range utility and modularize definition handling functions

* improve citation and range handling across parser and definition providers

* fix formatting

* fix jbang

* update associated tests

* update associated tests2

---------

Co-authored-by: Oliver Kopp <kopp.dev@gmail.com>
Merged via the queue into JabRef:main with commit ea18473 Nov 9, 2025
51 of 56 checks passed
@koppor koppor deleted the add-tex-definiton branch November 9, 2025 23:48
@palukku palukku restored the add-tex-definiton branch November 10, 2025 02:25
@palukku palukku mentioned this pull request Nov 10, 2025
1 task
Siedlerchr added a commit that referenced this pull request Nov 10, 2025
* main:
  Fix calling JBang command (#14282)
  .jbang scripts should not be included inside themselves (#14278)
  Fix typos (#14277)
  Refactor importDatabase for better readability (#14274)
  fix jbang (#14276)
  Feat: Add definition links for TeX Files (#14260)
  Update preventing module commits (#14273)
  Fix JabKitLuancher
  Rename packages in jabkit to start with org.jabref.toolkit to avoid split packages between jabkit and jabgui (#14052). (#14271)
  Add doi-to-bibtex to examples and JabKit (#14244)
merlinymy pushed a commit to merlinymy/jabref that referenced this pull request Nov 19, 2025
* add support for latex citation definitions and refactor citation handling logic

* enhance LSP range utility and modularize definition handling functions

* improve citation and range handling across parser and definition providers

* fix formatting

* fix jbang

* update associated tests

* update associated tests2

---------

Co-authored-by: Oliver Kopp <kopp.dev@gmail.com>
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.

in .tex files

2 participants