-
-
Notifications
You must be signed in to change notification settings - Fork 140
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
Help reconsturcting comrak manually #186
Comments
Unfortunately, I won’t have the time to put this together for you. Maybe another user does! |
Wow, it is that difficult to programmatically add text to node? I'm sure you miss understood what I'm asking here. I simply want know how add content/text to a node, not asking you to help me build a manipulation library, I know how busy you are. Node {
data: RefCell {
value: Ast {
value: Paragraph,
start_line: 0,
content: [], //// how to access this?
open: true,
last_line_blank: false
}
} I tried the following but didn't work paragraph.data.borrow_mut().value.content = .....; For example in pulldown_cmark they does it with let inputs = vec![
(Event::Start(Tag::Paragraph), false),
(Event::Text("This is some text.".into()), false),
(Event::End(Tag::Paragraph), false),
(Event::Start(Tag::Heading(2)), true),
(Event::Text("Then a ".into()), true),
(Event::Start(Tag::Emphasis), true),
(Event::Text("header".into()), true),
(Event::End(Tag::Emphasis), true),
(Event::End(Tag::Heading(2)), true),
(Event::Start(Tag::Paragraph), false),
(
Event::Start(Tag::Link(
LinkType::Inline,
"https://example.com".into(),
"".into(),
)),
false,
),
(Event::Text("And a link".into()), false),
(
Event::End(Tag::Link(
LinkType::Inline,
"https://example.com".into(),
"".into(),
)),
false,
),
(Event::End(Tag::Paragraph), false),
]; Thanks |
It was not at all clear that's what you were asking. Per #175 (comment), you need to add a |
🥲 wish if your architecture and api considered future users aiming to build upon the library to create awesome extensions and tools. Although this still does not solve my issue, I will close and give up. Thanks @kivikakk |
The architecture maps exactly one-to-one with the architecture of Adding a All the best ❤️ |
And? so what? yours is in rust and much better, sadly limited to one-three helper function and the low level api just sucks and feels impossible. Yah the text thing is not a serious use case, but it shows how poor the api for supporting such a small tasks. Finally, why is it the way it is? If I ware you, and I came with such a great tool, I'd ensure that others have idiomatic apis that make their life easier and support further development. Anyway, I do apologize, please ignore me, I'm just a bit frustrated that's all. Thanks, all the best to you too 🤗 |
I'm just saying, the reason the node structure is as it is(text content is in a subnode and not just on the paragraph itself) is because it matches cmark-gfm, and the purpose of the design is that the internal structure will always match cmark-gfm in order to facilitate changing with the spec. (e.g. #183)
I'm not against adding helpers, I just don't have any desire to write them myself. I will accept thoughtful PRs. (I'm not against exposing anything; the reason that field isn't exposed is because exposing to users it would make no sense. As you've seen yourself, setting
Then please, do. I haven't used Rust myself in years. I maintain CommonMark/GFM spec compatibility, fix bugs and security issues that arise, and try to help users with what time and energy I can spare, but that's not a lot these days -- my priorities have changed a lot in the almost 5 years since I started this project. If you want to add those idiomatic APIs yourself, by all means do. I'm happy to spend proper time on reviewing larger changes. I don't have any intrinsic motivation to add such APIs myself: I am not a user of the library these days, just the author. But I am motivated to help others improve it if they would like to. |
❤️❤️🙏 |
Hey @kivikakk I'm trying to create a manipulation library for comrak to both solve a previous challenge I told you about and to have something to be reused in other projects.
I'd like to construct the following manually for learning purpose to
Thanks and sorry for the inconvenience
The text was updated successfully, but these errors were encountered: