Skip to content

Highlight code block at runtime #676

Closed
@faustbrian

Description

@faustbrian

I am currently trying to figure out if there is some way to render a code block at runtime. What I am trying to achieve is to create a highlighted JSON code block based on a response I receive from a request.

<template>
    <div>
        <div ref="request">
            <slot></slot>
        </div>

        <button @click="sendRequest">Something</button>
        
        <div ref="response">
// response here once the request is done
       </div>
    </div>
</template>

<script type="text/javascript">
    export default {
        methods: {
            sendRequest() {
                request(options).then(data => {
                    // show JSON.stringify(data) in this.$refs.response as highlighted JSON
                }).catch(err => {
                    // do nothing...
                })
            }
        }
    }
</script>

Is there any way to achieve this? Tried a few things and looked for a component but assume that markdown-it does the rendering for the normal templates.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: feature requestRequest to add a new featureversion: nextPlanned to do or already included in the next(1.0.0) version

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions