summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/biblatex-iso690/iso.bbx
blob: ce2668f718b704577328d5190633452f89189e22 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
\ProvidesFile{iso.bbx}
  [2020/03/25 v0.4.0 ISO 690 biblatex bibliography style]

% Currently available language mappings:
% Czech, English, Slovak, German, Polish, Bulgarian,
% French
\DeclareLanguageMappingSuffix{-iso}
% Currently needed the following additional language strings:
\NewBibliographyString{at,bysupervisor,urlalso,
  director,bydirector,inventor,byinventor,online,film}

% PACKAGE OPTIONS

% Define new package options
% These toggle names are internal
\newtoggle{bbx:spcolon}
\newtoggle{bbx:totalpages}
\newtoggle{bbx:shortnum}
\newtoggle{bbx:thesisinfoinnotes}
\newtoggle{bbx:url}
\newtoggle{bbx:isbn}
\newtoggle{bbx:doi}
\newtoggle{bbx:eprint}
\newtoggle{bbx:articlepubinfo}

% Print info about package options into .log file
\protected\def\isoblx@info@noline#1{%
  \PackageInfo{biblatex-iso690}{#1\@gobble}}
\let\isoblx@info\isoblx@info@noline
\AtEndOfPackage{%
  \protected\def\isoblx@info#1{%
    \PackageInfo{biblatex-iso690}{#1}}}

% Declare new package options
% Description of these options is in the doc file
% '\isoblx@info@noline' command prints to the .log file
\DeclareBibliographyOption{spacecolon}[true]{%
  \settoggle{bbx:spcolon}{#1}%
  \isoblx@info@noline{Space colon enabled: #1}}

\DeclareBibliographyOption{pagetotal}[true]{%
  \settoggle{bbx:totalpages}{#1}%
  \isoblx@info@noline{Total pages enabled: #1}}

\DeclareBibliographyOption{shortnumeration}[true]{%
  \settoggle{bbx:shortnum}{#1}%
  \isoblx@info@noline{Short numeration enabled: #1}}

\DeclareBibliographyOption{thesisinfoinnotes}[true]{%
  \settoggle{bbx:thesisinfoinnotes}{#1}%
  \isoblx@info@noline{Printing thesis info at the end enabled: #1}}

\DeclareBibliographyOption{url}[true]{%
  \settoggle{bbx:url}{#1}%
  \isoblx@info@noline{URL field enabled: #1}}

\DeclareBibliographyOption{isbn}[true]{%
  \settoggle{bbx:isbn}{#1}%
  \isoblx@info@noline{ISBN field enabled: #1}}

\DeclareBibliographyOption{doi}[true]{%
  \settoggle{bbx:doi}{#1}%
  \isoblx@info@noline{DOI field enabled: #1}}

\DeclareBibliographyOption{eprint}[true]{%
  \settoggle{bbx:eprint}{#1}%
  \isoblx@info@noline{eprint field enabled: #1}}

\DeclareBibliographyOption{articlepubinfo}[true]{%
  \settoggle{bbx:articlepubinfo}{#1}%
  \isoblx@info@noline{Article publication info enabled: #1}}

% Set default package options
\ExecuteBibliographyOptions{%
  spacecolon=false,
  pagetotal=false,
  shortnumeration=false,
  thesisinfoinnotes=true,
  url=true,
  isbn=true,
  doi=true,
  eprint=true,
  articlepubinfo=false, % Printing article publication info is unusual
  maxnames=99,% If possible, all creators should be given in the reference
  minnames=1,% If any names are omitted => first creator + and others (et al.)
  citetracker=true,% Citation tracker in global mode
  autolang=other,% Use the 'langid' language for the entry
  date=year,% Use only years
  urldate=iso,% Use ISO8601 Extended Format (yyyy-mm-dd) for URL 'seen' dates
  seconds=true,% ISO8601 format requires 'seconds=true'
  datecirca=true,% Use circa for approximate dates
}

% Default definitions of beginning and closing macro
% in bibliography drivers
\newbibmacro*{begentry}{}
\newbibmacro*{finentry}{\finentry}

% COMMANDS

% The separator between 'titles' and 'subtitles'
\renewcommand*{\subtitlepunct}{\addspacecolon\space}

% The separator between more standard identifiers, like ISBNs or ISSNs.
% Default separator is comma and space. You can use something like
% \renewcommand{\stdidentifierspunct}{\addsemicolon\space}
% in the preamble to change the separator
\newcommand{\stdidentifierspunct}{\addcomma\space}

% The separator between date and dateaddon
\newcommand{\dateaddonpunct}{\addspace}

% The separator between 'dates' and the numeration section
\newcommand{\numerationpunct}{\addcomma\space}

% A colon preceded with or without space
\newcommand{\addspacecolon}{%
  \iftoggle{bbx:spcolon}
    {\addnbspace\addspcolon}
    {\unspace\addspcolon}%
}

% Context-sensitive delimiters

% The delimiter between mutliple names
% A semicolon: legacy of older versions of standard / Czech interpretations
\DeclareDelimFormat{multinamedelim}{\addsemicolon\space}

% The delimiter before the final name
% Use consistent name format for all creators
\DeclareDelimAlias{finalnamedelim}{multinamedelim}

% Thanks Moewew for sugesting this. Make uppercase names only in bibliography.
% Default name format is ALL-CAPS
% use something like
% \let\familynameformat=\textsc
% to change this
\newcommand{\familynameformat}[1]{\MakeUppercase{#1}}
\AtBeginBibliography{%
  \renewcommand{\mkbibnamefamily}{\familynameformat}%
}

% Default bibliography environment (layout)
\defbibenvironment{bibliography}
  {\list%
     {}%
     {\setlength{\leftmargin}{\bibhang}%
      \setlength{\itemindent}{-\leftmargin}%
      \setlength{\itemsep}{\bibitemsep}%
      \setlength{\parsep}{\bibparsep}}%
      \renewcommand*{\makelabel}[1]{\hss##1}}%
  {\endlist}%
  {\item}%


% FIELD FORMATS

% Format title and subtitle as is
\DeclareFieldFormat*{title}{#1}
\DeclareFieldFormat*{subtitle}{#1}

% Format volume field with localisation string
\DeclareFieldFormat{volume}{\bibstring{volume}\addnbspace#1}% volume of a book
% Differentiate volume in journal
\DeclareFieldFormat[article,periodical]{volume}{%
  \iftoggle{bbx:shortnum}
    {\mkbibbold{#1}}
    {\bibstring{jourvol}\addnbspace#1}% volume of a journal
}

% Edition field could be:
% a) numeral: use with localisation string
% b) literal: capitalize given string
\DeclareFieldFormat*{edition}{%
  \ifnumeral{#1}%
    {\mkbibordedition{#1}\addnbspace\bibstring{edition}}%
    {\MakeCapital{#1}}%
}%

% Format pagination for page range
% Always use main document language for this field
\DeclareFieldFormat*{pages}{\mkmlpageprefix[bookpagination]{#1}}
% Differentiate page range in journal
\DeclareFieldFormat[article,periodical]{pages}{%
  \iftoggle{bbx:shortnum}
    {#1}
    {\mkmlpageprefix[bookpagination]{#1}}%
}

% Format pagination for total number of pages
% Always use main document language for this field
\DeclareFieldFormat*{pagetotal}{\mkbibbrackets{\mkmlpagetotal[bookpagination]{#1}}}

% Format number field with localisation string
\DeclareFieldFormat*{number}{\bibstring{number}\addspace #1}
% Differentiate number in journal
\DeclareFieldFormat[article,periodical]{number}{%
  \iftoggle{bbx:shortnum}
    {\mkbibparens{#1}}
    {\bibstring{number}\addspace #1}%
}
% Differentiate number for patent and report: format as is
\DeclareFieldFormat[patent,report]{number}{#1}

% a) url AND no urldate: use localisation string 'available ALSO from',
%    meaning: the work is not primarily published electronically
% b) url AND urldate: use localisation string 'available from'
\DeclareFieldFormat*{url}{%
  \iffieldundef{urlyear}
    {\mainlangbibstring{urlalso}}
    {\mainlangbibstring{urlfrom}}%
  \addcolon\space\url{#1}%
}

% Format medium type in square brackets
% If available, use the localisation string for the key
\DeclareFieldFormat{howpublished}{%
  \ifbibstring{#1}
    {\mainlangbibstring[\mkbibbrackets]{#1}}
    {\mkbibbrackets{#1}}%
}

% Format type, e.g. type of thesis
% If available, use the localisation string for the key
\DeclareFieldFormat{type}{%
  \ifbibstring{#1}
    {\mainlangbibstring{#1}}
    {#1}%
}

% Format supervisor of thesis (precedes the name with a localisation string)
\DeclareFieldFormat{supervisor}{%
  \mainlangbibstring{bysupervisor}\addspace#1}

% \mkbibacro typesets acronyms in small caps by default,
% if we want to override this, pass the value as is (uppercase)
% \renewcommand*{\mkbibacro}[1]{#1}
% Applies to DOI, ISBN, ISSN, ISAN, ISMN, ISRN, ISWC

% If we really must handle more than one ISBN and ISSN.
%
% Typically there could be different ISBN / ISSN for printed and electronic
% media versions, but the standard says that the specific copy or instance of
% the document should be cited, so the author should choose the appropriate
% number in the bib file. Otherwise include comma-separated list of numbers in
% the bib field 'isbn' or 'issn'.

% Separator value between more ISBNs / ISSNs is handled by '\stdidentifierspunct'.
% Default format is the name of identifier + space + number:
% e.g. 'ISBN 978-3-642-21665-7'
\DeclareFieldFormat{isbn}{%
  % Execute this rule for the first value of the csv field
  \def\do##1{\mkbibacro{ISBN}\space##1%
    % Execute this rule for the next value(s) of the csv field
    \def\do####1{\stdidentifierspunct\mkbibacro{ISBN}\space####1}}%
  % Process the csv field with \do command
  \docsvfield{isbn}%
}

% The same formatting rules as for ISBN above
\DeclareFieldFormat{issn}{%
  \def\do##1{\mkbibacro{ISSN}\space##1%
    \def\do####1{\stdidentifierspunct\mkbibacro{ISSN}\space####1}}%
  \docsvfield{issn}%
}

% Format other standard identifiers
% Default format is the name of identifier + space + number
\DeclareFieldFormat{isan}{\mkbibacro{ISAN}\addspace#1}
\DeclareFieldFormat{ismn}{\mkbibacro{ISMN}\addspace#1}
\DeclareFieldFormat{isrn}{\mkbibacro{ISRN}\addspace#1}
\DeclareFieldFormat{iswc}{\mkbibacro{ISWC}\addspace#1}

% Format url seen date with preceding localisation string in square brackets
\DeclareFieldFormat{urldate}{\mkbibbrackets{\mainlangbibstring{urlseen}\space#1}}

% Format additional date information as is (use bib file for modifications).
\DeclareFieldFormat{dateaddon}{#1}

% Format circa date with preceding localisation string in square brackets;
% default \datecircaprint is \bibstring{circa}\printdelim{datecircadelim},
% e.g. [ca. 1940].
\DeclareFieldFormat{date}{%
  \ifdatecirca
    {\mkbibbrackets{#1}}%
    {#1}%
}

% Format 'labeldate' the same as 'date' field.
% We use 'labeldate' in 'iso-authoryear' style.
% Format circa date and nodate. Dateaddon and date as is.
\DeclareFieldFormat{labeldate}{%
  \ifdatecirca
    {\mkbibbrackets{#1}}%
    {% Check if there is 'nodate' from 'labeldate'
      \iffieldequalstr{labeldatesource}{nodate}
        % This is a \literal{nodate}, meaning that it uses the 'nodate'
        % localisation string due to default \DeclareLabeldate setting
        {\mkbibbrackets{#1}}%
        {#1}}% This is the go-to format
}

% Define dates to consider for 'labeldate', based on
% the default definition, but without 'urldate' field,
% preventing printing url seen date in place of the year
% of a publication.
\DeclareLabeldate{%
  \field{date}
  \field{year}
  \field{dateaddon}% <---- biblatex-iso690 data model extension
  \field{eventdate}
  \field{origdate}
  \literal{nodate}
}

% Format chapter of book with preceding localisation string
\DeclareFieldFormat{chapter}{\bibstring{chapter}\addnbspace#1\isdot}

% Version field could be:
% a) numeral: use with localisation string
% b) literal: capitalize given string
\DeclareFieldFormat{version}{%
  \ifnumeral{#1}%
    {\bibstring{version}\addnbspace#1}%
    {\MakeCapital{#1}}%
}

% Format library field as is (location information)
\DeclareFieldFormat{library}{#1}

% Format (sub)titles as they are
\DeclareFieldFormat{journaltitle}{#1}
\DeclareFieldFormat{booktitle}{#1}
\DeclareFieldFormat{maintitle}{#1}
\DeclareFieldFormat{issuetitle}{#1}
\DeclareFieldFormat{journalsubtitle}{#1}
\DeclareFieldFormat{booksubtitle}{#1}
\DeclareFieldFormat{mainsubtitle}{#1}
\DeclareFieldFormat{issuesubtitle}{#1}

% Format other / alternative titles in square brackets
\DeclareFieldFormat{titleaddon}{\mkbibbrackets{#1}}
\DeclareFieldAlias{booktitleaddon}{titleaddon}
\DeclareFieldAlias{maintitleaddon}{titleaddon}

% Format additional name information in square brackets
\DeclareFieldFormat{nameaddon}{\mkbibbrackets{#1}}

% NAME ALIAS

% Default name list format is last (family) followed by given (first) name
\DeclareNameAlias{default}{family-given}
% For supervisor, use the reversed order format:
% given (first) name followed by last (family) name,
% so it may sound more naturally in this order
\DeclareNameAlias{supervisor}{given-family}

% BIBLIOGRAPHY MACROS

% NAMES MACROS

% Based on author/editor macro
% Adds nameaddon field to author names
\newbibmacro*{names:primary}{%
  \ifboolexpr{
    test \ifuseauthor
    and
    not test {\ifnameundef{author}}
  }
    {\usebibmacro{author}%
     \setunit{\addspace}%
     \printfield{nameaddon}}%
    {\usebibmacro{editor}}%
}

% Macro for secondary authors with their role
\newbibmacro*{names:subsidiary}{%
  \usebibmacro{byeditor}%
  \newunit
  \usebibmacro{bytranslator}%
}

% Don't owerwrite default macros to change only delimiters / punctuation,
% declare their format instead.
% https://github.com/michal-h21/biblatex-iso690/issues/68#issuecomment-435650072
\DeclareFieldFormat{editortype}{\mkbibparens{#1}}
\DeclareDelimFormat{editortypedelim}{\addspace}

\DeclareFieldFormat{authortype}{\mkbibparens{#1}}
\DeclareDelimFormat{authortypedelim}{\addspace}

% Macro for printing supervisor field
\newbibmacro*{thesissupervisor}{%
  \ifnameundef{supervisor}
    {}
    {\mainlangbibstring{bysupervisor}%
     \setunit{\addspace}%
     \printnames{supervisor}}%
}

% TITLES MACROS

% Macro for formatting <prefix>titles
% 1st argument: prefix / type of title (e.g. main, book, event),
%               if empty, 'title' field is handled
% 2nd argument: formatting directive (e.g. emph)
\newbibmacro{titles}[2]{%
  \ifboolexpr{
    test {\iffieldundef{#1title}}
    and
    test {\iffieldundef{#1subtitle}}}
    {}
    {\printtext[#2]{%
       \printfield{#1title}%
       \setunit{\subtitlepunct}%
       \printfield{#1subtitle}}%
     \setunit{\addspace}}%
  \printfield{#1titleaddon}%
  \newunit
}%

% Macro for printing volumes (part of volumes)
\newbibmacro{volume}{%
  \iffieldundef{volume}
    {}
    {\printfield{volume}%
     \printfield{part}%
     \setunit{\addcomma\space}}%
}

% Macro for formatting multiple titles
\newbibmacro{multi:titles}{%
  \iffieldundef{maintitle}
    {\iffieldundef{booktitle}
      {\usebibmacro{titles}{}{emph}}
      {\usebibmacro{titles}{book}{emph}%
       \usebibmacro{volume}%
       \usebibmacro{titles}{}{}}}%
    {\usebibmacro{titles}{main}{emph}%
     \usebibmacro{volume}%
     \usebibmacro{titles}{}{}}%
}

% Macro for formatting multiple hierarchical titles
% (e.g. for inbook, incollection)
\newbibmacro{host:titles}{%
 \iffieldundef{maintitle}
   {\iffieldundef{booktitle}
      {}
      {\usebibmacro{titles}{book}{emph}}}
   {\usebibmacro{titles}{main}{emph}}%
}%

% Macro for formatting multiple titles in periodicals
\newbibmacro{periodical:titles}{%
  \usebibmacro{titles}{}{emph}%
  \newunit
  \iffieldundef{issuetitle}
    {\iffieldundef{journaltitle}
       {}
       {\usebibmacro{titles}{journal}{}}}
    {\usebibmacro{titles}{issue}{}}%
}

% MEDIUM TYPE MACROS

\newbibmacro*{medium-type}{%
  \iffieldundef{howpublished}
    {% Automatic printing of '[online]' type of medium when
     % a) 'urldate' is present AND
     % b) url is enabled (pkg option url=true) OR
     %    entry type is '@online'
      \ifboolexpr{
        not test {\iffieldundef{urlyear}}
        and (   test {\iftoggle{bbx:url}}
             or test {\ifentrytype{online}})
      }
        % Use a localisation string 'online' in the main document language
        {\mainlangbibstring[\mkbibbrackets]{online}}%
        {}}% Don't print anything
    {% The only situation when we don't want to print
     % 'howpublished' field is when
     % a) url is disabled (pkg option url=false) AND
     % b) entry type is other than '@online' AND
     % c) 'howpublished' field is 'online'.
     % Please note that this field is not checked against
     % any possible literal value (e.g. electronic, online article)
     % that should be probably also hidden when a) AND b) hold.
      \ifboolexpr{
        test {\iffieldequalstr{howpublished}{online}}
        and not test {\iftoggle{bbx:url}}
        and not test {\ifentrytype{online}}
      }
        {}% Don't print 'howpublished' field
        {\printfield{howpublished}}}%
}

% PUBLICATION INFO MACROS

% By default only year is used, but for some entries,
% we need full date (day or even time precision),
% (e.g. patents, TV shows, newspapers, online news)

% Macro for printing full date (full = YYYY-MM-DD)
\newbibmacro*{fulldate}{%
  \mkdaterangeiso{}%
}

% a)
% If there is no date field in the bib entry,
% we should state there is no date by printing
% a localisation string, e.g. [n.d.].
% b)
% Order: <date> <dateaddon>
\renewbibmacro*{date}{%
  \iffieldundef{year}
    {\iffieldundef{dateaddon}
      {\bibstring[\mkbibbrackets]{nodate}}%
      {\printfield{dateaddon}}}%
    {\printdate%
     \setunit{\dateaddonpunct}%
     \printfield{dateaddon}}%
}

% Based on publisher+location+date macro (defined in standard.bbx)
% Differs only in punctuation
%
% Wrapper for printing normal or full date. 1st argument:
% * empty: \usebibmacro{date}
% * 'full': \usebibmacro{fulldate}
\newbibmacro*{location+publisher+dateform}[1]{%
  \printlist{location}%
  \iflistundef{publisher}
    {\setunit*{\addcomma\space}}
    {\setunit*{\subtitlepunct}}% <---- different punctuation
  \printlist{publisher}%
  \setunit*{\addcomma\space}%
  \usebibmacro{#1date}%
  \newunit}

\newbibmacro*{location+publisher+date}{%
  \usebibmacro{location+publisher+dateform}{}}

\newbibmacro*{location+publisher+fulldate}{%
  \usebibmacro{location+publisher+dateform}{full}}

% NUMERATION MACROS

\newbibmacro*{serial:numeration}{%
  \printfield{volume}%
  \iftoggle{bbx:shortnum}
    {}
    {\setunit*{\addcomma\space}}%
  \printfield{number}%
}

\newbibmacro*{book:numeration}{%
  \printfield{volume}%
  \setunit*{\addcomma\space}%
  \printfield{chapter}%
}

% SERIES TITLE AND NUMBER MACROS

% Based on series+number macro (defined in standard.bbx)
% Differs only in punctuation
\newbibmacro*{series+number}{%
  \printfield{series}%
  \setunit*{\addcomma\space}%
  \printfield{number}%
}%

% STANDARD IDENTIFIERS MACROS

% Bunch of standard identifiers
\newbibmacro*{identifier}{%
  \iftoggle{bbx:isbn}
    {\printfield{isan}%
     \newunit
     \printfield{isbn}%
     \newunit
     \printfield{ismn}%
     \newunit
     \printfield{isrn}%
     \newunit
     \printfield{issn}%
     \newunit
     \printfield{iswc}%
     \newunit}
    {}%
}

% AVAILABILITY AND ACCESS MACROS

% Precedes DOI field with urlfrom localisation string
\newbibmacro*{from-doi}{%
  \mainlangbibstring{urlfrom}%
  \setunit{\addspace}%
  \printfield{doi}%
}

% Precedes eprint field with urlfrom localisation string
% Use default eprint formatting macro
\newbibmacro*{from-eprint}{%
  \mainlangbibstring{urlfrom}
  \setunit{\addspace}%
  \usebibmacro{eprint}%
}

% Macro for availability and access information
% with order of importance: doi, eprint, url
\newbibmacro*{availability+access}{%
  \ifboolexpr{
    test {\iftoggle{bbx:doi}}
    and not test {\iffieldundef{doi}}
  }
    {\usebibmacro{from-doi}}%
    {%
      \ifboolexpr{
        test {\iftoggle{bbx:eprint}}
        and not test {\iffieldundef{eprint}}
      }
        {\usebibmacro{from-eprint}}%
        {\usebibmacro{url}}}%
}

% The url field of @online entries is always printed
\renewbibmacro*{url}{%
  \ifboolexpr{
    test {\iftoggle{bbx:url}}
    or test {\ifentrytype{online}}
  }
    {\printfield{url}}%
    {}%
}

% The url seen date of @online entries is always printed
\renewbibmacro*{urldate}{%
  \ifboolexpr{
    test {\iftoggle{bbx:url}}
    or test {\ifentrytype{online}}
  }
    {\printurldate}%
    {}%
}

% LOCATION MACROS

% Additional location information (e.g. library, repository)
\newbibmacro*{location}{%
  \iffieldundef{library}
    {}
    {\usebibmacro{at:}%
     \printfield{library}}%
}

% OTHER MACROS

% Redeclare in: bibmacro to use the main document language.
% There was discussion whether literal "In:" should be used,
% but that would look weird in non-latin languages.
% Context: https://github.com/michal-h21/biblatex-iso690/pull/33

% Force to use the main document language for 'in' localisation string
\renewbibmacro*{in:}{%
  \mainlangbibstring{in}%
  \printunit{\intitlepunct}%
}

% Based on 'in:' macro for 'at' localisation string
\newbibmacro*{at:}{%
  \mainlangbibstring{at}%
  \printunit{\intitlepunct}%
}

% BIBLATEX CORE ADJUSTMENTS

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Localisation strings in the main document language
%
% \mainlangbibstring in place of \bibstring
% \mainlangbiblstring in place of \biblstring
% \mainlangbibsstring in place of \bibsstring

% [<wrapper>]{<string>}
\newrobustcmd*{\blx@imc@mainlangbibstring}[2][\@firstofone]{%
  \blx@mainlangbibstring{#1}{\abx@str}{#2}}

\newrobustcmd*{\blx@imc@mainlangbiblstring}[2][\@firstofone]{%
  \blx@mainlangbibstring{#1}{abx@lstr}{#2}}

\newrobustcmd*{\blx@imc@mainlangbibsstring}[2][\@firstofone]{%
  \blx@mainlangbibstring{#1}{abx@sstr}{#2}}

\protected\def\blx@mainlangbibstring#1#2#3{%
  {\mainlang% <---- use main document language
  \blx@begunit
  \blx@hyphenreset
  \blx@bibstringsimple
  \lowercase{\edef\blx@tempa{#3}}%
  \ifcsundef{#2@\blx@tempa}
    {\blx@warn@nostring\blx@tempa
     \blx@endnounit}
    {\blx@imc@ifcapital
       {#1{\MakeCapital{\csuse{#2@\blx@tempa}}}}
       {#1{\csuse{#2@\blx@tempa}}}%
     \blx@endunit}}}

\blx@regimcs{%
  \mainlangbibstring \mainlangbiblstring \mainlangbibsstring
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Overriding bookpagination to use document main language
%
% Use new name 'mkpagetotal' over 'mkmlpagetotal'
% Use 'mainlangbibsstring' over 'bibstring'

\newrobustcmd*{\blx@imc@mkmlpagetotal}[1][bookpagination]{%
  \begingroup
  \def\blx@tempa{\blx@mkmlpagetotal{pagetotal}}%
  \iffieldundef{#1}
    {}
    {\iffieldequalstr{#1}{none}
       {\def\blx@tempa{\blx@mkmlpagetotal@i}}
       {\iffieldplusstringbibstring{#1}{total}
          {\edef\blx@tempa{\blx@mkmlpagetotal{\thefield{#1}total}}}
          {\blx@warning@entry{%
             Unknown pagination type '\strfield{#1}total'}}}}%
  \@ifnextchar[%]
    {\blx@tempa}
    {\blx@tempa[\@firstofone]}}

\protected\long\def\blx@mkmlpagetotal#1[#2]#3{%
  \ifnumeral{#3}
    {\setbox\@tempboxa=\hbox{%
       \blx@tempcnta0#3\relax
       \ifnum\blx@tempcnta=\@ne
         \aftergroup\@firstoftwo
       \else
         \aftergroup\@secondoftwo
       \fi}%
     {#2{#3}\ppspace\mainlangbibsstring{#1}}
     {#2{#3}\ppspace\mainlangbibsstring{#1s}}}
    {\def\pno{\mainlangbibsstring{#1}}%
     \def\ppno{\mainlangbibsstring{#1s}}%
     #2{#3}}%
  \endgroup}

\long\def\blx@mkmlpagetotal@i[#1]#2{#1{#2}\endgroup}

\blx@regimcs{\mkmlpagetotal}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Overriding pagination to use document main language
%
% Use new name 'mkmlpageprefix' over 'mkpageprefix'
% Use 'mainlangbibsstring' over 'bibstring'

\newrobustcmd*{\blx@imc@mkmlpageprefix}[1][pagination]{%
  \begingroup
  \def\blx@tempa{\blx@mkmlpageprefix{page}}%
  \iffieldundef{#1}
    {}
    {\iffieldequalstr{#1}{none}
       {\def\blx@tempa{\blx@mkmlpageprefix@i}}
       {\iffieldbibstring{#1}
          {\edef\blx@tempa{\blx@mkmlpageprefix{\thefield{#1}}}}
          {\blx@warning@entry{%
             Unknown pagination type '\strfield{#1}'}}}}%
  \@ifnextchar[%]
    {\blx@tempa}
    {\blx@tempa[\@firstofone]}}

\protected\long\def\blx@mkmlpageprefix#1[#2]#3{%
  \ifnumeral{#3}
    {\mainlangbibsstring{#1}\ppspace}
    {\ifnumerals{#3}
       {\mainlangbibsstring{#1s}\ppspace}
       {\def\pno{\mainlangbibsstring{#1}}%
        \def\ppno{\mainlangbibsstring{#1s}}}}%
  \blx@mkmlpageprefix@i[#2]{#3}}

\long\def\blx@mkmlpageprefix@i[#1]#2{#1{#2}\endgroup}

\blx@regimcs{\mkmlpageprefix}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Use space punctuation, package option 'spacecolon',
% toggle 'bbx:spcolon', command '\addspcolon' / '\addspacecolon'

% See 'biblatex.sty' for these macros
%
% Let biblatex know the new macro
\blx@regimcs{\addspcolon}
% Define the new macro
\protected\def\blx@imc@addspcolon{\blx@addsppunct{colon}}
% Implement the new macro
\def\blx@addsppunct#1{% <---- new name for spaced punctuation
  %\unspace <----- commented out
  \ifnum\blx@spacefactor<\blx@sf@threshold@low
    \csuse{blx@qp@#1}\csuse{abx@#1}%
  \else%
    \ifnum\blx@spacefactor>\blx@sf@threshold@high
      \csuse{blx@qp@#1}\csuse{abx@#1}%
    \else%
      \ifcsdef{blx@pp@\the\csname blx@sf@#1\endcsname @\blx@spacefactor}%
        {\csuse{blx@qp@#1}\csuse{abx@#1}}%
        {\csuse{blx@qp@#1}}%%
    \fi%
  \fi%
  \csuse{blx@pq@#1}}%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Adds non-breaking space after open date range, e.g. '1492-- '
%

\newcommand*{\mkopenendeddaterange}{\mbox{\bibdaterangesep\addnbspace}}

% Used by '\printdate'
%
% {<short|long>}{<datetype>}
\renewrobustcmd*{\mkdaterangefull}[2]{%
  \begingroup
    \blx@metadateinfo{#2}%
    \iffieldundef{#2year}
      {\blx@nounit}
      {\printtext[{#2date}]{%
         \datecircaprint
         % Such a season component can only come from an ISO8601 season which replaces
         % a normal month so if it exists, we know that a normal date print is ruled out
         \iffieldundef{#2season}
           {\csuse{mkbibdate#1}{#2year}{#2month}{#2day}%
            % Optionally print the time after the date
            \blx@printtime{#2}{}}
           {\csuse{mkbibseasondate#1}{#2year}{#2season}}%
         \dateuncertainprint
         \dateeraprint{#2year}%
         \iffieldundef{#2endyear}
           {}
           {\iffieldequalstr{#2endyear}{}
              {\mkopenendeddaterange}% <---- added \addnbspace
              {\bibdaterangesep
               \enddatecircaprint
               \iffieldundef{#2endseason}
                 {\csuse{mkbibdate#1}{#2endyear}{#2endmonth}{#2endday}%
                  % Optionally print the time after the date
                  \blx@printtime{#2}{end}}
                 {\csuse{mkbibseasondate#1}{#2endyear}{#2endseason}}%
               \enddateuncertainprint
               \dateeraprint{#2endyear}}}}}%
  \endgroup}

% Used by '\printlabeldateextra' in 'iso-authoryear.bbx'
%
% {<short|long>}{<datetype>}
\renewrobustcmd*{\mkdaterangefullextra}[2]{%
  \begingroup
    \blx@metadateinfo{#2}%
    \iffieldundef{#2year}
      {\blx@nounit}
      {\printtext[{#2date}]{%
         \datecircaprint
         % Such a season component can only come from an ISO8601 season which replaces
         % a normal month so if it exists, we know that a normal date print is ruled out
         \iffieldundef{#2season}
           {\csuse{mkbibdate#1}{#2year}{#2month}{#2day}%
            % Optionally print the time after the date
            \blx@printtime{#2}{}}
           {\csuse{mkbibseasondate#1}{#2year}{#2season}}%
         \dateuncertainprint
         \dateeraprint{#2year}%
         \iffieldundef{#2endyear}
           {\printfield{extradate}}
           {\iffieldequalstr{#2endyear}{}
              {\printfield{extradate}%
               \printtext{\mkopenendeddaterange}}% <---- added \addnbspace
              {\printtext{%
                 \bibdaterangesep
                 \enddatecircaprint
                 \iffieldundef{#2endseason}
                   {\csuse{mkbibdate#1}{#2endyear}{#2endmonth}{#2endday}%
                    % Optionally print the time after the date
                    \blx@printtime{#2}{end}}
                   {\csuse{mkbibseasondate#1}{#2endyear}{#2endseason}}}%
                 \printfield{extradate}%
                 \enddateuncertainprint
                 \dateeraprint{#2endyear}}}}}%
  \endgroup}

% Other date formats for completeness

% Avoids error with older biblatex version
% WARNING: of course this means that in older versions the
% date printing macro will not be changed as expected
% this is not an issue for biblatex-iso690 since it only uses
% \mkdaterangefull and \mkdaterangefullextra anyway
\providecommand*{\mkdaterangetrunc@i}{}

\renewrobustcmd*{\mkdaterangetrunc@i}[2]{%
  \begingroup
    \blx@metadateinfo{#2}%
    \iffieldundef{#2year}
      {\blx@nounit}
      {\printtext[{#2date}]{%
         \datecircaprint
         % Such a season component can only come from an ISO8601 season which replaces
         % a normal month so if it exists, we know that a normal date print is ruled out
         \iffieldundef{#2season}
           {\ifdateyearsequal{#2}{#2end}
              {\iffieldsequal{#2month}{#2endmonth}
                 {\csuse{mkbibdate#1}{}{}{#2day}}
                 {\csuse{mkbibdate#1}{}{#2month}{#2day}}}
              {\csuse{mkbibdate#1}{#2year}{#2month}{#2day}%
               \iffieldsequal{#2dateera}{#2enddateera}{}
                 {\dateeraprint{#2year}}}}
           {\ifdateyearsequal{#2}{#2end}
             {\csuse{mkbibseasondate#1}{}{#2season}}
             {\csuse{mkbibseasondate#1}{#2year}{#2season}%
              \iffieldsequal{#2dateera}{#2enddateera}{}
                {\dateeraprint{#2year}}}}%
         \dateuncertainprint
         \iffieldundef{#2endyear}
           {}
           {\iffieldequalstr{#2endyear}{}
              {\mkopenendeddaterange}
              {\bibdaterangesep
               \enddatecircaprint
               \iffieldundef{#2endseason}
                 {\csuse{mkbibdate#1}{#2endyear}{#2endmonth}{#2endday}}
                 {\csuse{mkbibseasondate#1}{#2endyear}{#2endseason}}%
               \enddateuncertainprint
               \dateeraprint{#2endyear}}}}}%
  \endgroup}

% Avoids error with older biblatex version
% WARNING: of course this means that in older versions the
% date printing macro will not be changed as expected
% this is not an issue for biblatex-iso690 since it only uses
% \mkdaterangefull and \mkdaterangefullextra anyway
\providecommand*{\mkdaterangetruncextra@i}{}

\renewrobustcmd*{\mkdaterangetruncextra@i}[2]{%
  \begingroup
    \blx@metadateinfo{#2}%
    \iffieldundef{#2year}
      {\blx@nounit}
      {\printtext[{#2date}]{%
         \datecircaprint
         % Such a season component can only come from an ISO8601 season which replaces
         % a normal month so if it exists, we know that a normal date print is ruled out
         \iffieldundef{#2season}
           {\ifdateyearsequal{#2}{#2end}
              {\iffieldsequal{#2month}{#2endmonth}
                 {\csuse{mkbibdate#1}{}{}{#2day}}
                 {\csuse{mkbibdate#1}{}{#2month}{#2day}}}
              {\csuse{mkbibdate#1}{#2year}{#2month}{#2day}%
               \iffieldsequal{#2dateera}{#2enddateera}{}
                 {\dateeraprint{#2year}}}}
           {\ifdateyearsequal{#2}{#2end}
             {\csuse{mkbibseasondate#1}{}{#2season}}
             {\csuse{mkbibseasondate#1}{#2year}{#2season}%
              \iffieldsequal{#2dateera}{#2enddateera}{}
                {\dateeraprint{#2year}}}}%
         \dateuncertainprint
         \iffieldundef{#2endyear}
           {\printfield{extradate}}
           {\iffieldequalstr{#2endyear}{}
              {\printfield{extradate}%
               \printtext{\mkopenendeddaterange}}
              {\printtext{%
                 \bibdaterangesep
                 \enddatecircaprint
                 \iffieldundef{#2endseason}
                   {\csuse{mkbibdate#1}{#2endyear}{#2endmonth}{#2endday}}
                   {\csuse{mkbibseasondate#1}{#2endyear}{#2endseason}}}%
                 \printfield{extradate}%
                 \enddateuncertainprint
                 \dateeraprint{#2endyear}}}}}%
  \endgroup}


% {<datetype>}
\renewrobustcmd*{\mkdaterangeymd}[1]{%
  \begingroup
    \blx@metadateinfo{#1}%
    \iffieldundef{#1year}
      {\blx@nounit}
      {\printtext[{#1date}]{%
         \datecircaprint
         % Such a season component can only come from an  ISO8601 season which replaces
         % a normal month so if it exists, we know that a normal date print is ruled out
         \iffieldundef{#1season}
           {\blx@ymddate{#1}{}%
            % Optionally print the time after the date
            \blx@printtime{#1}{}}
           {\csuse{mkbibseasondateshort}{#1year}{#1season}}%
         \dateuncertainprint
         \dateeraprint{#1year}%
         \iffieldundef{#1endyear}
           {}
           {\iffieldequalstr{#1endyear}{}
              {\mkopenendeddaterange}
              {\bibdaterangesep
               \enddatecircaprint
               \iffieldundef{#1season}
                 {\blx@ymddate{#1}{end}%
                  % Optionally print the time after the date
                  \blx@printtime{#1}{end}}
                 {\csuse{mkbibseasondateshort}{#1endyear}{#1endseason}}%
               \enddateuncertainprint
               \dateeraprint{#1endyear}}}}}%
  \endgroup}

% {<datetype>}
\renewrobustcmd*{\mkdaterangeymdextra}[1]{%
  \begingroup
    \blx@metadateinfo{#1}%
    \iffieldundef{#1year}
      {\blx@nounit}
      {\printtext[{#1date}]{%
         \datecircaprint
         % Such a season component can only come from an ISO8601 season which replaces
         % a normal month so if it exists, we know that a normal date print is ruled out
         \iffieldundef{#1season}
           {\blx@ymddate[extradate]{#1}{}%
            % Optionally print the time after the date
            \blx@printtime{#1}{}}
           {\csuse{mkbibseasondateshort}{#1year}{#1season}}%
         \dateuncertainprint
         \dateeraprint{#1year}%
         \iffieldundef{#1endyear}
           {}
           {\iffieldequalstr{#1endyear}{}
              {\mkopenendeddaterange}
              {\printtext{%
                 \bibdaterangesep
                 \enddatecircaprint
                 \iffieldundef{#1season}
                   {\blx@ymddate{#1}{end}%
                    % Optionally print the time after the date
                    \blx@printtime{#1}{end}}
                   {\csuse{mkbibseasondateshort}{#1endyear}{#1endseason}}}%
               \enddateuncertainprint
               \dateeraprint{#1endyear}}}}}%
  \endgroup}

% BIBLIOGRAPHY DRIVERS

\DeclareBibliographyDriver{book}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{names:primary}%
  \setunit{\printdelim{nametitledelim}}\newblock
  \usebibmacro{multi:titles}%
  \setunit{\addspace}%
  \usebibmacro{medium-type}%
  \newunit\newblock
  \printfield{edition}%
  \newunit\newblock
  \usebibmacro{names:subsidiary}%
  \newunit\newblock
  \usebibmacro{location+publisher+date}%
  \newunit
  \printfield{version}%
  \setunit{\addspace}%
  \usebibmacro{urldate}%
  \newunit\newblock
  \usebibmacro{series+number}%
  \newunit\newblock
  \usebibmacro{identifier}%
  \newunit\newblock
  \usebibmacro{availability+access}%
  \newunit\newblock
  \usebibmacro{location}%
  \setunit{\addspace}%
  \iftoggle{bbx:totalpages}
    {\printfield{pagetotal}}
    {}%
  \newunit\newblock
  \printfield{note}%
  \newunit\newblock
  \setunit{\bibpagerefpunct}\newblock
  \usebibmacro{pageref}%
  \usebibmacro{finentry}}

\DeclareBibliographyDriver{periodical}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  % Names macro just because of author-year style
  \usebibmacro{names:primary}%
  \setunit{\printdelim{nametitledelim}}\newblock
  \usebibmacro{periodical:titles}%
  \setunit{\addspace}%
  \usebibmacro{medium-type}%
  \newunit\newblock
  \printfield{edition}%
  \newunit\newblock
  \usebibmacro{location+publisher+date}%
  \setunit{\numerationpunct}%
  \usebibmacro{serial:numeration}%
  \setunit{\addspace}%
  \usebibmacro{urldate}%
  \newunit\newblock
  \usebibmacro{identifier}%
  \newunit\newblock
  \usebibmacro{availability+access}%
  \newunit\newblock
  \usebibmacro{location}%
  \newunit\newblock
  \printfield{note}%
  \newunit\newblock
  \setunit{\bibpagerefpunct}\newblock
  \usebibmacro{pageref}%
  \usebibmacro{finentry}}%

\DeclareBibliographyDriver{article}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{names:primary}%
  \setunit{\printdelim{nametitledelim}}\newblock
  \usebibmacro{titles}{}{}%
  \newunit\newblock
  \usebibmacro{titles}{journal}{emph}%
  \setunit{\addspace}%
  \usebibmacro{medium-type}%
  \newunit\newblock
  \printfield{edition}%
  \newunit\newblock
  \iftoggle{bbx:articlepubinfo}
    {\usebibmacro{location+publisher+date}}
    {\usebibmacro{date}}%
  \setunit{\numerationpunct}%
  \usebibmacro{serial:numeration}%
  \setunit{\bibpagespunct}%
  \printfield{pages}%
  \setunit{\addspace}%
  \usebibmacro{urldate}%
  \newunit\newblock
  \usebibmacro{identifier}%
  \newunit\newblock
  \usebibmacro{availability+access}%
  \newunit\newblock
  \usebibmacro{location}%
  \newunit\newblock
  \printfield{note}%
  \setunit{\bibpagerefpunct}\newblock
  \usebibmacro{pageref}%
  \usebibmacro{finentry}}%

\DeclareBibliographyDriver{inbook}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{names:primary}%
  \setunit{\printdelim{nametitledelim}}\newblock
  \usebibmacro{titles}{}{}%
  \newunit\newblock
  \usebibmacro{in:}%
  \printnames{bookauthor}%
  \newunit\newblock
  \usebibmacro{host:titles}%
  \setunit{\addspace}%
  \usebibmacro{medium-type}%
  \newunit\newblock
  \printfield{edition}%
  \newunit\newblock
  \usebibmacro{names:subsidiary}%
  \newunit\newblock
  \usebibmacro{location+publisher+date}%
  \setunit{\addcomma\space}%
  \usebibmacro{book:numeration}%
  \setunit{\bibpagespunct}%
  \printfield{pages}%
  \newunit
  \printfield{version}%
  \setunit{\addspace}%
  \usebibmacro{urldate}%
  \newunit\newblock
  \usebibmacro{series+number}%
  \newunit\newblock
  \usebibmacro{identifier}%
  \newunit\newblock
  \usebibmacro{availability+access}%
  \newunit\newblock
  \usebibmacro{location}%
  \newunit\newblock
  \printfield{note}%
  \newunit\newblock
  \setunit{\bibpagerefpunct}\newblock
  \usebibmacro{pageref}%
  \usebibmacro{finentry}}%

\DeclareBibliographyDriver{incollection}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{names:primary}%
  \setunit{\printdelim{nametitledelim}}\newblock
  \usebibmacro{titles}{}{}%
  \newunit\newblock
  \usebibmacro{in:}%
  \usebibmacro{editor}%
  \newunit\newblock
  \usebibmacro{host:titles}%
  \setunit{\addspace}%
  \usebibmacro{medium-type}%
  \newunit\newblock
  \printfield{edition}%
  \newunit\newblock
  \usebibmacro{names:subsidiary}%
  \newunit\newblock
  \usebibmacro{location+publisher+date}%
  % could number be even used in `incollection`?
  % It should be at some other place in this case
  \setunit{\numerationpunct}%
  \usebibmacro{book:numeration}%
  \setunit{\bibpagespunct}%
  \printfield{pages}%
  \newunit
  \printfield{version}%
  \setunit{\addspace}%
  \usebibmacro{urldate}%
  \newunit\newblock
  \usebibmacro{series+number}%
  \newunit\newblock
  \usebibmacro{identifier}%
  \newunit\newblock
  \usebibmacro{availability+access}%
  \newunit\newblock
  \usebibmacro{location}%
  \newunit\newblock
  \printfield{note}%
  \newunit\newblock
  \setunit{\bibpagerefpunct}\newblock
  \usebibmacro{pageref}%
  \usebibmacro{finentry}}%

\DeclareBibliographyDriver{online}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{names:primary}%
  \setunit{\printdelim{nametitledelim}}\newblock
  \usebibmacro{multi:titles}%
  \setunit{\addspace}%
  \usebibmacro{medium-type}%
  \newunit\newblock
  \printfield{edition}%
  \newunit\newblock
  \usebibmacro{names:subsidiary}%
  \newunit\newblock
  \usebibmacro{location+publisher+fulldate}%
  \newunit
  \printfield{version}%
  \setunit{\addspace}%
  \usebibmacro{urldate}%
  \newunit\newblock
  \usebibmacro{series+number}%
  \newunit\newblock
  \usebibmacro{identifier}%
  \newunit\newblock
  \usebibmacro{availability+access}%
  \setunit{\addspace}%
  \iftoggle{bbx:totalpages}
    {\printfield{pagetotal}}
    {}%
  \newunit\newblock
  \printfield{note}%
  \newunit\newblock
  \setunit{\bibpagerefpunct}\newblock
  \usebibmacro{pageref}%
  \usebibmacro{finentry}}%

\DeclareBibliographyDriver{thesis}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{names:primary}%
  \setunit{\printdelim{nametitledelim}}\newblock
  \usebibmacro{titles}{}{emph}%
  \setunit{\addspace}%
  \usebibmacro{medium-type}%
  \newunit\newblock
  \usebibmacro{location+publisher+date}%
  \newunit
  \printfield{version}%
  \setunit{\addspace}%
  \usebibmacro{urldate}%
  \newunit\newblock
  \usebibmacro{identifier}%
  \newunit\newblock
  \iftoggle{bbx:thesisinfoinnotes}
    {}
    {\printfield{type}%
     \newunit\newblock
     \printlist{institution}%
     \newunit\newblock
     \usebibmacro{thesissupervisor}}%
  \newunit\newblock
  \usebibmacro{availability+access}%
  \setunit{\addspace}%
  \iftoggle{bbx:totalpages}
    {\printfield{pagetotal}}
    {}%
  \newunit\newblock
  \iftoggle{bbx:thesisinfoinnotes}
    {\printfield{type}
     \newunit\newblock
     \printlist{institution}%
     \newunit\newblock
     \usebibmacro{thesissupervisor}}
    {}%
  \newunit\newblock
  \printfield{note}%
  \newunit\newblock
  \setunit{\bibpagerefpunct}\newblock
  \usebibmacro{pageref}%
  \usebibmacro{finentry}}%

\DeclareBibliographyDriver{report}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{names:primary}%
  \setunit{\printdelim{nametitledelim}}\newblock
  \usebibmacro{titles}{}{emph}%
  \setunit{\addspace}%
  \usebibmacro{medium-type}%
  \newunit\newblock
  \usebibmacro{location+publisher+fulldate}%
  \newunit
  \printfield{version}%
  \setunit{\addspace}%
  \usebibmacro{urldate}%
  \newunit\newblock
  \iffieldundef{type}
    {}
    {\printfield{type}%
     \setunit*{\addcomma\space}}%
  \printfield{number}%
  \newunit\newblock
  \printlist{institution}%
  \newunit\newblock
  \usebibmacro{identifier}%
  \newunit\newblock
  \usebibmacro{availability+access}%
  \setunit{\addspace}%
  \iftoggle{bbx:totalpages}
    {\printfield{pagetotal}}
    {}%
  \newunit\newblock
  \printfield{note}%
  \newunit\newblock
  \setunit{\bibpagerefpunct}\newblock
  \usebibmacro{pageref}%
  \usebibmacro{finentry}}

\DeclareBibliographyDriver{patent}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{names:primary}%
  \setunit{\printdelim{nametitledelim}}\newblock
  \usebibmacro{titles}{}{emph}%
  \newunit\newblock
  \usebibmacro{names:subsidiary}%
  \newunit\newblock
  \printlist{location}%
  \newunit\newblock
  \iffieldundef{type}
    {}
    {\printfield{type}%
     \setunit*{\addcomma\space}}%
  \printfield{number}%
  \newunit\newblock
  \usebibmacro{fulldate}%
  \setunit{\addspace}%
  \usebibmacro{urldate}%
  \newunit\newblock
  \usebibmacro{availability+access}%
  \newunit\newblock
  \printfield{note}%
  \newunit\newblock
  \setunit{\bibpagerefpunct}\newblock
  \usebibmacro{pageref}%
  \usebibmacro{finentry}}%

% BIBLIOGRAPHY ALIASES

\DeclareBibliographyAlias{bookinbook}{inbook}
\DeclareBibliographyAlias{suppbook}{inbook}
\DeclareBibliographyAlias{booklet}{book}
\DeclareBibliographyAlias{collection}{book}
\DeclareBibliographyAlias{suppcollection}{incollection}
\DeclareBibliographyAlias{manual}{book}
\DeclareBibliographyAlias{misc}{book}
\DeclareBibliographyAlias{suppperiodical}{article}
\DeclareBibliographyAlias{proceedings}{collection}
\DeclareBibliographyAlias{inproceedings}{incollection}
\DeclareBibliographyAlias{reference}{collection}
\DeclareBibliographyAlias{inreference}{incollection}
\DeclareBibliographyAlias{unpublished}{book}
\DeclareBibliographyAlias{movie}{book}
\DeclareBibliographyAlias{music}{book}
\DeclareBibliographyAlias{*}{misc}

\endinput

% vim: ft=tex