Code Monkey home page Code Monkey logo

pork2sausage's Introduction

Pork to Sausage is a plugin for Notepad++ that allows you to transform selected text from one format to another. For example, you can convert clear text to zip text encoded in base64, or decode an encoded URL to a clear URL. Some transformations are easy to implement in C or C++, while others can be done more easily in Java or .NET using their rich libraries.

The idea behind Pork to Sausage is to create a plugin that can pass any selected text to a command-line program as input and replace the selected text with the output of the program. To use the plugin, you need to write a transformer in your favorite language. The transformer should take input from a file or stdin and generate output to a file or stdout.

To configure your transformer, you can edit the pork2sausage.ini file. The plugin supports up to 20 commands that can be customized to suit your needs.

Enjoy your sausage ;)

Don Ho
[email protected]

pork2sausage's People

Contributors

chcg avatar dinkumoil avatar donho avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pork2sausage's Issues

pork2Sausage.ini” is not present.

See my issue at this url:
https://community.notepad-plus-plus.org/topic/24566/notepad-says-it-cannot-find-the/3?_=1687965416263
I previously posted a question and got some help, “https://community.notepad-plus-plus.org/topic/24060/how-to-add-or-install-pork2sausage-to-notepad”, that I was not able to figure out how to use that help to fix the Pork2Sausage installation problem.
So, I uninstalled and reinstalled Notepad++.
Now, when I open Notepad++, I get a message telling me that “C:\Users\marc\AppData\Roaming\Notepad++\plugins\Config\pork2Sausage.ini” is not present.
I did a search for files I thought are significant and found the following files:

C:\Program Files\Notepad++\plugins\pork2sausage\pork2sausage.dll
C:\Program Files\Notepad++\plugins\pork2sausage\Config\pork2Sausage.ini
So, the pork2Sausage.ini file and the pork2sausage.dll are both present on my PC.

The page “https://npp-user-manual.org/docs/plugins/#install-plugin-manually” does not explain how to fix a plugin installation that did not get done right, which I think is what happened in my case.

Marc

### SOLUTION:
Peter Jones' gave me a solution (at the same URL) and I'm sharing his solution here so that you folks fix this problem so that other people don't have to struggle.

Here's peter's solution
PeterJones Jun 12, 2023, 8:23 PM
@Marc-Hankin ,

I ran some experiments. It had nothing to do with version, nor with whether it was local-config or AppData config, like I was originally thinking when I asked for the Debug Info.

Apparently, that plugin does not automatically install its config file when it gets installed, and instead just stores it in a subdirectory of the plugin’s installation directory.

You will want to exit the Notepad++ application; then copy C:\Program Files\Notepad++\plugins\pork2sausage\Config\pork2Sausage.ini to C:\Users\marc\AppData\Roaming\Notepad++\plugins\Config\pork2Sausage.ini; then restart Notepad++ – the error message should stop at this point, and Plugins > Pork to Sausage will now list some example converters, as well as a command to edit the User Commands. (Please note: unless you have an ancient version of java where Don had them, and have a working directory already created under Don’s personal user name, the default pork2sausage.ini commands will not work for you.)

Other readers of this topic: since your username is likely not marc, you should copy the source ini to %AppData%\Notepad++\plugins\Config\pork2Sausage.ini, which uses the Windows OS Envioronment Variable %AppData% 🛈 to find the right hiearchy based on the active username and settings.

Error corrections and suggested improvements.

; Pork to sausage plugin launches a program you defined, pass a selected text from Notepad++ to your program as input argument, then it replaces the selected text in Notepad++ by the result of your program.

  1. Replace Pork to sausage with Pork to Sausage [consistency].
  2. Replace pass a with passes giving passes selected test [grammar].
  3. Insert an between program as and input argument [grammar].
  4. Replace by the result of with with the output from [grammar].

; progPath: Mandatory. the full path of the program to launch

  1. Replace the full path of the program to launch with The full path and name of the program to launch. [clarity].

; progCmd: Mandatory. the whole command to call the program

  1. Replace the whole command to call the program with The full command line required to invoke the program. [clarity].

; workDir: Mandatory. the path of working directory

  1. Replace the path of working directory with The full path of the working directory. [clarity, grammar].

; progInput: Optional. The full path name of the program input file. Pork to sausage plugin will write the selected text in a new created file with the given full path file name.

  1. Replace The full path name with The full path and name [clarity].
  2. Replace Pork to sausage with Pork to Sausage [consistency].

; progOutput: Optional. the full path name of the program output file. Pork to sausage plugin will replace selected text by the content of indicated file, which is supposed to be the output file of the program. If this parameter is absent, then Pork to sausage plugin will use the stdout of program to replace the selected text.

  1. Replace the full path name with The full path and name [clarity].
  2. Replace Pork to sausage with Pork to Sausage [consistency].
  3. Replace replace selected text by with replace the selected text with [grammar].
  4. Replace content of indicated with contents of the defined [grammar].
  5. Remove supposed to be [clarity].
  6. Replace Pork to sausage with Pork to Sausage [consistency].
  7. Replace stdout of program with stdout of the program [grammar].

; $(TIMSTAMP): the Timestamp which will be generated by Pork to sausage on the bigining. This varible used for naming the file created by Pork to sausage plugin (progInput) to ensure the unicity of created file.

  1. Replace $(TIMSTAMP) with $(TIMESTAMP) [error].
  2. Replace the Timestamp with The timestamp [grammar].
  3. Replace Pork to sausage with Pork to Sausage [consistency].
  4. Replace on the bigining with at the beginning [grammar, spelling] or at the start [clarity].
  5. Replace varible used with variable is used [spelling, grammar].
  6. Replace Pork to sausage with Pork to Sausage [consistency].
  7. Replace unicity of with uniqueness of the [clarity, grammar].

; Note that you should provide $(SELECTION) or indicate the file name in progInput for the input of you program.

  1. replace you program with your program [spelling].

Feature request: Plugin should support environment variables and relative paths for use in the configuration file

Description

It is not possible to use environment variables or relative paths for the keys progPath and workDir in the configuration file. This is a problem especially when one wants to use a portable version of Notepad++. Moreover, to be able to use environment variables could be helpful when it comes to creating configurations that can be used for 32 bit and 64 bit versions of Notepad++.

Proposed Solution

Both issues can be solved easily by doing appropriate Win32 API calls. As the base path for relative paths used in the configuration file the plugins config dir could be used. This would be a reasonable solution and there already exists the NPPM_GETPLUGINSCONFIGDIR message in the Notepad++ plugin API to retrieve this path.

Plugin appears to be both Available and Installed.

I have installed version 2.1 of this plugin in Notepad++ version 7.5.4 (64-bit).
When I check using Plugin Manager version 1.4.11, listed under the Installed tab there is a row with the following details:

  • Plugin: Pork to Sausage
  • Category: blank
  • Installed Version: 2.1
  • Stability: blank

and when I highlight the row or tick its check-box, this is displayed in the message box below:

Unknown plugin - please let us know about this plugin on the forums
Stability: 

If I then switch to the Available tab in Plugin Manager, the plugin is also listed here, as follows:

  • Plugin: Pork2Sausage
  • Category: others
  • Available Version: 2.1
  • Stability: Good

and highlighting the row or checking its box gives this in the message area:

Transforms selected text to through a transformer (a console program which takes inputs then generates output). Up to 20 transformers can be defined
Author: Don Ho
Source: https://github.com/npp-plugins/pork2sausage
Latest update: 16 Sep 2016 Remove the dependecy issue

I'm not sure whether this is a Plugin Manager issue, but the difference in the names of the plugin between the two tabs in Plugin Manager is worth noting.

Also, note the typo in the message that displays on the Available tab in Plugin Manager:
Transforms selected text to through ... should be simply Transforms selected text through ....

Consistency in naming of this plug-in.

There are inconsistencies in the names used in reference to this plugin, as follows:

  • the GitHub project is named pork2sausage
  • the readme.txt file refers to it as Pork to Sausage
  • in GitHub, both versions 1.0 and 2.0 use the name Pork2Sausage
  • in GitHub, version 2.1 calls it Pork to Sausage
  • the drop-down Plugins menu in Notepad++ uses the label Pork to Sausage
  • in Notepad++, the Plugin Manager lists Pork2Sausage in the Available tab
  • in Notepad++, the Plugin Manager lists Pork to Sausage in the Installed tab

Can these references (and any others I have missed) all be reconciled to a single consistent name? I suggest using Pork to Sausage for all references that are visible to the end-user, as this provides the most clarity.

[Feature Request] Variable to load output file in Notepad++

When progOutput is set and replaceSelection=false, it would be useful to add a variable to load the output file.

It would be useful e. g. when one is using Notepad++ to build simple commands and don't actually want the selection to be overwritten, but still want to immediately view the output. More specifically, it would have been great when I used RegEx in Notepad++ to turn the output from some data fetched via REST API into a curl command for a new fetch.

The plug-in gives error with text in Chinese when processing text with Python

I installed Pork2sausage plug-in and decided to check how it goes along with Python. So, I created the following pork2sausage.ini file:
[Python]
progPath=C:\Users\Sergey\AppData\Local\Programs\Python\Python39\python.exe
progCmd=python $(SELECTION)
workDir=C:\Users\Sergey\AppData\Local\Programs\Python\Python39\

Should I select 3+2 and give command to make the sausage, I have got error message with text in Chinese, depicted at the screen-shot.

Screen-shot_2021-03-19_17-32-46

I would appreciate some one telling me what is wrong with my ini-file (really, I have no clue about it, everything seems to be correct) and what this message means.

@donho You may want to consider replacing the Chinese text with its English equivalent. And the last, but not the least, thank you very much for great text editor.

feature request: allow pork to be empty

Since N++ 7.6 TextFX isn't supported even in 32-bit and I would really like to be able to use the insert timestamps feature (like standard Notepad). It works...but requires me to create a selection first, which slows progress quite a bit.

Would you please enable Pork2Sausage to work without an active selection?

I could see using this for other system-state or diagnostic information as well where the "pork" is coming from outside Notepad++.

Multiple lines into command

When I select multiple lines, only the first line goes to the command in Windows. Tested this with two round-trip commands. Windows command prompt requires a special escape of multi-line commands. Wat do?

Error corrections and suggested improvements.

This is a demo program made in java for Pork2Sausage (un Notepad++ plugin).

  1. Replace java with Java [proper case].
  2. Replace Pork2Sausage with Pork to Sausage [consistency].
  3. Replace un Notepad++ plugin with a Notepad++ plugin [English].

The program zip or unzip a given string from stdin then put the result to stdout.

  1. Replace zip with zips [grammar].
  2. Replace unzip with unzips [grammar].
  3. Replace put with writes [grammar].

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.