Notepad3 icon indicating copy to clipboard operation
Notepad3 copied to clipboard

Code folding for markdown

Open goyalyashpal opened this issue 2 years ago • 1 comments

Summary

It will be nice to have ability to fold the markdown code too

Details

The tags which can be supported:

  • # - headings tags (hashtags symbols)
  • <> ... </> - HTML tags (2 pairs of angle brackets)
    example: <details> ... </details> or the like.
  • ``` ... ``` or ~~~ ... ~~~ - code blocks (pair of triple backticks or tildes)
  • Sub-lines & subitems under a list item

Samples

  • Screen record of code folding for markdown in vscodium (using "symbols"

https://user-images.githubusercontent.com/19423063/173225822-6aaf7b82-531a-48ed-b7da-1c5be5413349.mp4

Versions:

Notepad3 (x64) v5.21.1129.1 (ba6de2c2)
Compiler: MS Visual C++ 2022 v17.0.(0-1) (VC v1930)
OS Version: Windows 10  Version 20H2 (Build 19042)
Windows Colors 'Dark-Mode' Theme is SUPPORTED and SELECTED.
Scintilla v511
Lexilla v511
Oniguruma v7.0.0
- Current Lexer -> 'Markdown'

goyalyashpal avatar Jun 12 '22 09:06 goyalyashpal

maybe related:

  • https://github.com/rizonesoft/Notepad3/issues/240
  • https://github.com/rizonesoft/Notepad3/issues/1902

goyalyashpal avatar Jun 12 '22 09:06 goyalyashpal

Code-Folding is a thing the Lexer cares for, better to send this enhancement request to Lexilla (https://github.com/ScintillaOrg/lexilla/issues).

RaiKoHoff avatar Oct 20 '22 09:10 RaiKoHoff

Code-Folding is a thing the Lexer cares for ...

Just mentioning the following for my own:

  • lexer - works at word level
  • parser - workes at "sentence" level (src)

so, is LSP different than those?

  • I was thinking that maybe the VS-Code's Markdown language server can be used
  • oh, wait, notepad3 doesn't use MS's LSP right?
  • and for obvious reasons - "ugh MS" - am i right?

As for the:

  • ~"Lexilla upstream" - sure, i'd do that (not necessarily immediately though)
  • ~"close on approval" - thanks for the info, i'd say please let it stay open for a bit more, i'll close it in some weeks myself

goyalyashpal avatar Oct 22 '22 01:10 goyalyashpal

Hello @yashpalgoyal1304 ,

About lexer & parser: word vs. sentence is a nice (still very simple) analogy. A lexer tries to identify language related "tokens" (keywords, operators, numbers, strings, comments, etc.). A parser tries to find a sensible structure, e.g. 123 + 456 -> number plus-op number -> sum -> part-of-expression. So, a parser is based on a lexer to get a stream of tokens to build structures. For syntax highlighting, you need mainly a lexer, since you are highlighting tokens. Lexilla provides lexers for several programming languages (like MS's LSP). For code-folding you need a parser to identify the structure: code-blocks. Most of Lexilla's "lexers" also have a code-block parser inside, so they are a little bit more than a simple lexer but far away from being a complete parser. Unfortunately, Lexilla's Markdown lexer does not provide a code-block parser, so code-folding is not available for Markdown.

Notepad2 & Notepad3 are historically based on Scintilla-Library (splitted into Core-Scintilla and Lexilla-Library some years ago). Switching Lexilla to MS' LSP would mean exchange the combustion engine of your car to an electric drive or adding an electric drive side-by-side. This does not really make sense.

Notepad3 can not and will not try to compete with VSCode (3 developers vs. 15000). Would be like comparing a leatherman multitool (NP3) vs. well equipped workshop. Notepad3 has its own place in the wide range of the tooling landscape - even it is an "classic vintage car" (in German: "Oldtimer").

And finally "no", there is no "ugh MS", all my development (work and free time) is MS based.

RaiKoHoff avatar Oct 22 '22 06:10 RaiKoHoff

Okay,

  • say i made required changes to the lexer from upstream, then what would be the steps to test those changes with notepad3 locally?
  • would i need to build notepad3 too? or can it link in some other way?

goyalyashpal avatar Oct 24 '22 07:10 goyalyashpal

Best would be to compile Notepad3 after integration of adapted Lexer. You can use Visual Studio Community Edition.

RaiKoHoff avatar Nov 18 '22 09:11 RaiKoHoff