Markdown Generator Plugins
The Markdown Generator custom plugin allows you to create a form for your project managers, to which they will upload a Markdown and a CSV file. You will get access to both in your Python script, and you'll be able to manipulate both to then upload assets to a project.
Usually, the Markdown file will be be populated with data from the CSV file and will be imported to your project of choice as an asset, as shown in the example below.
Creating a Markdown Generator Plugin
Following the steps outlined in this section, create a new plugin from the UI, choosing "Markdown Generator" as the plugin type.
Then, create and run a Python script using the MarkdownPlugin
class you can find in our imerit-ango
Python package under imerit_ango.plugins
.
You will need to add the imerit-ango
package to your Python environment by running
Here is the class's documentation, and an example:
MarkdownPlugin
Parameters:
id: string
The plugin's ID. You may obtain this ID from the plugin's information box in the Development section of the Plugin page.
secret: string
The plugin's secret. You can think of this as a private key you'll need to be able to connect your script to the plugin. You may obtain this secret from the plugin's information box in the Development section of the Plugin page.
callback: Callable[[str, dict], Tuple[str, BytesIO]]
The callback function. This function will be run whenever a user runs this plugin. More on the callback function below.
Callback Function
Parameters:
**data: dict
projectId: str
The ID of the project to which the populated Markdown file needs to be uploaded.
fileList: List[dict]
inputFile: str
apiKey: str
The API key of the user running the plugin.
orgId: str
The ID of the organization where the plugin is being run.
runBy: str
The ID of the user running the plugin.
session: str
The ID of the session created when running the plugin.
batches: List[str]
Batches to which the final text assets will be assigned.
markdownText: string
The Markdown text the contents of which will be populated with the CSV.
logger: PluginLogger
[TODO]
configJSON: str
The config JSON your users will pass to you through the Config JSON text field when running the plugin. Warning: the JSON will be passed as a string so you will have to destringify it. Example code to obtain the original JSON as a Python object:
Returns:
message: string
Message to show users once the plugin has finished running.
Sample Python Script
Find sample code here:
For this example, we use the following default Config JSON:
Creating a Markdown Asset with the Plugin
Your Python script needs to be running for users to be able to run your plugin.
If you are the creator of the plugin, from the Plugins page, enter the Development section and click on Open on the relevant plugin. A dialog will pop up.
If you have added the plugin from the Directory, go to the project where you'd like to use the plugin, and from the Settings tab (1) click on Plugins (2). Then, click on Open (3) on the relevant plugin. A dialog will pop up.
This is the dialog that will appear when clicking on Run on the Markdown plugin:
Project: The project where you'd like the final assembled asset to be uploaded. If you are running this plugin from a project, the project you're in will be pre-selected.
File Upload: Upload the CSV file you'd like to use as base to populate the Markdown file.
Create Markdown: Upload or write a Markdown file to use as skeleton. Clicking on Open Editor will open a simple Markdown text editor with built-in preview of what it will look like on Hub.
For example, if you were to use the Python code provided above, you might use the following CSV file:
And the following Markdown file:
You would obtain three assets, one from each of the CSV lines, looking like the Markdown but populated in the |name|, |surname|, etc. areas with the data in the CSV.
Last updated