Skip to content
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

Adding option for angle bracket escaping over url-encoding #139

Open
kvietcong opened this issue Dec 25, 2022 · 1 comment
Open

Adding option for angle bracket escaping over url-encoding #139

kvietcong opened this issue Dec 25, 2022 · 1 comment

Comments

@kvietcong
Copy link

Hi, thanks for such a great tool! I was wondering if it would be possible to make the markdown links angle bracket escaped instead of url-encoding escaped ([some title](<../filepath with spaces/test.md#section>) vs [some title](<../filepath%20with%20spaces/test.md#section>)). This is supported by CommonMark/Obsidian and is much more readable on a quick glance IMO.

I saw this piece of the code in lib.rs

obsidian-export/src/lib.rs

Lines 688 to 706 in 8013026

let rel_link = rel_link.to_string_lossy();
let mut link = utf8_percent_encode(&rel_link, PERCENTENCODE_CHARS).to_string();
if let Some(section) = reference.section {
link.push('#');
link.push_str(&slugify(section));
}
let link_tag = pulldown_cmark::Tag::Link(
pulldown_cmark::LinkType::Inline,
CowStr::from(link),
CowStr::from(""),
);
vec![
Event::Start(link_tag.clone()),
Event::Text(CowStr::from(reference.display())),
Event::End(link_tag.clone()),
]

and think it would be two if statements on lines 689 and 698. One to block out the percent encoding and then another to prepend and append the angled brackets. I couldn't figure out how to add it as an option to the tool though so I would really appreciate it if it could be there. Thanks again for making this tool and if you are able to add this feature!

@kvietcong
Copy link
Author

I was able to figure it out. My pull request: #140

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant