Initial commit
This commit is contained in:
commit
c534d5ce80
163 files changed
+11500
No files matched your search
@@ -0,0 +1,62 @@
|
||||
// ==========================================
|
||||
// DOMAIN: БИБЛИОГРАФИЧЕСКИЕ СЕКЦИИ
|
||||
// ==========================================
|
||||
#import "document.typ": fail
|
||||
|
||||
#let bibliography-section(
|
||||
id,
|
||||
sources,
|
||||
title: auto,
|
||||
style: "gost-r-705-2008-numeric",
|
||||
target: auto,
|
||||
group: auto,
|
||||
full: false,
|
||||
page_break: true,
|
||||
) = {
|
||||
if type(id) != str or id.trim() == "" {
|
||||
fail("bibliography.id", "нужна непустая строка")
|
||||
}
|
||||
let normalized-sources = if type(sources) == array { sources } else { (sources,) }
|
||||
if normalized-sources.len() == 0 {
|
||||
fail("bibliography.sources", "нужен хотя бы один источник")
|
||||
}
|
||||
for source in normalized-sources {
|
||||
if type(source) not in (str, path, bytes) {
|
||||
fail("bibliography.sources", "ожидались str, path или bytes")
|
||||
}
|
||||
}
|
||||
if type(full) != bool {
|
||||
fail("bibliography.full", "ожидался bool")
|
||||
}
|
||||
if type(page_break) != bool {
|
||||
fail("bibliography.page-break", "ожидался bool")
|
||||
}
|
||||
(
|
||||
kind: "bibliography-section",
|
||||
id: id,
|
||||
sources: normalized-sources,
|
||||
title: title,
|
||||
style: style,
|
||||
target: target,
|
||||
group: group,
|
||||
full: full,
|
||||
page-break: page_break,
|
||||
)
|
||||
}
|
||||
|
||||
#let validate-bibliographies(sections) = {
|
||||
if type(sections) != array {
|
||||
fail("bibliographies", "ожидался array")
|
||||
}
|
||||
let seen = ()
|
||||
for section in sections {
|
||||
if type(section) != dictionary or section.at("kind", default: none) != "bibliography-section" {
|
||||
fail("bibliographies", "каждый элемент должен быть bibliography-section")
|
||||
}
|
||||
if section.id in seen {
|
||||
fail("bibliographies", "повторяющийся id " + repr(section.id))
|
||||
}
|
||||
seen.push(section.id)
|
||||
}
|
||||
sections
|
||||
}
|
||||
Reference in new issue
Block a user