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

feat(parser): highlight inline links #157

Closed

Conversation

orhun
Copy link
Contributor

@orhun orhun commented Sep 4, 2024

closes #156

@orhun orhun mentioned this pull request Sep 4, 2024
@henriklovhaug
Copy link
Owner

Good start, but it would be beneficial to treat it the same way as a wiki link.

See parser.rs around line 200

        MdParseEnum::Paragraph => {
            let leaf_nodes = get_leaf_nodes(parse_node);
            let mut words = Vec::new();
            for node in leaf_nodes {
                let word_type = WordType::from(node.kind());
                let mut content = node.content().to_owned();

                if node.kind() == MdParseEnum::WikiLink {
                    let comp = Word::new(content.clone(), WordType::LinkData);
                    words.push(comp);
                }

                if content.starts_with(' ') {
                    content.remove(0);
                    let comp = Word::new(" ".to_owned(), word_type);
                    words.push(comp);
                }
                words.push(Word::new(content, word_type));
            }
            if let Some(w) = words.first_mut() {
                w.set_content(w.content().trim_start().to_owned());
            }
            Component::TextComponent(TextComponent::new(TextNode::Paragraph, words))
        }

This will allow the link to be selectable and not just colourable.

@orhun
Copy link
Contributor Author

orhun commented Sep 5, 2024

Yeah, that'd be a good addition after I can make the parser correct :D

Right now the following file is recognized as Paragraph for some reason.

<https://inline.com>

And it is not being rendered at all.

Can you take a look at the pest file and let me know if I'm doing something wrong? 🤔

@henriklovhaug henriklovhaug changed the base branch from main to inline-link September 15, 2024 19:06
@henriklovhaug
Copy link
Owner

You can see some differences in PR #158

@orhun
Copy link
Contributor Author

orhun commented Sep 19, 2024

I was close! :D

@orhun orhun closed this Sep 19, 2024
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

Successfully merging this pull request may close these issues.

Link colors
2 participants