Preview HTML files as text

Discussion related to "Everything" 1.5 Alpha.
Post Reply
Fleet
Posts: 7
Joined: Wed Aug 25, 2021 10:52 am

Preview HTML files as text

Post by Fleet »

The Preview pane (most recent version of 1.5(a)) renders an HTML file as a webpage (if the file has renderable elements; as opposed to just a script). I would like it to render it as plain text (i.e., show the tags, scripts, etc.).

I know I can edit the registry to do that, but I'd rather not do that if at all possible - I'd like File Explorer, for example, to continue to render these files as a web page.

My default text_plain_extensions entry in Everything-1.5a.ini already contains html.

Is that possible?
Last edited by NotNull on Thu Jun 15, 2023 6:49 pm, edited 1 time in total.
Reason: Moved to Everything 1.5 forum
NotNull
Posts: 5481
Joined: Wed May 24, 2017 9:22 pm

Re: Preview HTML files as text

Post by NotNull »

Everything uses the Windows 'engine' to preview files, so Explorer and Everything should show the same layout.

text_plain_extensions is for searching in the content of files; it is not used for previewing files.


However, there are ways ...
Those do involve changing the registry and those settings might be overwritten with the next Windows update.
Or the next Everything update.

Let me know if interested



2023-06-15 21_05_07-C__test_RegexBuddy.png
2023-06-15 21_05_07-C__test_RegexBuddy.png (152.65 KiB) Viewed 16367 times
Fleet
Posts: 7
Joined: Wed Aug 25, 2021 10:52 am

Re: Preview HTML files as text

Post by Fleet »

Let me know if interested
Always interested in learning something new! Yes, please.
void
Developer
Posts: 16974
Joined: Fri Oct 16, 2009 11:31 pm

Re: Preview HTML files as text

Post by void »

Everything doesn't have a good solution to do this at the moment.

I will explore ways to override the registry just for Everything, or add a custom ini setting to override the preview handler for certain extensions.



Like Windows Explorer, Everything will currently load preview handlers in the following order:
  • HKEY_CLASSES_ROOT\<class>\ShellEx\{8895b1c6-b41f-4c1c-a562-0d564250836f}
  • HKEY_CLASSES_ROOT\<.extension>\<class>\ShellEx\{8895b1c6-b41f-4c1c-a562-0d564250836f}
  • HKEY_CLASSES_ROOT\SystemFileAssociations\<.extension>\<class>\ShellEx\{8895b1c6-b41f-4c1c-a562-0d564250836f}
horst.epp
Posts: 1453
Joined: Fri Apr 04, 2014 3:24 pm

Re: Preview HTML files as text

Post by horst.epp »

XYplorer has the concept of "User defined preview handlers".
This allows to override the system defaults by selecting the desired one with its Id.
The format looks like this:
Screenshot - 16.06.2023 , 13_31_55.png
Screenshot - 16.06.2023 , 13_31_55.png (42.92 KiB) Viewed 16333 times
NotNull
Posts: 5481
Joined: Wed May 24, 2017 9:22 pm

Re: Preview HTML files as text

Post by NotNull »

Fleet wrote: Thu Jun 15, 2023 8:57 pm Always interested in learning something new! Yes, please.
Assuming you are running Everything as regular user (no Administrator in the title bar).
If not: don't proceed and reply back. This requires a different soloution (which is available too).

If running as regular user:
  • Start Command Prompt (CMD.exe)
  • Execute the following 2 commands

    Code: Select all

    reg.exe add "HKCU\Software\Classes\.html\shellex\{8895B1C6-B41F-4C1C-A562-0D564250836F}"     /ve /D  "{f8b8412b-dea3-4130-b36c-5e8be73106ac}" /f
    reg.exe add "HKCU\Software\Classes\htmlfile\shellex\{8895B1C6-B41F-4C1C-A562-0D564250836F}"  /ve /D  "{1531d583-8375-4d3f-b5fb-d23bbd169f22}" /f
    
    
  • Done!
The effect should be instant, but if not: restart Everything.


To bring your system back to its original state, run tthe following 2 commands in Command Prompt:

Code: Select all

reg.exe delete "HKCU\Software\Classes\.html\shellex\{8895B1C6-B41F-4C1C-A562-0D564250836F}"    /f
reg.exe delete "HKCU\Software\Classes\htmlfile\shellex\{8895B1C6-B41F-4C1C-A562-0D564250836F}" /f


(tested on Win11 22H2)
therube
Posts: 5016
Joined: Thu Sep 03, 2009 6:48 pm

Re: Preview HTML files as text

Post by therube »

Isn't that going to change the (OS) preview handler for html, to the windows text preview handler?
NotNull
Posts: 5481
Joined: Wed May 24, 2017 9:22 pm

Re: Preview HTML files as text

Post by NotNull »

therube wrote: Fri Jun 16, 2023 8:30 pm Isn't that going to change the (OS) preview handler for html, to the windows text preview handler?
What do you mean by "the (OS) preview handler for html"?
A preview handler can be configured on multiple levels (at least 6).

Explorer will still show .html files as html formatted, not as plain (raw) text.
horst.epp
Posts: 1453
Joined: Fri Apr 04, 2014 3:24 pm

Re: Preview HTML files as text

Post by horst.epp »

For me the OS html preview handler is

Preview Handler information:
GUID : {f8b8412b-dea3-4130-b36c-5e8be73106ac}
Description : CLSID_PreviewHtml
Module name : C:\Windows\System32\inetcomm.dll
Localserver :
Note: Preview Handler is registered on the ProgID (htmlfile)

In my preferred tool to change it, its the 2nd of the handlers named
Microsoft Windows Mail Mime Preview Handler
Screenshot - 17.06.2023 , 13_41_28.png
Screenshot - 17.06.2023 , 13_41_28.png (5.86 KiB) Viewed 16293 times
______________________________________________________
Windows 11 Home x64 Version 22H2 (OS Build 22621.1848)
Everything 1.5.0.1350a (x64), Everything Toolbar 1.1.1
NotNull
Posts: 5481
Joined: Wed May 24, 2017 9:22 pm

Re: Preview HTML files as text

Post by NotNull »

horst.epp wrote: Sat Jun 17, 2023 11:47 am Preview Handler information:
GUID : {f8b8412b-dea3-4130-b36c-5e8be73106ac}
Same here. That is the out-of-the-box html previewer (and also the one I used in the command above).

Thanks for the info!


(I changed my previous message/question to make the intent more clear)
horst.epp
Posts: 1453
Joined: Fri Apr 04, 2014 3:24 pm

Re: Preview HTML files as text

Post by horst.epp »

On possible way may be using the Delphi preview handler
and assign the type htmlfile to it.
void
Developer
Posts: 16974
Joined: Fri Oct 16, 2009 11:31 pm

Re: Preview HTML files as text

Post by void »

Everything 1.5.0.1351a adds a preview_handlers ini setting.

To preview html/htm files as text/plain:
  • In Everything 1.5, from the Tools menu, click Options.
  • Click the Advanced tab on the left.
  • To the right of Show settings containing, search for:
    preview
  • Select preview_handlers.
  • Set the value to:

    Code: Select all

    [{"filter":"*.html;*.htm","handler":"{1531d583-8375-4d3f-b5fb-d23bbd169f22}"}]
    
  • Click OK.


A Custom Preview Handler UI is on my TODO list.
Fleet
Posts: 7
Joined: Wed Aug 25, 2021 10:52 am

Re: Preview HTML files as text

Post by Fleet »

In my Everything (version 1.5.0.1347a (x64)) there is no preview_handlers entry in Advanced:
Attachments
preview_handlers.png
preview_handlers.png (19.89 KiB) Viewed 15867 times
horst.epp
Posts: 1453
Joined: Fri Apr 04, 2014 3:24 pm

Re: Preview HTML files as text

Post by horst.epp »

Fleet wrote: Thu Jun 22, 2023 8:44 pm In my Everything (version 1.5.0.1347a (x64)) there is no preview_handlers entry in Advanced:
Of course not.
Did you read the minimum version ?
Update and you will find it.
therube
Posts: 5016
Joined: Thu Sep 03, 2009 6:48 pm

Re: Preview HTML files as text

Post by therube »

In my Everything (version 1.5.0.1347a (x64))
It's not in 1347a.

Download 1351a & it will be there.


(When I looked in my end, it wasn't in my 1349a either ;-).
So I put in 1351a, & sure enough...)
NotNull
Posts: 5481
Joined: Wed May 24, 2017 9:22 pm

Re: Preview HTML files as text

Post by NotNull »

void wrote: Thu Jun 22, 2023 5:53 am Everything 1.5.0.1351a adds a preview_handlers ini setting.
Fleet
Posts: 7
Joined: Wed Aug 25, 2021 10:52 am

Re: Preview HTML files as text

Post by Fleet »

It's not in 1347a.

Download 1351a & it will be there.
I'll do that, of course. But I have to point out that before I ask any question, I do check with Help/Check for Updates. The response I get is "Everything is up to date!"...
NotNull
Posts: 5481
Joined: Wed May 24, 2017 9:22 pm

Re: Preview HTML files as text

Post by NotNull »

It is an alpha version .. Just check the forum to see if there are any updates.

This link points to the latest version.
Fleet
Posts: 7
Joined: Wed Aug 25, 2021 10:52 am

