-
Notifications
You must be signed in to change notification settings - Fork 9
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
Parsing content in a fenced block (for a new plugin) #15
Comments
I added node.children.push(Node::new(InlineRoot::new(content, mapping))); and that gets the first line of the block parsed, but not the rest of it. Looking at https://github.com/rlidwka/markdown-it.rs/blob/master/src/parser/block/builtin/block_parser.rs, I don't see an analogous Or would I need to run the block parser directly? The code is in https://gitlab.com/digitalmoksha/glfm_multiline_blockquote.rs/-/blob/master/src/lib.rs |
Ideally a Rust port of https://github.com/markdown-it/markdown-it-container would solve it |
I've got things working like this. use markdown_it::{NodeValue};
use markdown_it::parser::block::{BlockRule, BlockState};
use markdown_it::common::sourcemap::SourcePos;
struct MyBlockType;
impl NodeValue for MyBlockType {...}
struct MyBlockTypeScanner;
impl BlockRule for MyBlockTypeScanner {
fn run(state: &mut BlockState) -> Option<(Node, usize)> {
let start_line = state.line;
let end_line = start_line + 10; // for example
let (content, _mapping) = state.get_lines(start_line, end_line);
let mut node = state.md.parse(content);
node.replace(MyBlockType);
node.srcmap = Some(SourcePos::new(start_line, end_line));
Some((node, end_line - start_line));
}
} P.S. I'm just guessing with the source map stuff. Not sure how to test it. |
Actually, I think this is the way to do it... |
Hi, I'm writing a plugin that adds syntax for multiline block quotes, such as
In general I have it working by creating a version of
FenceScanner
(asMultilineBlockquoteScanner
) andCodeFence
(asMultilineBlockquote
). Of course, the code fencing doesn't parse the content inside the fence, which needs to happen for a blockquote.I've replaced the
fmt.text(&self.content);
withfmt.contents(&node.children);
when rendering the newMultilineBlockquote
node.However I'm having trouble figuring out how to actually get the contents parsed and added as children.
Any suggestions?
The text was updated successfully, but these errors were encountered: