summaryrefslogtreecommitdiff
path: root/library/src/text/symbol.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2023-01-27 12:04:23 +0100
committerLaurenz <laurmaedje@gmail.com>2023-01-27 12:04:36 +0100
commit1de53730bce0bd3f9de89db1da7c19b7889b9a75 (patch)
treee2746f4853a5a8e99f32e8c52d6e4b4f411c1933 /library/src/text/symbol.rs
parent13efa128c855637a7fe3351a4579383359d1be1b (diff)
Symbol values and modules
Diffstat (limited to 'library/src/text/symbol.rs')
-rw-r--r--library/src/text/symbol.rs111
1 files changed, 0 insertions, 111 deletions
diff --git a/library/src/text/symbol.rs b/library/src/text/symbol.rs
deleted file mode 100644
index 4a7c8ad3..00000000
--- a/library/src/text/symbol.rs
+++ /dev/null
@@ -1,111 +0,0 @@
-use crate::prelude::*;
-use crate::text::TextNode;
-
-/// # Symbol
-/// A symbol identified by symmie notation.
-///
-/// Symmie is Typst's notation for Unicode symbols. It is based on the idea of
-/// _modifiers._ Many symbols in Unicode are very similar. In symmie, such
-/// groups of symbols share a common name. To distinguish between the symbols
-/// within a group, we use one or multiple modifiers that are separated from the
-/// name by colons.
-///
-/// There is currently no easily viewable list of all names, but in the
-/// meantime you can rely on the autocompletion in Typst's web editor.
-///
-/// ## Syntax
-/// This function also has dedicated syntax: In markup, you can enclose symmie
-/// notation within colons to produce a symbol. And in math, you can just write
-/// the notation directly. There, all letter sequence of length at least two are
-/// automatically parsed as symbols (unless a variable of that name is defined).
-///
-/// Additionally, some very common but hard to type symbols can be expressed with
-/// dedicated shortcuts. These are:
-///
-/// | Symmie | Shorthand | Result |
-/// | ----------- | --------- | ------ |
-/// | `dots:b` | `...` | … |
-/// | `dash:en` | `---` | – |
-/// | `dash:em` | `--` | — |
-/// | none yet | `-?` | A soft hyphen |
-/// | none yet | `~` | A non breaking space |
-///
-/// Within math mode, additional shorthands are available:
-///
-/// | Symmie | Shorthand | Result |
-/// | ------------------ | --------- | ------ |
-/// | `arrow:r` | `->` | `→` |
-/// | `arrow:r:double` | `=>` | `⇒` |
-/// | `arrow:l` | `<-` | `←` |
-/// | `arrow:r:bar` | <code>&VerticalLine;-></code> | `↦` |
-/// | `arrow:l:r` | `<->` | `↔` |
-/// | `arrow:l:r:double` | `<=>` | `⇔` |
-/// | `eq:not` | `!=` | `≠` |
-/// | `eq:gt` | `>=` | `≥` |
-/// | `eq:lt` | `<=` | `≤` |
-/// | `colon:eq` | `:=` | `≔` |
-///
-/// ## Example
-/// ```
-/// // In text, with colons.
-/// :arrow:l: \
-/// :arrow:r: \
-/// :arrow:t: \
-/// :turtle: \
-/// :face:halo: \
-/// :woman:old:
-///
-/// // In math, directly.
-/// $f : NN -> RR$ \
-/// $A sub:eq B without C$ \
-/// $a times:div b eq:not c$
-/// ```
-///
-/// ## Parameters
-/// - notation: EcoString (positional, required)
-/// The symbol's symmie notation.
-///
-/// Consists of a name, followed by a number colon-separated modifiers
-/// in no particular order.
-///
-/// ### Example
-/// ```
-/// #symbol("NN") \
-/// #symbol("face:grin")
-/// ```
-///
-/// ## Category
-/// text
-#[func]
-#[capable(Show)]
-#[derive(Debug, Hash)]
-pub struct SymbolNode(pub EcoString);
-
-#[node]
-impl SymbolNode {
- fn construct(_: &Vm, args: &mut Args) -> SourceResult<Content> {
- Ok(Self(args.expect("notation")?).pack())
- }
-
- fn field(&self, name: &str) -> Option<Value> {
- match name {
- "notation" => Some(Value::Str(self.0.clone().into())),
- _ => None,
- }
- }
-}
-
-impl Show for SymbolNode {
- fn show(&self, _: &mut Vt, this: &Content, _: StyleChain) -> SourceResult<Content> {
- match symmie::get(&self.0) {
- Some(c) => Ok(TextNode::packed(c)),
- None => {
- if let Some(span) = this.span() {
- bail!(span, "unknown symbol");
- }
-
- Ok(Content::empty())
- }
- }
- }
-}