Re: Preview HTML files as text

Post by Fleet »

NotNull wrote: Fri Jun 23, 2023 6:31 pm It is an alpha version .. Just check the forum to see if there are any updates.

This link points to the latest version.
Understood, just didn't think about this particular point in that context. Maybe until it comes out of alpha, the message there should indeed be to check the forum.
NotNull
Posts: 5481
Joined: Wed May 24, 2017 9:22 pm

Re: Preview HTML files as text

Post by NotNull »

Fleet wrote: Fri Jun 23, 2023 7:07 pm Maybe until it comes out of alpha, the message there should indeed be to check the forum.
I like that idea!! :thumbsup:
meteorquake
Posts: 518
Joined: Thu Dec 15, 2016 9:44 pm

Re: Preview HTML files as text

Post by meteorquake »

I got informed by Everything of the latest alpha release just now. This may be relatively new.
phil2search
Posts: 23
Joined: Tue Mar 20, 2018 9:04 pm

Re: Preview HTML files as text

Post by phil2search »

Hello,

I updated to 1352a and I have a problem with the preview behavior.

I have lot of text files types (some non standard) that I ask windows to perceive as text. e.g. in the registry:
[HKEY_CLASSES_ROOT\.cps]
"PerceivedType"="text
[HKEY_CLASSES_ROOT\.py]
"PerceivedType"="text
[HKEY_CLASSES_ROOT\.txt]
"PerceivedType"="text

I can then see a quick preview in explorer and everything. I use it all the time to locate scripts, etc.

After updating to 1352a: this preview does not work anymore (even .txt).
I can preview pdf, etc. but not these text files
I downgraded to 1349a and it is the same.

Any idea on how to get it to work again?

Thanks
Philippe
NotNull
Posts: 5481
Joined: Wed May 24, 2017 9:22 pm

Re: Preview HTML files as text

Post by NotNull »

phil2search wrote: Tue Jul 11, 2023 8:32 am Any idea on how to get it to work again?
Without further details: Sounds like you installed and uninstalled Microsoft PowerToys in between? The Monaco code preview handler that comes with it is a mess (to put it politely). But there are solutions for that (I had to write a script as all code extensions were broken by PowerToys ..


For better assistance, more information is needed:

After uprading to Everything 1352a, did the preview fail in Everything or in Explorer too?
And after downgrading to 1349a, "it is the same". Same behaviour as 1352a or same behaviour as the original pre-1352a setup?
phil2search
Posts: 23
Joined: Tue Mar 20, 2018 9:04 pm

Re: Preview HTML files as text

Post by phil2search »

Thank you for your response (and sorry for the missing details).

* It always kept working in explorer
* I have powertoys with monaco disabled (a long time ago). It crashed all the time so I don't use it. I don't think it was ever enabled on the PC where the problem occured.
* downgrading: it did not work anymore in 1349a after downgrading (=no preview for extensions for which I used the PerceivedType=text in the registry). But I rebooted and now it works again.

As a summary: So it seems like Everything did not consider the PerceivedType=text settings?? (I have many of those).
[HKEY_CLASSES_ROOT\.xydata]
"PerceivedType"="text"

I can try to update again if there is something to try.

Thanks
Philippe
NotNull
Posts: 5481
Joined: Wed May 24, 2017 9:22 pm

Re: Preview HTML files as text

Post by NotNull »

phil2search wrote: Wed Jul 12, 2023 10:32 am As a summary: So it seems like Everything did not consider the PerceivedType=text settings?? (I have many of those).
It does, but there are several places in the registry where a preview handler can be configured.

You can run [ur=viewtopic.php?p=56809#p56809l]this script[/url] and post the output of a .py and a .xydata file here (see instructions in that post).
That should give a decent clue of what is going on.
phil2search
Posts: 23
Joined: Tue Mar 20, 2018 9:04 pm

Re: Preview HTML files as text

Post by phil2search »

Thanks for your response.

I started looking at the page and then tried 1352a portable on my second machine (similar configuration). And it worked.
Installed it. And it worked.
Went back to the one with the issue and reinstalled 1352a. And it is worked...
Strange.
So it seems it just needed to reboot.
Problem solved.
Sorry for the disturbance.
Philippe
void
Developer
Posts: 16974
Joined: Fri Oct 16, 2009 11:31 pm

Re: Preview HTML files as text

Post by void »

Just making a note here...

Everything 1.5.0.1356a will now support full filename filters in preview_handlers.

This includes regex support with the regex: prefix and full path matching.

For example:

"filter":"regex:^foo"
"filter":"regex:\\.(jpg|jpeg)$"
"filter":"c:\\only-this-folder\\**.jpg"

The first (or left-most) filter that matches is used.
Post Reply