Skip to content

Commit

Permalink
Fix missing year when only date is presented in article (#299)
Browse files Browse the repository at this point in the history
  • Loading branch information
zepinglee committed May 8, 2021
1 parent b772e30 commit a41f686
Show file tree
Hide file tree
Showing 4 changed files with 136 additions and 159 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 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- 修正了与 `chapterbib` 宏包的兼容性。
- 去掉 `notoccite` 宏包,防止造成 PDF 书签中页码的错误(#293)。
- 修正了表题的字体(#295)。
- 修正了 `article` 只有 `date` 时年份缺失的问题(#299)。

## [v3.3.0] - 2021-03-18

Expand Down
98 changes: 45 additions & 53 deletions ustcthesis-authoryear.bst
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@
%%
%% The original source files were:
%%
%% gbt7714.dtx (with options: `ustc,2015,authoryear')
%% gbt7714.dtx (with options: `2015,ustc,authoryear')
%% -------------------------------------------------------------------
%% GB/T 7714—2015 BibTeX Style
%% https://github.com/CTeX-org/gbt7714-bibtex-style
%% Version: 2020/12/17 v2.1
%% Version: 2021/04/03 v2.1.1
%% -------------------------------------------------------------------
%% Copyright (C) 2016-2021 by Zeping Lee <zepinglee AT gmail.com>
%% Copyright (C) 20162021 by Zeping Lee <zepinglee AT gmail.com>
%% -------------------------------------------------------------------
%% This file may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3c
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%% https://www.latex-project.org/lppl.txt
%% and version 1.3c or later is part of all distributions of LaTeX
%% version 2005/12/01 or later.
%% version 2008 or later.
%% -------------------------------------------------------------------
INTEGERS {
citation.et.al.min
Expand Down 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 @@ -1302,11 +1282,16 @@ FUNCTION {format.periodical.year}
}

FUNCTION {format.date}
{ type$ "patent" = type$ "newspaper" = or
date empty$ not and
{ date }
{ year field.or.null
extra.label *
{ date empty$ not
{ type$ "patent" = type$ "newspaper" = or
{ date }
{ format.year }
if$
}
{ year empty$ not
{ format.year }
{ "" }
if$
}
if$
}
Expand Down Expand Up @@ -2222,14 +2207,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
98 changes: 45 additions & 53 deletions ustcthesis-bachelor.bst
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@
%%
%% The original source files were:
%%
%% gbt7714.dtx (with options: `ustc,2015,numerical,nouppercase,nomark,italicjournal')
%% gbt7714.dtx (with options: `2015,ustc,numerical,nouppercase,nomark,italicjournal')
%% -------------------------------------------------------------------
%% GB/T 7714—2015 BibTeX Style
%% https://github.com/CTeX-org/gbt7714-bibtex-style
%% Version: 2020/12/17 v2.1
%% Version: 2021/04/03 v2.1.1
%% -------------------------------------------------------------------
%% Copyright (C) 2016-2021 by Zeping Lee <zepinglee AT gmail.com>
%% Copyright (C) 20162021 by Zeping Lee <zepinglee AT gmail.com>
%% -------------------------------------------------------------------
%% This file may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3c
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%% https://www.latex-project.org/lppl.txt
%% and version 1.3c or later is part of all distributions of LaTeX
%% version 2005/12/01 or later.
%% version 2008 or later.
%% -------------------------------------------------------------------
INTEGERS {
citation.et.al.min
Expand Down Expand Up @@ -240,6 +240,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 @@ -703,17 +719,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 @@ -1176,21 +1188,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 @@ -1235,23 +1232,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 @@ -1292,11 +1272,16 @@ FUNCTION {format.periodical.year}
}

FUNCTION {format.date}
{ type$ "patent" = type$ "newspaper" = or
date empty$ not and
{ date }
{ year field.or.null
extra.label *
{ date empty$ not
{ type$ "patent" = type$ "newspaper" = or
{ date }
{ format.year }
if$
}
{ year empty$ not
{ format.year }
{ "" }
if$
}
if$
}
Expand Down Expand Up @@ -2212,14 +2197,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 a41f686

Please sign in to comment.