Skip to content

Parse mardown from string inside remark plugin #725

Answered by stevemk14ebr
stevemk14ebr asked this question in Q&A
Discussion options

You must be logged in to vote

Nvm I figured it out. Cool :)

function myDerectives() {
    let RemarkParser = this;
    return (...args) => { transform(RemarkParser, ...args) } ;

    function transform(RemrkParser, tree) {
        visit(tree, ['textDirective'], (...args) => { ondirective(RemarkParser, ...args) } )
    }

    function ondirective(RemarkParser, node) {
        const content = NodeToString(node);
        const tag = node.name;
        if (tag === 'aster') {
            let replacementText = ... do some application specific stuff ...

            // currently using mdast-util-from-markdown
            let renderedChildren = RemarkParser.parse(replacementText);

            // get children of the new root,…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@wooorm
Comment options

Answer selected by ChristianMurphy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants