Open digitalmoksha opened 1 year ago
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 BlockRoot
available.
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?