@@ -27,12 +27,12 @@ class DefaultTexParserTest {
2727 private final static String UNRESOLVED = "UnresolvedKey" ;
2828 private final static String UNKNOWN = "UnknownKey" ;
2929
30- private void testMatchCite (String key , String citeString ) {
30+ private void testMatchCite (String key , int expectedStart , int expectedEnd , String citeString ) {
3131 Path path = Path .of ("" );
3232 LatexParserResult latexParserResult = new DefaultLatexParser ().parse (citeString );
3333 LatexParserResult expectedParserResult = new LatexParserResult (path );
3434
35- expectedParserResult .addKey (key , path , 1 , 0 , citeString . length () , citeString );
35+ expectedParserResult .addKey (key , path , 1 , expectedStart , expectedEnd , citeString );
3636
3737 assertEquals (expectedParserResult , latexParserResult );
3838 }
@@ -55,21 +55,21 @@ void nonMatchCite(String citeString) {
5555
5656 private static Stream <Arguments > matchCiteCommandsProvider () {
5757 return Stream .of (
58- Arguments .of (UNRESOLVED , "\\ cite[pre][post]{UnresolvedKey}" ),
59- Arguments .of (UNRESOLVED , "\\ cite*{UnresolvedKey}" ),
60- Arguments .of (UNRESOLVED , "\\ parencite[post]{UnresolvedKey}" ),
61- Arguments .of (EINSTEIN_C , "\\ citep{Einstein1920c}" ),
62- Arguments .of (EINSTEIN_C , "\\ autocite{Einstein1920c}" ),
63- Arguments .of (EINSTEIN_C , "\\ Autocite{Einstein1920c}" ),
64- Arguments .of (DARWIN , "\\ blockcquote[p. 28]{Darwin1888}{some text}" ),
65- Arguments .of (DARWIN , "\\ textcquote[p. 18]{Darwin1888}{blablabla}" )
58+ Arguments .of (UNRESOLVED , 17 , 30 , "\\ cite[pre][post]{UnresolvedKey}" ),
59+ Arguments .of (UNRESOLVED , 7 , 20 , "\\ cite*{UnresolvedKey}" ),
60+ Arguments .of (UNRESOLVED , 17 , 30 , "\\ parencite[post]{UnresolvedKey}" ),
61+ Arguments .of (EINSTEIN_C , 7 , 20 , "\\ citep{Einstein1920c}" ),
62+ Arguments .of (EINSTEIN_C , 10 , 23 , "\\ autocite{Einstein1920c}" ),
63+ Arguments .of (EINSTEIN_C , 10 , 23 , "\\ Autocite{Einstein1920c}" ),
64+ Arguments .of (DARWIN , 20 , 30 , "\\ blockcquote[p. 28]{Darwin1888}{some text}" ),
65+ Arguments .of (DARWIN , 19 , 29 , "\\ textcquote[p. 18]{Darwin1888}{blablabla}" )
6666 );
6767 }
6868
6969 @ ParameterizedTest
7070 @ MethodSource ("matchCiteCommandsProvider" )
71- void matchCiteCommands (String expectedKey , String citeString ) {
72- testMatchCite (expectedKey , citeString );
71+ void matchCiteCommands (String expectedKey , int expectedStart , int expectedEnd , String citeString ) {
72+ testMatchCite (expectedKey , expectedStart , expectedEnd , citeString );
7373 }
7474
7575 @ Test
@@ -80,8 +80,8 @@ void twoCitationsSameLine() {
8080 LatexParserResult latexParserResult = new DefaultLatexParser ().parse (citeString );
8181 LatexParserResult expectedParserResult = new LatexParserResult (path );
8282
83- expectedParserResult .addKey (EINSTEIN_C , path , 1 , 0 , 21 , citeString );
84- expectedParserResult .addKey (EINSTEIN_A , path , 1 , 26 , 47 , citeString );
83+ expectedParserResult .addKey (EINSTEIN_C , path , 1 , 7 , 20 , citeString );
84+ expectedParserResult .addKey (EINSTEIN_A , path , 1 , 33 , 46 , citeString );
8585
8686 assertEquals (expectedParserResult , latexParserResult );
8787 }
@@ -93,7 +93,7 @@ void fileEncodingUtf8() throws URISyntaxException {
9393 LatexParserResult parserResult = new DefaultLatexParser ().parse (texFile ).get ();
9494 LatexParserResult expectedParserResult = new LatexParserResult (texFile );
9595
96- expectedParserResult .addKey ("anykey" , texFile , 1 , 32 , 45 ,
96+ expectedParserResult .addKey ("anykey" , texFile , 1 , 38 , 44 ,
9797 "Danach wir anschließend mittels \\ cite{anykey}." );
9898
9999 assertEquals (expectedParserResult , parserResult );
@@ -107,7 +107,7 @@ void fileEncodingIso88591() throws URISyntaxException {
107107 LatexParserResult expectedParserResult = new LatexParserResult (texFile );
108108
109109 // The character � is on purpose - we cannot use Apache Tika's CharsetDetector - see ADR-0005
110- expectedParserResult .addKey ("anykey" , texFile , 1 , 32 , 45 ,
110+ expectedParserResult .addKey ("anykey" , texFile , 1 , 38 , 44 ,
111111 "Danach wir anschlie�end mittels \\ cite{anykey}." );
112112
113113 assertEquals (expectedParserResult , parserResult );
@@ -121,7 +121,7 @@ void fileEncodingIso885915() throws URISyntaxException {
121121 LatexParserResult expectedParserResult = new LatexParserResult (texFile );
122122
123123 // The character � is on purpose - we cannot use Apache Tika's CharsetDetector - see ADR-0005
124- expectedParserResult .addKey ("anykey" , texFile , 1 , 32 , 45 ,
124+ expectedParserResult .addKey ("anykey" , texFile , 1 , 38 , 44 ,
125125 "Danach wir anschlie�end mittels \\ cite{anykey}." );
126126
127127 assertEquals (expectedParserResult , parserResult );
@@ -137,12 +137,12 @@ void fileEncodingForThreeFiles() throws URISyntaxException {
137137 List .of (texFile , texFile2 , texFile3 ));
138138
139139 LatexParserResult result1 = new LatexParserResult (texFile );
140- result1 .addKey ("anykey" , texFile , 1 , 32 , 45 , "Danach wir anschließend mittels \\ cite{anykey}." );
140+ result1 .addKey ("anykey" , texFile , 1 , 38 , 44 , "Danach wir anschließend mittels \\ cite{anykey}." );
141141 LatexParserResult result2 = new LatexParserResult (texFile2 );
142- result2 .addKey ("anykey" , texFile2 , 1 , 32 , 45 ,
142+ result2 .addKey ("anykey" , texFile2 , 1 , 38 , 44 ,
143143 "Danach wir anschlie�end mittels \\ cite{anykey}." );
144144 LatexParserResult result3 = new LatexParserResult (texFile3 );
145- result3 .addKey ("anykey" , texFile3 , 1 , 32 , 45 ,
145+ result3 .addKey ("anykey" , texFile3 , 1 , 38 , 44 ,
146146 "Danach wir anschlie�end mittels \\ cite{anykey}." );
147147
148148 LatexParserResults expectedParserResults = new LatexParserResults (result1 , result2 , result3 );
@@ -158,11 +158,11 @@ void singleFile() throws URISyntaxException {
158158 LatexParserResult expectedParserResult = new LatexParserResult (texFile );
159159
160160 expectedParserResult .addBibFile (texFile .getParent ().resolve ("origin.bib" ));
161- expectedParserResult .addKey (EINSTEIN , texFile , 4 , 0 , 19 , "\\ cite{Einstein1920}" );
162- expectedParserResult .addKey (DARWIN , texFile , 5 , 0 , 17 , "\\ cite{Darwin1888}." );
163- expectedParserResult .addKey (EINSTEIN , texFile , 6 , 14 , 33 ,
161+ expectedParserResult .addKey (EINSTEIN , texFile , 4 , 6 , 18 , "\\ cite{Einstein1920}" );
162+ expectedParserResult .addKey (DARWIN , texFile , 5 , 6 , 16 , "\\ cite{Darwin1888}." );
163+ expectedParserResult .addKey (EINSTEIN , texFile , 6 , 20 , 32 ,
164164 "Einstein said \\ cite{Einstein1920} that lorem impsum, consectetur adipiscing elit." );
165- expectedParserResult .addKey (DARWIN , texFile , 7 , 67 , 84 ,
165+ expectedParserResult .addKey (DARWIN , texFile , 7 , 73 , 83 ,
166166 "Nunc ultricies leo nec libero rhoncus, eu vehicula enim efficitur. \\ cite{Darwin1888}" );
167167
168168 assertEquals (expectedParserResult , parserResult );
@@ -177,20 +177,20 @@ void twoFiles() throws URISyntaxException {
177177
178178 LatexParserResult result1 = new LatexParserResult (texFile );
179179 result1 .addBibFile (texFile .getParent ().resolve ("origin.bib" ));
180- result1 .addKey (EINSTEIN , texFile , 4 , 0 , 19 , "\\ cite{Einstein1920}" );
181- result1 .addKey (DARWIN , texFile , 5 , 0 , 17 , "\\ cite{Darwin1888}." );
182- result1 .addKey (EINSTEIN , texFile , 6 , 14 , 33 ,
180+ result1 .addKey (EINSTEIN , texFile , 4 , 6 , 18 , "\\ cite{Einstein1920}" );
181+ result1 .addKey (DARWIN , texFile , 5 , 6 , 16 , "\\ cite{Darwin1888}." );
182+ result1 .addKey (EINSTEIN , texFile , 6 , 20 , 32 ,
183183 "Einstein said \\ cite{Einstein1920} that lorem impsum, consectetur adipiscing elit." );
184- result1 .addKey (DARWIN , texFile , 7 , 67 , 84 ,
184+ result1 .addKey (DARWIN , texFile , 7 , 73 , 83 ,
185185 "Nunc ultricies leo nec libero rhoncus, eu vehicula enim efficitur. \\ cite{Darwin1888}" );
186186
187187 LatexParserResult result2 = new LatexParserResult (texFile2 );
188188 result2 .addBibFile (texFile2 .getParent ().resolve ("origin.bib" ));
189- result2 .addKey (DARWIN , texFile2 , 4 , 48 , 65 ,
189+ result2 .addKey (DARWIN , texFile2 , 4 , 54 , 64 ,
190190 "This is some content trying to cite a bib file: \\ cite{Darwin1888}" );
191- result2 .addKey (EINSTEIN , texFile2 , 5 , 48 , 67 ,
191+ result2 .addKey (EINSTEIN , texFile2 , 5 , 54 , 66 ,
192192 "This is some content trying to cite a bib file: \\ cite{Einstein1920}" );
193- result2 .addKey (NEWTON , texFile2 , 6 , 48 , 65 ,
193+ result2 .addKey (NEWTON , texFile2 , 6 , 54 , 64 ,
194194 "This is some content trying to cite a bib file: \\ cite{Newton1999}" );
195195
196196 LatexParserResults expectedParserResults = new LatexParserResults (result1 , result2 );
@@ -207,11 +207,11 @@ void duplicateFiles() throws URISyntaxException {
207207 LatexParserResult result = new LatexParserResult (texFile );
208208
209209 result .addBibFile (texFile .getParent ().resolve ("origin.bib" ));
210- result .addKey (EINSTEIN , texFile , 4 , 0 , 19 , "\\ cite{Einstein1920}" );
211- result .addKey (DARWIN , texFile , 5 , 0 , 17 , "\\ cite{Darwin1888}." );
212- result .addKey (EINSTEIN , texFile , 6 , 14 , 33 ,
210+ result .addKey (EINSTEIN , texFile , 4 , 6 , 18 , "\\ cite{Einstein1920}" );
211+ result .addKey (DARWIN , texFile , 5 , 6 , 16 , "\\ cite{Darwin1888}." );
212+ result .addKey (EINSTEIN , texFile , 6 , 20 , 32 ,
213213 "Einstein said \\ cite{Einstein1920} that lorem impsum, consectetur adipiscing elit." );
214- result .addKey (DARWIN , texFile , 7 , 67 , 84 ,
214+ result .addKey (DARWIN , texFile , 7 , 73 , 83 ,
215215 "Nunc ultricies leo nec libero rhoncus, eu vehicula enim efficitur. \\ cite{Darwin1888}" );
216216
217217 LatexParserResults expectedParserResults = new LatexParserResults (result , result );
@@ -227,11 +227,11 @@ void unknownKey() throws URISyntaxException {
227227 LatexParserResult expectedParserResult = new LatexParserResult (texFile );
228228
229229 expectedParserResult .addBibFile (texFile .getParent ().resolve ("origin.bib" ));
230- expectedParserResult .addKey (DARWIN , texFile , 4 , 48 , 65 ,
230+ expectedParserResult .addKey (DARWIN , texFile , 4 , 54 , 64 ,
231231 "This is some content trying to cite a bib file: \\ cite{Darwin1888}" );
232- expectedParserResult .addKey (EINSTEIN , texFile , 5 , 48 , 67 ,
232+ expectedParserResult .addKey (EINSTEIN , texFile , 5 , 54 , 66 ,
233233 "This is some content trying to cite a bib file: \\ cite{Einstein1920}" );
234- expectedParserResult .addKey (UNKNOWN , texFile , 6 , 48 , 65 ,
234+ expectedParserResult .addKey (UNKNOWN , texFile , 6 , 54 , 64 ,
235235 "This is some content trying to cite a bib file: \\ cite{UnknownKey}" );
236236
237237 assertEquals (expectedParserResult , parserResult );
0 commit comments