summaryrefslogtreecommitdiff
path: root/src/library
diff options
context:
space:
mode:
Diffstat (limited to 'src/library')
-rw-r--r--src/library/mod.rs1
-rw-r--r--src/library/structure/mod.rs2
-rw-r--r--src/library/structure/reference.rs28
-rw-r--r--src/library/text/raw.rs5
4 files changed, 34 insertions, 2 deletions
diff --git a/src/library/mod.rs b/src/library/mod.rs
index bd34590a..c1a645fb 100644
--- a/src/library/mod.rs
+++ b/src/library/mod.rs
@@ -37,6 +37,7 @@ pub fn new() -> Scope {
std.def_fn("smallcaps", text::smallcaps);
// Structure.
+ std.def_node::<structure::RefNode>("ref");
std.def_node::<structure::HeadingNode>("heading");
std.def_node::<structure::ListNode>("list");
std.def_node::<structure::EnumNode>("enum");
diff --git a/src/library/structure/mod.rs b/src/library/structure/mod.rs
index a597211e..088d1e6c 100644
--- a/src/library/structure/mod.rs
+++ b/src/library/structure/mod.rs
@@ -3,9 +3,11 @@
mod doc;
mod heading;
mod list;
+mod reference;
mod table;
pub use doc::*;
pub use heading::*;
pub use list::*;
+pub use reference::*;
pub use table::*;
diff --git a/src/library/structure/reference.rs b/src/library/structure/reference.rs
new file mode 100644
index 00000000..0eeb4bf5
--- /dev/null
+++ b/src/library/structure/reference.rs
@@ -0,0 +1,28 @@
+use crate::library::prelude::*;
+
+/// A reference to a label.
+#[derive(Debug, Hash)]
+pub struct RefNode(pub EcoString);
+
+#[node(showable)]
+impl RefNode {
+ fn construct(_: &mut Machine, args: &mut Args) -> TypResult<Content> {
+ Ok(Content::show(Self(args.expect("label")?)))
+ }
+}
+
+impl Show for RefNode {
+ fn unguard(&self, _: Selector) -> ShowNode {
+ Self(self.0.clone()).pack()
+ }
+
+ fn encode(&self, _: StyleChain) -> Dict {
+ dict! {
+ "label" => Value::Str(self.0.clone().into()),
+ }
+ }
+
+ fn realize(&self, _: &mut Context, _: StyleChain) -> TypResult<Content> {
+ Ok(Content::Text(format_eco!("@{}", self.0)))
+ }
+}
diff --git a/src/library/text/raw.rs b/src/library/text/raw.rs
index e64636f8..a09d791d 100644
--- a/src/library/text/raw.rs
+++ b/src/library/text/raw.rs
@@ -169,6 +169,9 @@ pub static THEME: Lazy<Theme> = Lazy::new(|| Theme {
item("markup.raw", Some("#818181"), None),
item("markup.list", Some("#8b41b1"), None),
item("comment", Some("#8a8a8a"), None),
+ item("punctuation.shortcut", Some("#1d6c76"), None),
+ item("constant.character.escape", Some("#1d6c76"), None),
+ item("entity.name.label, markup.other.reference", Some("#1d6c76"), None),
item("keyword, constant.language, variable.language", Some("#d73a49"), None),
item("storage.type, storage.modifier", Some("#d73a49"), None),
item("entity.other", Some("#8b41b1"), None),
@@ -177,8 +180,6 @@ pub static THEME: Lazy<Theme> = Lazy::new(|| Theme {
item("meta.annotation", Some("#301414"), None),
item("constant", Some("#b60157"), None),
item("string", Some("#298e0d"), None),
- item("punctuation.shortcut", Some("#1d6c76"), None),
- item("constant.character.escape", Some("#1d6c76"), None),
item("invalid", Some("#ff0000"), None),
],
});