Skip to content

VS Code Task Configuration

Tom Thornton edited this page Dec 5, 2019 · 2 revisions

VS Code Task Configuration

Created this wiki doc to show how you can use this (and I use this myself) to run the process directly from VSCode as a Task on the current document. I wanted a quick way of running the conversion and thought to share here.

Requirements

  • You've already downloaded the md2toconf module locally
  • You've already got a Python environment setup with the necessary dependencies.
  • You've set credentials up as environment variables.

Create the Task

  • Click Terminal > Configure Tasks
  • Hit enter then select Other Task, VS Code will create a .vscode directory and populate it with a basic tasks.json
  • Replace the content of your tasks.json with the below:
{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Upload",
            "type": "shell",
            "command": "<python-env-call> && python .\\md2conf.py \"${file}\" ${input:SpaceKey} -a ${input:ParentPage}",
            "windows": {
                "command": "<python-env-call> && python .\\md2conf.py \"${file}\" ${input:SpaceKey} -a ${input:ParentPage}"
            },
            "problemMatcher": [
                "$eslint-compact"
            ],
            "options": {
                "cwd": "<path-to-md2conf-module>"
            }
        },
    ],
    "inputs": [
        {
            "type": "pickString",
            "id": "SpaceKey",
            "description": "The Confluence space key to create the page under.",
            "default": "<default-space-key>", 
            "options": [
                "<your-space-keys>"
            ]
        },
        {
            "type":"promptString",
            "id": "ParentPage",
            "description": "The name of the parent page to create the page under.",
            "default": "<parent-page-name>"
        }
    ]
}

Please replace the following values as you require:

  • python-env-call
    • This should be the call to activate your Python environment
  • path-to-md2conf-module
    • The path to the md2conf module directory
  • default-space-key
    • The space key to select when running the process.
  • your-space-keys
    • Any other space keys you may want to select.
  • parent-page-name
    • The default name of the page you want to create the page under.

Running the Process

Inside the same VS Code directory (where .vscode is at the root):

  • Open the markdown file you wish to upload to confluence in VS Code.
  • Go to Terminal > Run Task...
  • On the dropdown that appears hit 'Upload'
  • The document should then upload and then open in the browser as normal.