Skip to content

Match link types besides Inline #24

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub mod lua;
#[cfg(feature = "python")]
pub mod python;

use pulldown_cmark::{html, CodeBlockKind, Event, Options, Parser, Tag};
use pulldown_cmark::{html, CodeBlockKind, Event, Options, Parser, Tag, LinkType};
use std::{error, fmt, result, sync};

type Result<T> = result::Result<T, Box<dyn error::Error>>;
Expand Down Expand Up @@ -90,7 +90,18 @@ fn get_offsets(buffer: String) -> Result<Events> {
Tag::List(_) => Some(String::from("cmarkList")),
Tag::FootnoteDefinition(_) => Some(String::from("cmarkFootnoteDefinition")),
Tag::Table(_) => Some(String::from("cmarkTable")),
Tag::Link { .. } => Some(String::from("cmarkLink")),
Tag::Link(kind, a, b) => match kind {
LinkType::Inline => Some(String::from("cmarkLink")),
LinkType::Reference => {
// How do we look-ahead and get the end offset?
eprintln!("Got a {:?} with {} AND {}", kind, a, b);
Some(String::from("cmarkLink"))
},
_ => {
eprintln!("Got a {:?} with {} AND {}", kind, a, b);
None
},
},
Tag::Image { .. } => Some(String::from("cmarkImage")),
Tag::Paragraph { .. } => None,
_ => Some(format!("cmark{:?}", tag)),
Expand Down