diff options
author | Ben Bridle <ben@derelict.engineering> | 2025-03-14 12:55:00 +1300 |
---|---|---|
committer | Ben Bridle <ben@derelict.engineering> | 2025-03-14 12:55:00 +1300 |
commit | 01d6fb5a1f79ff1ef48cc69b42d8a91ef9a6d2f1 (patch) | |
tree | 410b7f28420be833dbcb57cbdb93c01ce6ad300f /src/token.rs | |
parent | 883a2a63023ea9b1e4b2bb51831ea1dafcb7346a (diff) | |
download | markdown-01d6fb5a1f79ff1ef48cc69b42d8a91ef9a6d2f1.zip |
Add optional labels to internal links
Internal links can have labels in the same manner as with external
links, by separating the label and path from each other with a ::
token.
Diffstat (limited to 'src/token.rs')
-rw-r--r-- | src/token.rs | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/token.rs b/src/token.rs index f1f8288..0f44dc2 100644 --- a/src/token.rs +++ b/src/token.rs @@ -5,7 +5,7 @@ pub enum Token { Italic(String), Monospace(String), Math(String), - InternalLink(String), + InternalLink { label: String, path: String }, ExternalLink { label: String, path: String }, } @@ -17,10 +17,13 @@ impl AsRef<str> for Token { Token::Italic(text) => text, Token::Monospace(text) => text, Token::Math(text) => text, - Token::InternalLink(name) => name, - Token::ExternalLink { label, path } => match !label.is_empty() { - true => label, - false => path, + Token::InternalLink { label, path } => match label.is_empty() { + true => path, + false => label, + }, + Token::ExternalLink { label, path } => match label.is_empty() { + true => path, + false => label, }, } } |