Skip to content
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

Render markdown as HTML #1

Open
nikomatsakis opened this issue Jun 9, 2024 · 4 comments
Open

Render markdown as HTML #1

nikomatsakis opened this issue Jun 9, 2024 · 4 comments

Comments

@nikomatsakis
Copy link
Collaborator

The current chat is just dumping text into the window. It looks terrible.

image

We should render the markdown to HTML.

(We could also use the "real" chat that VSCode provides and make a chat participant, but I kind of like having full control over the interface, and I also want the freedom to move to smaller, local models, etc)

@nikomatsakis
Copy link
Collaborator Author

copilot suggested markdown be converted with markdown-it....not sure if there's a better library out there.

import * as vscode from 'vscode';
import MarkdownIt from 'markdown-it';

export function convertMarkdownToHtml() {
    const editor = vscode.window.activeTextEditor;
    if (!editor) {
        vscode.window.showInformationMessage('No editor is active');
        return;
    }

    const document = editor.document;
    const markdown = document.getText();

    const md = new MarkdownIt();
    const html = md.render(markdown);

    // Now you can use the HTML string
    console.log(html);
}

@nikomatsakis nikomatsakis self-assigned this Jun 10, 2024
@nikomatsakis
Copy link
Collaborator Author

This interferes with tolerable demos so I'm going to see what I can do quickly.

@nikomatsakis
Copy link
Collaborator Author

ok, did the very minimum. Unassigning myself but leaving issue open since there's so much room to make this less ugly. Other interesting add-ons include #8 (e.g., decorating source blocks) and that sort of thing.

@kwdev
Copy link
Collaborator

kwdev commented Jun 10, 2024

bad formatting

Different example with different formatting, also doesn't look great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants