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

Linting inside Markdown blocks outside of .md files #25

Open
lleger opened this issue Jan 17, 2018 · 11 comments
Open

Linting inside Markdown blocks outside of .md files #25

lleger opened this issue Jan 17, 2018 · 11 comments

Comments

@lleger
Copy link

lleger commented Jan 17, 2018

Is it possible to get linting inside of Markdown-like blocks inside of non-Markdown files? The use case here is in Elixir documentation, which is formatted in Markdown, but it’s actually just a block inside of a .ex or .exs file.

From the above link, an example:

defmodule MyApp.Hello do
  @moduledoc """
  This is the Hello module.
  """

  @doc """
  Says hello to the given `name`.

  Returns `:ok`.

  ## Examples

      iex> MyApp.Hello.world(:john)
      :ok

  """
  def world(name) do
    IO.puts "hello #{name}"
  end
end

What’s between the """ of @moduledoc and @doc (and also, though not shown, @typedoc) is formatted with Markdown. Getting the warnings and/or, if possible, the auto-formatting inside of those blocks would be tremendous!

@DavidAnson
Copy link
Owner

Does VS Code recognize that section as Markdown? That’s the first step.

@lleger
Copy link
Author

lleger commented Jan 17, 2018

How be happy to check that for you — how does VSCode determine that, and how would I verify?

@DavidAnson
Copy link
Owner

Open the file in Code and see if you get Markdown intellisense in that block. Maybe also check if the language chooser in the lower right changes.

More info: https://code.visualstudio.com/docs/editor/intellisense

@lleger
Copy link
Author

lleger commented Jan 17, 2018

As far as I can tell, it doesn’t seem to be picking it up.

@DavidAnson
Copy link
Owner

Bummer. That’s definitely how I’d want to go about this. I’ll leave the issue open, but please don’t hold your breath. :)

@lleger
Copy link
Author

lleger commented Jan 17, 2018

Is that something that would have to be added upstream in VSCode itself in order to hook into it?

@DavidAnson
Copy link
Owner

That would be ideal, yes. If that support were present (and it might be, I just didn’t see it from my phone) then an extension could easily find out which parts of a document it can understand and could then process them. Without support like that, each extension needs to understand every relevant file type, parse it, and find the relevant sections. It’s possible, but it’s a lot more work and it doesn’t scale as well.

@lleger
Copy link
Author

lleger commented Jan 17, 2018

So, I think it must be possible already, since it works with HTML/JS. Test: create a file, set language to HTML. Add inline script tags. Type some JS—intellisense is there.

Google fu is failing me though, haven’t been able to figure out what it’s called in order to track down docs.

screen shot 2018-01-16 at 10 53 22 pm

@lleger
Copy link
Author

lleger commented Jan 17, 2018

I think this plugin does something similar: provides HTML intellisense inside of JS files. https://github.com/Microsoft/typescript-lit-html-plugin

@DavidAnson
Copy link
Owner

That extension seems to be implemented as a language service (a different thing) and uses a package by Microsoft specifically to enable template strings in TypeScript: https://github.com/Microsoft/typescript-template-language-service-decorator

I've looked a bit more and not found anything that looks like it does what I want. Also, the presence of languageId on TextDocument suggests a document is assumed to have just one format: https://code.visualstudio.com/docs/extensionAPI/vscode-api#_a-nametextdocumentaspan-classcodeitem-id38textdocumentspan

@texastoland
Copy link

Here's a grammar injection approach https://github.com/mjbvz/vscode-comment-tagged-templates.

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

No branches or pull requests

3 participants