Git Product home page Git Product logo

Comments (7)

archiewood avatar archiewood commented on June 24, 2024

Alternative would be to identify .md documents as Evidence using some other method.

Eg

---
md_flavour: Evidence
---

etc

Regarding rendering on Github and other platforms, there is an interesting thread about R markdown here, which might be instructive: https://yihui.org/en/2018/10/rmd-github/

from evidence-vscode.

RandomFractals avatar RandomFractals commented on June 24, 2024

@archiewood, we can certainly identify when we load emd markdown document.

The problem with the current emd language config is that it overwrites default markdown document Preview, Outline and rendering when .md documents are created or open in VS Code.

I outlined the solution we'll pursue to resolve this issue in this slack thread.

Brief notes:

  1. VS Code uses markdown-it engine.
  2. In order to tap into it, we'd need to create evidence markdown-it plugin.
  3. Then we need to enable custom markdown plugins in package.json by adding markdown.markdownItPlugins ext. contribution point.
  4. Then we should create our own custom .md preview that will render your app content via new Preview in simple browser added in sprint 1, or via markdown.showPreview if there is no custom emd content in the loaded .md doc.

Then and only then we can make everything work without breaking default markdown Preview in vscode. Example of hooking up custom markdown-it plugin in vscode extension:

import * as vscode from 'vscode';
import * as path from 'path';
import * as fs from 'fs';

export function activate(context: vscode.ExtensionContext) {
  const md = require('markdown-it')();
  const extPath = context.extensionPath;
  const customPluginPath = path.join(extPath, 'customPlugin.js');
  const customPlugin = fs.readFileSync(customPluginPath, 'utf8');

  md.use(require(customPlugin).extendMarkdownIt);

  context.subscriptions.push(
    vscode.commands.registerCommand('extension.previewMarkdown', () => {
      const editor = vscode.window.activeTextEditor;
      if (editor) {
        const document = editor.document;
        const uri = document.uri;
        if (uri.scheme === 'file') {
          vscode.commands.executeCommand('markdown.showPreview', uri);
        }
      }
    })
  );
}

from evidence-vscode.

mcrascal avatar mcrascal commented on June 24, 2024

Then we should create our own custom .md preview that will render your app content via new Preview in simple browser added in sprint 1, or via markdown.showPreview if there is no custom emd content in the loaded .md doc.

@RandomFractals

  1. How do we detect "custom emd content"?
  2. Is there a particular reason to offer the markdown.showPreview option? If I am working on an evidence project, I think I would always want to see the preview in a browser.

from evidence-vscode.

RandomFractals avatar RandomFractals commented on June 24, 2024

@mcrascal even the template Evidence project has README.md which should show up as Markdown document not Evidence Markdown and the built-in markdown.showPreview command should be available to all .md files independent of the open project. Current emd config hides it for all standard .md docs and needs to be resolved.

image

from evidence-vscode.

RandomFractals avatar RandomFractals commented on June 24, 2024

Partial patch for the built-in markdown previews was added in #29.

We should also remove your custom keybdings remapping those built-in commands.

Extensions should not change built-in shortcuts or map built-in commands to new shortcuts. We can only use them as was added in #29.

from evidence-vscode.

RandomFractals avatar RandomFractals commented on June 24, 2024

The official vscode markdown Preview documentation for more info:

https://code.visualstudio.com/Docs/languages/markdown#_markdown-preview

from evidence-vscode.

RandomFractals avatar RandomFractals commented on June 24, 2024

Closing this ticket. The missing markdown Outline will be added in #33.

from evidence-vscode.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.