mohzy83 / NppMarkdownPanel

Lightweight Notepad++ plugin to preview Markdown files
MIT License
228 stars 37 forks source link

Would you get ProcessorExe to support scripts? #77

Closed linpengcheng closed 8 months ago

linpengcheng commented 1 year ago

Would you get ProcessorExe to support scripts? The script is simpler, more flexible and more practical.

For example:


[Options]
PreProcessorExe=C:\python.exe
PreProcessorArguments=C:\ConvertxxxTOxxx.py %inputfile% %outputfile%
PostProcessorExe=C:\python.exe
PostProcessorArguments=C:\ConvertyyyTOyyy.py %inputfile% %outputfile%
mohzy83 commented 1 year ago

The PreProcessorExe and PostProcessorExe can be any commandline program. Maybe the documention is not clear enough about that point. Actually your configration should work when the python executable accepts the parameters in that order.

linpengcheng commented 1 year ago

Thank you for your reply and work!

According to NppMarkdownPanel.ini, it can choose a different ProcessorExe configuration based on the file extension, just like Preview HTML's Filters.ini, right?

From the default [Filter0] of NppMarkdownPanel.ini, it seems that the configuration name is a bit different.

NppMarkdownPanel.ini


; [Filter0]
; Extensions=.pl,.pm
; Program=pod2html.bat
; Arguments=--css C:\notepad++\plugins\NppMarkdownPanel\style.css

[Filter1]
Extensions=.xyz
Arguments=--css C:\notepad++\plugins\NppMarkdownPanel\style.css
PreProcessorExe=C:\python.exe
PreProcessorArguments=C:\ConvertxxxTOxxx.py %inputfile% %outputfile%
PostProcessorExe=C:\python.exe
PostProcessorArguments=C:\ConvertyyyTOyyy.py %inputfile% %outputfile%

[Filter2]
Extension=.hiccup, .hip
;Program=C:\dev\Notepad++\tools\comrak\comrak.exe
;bb.exe from  https://github.com/babashka/babashka
PreProcessorExe=C:\Notepad++\tools\clj\bb.exe
PreProcessorArguments=C:\Notepad++\tools\clj\hiccup2html.clj %inputfile% %outputfile%

hiccup2html.clj

(use 'hiccup.core)
(let [[inputfile outputfile] *command-line-args*
      f #(spit outputfile % :encoding "utf-8")]
  (->> inputfile
       slurp
       read-string
       eval
       html
       f))

test.hiccup

[:p
  [:h1 "List"]
  [:ul
    (for [x (range 1 4)]
      [:li x])]
  [:p "Hello, world!"]]

preview is wrong

[:p[:h1 "List"]  [:ul (for [x (range 1 4)] [:li x])]  [:p "Hello, world!"]]

update01:

linpengcheng commented 1 year ago

NppMarkdwonPanel and PreviewHTML both work fine under win7, but not under win11. It may be a problem with npp or OS.

Here is the configuration that works under win7:

NppMarkdownPanel.ini

[Options]
CssFileName=style.css
CssDarkModeFileName=style-dark.css
ZoomLevel=301
HtmlFileName=
ShowToolbar=True
ShowStatusbar=True
SupportedFileExt=md,mkd,mdwn,mdown,mdtxt,markdown,text,hiccup
AutoShowPanel=False
SyncViewWithCaretPosition=0
SyncWithFirstVisibleLine=0
PreProcessorExe=C:\Notepad++\tools\clj\bb.exe
PreProcessorArguments=C:\Notepad++\tools\clj\hiccup2html_mdpanel.clj %inputfile% %outputfile%

hiccup2html_mdpanel.clj


(use 'hiccup.core)

(let [[inputfile outputfile] *command-line-args*
      f #(spit outputfile % :encoding "utf-8")]
    (->> inputfile
         slurp
         read-string
         eval
         html
         f))

test.hiccup


[:p
  [:h1 "List"]
  [:ul
    (for [x (range 1 4)]
      [:li x])]
  [:p "Hello, world!"]]
npp_mdpanel
mohzy83 commented 1 year ago

I'm working with Win11 and have no problems so far. Please specify your problem.

linpengcheng commented 1 year ago

Microsoft is phasing out IE in Windows 11, so some Windows 11 users cannot use the IE kernel-based notepad++ plugin.