dendronhq / dendron

The personal knowledge management (PKM) tool that grows as you do!
https://wiki.dendron.so
Apache License 2.0
6.67k stars 252 forks source link

Add Emmet #319

Open tfer opened 3 years ago

tfer commented 3 years ago

Is your feature request related to a problem? No

Background:

Emmet is a system for quickly erecting a tree, (scaffold), of fill-in templates when coding in a Markup language. The problem is that Markdown is not a normal Markup language, it is intended to be converted into a Markup language, (usually HTML). As a consequence, no one has ever written an Emmet module for Markdown even though it would be very useful.

Describe the solution you'd like

example line for expansion:

h3*2>bl*3

becomes:

### |
  - |
  - |
  - |
### |
  - |
  - |
  - |

Where the pipe character stands in for a tabstop

Describe alternatives you've considered

See if the built in Emmet support can be made to handle this.

Additional context

Looking around VSCode doc, they mention that support for emmet expansion for languages that don't have built-in support can have that support put in a lsp for that language.

tfer commented 3 years ago

I going to put together a list of abbreviations that expand into useful Markdown constructs. e.g.

h1 -> # |
h2 -> ## |
kevinslin commented 3 years ago

Hmm, haven't thought of emmet for markdown. would builtin vscode snippets help with this?

tfer commented 3 years ago

Maybe, but maybe not. It appears Emmet is meant for Markup languages with open/close tag pairs. Markdown is a simplified syntax that gets expanded into a particular Markup language, (usually HTML), but I'm not sure that it even qualifies as a Markup language.

Emmet, (for a particular language), can include snippets. It has abbreviations which are triggers for expansion into various tag-pairs. Those abbreviations can be combined with emmet operators to form a string that expands into a tree of tag pairs that are nested, made siblings of, repeated, promoted, and decorated with other info.

I'm intending to get a better handle on this so I can flesh out this feature request.

tfer commented 3 years ago

One approach that I thought of last night, is to use emmet tuned to a target language, (HTML by default), take the output tree of an expansion, and then convert it into Markdown retaining the tabstops.

This might be a good approach, because it could made to leave emmet-html in place for when we want to embed HTML in a markdown note. Just have two expansion triggers, one to that yields markdown, and one that just expands into html.

kevinslin commented 3 years ago

It looks like vscode lets you use the builtin emmet snippets in other file types: https://code.visualstudio.com/docs/editor/emmet#_emmet-abbreviations-in-other-file-types

Looks like you also need these settings:

I like your idea of html -> markdown.

What would be helpful is if you had some sample use cases where using emmet syntax would hook into your workflow

tfer commented 3 years ago

Using the stackoverflow settings just gives you html expansions in markdown documents, not markdown expansions.

I'm going to post a table with 3 columns:

emmet string to expand HTML expansion HTML expansion to Markdown conversion

There are online HTML to Markdown convertors.

This should give a better idea of what we might want to support

kevinslin commented 3 years ago

I think you've convinced me that emmet for markdown would be useful to support. This would fall under the bucket of advanced functionality which we have currently set aside for the December bucket.

I'll do some more reading on emmet to figure out how we can best integrate this.

In the meanwhile, could I ask you to do a project proposal? You can see a sample one here. This will help me plan out the feature.