Coder Social home page Coder Social logo

microsoft / vscode-markdown-languageservice Goto Github PK

View Code? Open in Web Editor NEW
398.0 15.0 9.0 681 KB

The language service that powers VS Code's Markdown support, extracted so that it can be reused by other editors and tools

License: MIT License

JavaScript 0.72% TypeScript 99.28%
lsp markdown vscode

vscode-markdown-languageservice's Introduction

VS Code Markdown Language Service

The language service that powers VS Code's Markdown support, extracted so that it can be reused by other editors and tools.

Features

This library targets CommonMark. Support for other Markdown dialects and extensions is not within the scope of this project.

Currently supported language features:

  • Document links (clickable spans in the editor)

    Supported links include:

    • Links to headers within the current file: [text](#header)
    • Absolute and relative links to files: [text](path/to/file.md)
    • Reference links: [text][link-name]
  • Document symbols

    Finds all headers within a markdown file

  • Workspace symbols

    Find all headers across all markdown files in the workspace.

  • Folding ranges

    Folding ranges are computed for:

    • Header sections
    • Region sections
    • Lists
    • Block elements
  • Smart select (expand selection)

  • Completions

    Supports completions for:

    • Links to headers
    • Path links
    • Reference links
  • Hover previews for images and videos

  • Find all references

    Supports finding references to:

    • Headers
    • Path links
    • Fragments in links
    • Reference links
  • Definitions

    Supports finding definitions headers and reference links.

  • Renames

    Supports renaming of headers and links.

  • Organize link definitions.

    Groups and sorts link definitions in a file, optionally also removing unused definitions.

  • Code actions

    • Extract all occurrences of a link in a file to a link definition at the bottom of the file.
    • Quick fixes for removing duplicated or unused link definitions.
  • Diagnostics (error reporting)

    Supports generating diagnostics for invalid links to:

    • References.
    • Header within the current file.
    • Files in the workspace.
    • Headers in other files.

    Also can generate diagnostics for:

    • Unused link definitions.
    • Duplicate link definitions.
  • Update links on file rename

    Generate an edit that updates all links when a file/directory in the workspace is renamed or moved.

  • (experimental) Update links when coping and pasting text between files.

Usage

To get started using this library, first install it into your workspace:

npm install vscode-markdown-languageservice

To use the language service, first you need to create an instance of it using createLanguageService. We use dependency injection to allow the language service to be used in as many contexts as possible.

import * as md from 'vscode-markdown-languageservice';

// Implement these
const parser: md.IMdParser = ...;
const workspace: md.IWorkspace = ...;
const logger: md.ILogger = ...;

const languageService = md.createLanguageService({ workspace, parser, logger });

After creating the service, you can ask it for the language features it supports:

// We're using the vscode-language types in this demo
// If you want to use them, make sure to run:
//
//     npm install vscode-languageserver vscode-languageserver-textdocument
//
// However you can also bring your own types if you want to instead.

import { CancellationTokenSource } from 'vscode-languageserver';
import { TextDocument } from 'vscode-languageserver-textdocument';

const cts = new CancellationTokenSource();

// Create a virtual document that holds our file content
const myDocument = TextDocument.create(
	URI.file('/path/to/file.md').toString(), // file path
	'markdown', // file language
	1, // version
	[ // File contents
		'# Hello',
		'from **Markdown**',
		'',
		'## World!',
	].join('\n')
);

const symbols = await languageService.getDocumentSymbols(myDocument, { includeLinkDefinitions: true }, cts.token);

See example.cjs for complete, minimal example of using the language service. You can run in using node example.cjs.

Additional Links

Contributing

If you're interested in contributing

  1. Clone this repo
  2. Install dependencies using npm install
  3. Start compilation using npm run watch

You can run the unit tests using npm test or by opening the project in VS Code and pressing F5 to debug.

vscode-markdown-languageservice's People

Contributors

bpasero avatar dependabot[bot] avatar lramos15 avatar lszomoru avatar microsoft-github-operations[bot] avatar microsoftopensource avatar mjbvz avatar remcohaszing avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vscode-markdown-languageservice's Issues

Make it easier to create a link to a header anywhere by name

Feature request

To create a link to a header in another file, currently I have to remember what file I want and type out the entire path. It would be nicer if I could just type out the header name and insert (or complete) a link to that header

bug(): extract link definition of assets

Type: Bug

The following syntax is buggy when trying to use extract link definition:

[![asset_name](asset_link)](link)

README.md.-.fabric.js.-.Visual.Studio.Code.2022-10-15.11-14-59.mp4

Opened as requested by microsoft/vscode#162149 (comment)


VS Code version: Code 1.72.2 (d045a5eda657f4d7b676dedbfa7aab8207f8a075, 2022-10-12T22:15:18.074Z)
OS version: Windows_NT x64 10.0.19043
Modes:
Sandboxed: No

System Info
Item Value
CPUs Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz (4 x 2712)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off
Load (avg) undefined
Memory (System) 7.87GB (1.30GB free)
Process Argv C:\Users\DELL\Desktop\DEV\fabric.js --crash-reporter-id ed04e42e-1d11-4683-872f-421f0db5bcc0
Screen Reader no
VM 0%
Extensions (32)
Extension Author (truncated) Version
vscode-zipfs arc 3.0.0
doxdocgen csc 1.4.0
vscode-eslint dba 2.2.6
prettier-vscode esb 9.9.0
vscode-pull-request-github Git 0.52.0
gitpod-desktop git 0.0.60
better-cpp-syntax jef 1.16.1
cmake-language-support-vscode jos 0.0.7
vscode-docker ms- 1.22.2
vscode-dotnet-runtime ms- 1.5.0
remote-containers ms- 0.255.4
remote-ssh ms- 0.90.1
remote-ssh-edit ms- 0.84.0
remote-wsl ms- 0.72.0
vscode-remote-extensionpack ms- 0.21.0
cmake-tools ms- 1.12.27
cpptools-extension-pack ms- 1.3.0
vsliveshare ms- 1.0.5739
vsliveshare-audio ms- 0.1.91
vscode-react-native msj 1.9.3
vetur oct 0.36.0
java red 1.11.0
code-spell-checker str 2.10.1
cmake twx 0.0.17
intellicode-api-usage-examples Vis 0.2.6
vscodeintellicode Vis 1.2.29
vscode-java-debug vsc 0.45.0
vscode-java-dependency vsc 0.21.0
vscode-java-pack vsc 0.25.3
vscode-java-test vsc 0.37.1
vscode-maven vsc 0.39.0
vscode-ruby win 0.28.0

(1 theme extensions excluded)

A/B Experiments
vsliv368cf:30146710
vsreu685:30147344
python383cf:30185419
vspor879:30202332
vspor708:30202333
vspor363:30204092
vslsvsres303:30308271
pythonvspyl392:30443607
vserr242cf:30382550
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vshan820:30294714
vstes263:30335439
vscorecescf:30445987
pythondataviewer:30285071
vscod805cf:30301675
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
cmake_vspar411:30581797
vsaa593:30376534
pythonvs932:30410667
cppdebug:30492333
vsclangdc:30486549
c4g48928:30535728
dsvsc012cf:30540253
azure-dev_surveyonecf:30548226
i497e931:30553904
pyindex848:30577860
nodejswelcome1:30587005
40g7c324:30573242

Renaming markdown files corrupts links with fragments and angle brackets

Type: Bug

Create a project with 2 files:

foobarA.md:

# header A

[foobarB: header-1](<foobarB.md#header-1>)

foobarB.md:

# header 1

[foobarA: header-a](<foobarA.md#header-a>)

Rename either file and answer yes to the "Update Markdown links" prompt.

The links in one or both files will be broken. The fragment delimiter ('#') and the left angle ('<') are deleted:

# header A

[foobarB: header-1](foobarB2.mdheader-1>)

VS Code version: Code 1.82.2 (abd2f3db4bdb28f9e95536dfa84d8479f1eb312d, 2023-09-14T05:55:25.390Z)
OS version: Windows_NT x64 10.0.22621
Modes:

System Info
Item Value
CPUs AMD Ryzen 7 3750H with Radeon Vega Mobile Gfx (8 x 2296)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
Load (avg) undefined
Memory (System) 13.95GB (3.40GB free)
Process Argv --crash-reporter-id f4d11365-b8df-4076-a7d2-5647e124f85c
Screen Reader no
VM 0%
Extensions: none
A/B Experiments
vsliv368cf:30146710
vsreu685:30147344
python383:30185418
vspor879:30202332
vspor708:30202333
vspor363:30204092
vslsvsres303:30308271
vserr242cf:30382550
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vsdfh931cf:30280410
vshan820:30294714
vstes263cf:30335440
vscoreces:30445986
vscod805:30301674
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
vsaa593cf:30376535
pythonvs932:30410667
py29gd2263cf:30792227
vscaac:30438847
vsclangdf:30486550
c4g48928:30535728
dsvsc012cf:30540253
pynewext54:30695312
azure-dev_surveyone:30548225
2e4cg342:30602488
f6dab269:30613381
showlangstatbar:30737416
03d35959:30757346
pythonfmttext:30731395
fixshowwlkth:30771522
showindicator:30805244
pythongtdpath:30769146
i26e3531:30792625
pythonnosmt12:30797651
pythonidxpt:30805730
pythonnoceb:30805159
copilotsettingc:30839828
synctok:30821570
dsvsc013:30795093
dsvsc014:30804076
diffeditorv1:30821571
dsvsc015cf:30829746

Figure out what to do about case insensitive file systems (if anything)

From microsoft/vscode#167857

Problem

Paths on windows are case insensitive. However this library makes a lot of assumptions about paths being case sensitive. Examples:

  • Path validation
  • Find all references
  • Rename

This means that if the casing of paths doesn't exactly match, we can end up missing references and reporting false positive diagnostics. We should figure out what to do about this (if anything)

MD files don't always get marked dirty & don't always identify problems

After initially filing this on VSCode, I'm refiling it here as I've only been able to reproduce on MD files, and consistently on the same files across machines. (in my case I'm using this primarily with my Obsidian vault... but I can duplicate all behavior with Obsidian closed, so it's not related to the syncing, or anything else in that app)

When I say "certain files" at the start of the next paragraph, I haven't noticed any pattern that would let me be more specific

For certain files, when the file is open, problems will not get yellow squiggles under them although they show int he problems list & the tab turns yellow. When this occurs, editing the document will not mark the file dirty, resulting in Save doing nothing. With a file in this state, closing & restarting VSCode will mark the file as dirty, but saving it will not mark the file as clean (unless the save is triggered by closing the dirty file). At that point restarting VSCode again will still show the file dirty even though it's saved. Saving here will result in a file conflict error from VSCode, although both versions are identical. If instead of saving the file, the file is Reverted, the file will then be marked clean again.

A side effect of this is that closing one of these dirty but unsaved files will result in the sidebar showing a count of dirty files that is greater than the number of dirty files open in tabs.

Some things I've tried, and their results...

  • disabling all extensions: no effect... the problems went away since Markdownlint was off, but the same files still produced the same behavior
  • deleting my %APPSETTINGS%/Code folder, except for the user settings json, keybindings json, and snippets... no effect
  • opening a file that consistently reproduces this issue, and removing the problem area... get the file to save, restart VSCode, open the file, then restore the file contents to its original... that file now behaves correctly, consistently

I did pour through the logging in the VSCode Output window and the only error I saw was an unexpected null thrown from the changecase extension... but it was showing in the MD language service logs even when I had that extension disabled (and yes, I had restarted)

if there's anything else I can copy-paste in here that might help isolate this, please let me know

markdown link in format [`abc`] not shown as link

Does this issue occur when all extensions are disabled?: Yes

[`abc`]  // <-- this is not shown as link

[`abc`]: https://some-link

The preview is working as expected.

I sometimes do that to links so that spell checker will ignore them.

Version: 1.72.0 (user setup)
Commit: 64bbfbf67ada9953918d72e1df2f4d8e537d340e
Date: 2022-10-04T23:20:39.912Z
Electron: 19.0.17
Chromium: 102.0.5005.167
Node.js: 16.14.2
V8: 10.2.154.15-electron.0
OS: Windows_NT x64 10.0.22621
Sandboxed: No

Add organize link definitions source action

Feature request

Add a code action / source action that:

  • Consolidates link definitions at the end of the file
  • Sorts link definitions
  • Potentially removes unused definitions (may be a separate action)

“Links” in Markdown Math Wrongly Validated

Does this issue occur when all extensions are disabled?: Yes. (I've tried Developer: Reload With Extensions Disabled)

  • VS Code Version: Code 1.68.0 (4af164ea3a06f701fe3e89a2bcbb421d2026b68f, 2022-06-08T11:44:16.822Z)
  • OS Version: Windows_NT x64 10.0.19043

Steps to Reproduce:

  1. Enable markdown.math.enabled, markdown.experimental.validate.enabled.
  2. Create a markdown file.
  3. Write$[0,1]$.
  4. “No link definition found: '0,1'”

image

Temporary solution: Write $[0, 1]$ instead. (insert a space after the comma)

Markdown - VSCode Mangles Anchor Links For Headings Containing Underscores

Type: Bug

When editing a markdown file, VSCode improperly mangles anchor links for heading containing underscores.

Consider the following markdown (link to later heading):
My Heading With_Underscore

Later in the file, the heading would be

My Heading With_Underscore

Some text in this section

When typing the link, VSCode will autocomplete the mangled link "#my-heading-withunderscore", with the underscore removed. However, this will not work with other platforms, like Github. Additionally, markdown extensions that generate TOC with links based on headings generate the links with the underscore included.

If the link contains the underscore it works with other platforms, like Github, but does not work within VSCode. (preview) If the link is created without the underscore it works within VSCode, but not other platforms, like Github.

VSCode should be updated to support markdown anchor/heading links containing underscores.

Note, this was also tested without any extensions installed on VSCode 1.71.0.

VS Code version: Code 1.71.0 (784b0177c56c607789f9638da7b6bf3230d47a8c, 2022-09-01T07:36:10.600Z)
OS version: Windows_NT x64 10.0.22000
Modes:
Sandboxed: No

System Info
Item Value
CPUs 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz (8 x 2995)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off
Load (avg) undefined
Memory (System) 15.85GB (6.02GB free)
Process Argv --crash-reporter-id 61969c6e-228b-4ba9-8a7d-1a30bd79db8a
Screen Reader no
VM 0%
Extensions: none
A/B Experiments
vsliv368cf:30146710
vsreu685:30147344
python383:30185418
vspor879:30202332
vspor708:30202333
vspor363:30204092
vslsvsres303:30308271
pythonvspyl392:30443607
vserr242:30382549
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vsdfh931:30280409
vshan820:30294714
vstes263:30335439
pythondataviewer:30285071
vscod805:30301674
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
cmake_vspar411:30557514
vsaa593:30376534
pythonvs932:30410667
cppdebug:30492333
pylanb8912:30545647
vsclangdf:30486550
c4g48928:30535728
hb751961:30553087
dsvsc012cf:30540253
azure-dev_surveyone:30548225
2144e591:30553903

Escaped md links recognized as links

Issue Type: Bug

  1. For the md:
\[text](./bla)

🐛

This is recognized as a link even though the [ is escaped

VS Code version: Code - Insiders 1.69.0-insider (Universal) (4c72dedb4ad283a569f83a7389468c3ae2c642c3, 2022-06-20T05:17:11.836Z)
OS version: Darwin x64 21.5.0
Restricted Mode: No

System Info
Item Value
CPUs Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz (16 x 2400)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
Load (avg) 3, 3, 3
Memory (System) 32.00GB (0.04GB free)
Process Argv --crash-reporter-id 48781ca2-1705-4f64-9bab-325055aab55d
Screen Reader no
VM 0%

Rename support

Tracks moving support for renaming in markdown from VS Code to the service

Markdown lint for links is not correct.

Does this issue occur when all extensions are disabled?: Yes/No

This is the markdown link I wrote

### [fs.openSync(path[,flags[,mode]])](https://nodejs.org/api/fs.html#fsopensyncpath-flags-mode)

VS Code linter complains that link.no-such-reference
image

  • VS Code Version: 1.73.1
  • OS Version: Windows_NT x64 10.0.19044

Steps to Reproduce:

  1. Create a markdown file
  2. Copy this code into the file
    ### [fs.openSync(path[,flags[,mode]])](https://nodejs.org/api/fs.html#fsopensyncpath-flags-mode)
    

Ability to provide an ignore list of reference links for markdown validation

When creating a README.md file for a GitLab repo, I received the following validation error after adding a reference of [TOC] 1. I recognize this Table of Contents element is a feature extension added by GitLab to the standard Markdown syntax, so there was no surprise that I received the following error: No link definition found: 'TOC'.

While searching for a way to disable or ignore this one error, I ran across https://stackoverflow.com/questions/75252767/have-vscode-ignore-specific-reference-links-in-markdown-validation, but there was no known solution offered.

As suggested in the the SO thread, it would be nice if there was a way to ignore just this one 'TOC' entry via an ignore list, instead of having to to completely disable reference link validation (with "markdown.validate.referenceLinks.enabled": "ignore") for the whole project.

Is there currently a way to ignore this TOC link that I've missed?

If not possible through some current means, can the reference link validation be modified to also consider entries in the markdown.validate.ignoredLinks list or a separate setting added for providing a list of reference links that should be ignored?

The setting under markdown.validate that I did find (markdown.validate.referenceLinks.enabled) does work, but is not desirable since it turns off all reference link validation for the whole project. What I was hoping for was a way to keep that validation rule enabled, but be able to provide an explicit list of links that would be ignored.

I tried adding the following configuration, but it did not work as I hoped it would:

"markdown.validate.ignoredLinks": [ "TOC" ] 

A little more detail on the specific error reported:

[{
	"resource": "/c:/Projects/..../readme.md",
	"owner": "markdown",
	"code": "link.no-such-reference",
	"severity": 4,
	"message": "No link definition found: 'TOC'",
	"startLineNumber": 17,
	"startColumn": 2,
	"endLineNumber": 17,
	"endColumn": 5
}]

Footnotes

  1. https://docs.gitlab.com/ee/user/markdown.html#table-of-contents

Add autocompletion support for reference links

Today, you can autocomplete URL links. For example, typing this will trigger completion starting at "bar":

[foo](##bar)

However, you currently can't autocomplete reference links. It would be great if you could do that, as well. In particular, in this example, completion should start at the first "bar":

[foo][bar]

[bar]: ./bar.md#baz

This would make working with Markdown files that use reference links much easier.

Some Markdown supports does not deal with multibyte character

This problem still occurs even if you disable all extensions and occurs in both stable and insider.

The following features do not deal with multibyte characters well. It encodes multibyte characters. Do not encode.

The path intellisense for headings works correctly.
Markdown rename support includes “Rename reference links”, but reference links works correctly.

Demonstrations

  .
  |- テスト1.md
  `- テスト2.md
<!-- テスト1.md -->
# 見出し

[見出し](#見出し)

[Visual Studio Code April 2022][vscode]

[vscode]: https://code.visualstudio.com/updates/v1_67

[テスト2の見出し](テスト2.md#見出し)
<!-- テスト2.md -->
# 見出し
  • Markdown path IntelliSense

    Image path IntelliSense

  • Drop into editor to create link

    Image Drop into editor to create link

  • Rename Headers

    Image Rename headers

    Image Rename headers

  • Rename Files

    Image Rename files

Rename reference links works correctly.

Image Rename reference links

Version

 Version: 1.67.2 (user setup)
  Commit: c3511e6c69bb39013c4a4b7b9566ec1ca73fc4d5
    Date: 2022-05-17T18:15:52.058Z
Electron: 17.4.1
Chromium: 98.0.4758.141
 Node.js: 16.13.0
      V8: 9.8.177.13-electron.0
      OS: Windows_NT x64 10.0.19043
 Version: 1.68.0-insider (user setup)
  Commit: c0769274fa136b45799edeccc0d0a2f645b75caf
    Date: 2022-05-23T05:17:12.256Z
Electron: 17.4.4
Chromium: 98.0.4758.141
 Node.js: 16.13.0
      V8: 9.8.177.13-electron.0
      OS: Windows_NT x64 10.0.19043

Add "Convert to reference link" refactoring

Feature request

Add a quick fix on links that goes from:

[text](http://example.com)

to

[text][ref] and rename should be triggered here after change

[ref]: http://example.com

Support smart selection for Markdown table

Future request

Some smart select in markdown is supported in microsoft/vscode#107410. However, markdown table is not supported in this issue.

In Markdown table, it would be nice to be able to select each cell with smart select.

Current situation

Demonstrate using the table below.

| Contents  | Description         |
| :-------: | :------------------ |
|  Fruits   | Sweet and delicious |
| Vegetable | Nutritious          |
|   Meat    | Source of power     |
  • Select cell of 2-1 with smart selection (Shift+Alt+Right one time)

    Select cell of 2-1

  • Select cell of 3-2 with smart selection (Shift+Alt+Right three times and Shift+Alt+Left three times)

    Select cell of 3-2

Expected behavior

  • Select cell of 2-1 with smart selection

    Select cell of 2-1

  • Select cell of 3-2 with smart selection

    Select cell of 3-2

Version

  • Stable

     Version: 1.69.0 (user setup)
      Commit: 92d25e35d9bf1a6b16f7d0758f25d48ace11e5b9
        Date: 2022-07-07T05:28:36.503Z
    Electron: 18.3.5
    Chromium: 100.0.4896.160
     Node.js: 16.13.2
          V8: 10.0.139.17-electron.0
          OS: Windows_NT x64 10.0.22000
    
  • Insider

     Version: 1.70.0-insider (user setup)
      Commit: 3104db414c8fedcf6e4493f14da7df0b7413853a
        Date: 2022-07-08T05:20:13.606Z
    Electron: 18.3.5
    Chromium: 100.0.4896.160
     Node.js: 16.13.2
          V8: 10.0.139.17-electron.0
          OS: Windows_NT x64 10.0.22000
    

Make logging more consistent

The logging interface is currently very inconsistent about how it uses debug vs trace. My current thinking :

  • debug — Should log enough info to understand what the server is doing. This is what almost all the log calls do today
  • trace — Should be extremely verbose, such logging all arguments and return values

Link detection is not robust

Link detection currently uses some terrible regular expressions to find document links. This leads to links incorrectly being detected when they should not be, as well as us missing some potential links. The upside is that the regular expression are pretty fast

Ideally we should instead get the link data from the markdown AST. However markdown-it currently doesn't provide line,column data for link tokens (or even file offsets, unless I've missed something)


I previously explored using tree sitter for this but performance wasn't acceptable. Not sure if that's a fundamental issue or something we could fix. Having the position data from markdown-it though would be a better solution

Relevant issues:

Rename should try removing angle brackets if they are no longer needed

  1. With a file:
![](<sp ace.gif>)

Rename sp ace.gif to space.gif

Feature request
We should remove the angle brackets

This flow often happens when copying and pasting or dnding MacOS screenshots into a markdown file. The file name starts with spaces, but often you want to rename it to something more meaningful

`markdown.validate.referenceLinks.enabled` Improperly marking Jekyll YAML Headers as "No like definition found"

Type: Bug

  1. Have a jekyll YAML header in a markdown file like this
---
title:      Post Title Here
author:     Person Doe
categories: [catagory1, catagory2]
tags:       [tag1, tag2]
---
  1. The catagory and tags info within the [] will be marked as "No like definition found"

VS Code version: Code 1.73.0 (8fa188b2b301d36553cbc9ce1b0a146ccb93351f, 2022-11-01T15:38:50.881Z)
OS version: Darwin x64 21.6.0
Modes:
Sandboxed: No

System Info
Item Value
CPUs Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz (12 x 2900)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off
Load (avg) 3, 2, 2
Memory (System) 32.00GB (10.15GB free)
Process Argv .
Screen Reader no
VM 0%
Extensions (52)
Extension Author (truncated) Version
better-comments aar 3.0.2
Bookmarks ale 13.3.1
preview-mp4 ana 0.0.1
converttoasciiart Bit 1.0.3
doxdocgen csc 1.4.0
vscode-markdownlint Dav 0.48.1
gitlens eam 13.0.3
prettier-vscode esb 9.9.0
linter-gfortran for 3.2.0
pythonsnippets frh 1.0.2
ginfuru-vscode-jekyll-syntax gin 0.1.1
todo-tree Gru 0.0.219
fortran-ls han 0.6.2
jenkinsfile-support ivo 1.1.0
vscode-edit-csv jan 0.7.2
better-cpp-syntax jef 1.16.3
vsc-python-indent Kev 1.18.0
vscode-cudacpp kri 0.1.1
vscode-hdf5-viewer loc 0.0.3
bash-ide-vscode mad 1.14.0
vscode-autohotkey-plus-plus mar 3.0.0
git-graph mhu 1.30.0
anaconda-extension-pack ms- 1.0.1
isort ms- 2022.4.0
python ms- 2022.18.0
vscode-pylance ms- 2022.11.10
jupyter ms- 2022.9.1202862440
jupyter-keymap ms- 1.0.0
jupyter-renderers ms- 1.0.12
vscode-jupyter-cell-tags ms- 0.1.6
vscode-jupyter-slideshow ms- 0.1.5
remote-containers ms- 0.262.3
remote-ssh ms- 0.90.1
remote-ssh-edit ms- 0.84.0
remote-wsl ms- 0.72.0
vscode-remote-extensionpack ms- 0.21.0
cpptools ms- 1.12.4
vsliveshare ms- 1.0.5750
autodocstring njp 0.6.1
clang-tidy not 0.5.1
nsight-vscode-edition nvi 2022.2.31663688
material-icon-theme PKi 4.21.0
trailing-spaces sha 0.4.1
rewrap stk 1.16.3
code-spell-checker str 2.10.1
cmantic tde 0.9.0
pdf tom 1.2.0
latex-support tor 3.10.0
errorlens use 3.6.0
snippet-creator vin 1.1.0
better-align wwm 1.1.6
markdown-all-in-one yzh 3.4.3

(5 theme extensions excluded)

Support link with column numbers in the markdown editor

Hi 👋

The ticket microsoft/vscode#40140 added support for following markdown links that specify local paths including line numbers.

Existing behaviour:

Given two files and their content:

a.md:

[b](./b.md#L3)

b.md:

1
2
3ABC
4
5

Clicking on link ./b.md#L3 in the markdown editor opens b.md with the cursor at the beginning of line 3.

Requested behaviour:

With this ticket I would liken to request support for adding also column numbers, so:

a.md:

[b](./b.md#L3C3)

b.md:

1
2
3ABC
4
5

Clicking on link ./b.md#L3C3 in the markdown editor should open b.md with the cursor position in line 3, letter B.

Thanks! 🙏

Add document highlighting support

https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_documentHighlight

Some cases for the cursor position:

On header (# header)

Should highlight all links in the current document to that header ([text](#header))

On reference link ([ref])

Should highlight the link definition as well as all uses of the reference link

On link path ([text](/path))

Should highlight all links to that file in the current document

On link path fragment ([text](/path#frag))

Should highlight all links to that specific fragment in the current document

TODO: maybe merge with the above case if having different highlighting for the fragment is too confusing

"No link definition found" for footnotes

When I use footnotes1, the language server generates a warning.

image

Here’s a repro, put this is src/test/diagnostic.test.ts:

	test('Should not generate diagnostic for valid footnotes', withStore(async (store) => {
		const doc = new InMemoryDocument(workspacePath('doc.test.md'), joinLines(
			`footnotes should work[^fn1]`,
			``,
			`[^fn1]: this is a footnote`,
		));

		const workspace = store.add(new InMemoryWorkspace([doc]));

		const diagnostics = await getComputedDiagnostics(store, doc, workspace);
		assertDiagnosticsEqual(diagnostics, []);
	}));

Footnotes

  1. https://github.blog/changelog/2021-09-30-footnotes-now-supported-in-markdown-fields/

Invalid link diagnostics support

Tracks moving support for computing diagnostics from VS Code to this service

We should also explore switching to a pull model for diagnostics since the LSP now supports this

Markdown Link Definitions: VS Code does not jump to link definition when label includes back-ticks

Markdown Link Definitions: VS Code does not jump to link definition when label includes back-ticks

Steps to reproduce the problem

(Please view this in the raw markdown and cut and paste it into VS Code to understand the issue fully)

In the example below, in the This Works example you will see that there is a valid link like under the github symbol and hovering over the symbol gives the tool tip 'Go to Link Definition' and clicking on the symbol will jump you to the bottom of the file and the associated link definition.

Conversly, in the This Doesn't Work example note that the label is surrounded by back-ticks and now the github symbol does not show a tool tip nor can it be clicked on to jump to the associated reference.

However, in preview mode both symbols will correctly redirect you to https://github.com

This Works

[github][github]

This Doesn't Work

[`github`][github]
<!-- links -->
[github]: https://github.com

Markdown footnote validation

Does this issue occur when all extensions are disabled?: Yes/No
Yes

  • VS Code Version: 1.73.1
  • OS Version: Windows_NT x64 10.0.19044

Steps to Reproduce:

  1. Create new markdown file
  2. Type a text:
text[^1]
[^1]: footnote
  1. See problems:
    (×) No link definition found: '^1' (link.no-such-reference) [Ln 1, Col 6]
    2022-11-22 14_23_58-test md - 555 - Visual Studio Code

Path suggestions insert invalid path if file name contains `%`

Type: Bug

Please consider following Markdown content:

[Link text](../../../../Tekninen-määrittely/Some-term-%2D-yet-more/File.md)

This is for wiki on Azure DevOps where we have to follow certain file naming conventions. Some-term-%2D-yet-more part from the example folder hierarchy is rendered as Some term - yet more on Azure DevOps wiki UI.

Previously VSCode's Markdown editor and preview window have resolved this correctly to actual file system file. I've observed lately that this kind of path having %2D doesn't work anymore as VSCode tries to access file system folder with - in its name instead of %2D in its name.

In pratice this means we cannot use VSCode's suggestions on Markdown links on quite many Azure DevOps wiki pages when we are using VSCode to edit those files nor we can use preview window to check if link is correct or not.

VS Code version: Code 1.81.1 (6c3e3dba23e8fadc360aed75ce363ba185c49794, 2023-08-09T22:22:42.175Z)
OS version: Windows_NT x64 10.0.19045
Modes:

Extensions (20)
Extension Author (truncated) Version
markdown-mermaid bie 1.19.0
LinkCheckMD bla 0.3.1
vscode-markdownlint Dav 0.51.0
vscode-html-validate htm 2.8.0
vscode-azurefunctions ms- 1.12.4
vscode-azureresourcegroups ms- 0.7.5
vscode-bicep ms- 0.20.4
csharp ms- 2.0.413
vscode-dotnet-runtime ms- 1.7.1
isort ms- 2023.10.1
python ms- 2023.14.0
vscode-pylance ms- 2023.8.40
jupyter ms- 2023.7.1002162226
jupyter-keymap ms- 1.1.2
jupyter-renderers ms- 1.0.17
vscode-jupyter-cell-tags ms- 0.1.8
vscode-jupyter-slideshow ms- 0.1.5
azure-account ms- 0.11.5
azurecli ms- 0.5.0
powershell ms- 2023.6.0
A/B Experiments
vsliv368:30146709
vsreu685:30147344
python383cf:30185419
vspor879:30202332
vspor708:30202333
vspor363:30204092
vslsvsres303:30308271
vserr242cf:30382550
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vshan820:30294714
vstes263:30335439
vscod805:30301674
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
vsaa593:30376534
pythonvs932:30410667
py29gd2263cf:30792227
vsclangdc:30486549
c4g48928:30535728
dsvsc012cf:30540253
pynewext54:30695312
azure-dev_surveyone:30548225
vsccc:30803844
3biah626:30602489
89544117:30613380
showlangstatbar:30737416
a2ce3375:30757347
pythonfmttext:30731395
fixshowwlkth:30771522
showindicator:30805244
pythongtdpath:30769146
i26e3531:30792625
gsofa:30804715
pythonnosmt12:30797651
pythonidxpt:30805730
pythonnoceb:30805159
asynctok:30821568
dsvsc013:30795093
dsvsc014:30804076
diffeditorv2:30821572

Feature Request: Show current reference link definition on hover

While working in a long Markdown document that extensively uses reference links, it can sometimes be frustrating to have to navigate to the link definitions and back to your original context while authoring/editing.

Hovering on a reference link allows you to go down to the definition:

Screenshot showing the go to definition UI when hovering on a reference

And you can use the go-to/find-all references to go back, but the UX isn't as smooth as it could be. It always requires some context switching to leave your current context, check the link, then go back.

If possible, it would be preferable to show the current definition in the hover UI and keep the option to jump to the definition if needed.

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.