Lister-Plugin for Markdown formatted text documents?

Discuss and announce Total Commander plugins, addons and other useful tools here, both their usage and their development.

Moderators: white, Hacker, petermad, Stefan2

User avatar
petermad
Power Member
Power Member
Posts: 14739
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Lister-Plugin for Markdown formatted text documents?

Post by *petermad »

2rg_software
Works fine under Windows XP with https://www.dropbox.com/s/gyx3rzsp8bryucl/README.md?dl=1 :D
License #524 (1994)
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50b4 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
rg_software
Member
Member
Posts: 113
Joined: 2009-08-06, 12:59 UTC
Location: Aizu-Wakamatsu, Japan

Re: Lister-Plugin for Markdown formatted text documents?

Post by *rg_software »

Code: Select all

Could you explain it more detaily, please? 
What bug do you mean? 
What toolset/compiler have you used and what compiler switches have you changed/added?
Well, if you interested, the details are here. In a nutshell,

Code: Select all

/Zc:threadSafeInit-
compiler option is needed.
Thread-safe static local variables use thread-local storage (TLS) internally to provide efficient execution when the static has already been initialized. The implementation of this feature relies on Windows operating system support functions in Windows Vista and later operating systems. Windows XP, Windows Server 2003, and older operating systems do not have this support, so they do not get the efficiency advantage. These operating systems also have a lower limit on the number of TLS sections that can be loaded. Exceeding the TLS section limit can cause a crash. If this is a problem in your code, especially in code that must run on older operating systems, use /Zc:threadSafeInit- to disable the thread-safe initialization code.
As of your comments on functionality -- yes, duly noted. I can't promise any quick fixes soon, since most of them actually caused with the fact that there is no html document to be loaded into the HTMLView window, which breaks some functionality, and there is no easy way to fix it.

Let me elaborate. In principle, the Web browser component used by HTMLView is designed to load and display an HTML file specified with a URL. Here I have to convert markdown into HTML in-memory and display the resulting data. In the first version of the plugin I tried to save a temp file on the disk and show it, but this solution has other disadvantages. So I go with in-memory processing.

Loading in-memory data into Web browser is not really supported, but there are quite hacky ways to do it. Regardless of the particular hack, there is no real URL-specified document anymore and thus no base directory, no way to refresh or reload it, and so on (for example, you cannot change character encoding if it was guessed incorrectly).

Basically, the only difference between the current plugin and the original HTMLView is this difference: disk file vs. in-memory string. Otherwise the functionality should be identical. So I get your points, but to be honest I simply cannot estimate how hard is to fix any of them and whether it is possible at all (for instance, I need to override menu actions of the right-click context menu, but I have no idea whather this is can be done).
User avatar
Usher
Power Member
Power Member
Posts: 1675
Joined: 2011-03-11, 10:11 UTC

Re: Lister-Plugin for Markdown formatted text documents?

Post by *Usher »

rg_software wrote: 2018-12-27, 20:36 UTC In a nutshell,

Code: Select all

/Zc:threadSafeInit-
compiler option is needed.
in code that must run on older operating systems, use /Zc:threadSafeInit- to disable the thread-safe initialization code.
Thanks a lot for your explanations and for your great work.
rg_software wrote: 2018-12-27, 20:36 UTC I tried to save a temp file on the disk and show it, but this solution has other disadvantages. So I go with in-memory processing.
I think you should create html file in the directory of the source md file, if possible. That way linking and navigation inside large documents will work OK - to me it's a key feature of markdown format and its support is a must.

And if the directory is read-only, use %temp% dir instead. Current hack for in-memory work is really ugly - Lister shows about:blank in the title as a file name…

And in any case you should disable unavailable buttons.
rg_software wrote: 2018-12-27, 20:36 UTC (for example, you cannot change character encoding if it was guessed incorrectly).
Well, markdown files by default are in UTF-8, so it's not the case…
Andrzej P. Wozniak
Polish subforum moderator
User avatar
rg_software
Member
Member
Posts: 113
Joined: 2009-08-06, 12:59 UTC
Location: Aizu-Wakamatsu, Japan

Re: Lister-Plugin for Markdown formatted text documents?

Post by *rg_software »

I agree that I perhaps should disable the buttons if they don't work, though you can still access the same items from the context menu :)
As of the temp file -- well, it was my initial approach. One of the problems with it is that if you write a temp file to the temp dir, then base_dir becomes the same as the temp dir, so all relative links to images are immediately broken. Also I got reports that if you quickly switch between the source files, it's really difficult to keep track of which temp files neccessary and which are not.

