| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- // ==========================================
- // 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
- }
|