Skip to content

Commit

Permalink
Fix square brackets in bib items while using bibunits (Fix #630)
Browse files Browse the repository at this point in the history
  • Loading branch information
zepinglee committed Apr 3, 2021
1 parent da50d0f commit 634d912
Show file tree
Hide file tree
Showing 13 changed files with 127 additions and 196 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
- 修正图表等浮动体与文字之间的距离(#614#617)。
- 修正表格、算法等浮动体的行距(#619)。
- 修正了上标式引用后与中文之间多余的空格(#624)。
- 修正了参考文献的姓名或年份中含有中括号时的引用错误(#630)。

## [v7.2.1] - 2021-03-21
### Added
Expand Down
1 change: 0 additions & 1 deletion ref/refs.bib
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,6 @@ @online{xiaoyu2001chubanye
@online{oclc2000about,
author = {{Online Computer Library Center, Inc}},
title = {About {OCLC}: History of Cooperation},
year = {2000},
urldate = {2000-01-08},
url = {http://www.oclc.org/about/cooperation.en.htm},
}
Expand Down
17 changes: 5 additions & 12 deletions testfiles/10-biblatex/10-biblatex-bachelor.tlg
Original file line number Diff line number Diff line change
Expand Up @@ -6436,7 +6436,7 @@ Completed box being shipped out [3]
...\glue 3.01125 plus 3.01125 minus 3.01125
...\glue(\parskip) 0.0
...\glue(\baselineskip) 8.23071
...\hbox(7.59741+2.29756)x398.33861, glue set 0.59871, shifted 28.45274
...\hbox(7.59741+2.29756)x398.33861, glue set 0.06696, shifted 28.45274
....\hbox(7.20892+1.64412)x0.0
.....\glue 0.0
.....\glue -25.6073
Expand Down Expand Up @@ -6517,23 +6517,16 @@ Completed box being shipped out [3]
....\kern -0.0002
....\kern 0.0002
....\glue 2.63484 plus 1.32532 minus 0.87303
....\TU/texgyretermes(0)/m/n/10.53937 2012
....\kern -0.0002
....\kern 0.0
....\glue(\rightskip) 0.0
...\penalty 25000
...\glue(\baselineskip) 6.56404
...\hbox(7.1984+2.29758)x398.33861, glue set 135.76099fil, shifted 28.45274
....\TU/texgyretermes(0)/m/n/10.53937 [2012
....\kern -0.0002
....\kern 0.0002
....\penalty 10000
....\TU/texgyretermes(0)/m/n/10.53937 -
....\discretionary
....\kern -0.00024
....\kern 0.00024
....\penalty 10000
....\glue 0.0
....\glue(\rightskip) 0.0
...\penalty 25100
...\glue(\baselineskip) 6.56404
...\hbox(7.1984+2.29758)x398.33861, glue set 163.85895fil, shifted 28.45274
....\TU/texgyretermes(0)/m/n/10.53937 03
....\kern -0.0002
....\kern 0.0002
Expand Down
17 changes: 5 additions & 12 deletions testfiles/10-biblatex/10-biblatex-inline.tlg
Original file line number Diff line number Diff line change
Expand Up @@ -5692,7 +5692,7 @@ Completed box being shipped out [3]
...\glue 3.01125 plus 3.01125 minus 3.01125
...\glue(\parskip) 0.0
...\glue(\baselineskip) 8.23071
...\hbox(7.59741+2.29756)x398.33861, glue set 0.59871, shifted 28.45274
...\hbox(7.59741+2.29756)x398.33861, glue set 0.06696, shifted 28.45274
....\hbox(7.12462+1.64412)x0.0
.....\glue 0.0
.....\glue -25.6073
Expand Down Expand Up @@ -5773,23 +5773,16 @@ Completed box being shipped out [3]
....\kern -0.0002
....\kern 0.0002
....\glue 2.63484 plus 1.32532 minus 0.87303
....\TU/texgyretermes(0)/m/n/10.53937 2000
....\kern -0.0002
....\kern 0.0
....\glue(\rightskip) 0.0
...\penalty 25000
...\glue(\baselineskip) 6.56404
...\hbox(7.1984+2.29758)x398.33861, glue set 138.69093fil, shifted 28.45274
....\TU/texgyretermes(0)/m/n/10.53937 [2000
....\kern -0.0002
....\kern 0.0002
....\penalty 10000
....\TU/texgyretermes(0)/m/n/10.53937 -
....\discretionary
....\kern -0.00024
....\kern 0.00024
....\penalty 10000
....\glue 0.0
....\glue(\rightskip) 0.0
...\penalty 25100
...\glue(\baselineskip) 6.56404
...\hbox(7.1984+2.29758)x398.33861, glue set 166.7889fil, shifted 28.45274
....\TU/texgyretermes(0)/m/n/10.53937 01
....\kern -0.0002
....\kern 0.0002
Expand Down
17 changes: 5 additions & 12 deletions testfiles/10-biblatex/10-biblatex-numeric.tlg
Original file line number Diff line number Diff line change
Expand Up @@ -5897,7 +5897,7 @@ Completed box being shipped out [3]
...\glue 3.01125 plus 3.01125 minus 3.01125
...\glue(\parskip) 0.0
...\glue(\baselineskip) 8.23071
...\hbox(7.59741+2.29756)x398.33861, glue set 0.59871, shifted 28.45274
...\hbox(7.59741+2.29756)x398.33861, glue set 0.06696, shifted 28.45274
....\hbox(7.12462+1.64412)x0.0
.....\glue 0.0
.....\glue -25.6073
Expand Down Expand Up @@ -5978,23 +5978,16 @@ Completed box being shipped out [3]
....\kern -0.0002
....\kern 0.0002
....\glue 2.63484 plus 1.32532 minus 0.87303
....\TU/texgyretermes(0)/m/n/10.53937 2000
....\kern -0.0002
....\kern 0.0
....\glue(\rightskip) 0.0
...\penalty 25000
...\glue(\baselineskip) 6.56404
...\hbox(7.1984+2.29758)x398.33861, glue set 138.69093fil, shifted 28.45274
....\TU/texgyretermes(0)/m/n/10.53937 [2000
....\kern -0.0002
....\kern 0.0002
....\penalty 10000
....\TU/texgyretermes(0)/m/n/10.53937 -
....\discretionary
....\kern -0.00024
....\kern 0.00024
....\penalty 10000
....\glue 0.0
....\glue(\rightskip) 0.0
...\penalty 25100
...\glue(\baselineskip) 6.56404
...\hbox(7.1984+2.29758)x398.33861, glue set 166.7889fil, shifted 28.45274
....\TU/texgyretermes(0)/m/n/10.53937 01
....\kern -0.0002
....\kern 0.0002
Expand Down
13 changes: 6 additions & 7 deletions testfiles/10-bibtex/10-bibtex-bachelor.tlg
Original file line number Diff line number Diff line change
Expand Up @@ -5242,7 +5242,7 @@ Completed box being shipped out [3]
...\glue 3.01125 plus 3.01125 minus 3.01125
...\glue(\parskip) 0.0
...\glue(\baselineskip) 8.6192
...\hbox(7.20892+2.29756)x398.33861, glue set 0.58844, shifted 28.45274
...\hbox(7.20892+2.29756)x398.33861, glue set 0.24536, shifted 28.45274
....\hbox(7.20892+1.64412)x0.0
.....\glue 0.0
.....\glue -25.6073
Expand Down Expand Up @@ -5310,15 +5310,14 @@ Completed box being shipped out [3]
....\kern 0.00021
....\glue 2.63484 plus 1.31741 minus 0.87828
....\glue 1.15933 plus 3.478 minus 0.73782
....\TU/texgyretermes(0)/m/n/10.53937 2012
....\kern -0.0002
....\kern 0.0002
....\penalty 0
....\TU/texgyretermes(0)/m/n/10.53937 [2012-
....\discretionary
....\glue(\rightskip) 0.0
...\penalty 15150
...\penalty 15250
...\glue(\baselineskip) 6.56404
...\hbox(7.1984+2.29758)x398.33861, glue set 134.60147fil, shifted 28.45274
....\TU/texgyretermes(0)/m/n/10.53937 [....-..-..].
...\hbox(7.1984+2.29758)x398.33861, glue set 162.69942fil, shifted 28.45274
....\TU/texgyretermes(0)/m/n/10.53937 03-27].
....\kern -0.00021
....\kern 0.00021
....\glue 2.63484 plus 1.31741 minus 0.87828
Expand Down
13 changes: 6 additions & 7 deletions testfiles/10-bibtex/10-bibtex-inline.tlg
Original file line number Diff line number Diff line change
Expand Up @@ -4840,7 +4840,7 @@ Completed box being shipped out [3]
...\glue 3.01125 plus 3.01125 minus 3.01125
...\glue(\parskip) 0.0
...\glue(\baselineskip) 8.62973
...\hbox(7.1984+2.29756)x398.33861, glue set 0.58844, shifted 28.45274
...\hbox(7.1984+2.29756)x398.33861, glue set 0.24536, shifted 28.45274
....\hbox(7.12462+1.64412)x0.0
.....\glue 0.0
.....\glue -25.6073
Expand Down Expand Up @@ -4908,15 +4908,14 @@ Completed box being shipped out [3]
....\kern 0.00021
....\glue 2.63484 plus 1.31741 minus 0.87828
....\glue 1.15933 plus 3.478 minus 0.73782
....\TU/texgyretermes(0)/m/n/10.53937 2000
....\kern -0.0002
....\kern 0.0002
....\penalty 0
....\TU/texgyretermes(0)/m/n/10.53937 [2000-
....\discretionary
....\glue(\rightskip) 0.0
...\penalty 15150
...\penalty 15250
...\glue(\baselineskip) 6.56404
...\hbox(7.1984+2.29758)x398.33861, glue set 137.53142fil, shifted 28.45274
....\TU/texgyretermes(0)/m/n/10.53937 [....-..-..].
...\hbox(7.1984+2.29758)x398.33861, glue set 165.62936fil, shifted 28.45274
....\TU/texgyretermes(0)/m/n/10.53937 01-08].
....\kern -0.00021
....\kern 0.00021
....\glue 2.63484 plus 1.31741 minus 0.87828
Expand Down
13 changes: 6 additions & 7 deletions testfiles/10-bibtex/10-bibtex-numeric.tlg
Original file line number Diff line number Diff line change
Expand Up @@ -4912,7 +4912,7 @@ Completed box being shipped out [3]
...\glue 3.01125 plus 3.01125 minus 3.01125
...\glue(\parskip) 0.0
...\glue(\baselineskip) 8.62973
...\hbox(7.1984+2.29756)x398.33861, glue set 0.58844, shifted 28.45274
...\hbox(7.1984+2.29756)x398.33861, glue set 0.24536, shifted 28.45274
....\hbox(7.12462+1.64412)x0.0
.....\glue 0.0
.....\glue -25.6073
Expand Down Expand Up @@ -4980,15 +4980,14 @@ Completed box being shipped out [3]
....\kern 0.00021
....\glue 2.63484 plus 1.31741 minus 0.87828
....\glue 1.15933 plus 3.478 minus 0.73782
....\TU/texgyretermes(0)/m/n/10.53937 2000
....\kern -0.0002
....\kern 0.0002
....\penalty 0
....\TU/texgyretermes(0)/m/n/10.53937 [2000-
....\discretionary
....\glue(\rightskip) 0.0
...\penalty 15150
...\penalty 15250
...\glue(\baselineskip) 6.56404
...\hbox(7.1984+2.29758)x398.33861, glue set 137.53142fil, shifted 28.45274
....\TU/texgyretermes(0)/m/n/10.53937 [....-..-..].
...\hbox(7.1984+2.29758)x398.33861, glue set 165.62936fil, shifted 28.45274
....\TU/texgyretermes(0)/m/n/10.53937 01-08].
....\kern -0.00021
....\kern 0.00021
....\glue 2.63484 plus 1.31741 minus 0.87828
Expand Down
4 changes: 0 additions & 4 deletions testfiles/support/refs-bachelor.bib
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@ @newspaper{dingwenxiang2000shuzi
author = {丁文详},
title = {数字革命与竞争国际化},
journal = {中国青年报},
year = {2000},
date = {2000-11-20},
number = {15},
}
Expand All @@ -234,7 +233,6 @@ @newspaper{liuyuguo2013wumai
author = {刘裕国 and 杨柳 and 张洋 and others},
title = {雾霾来袭, 如何突围},
journal = {人民日报},
year = {2013},
date = {2013-01-12},
urldate = {2013-11-06},
url = {http://paper.people.com.cn/rmrb/html/2013-01/12/nw.D110000renmrb_20130112_2-04.htm},
Expand All @@ -243,7 +241,6 @@ @newspaper{liuyuguo2013wumai
@online{liqiang2012huajie,
author = {李强},
title = {化解医患矛盾需釜底抽薪},
year = {2012},
date = {2012-05-03},
urldate = {2013-03-25},
url = {http://wenku.baidu.com/view/47e4f206b52acfc789ebc92f.html},
Expand All @@ -252,7 +249,6 @@ @online{liqiang2012huajie
@online{oclc2012about,
author = {{Online Computer Library Center, Inc}},
title = {About {OCLC}: History of Cooperation},
year = {2012},
urldate = {2012-03-27},
url = {http://www.oclc.org/about/cooperation.en.html},
}
2 changes: 0 additions & 2 deletions testfiles/support/refs-numeric.bib
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,6 @@ @newspaper{fugang2000fengsha
@online{xiaoyu2001chubanye,
author = {萧钰},
title = {出版业信息化迈入快车道},
year = {2001},
date = {2001-12-19},
urldate = {2002-04-15},
url = {http://www.creader.com/news/20011219/200112190019.htm},
Expand All @@ -316,7 +315,6 @@ @online{xiaoyu2001chubanye
@online{oclc2000about,
author = {{Online Computer Library Center, Inc}},
title = {About {OCLC}: History of Cooperation},
year = {2000},
urldate = {2000-01-08},
url = {http://www.oclc.org/about/cooperation.en.htm},
}
Expand Down
75 changes: 31 additions & 44 deletions thuthesis-author-year.bst
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,22 @@ FUNCTION {or}
if$
}

STRINGS { x y }

FUNCTION {contains}
{ 'y :=
'x :=
y text.length$ 'len :=
x text.length$ len - #1 + 'charptr :=
{ charptr #0 >
x charptr len substring$ y = not
and
}
{ charptr #1 - 'charptr := }
while$
charptr #0 >
}

STRINGS { s t }

FUNCTION {output.nonnull}
Expand Down Expand Up @@ -713,17 +729,13 @@ FUNCTION {output.bibitem}
"\bibitem[" write$
label ")" *
make.full.names duplicate$ short.list =
{ pop$ }
{ * }
if$
's :=
s text.length$ 'charptr :=
{ charptr #0 > s charptr #1 substring$ "[" = not and }
{ charptr #1 - 'charptr := }
while$
charptr #0 >
{ "{" s * "}" * }
{ s }
{ pop$ }
{ duplicate$ "]" contains
{ "{" swap$ * "}" * }
'skip$
if$
*
}
if$
"]{" * write$
cite$ write$
Expand Down Expand Up @@ -1186,21 +1198,6 @@ FUNCTION {extract.after.dash}
if$
}

FUNCTION {contains.dash}
{ duplicate$ empty$
{ pop$ #0 }
{ 's :=
{ s empty$ not
s #1 #1 substring$ "-" = not
and
}
{ s #2 global.max$ substring$ 's := }
while$
s empty$ not
}
if$
}

FUNCTION {extract.before.slash}
{ duplicate$ empty$
{ pop$ "" }
Expand Down Expand Up @@ -1245,23 +1242,6 @@ FUNCTION {extract.after.slash}
if$
}

FUNCTION {contains.slash}
{ duplicate$ empty$
{ pop$ #0 }
{ 's :=
{ s empty$ not
s #1 #1 substring$ "-" = not
and
s #1 #1 substring$ "/" = not
and
}
{ s #2 global.max$ substring$ 's := }
while$
s empty$ not
}
if$
}

FUNCTION {format.year}
{ year empty$ not
{ year extract.before.slash extra.label * }
Expand Down Expand Up @@ -2222,14 +2202,21 @@ FUNCTION {calc.short.authors}

FUNCTION {calc.label}
{ calc.short.authors
short.list
short.list "]" contains
{ "{" short.list * "}" * }
{ short.list }
if$
"("
*
format.year duplicate$ empty$
short.list key field.or.null = or
{ pop$ "" }
'skip$
if$
duplicate$ "]" contains
{ "{" swap$ * "}" * }
'skip$
if$
*
'label :=
short.label
Expand Down
Loading

0 comments on commit 634d912

Please sign in to comment.