intorust / intorust.vscode

A VSCode extension for learning Rust
Other
9 stars 2 forks source link

Render markdown as HTML #1

Open nikomatsakis opened 3 months ago

nikomatsakis commented 3 months ago

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 commented 3 months ago

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 commented 3 months ago

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

nikomatsakis commented 3 months ago

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 commented 3 months ago
bad formatting

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