I mean, I appreciate your comments, but believe me, there are no 100% solutions here. Initially I used a tempfile which is MUCH easier for me, but had to abandon this approach after all.
User avatar
Usher
Power Member
Power Member
Posts: 1675
Joined: 2011-03-11, 10:11 UTC

Re: Lister-Plugin for Markdown formatted text documents?

Post by *Usher »

I think you are going wrong way and doing unneeded work. There is a problem only with relative links to other files and only when you cannot write access to the source directory, but you must generate proper HTML code. Other links should always stay unchanged, even for in-memory work.

Short explanation of my requests follows below. It should work OK in almost all cases, use it at will.
  1. Make sure you can write to the source directory, otherwise use %TEMP% directory.
    If you have filename.md convert it to filename.html if possible.
  2. Make proper conversion from markdown to links:
    • For internal links (starting with #) - leave them relative and add proper id to any linked item.
      For example: You have [Linked item](#anchor-id). Convert it to <a href="#anchor-id">Linked item</a>, then find line:
      # Linked item
      or
      ## Linked item
      etc.
      and convert it to <h1 id="anchor-id">Linked item<h1>
      or <h2 id="anchor-id">Linked item<h2> etc.
    • Relative links to other files also leave unchanged.
      F.e. convert [LICENSE](LICENSE.txt) to <a href="LICENSE.txt">LICENSE</a>
      If you cannot write to the source directory, change relative links to other files into absolute links adding the source directory to the link.
      F.e. convert [LICENSE](LICENSE.txt) to <a href="file:///C:/TEST/LICENSE.txt">LICENSE</a>.
      I'm not sure if IE control used in HTMLView supports file: protocol, maybe you should use <a href="C:/TEST/LICENSE.txt">LICENSE</a> syntax.
    • Absolute links leave also unchanged.
  3. Add table support, see "Platform Matrix" in the linked Harbour readme.md (no explanation for now).
Now I'm going to look how HTMLView works, maybe it's the cause of some problems…
Andrzej P. Wozniak
Polish subforum moderator
Miy
New Member
New Member
Posts: 1
Joined: 2021-01-27, 14:15 UTC

Re: Lister-Plugin for Markdown formatted text documents?

Post by *Miy »

Thanks for the plugin!

I have found a bug though.

Lists are not indented correctly, see for example this text, obtained with VS Code and "create TOC":

Code: Select all

# Title

- [Title](#title)
  - [Section 1](#section-1)
    - [Subsection 1.1](#subsection-11)
  - [Section 2](#section-2)

## Section 1

### Subsection 1.1

## Section 2
The preview shows a single level of indentation, but there should be two of them.
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6449
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: Lister-Plugin for Markdown formatted text documents?

Post by *Horst.Epp »

Lister can display formated markdown fine for me if I set the preview to 8 (Explorer preview)
No need for any plugin.
Windows 11 Home x64 Version 23H2 (OS Build 22631.3374)
TC 11.03 x64 / x86
Everything 1.5.0.1371a (x64), Everything Toolbar 1.3.2, Listary Pro 6.3.0.69
QAP 11.6.3.2 x64
Gerby
Junior Member
Junior Member
Posts: 93
Joined: 2005-01-07, 16:11 UTC
Location: DE > SH > SE

Re: Lister-Plugin for Markdown formatted text documents?

Post by *Gerby »

It should be mentioned, that Horst.Epp's hint for the lister works only if you have installed an Markdown preview for Windows Explorer. One that is working here: Microsoft PowerToys (see Settings > File Explorer Add-ons)
User avatar
Brumm
Junior Member
Junior Member
Posts: 98
Joined: 2014-11-18, 11:00 UTC

Re: Lister-Plugin for Markdown formatted text documents?

Post by *Brumm »

2Gerby Thank you for this hint! :)
Dateimanagerfetischist.
User avatar
chriss
Senior Member
Senior Member
Posts: 221
Joined: 2003-02-12, 10:17 UTC

Re: Lister-Plugin for Markdown formatted text documents?

Post by *chriss »

Gerby wrote: 2022-04-27, 12:57 UTC preview for Windows Explorer.
Windows Explorer?
Whats this? Havent seen this for years.....
gruß


chriss
User avatar
Brumm
Junior Member
Junior Member
Posts: 98
Joined: 2014-11-18, 11:00 UTC

Re: Lister-Plugin for Markdown formatted text documents?

Post by *Brumm »

I've heard that some third-party file managers also use Windows Explorer plug-ins.
Dateimanagerfetischist.
Post Reply