summaryrefslogtreecommitdiff
path: root/library/src/meta/mod.rs
blob: dcac63795f2cda1ade3eaf94acb49ef9b4ab1823 (plain) (blame)
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
//! Interaction between document parts.

mod bibliography;
mod context;
mod counter;
mod document;
mod figure;
mod footnote;
mod heading;
mod link;
mod numbering;
mod outline;
mod query;
mod reference;
mod state;

pub use self::bibliography::*;
pub use self::context::*;
pub use self::counter::*;
pub use self::document::*;
pub use self::figure::*;
pub use self::footnote::*;
pub use self::heading::*;
pub use self::link::*;
pub use self::numbering::*;
pub use self::outline::*;
pub use self::query::*;
pub use self::reference::*;
pub use self::state::*;

use crate::prelude::*;
use crate::text::TextElem;

/// Hook up all meta definitions.
pub(super) fn define(global: &mut Scope) {
    global.define("document", DocumentElem::func());
    global.define("ref", RefElem::func());
    global.define("link", LinkElem::func());
    global.define("outline", OutlineElem::func());
    global.define("heading", HeadingElem::func());
    global.define("figure", FigureElem::func());
    global.define("footnote", FootnoteElem::func());
    global.define("cite", CiteElem::func());
    global.define("bibliography", BibliographyElem::func());
    global.define("locate", locate_func());
    global.define("style", style_func());
    global.define("layout", layout_func());
    global.define("counter", counter_func());
    global.define("numbering", numbering_func());
    global.define("state", state_func());
    global.define("query", query_func());
    global.define("selector", selector_func());
}

/// The named with which an element is referenced.
pub trait LocalName {
    /// Get the name in the given language and (optionally) region.
    fn local_name(&self, lang: Lang, region: Option<Region>) -> &'static str;

    /// Resolve the local name with a style chain.
    fn local_name_in(&self, styles: StyleChain) -> &'static str {
        self.local_name(TextElem::lang_in(styles), TextElem::region_in(styles))
    }
}