Sublime Forum

[SOLVED] Is it possible to use the current filename/basename in package specific settings

#1

I write a lot of stuff in Markdown and process them with Pandoc and create a .docx file from them. In the Pandoc sublime settings I can specify build options and I can also define the name of the output file.

But besides using a static output filename, e.g. output.docx it would be great to use the base filename and add the extension .docx.

Is that possible? I also opened an issue for the SublimeText-Pandoc package, but I didn’t get a response so far. In the issue you can also see my example settings.

I would like that the output file for pandoc should be based on the input filename.

Example:
input: document1.md
output: document1.docx

I tried to add the following in my pandoc user settings:

"pandoc-arguments": [
          "-t", "docx",
          "-o", "$file_base_name.docx",
          // if -o or --output missing, will write to a temporary file
          // "--output=~/Downloads/output.pdf"
        ]

But that generates unfortunately only a file called $file_base_name.docx.

How would I do that?

0 Likes

#2

There is no native functionality for this but there is an api that allows plugins to use these variables if they choose to do so. Basically, this should be done by the package and creating an issue on the repo Was the right choice.

0 Likes

#3

I think I know enough Python to try to add it on my own to the package. It might take a while. After that I will try to get my changes merged in the regular package.

First, I looked to find the package in my filesystem and I see only the Pandoc.sublime-package in my Data\Installed Packages folder.

How can I unpack the containing content to get to the Pandoc.py file? How can I use that package unpacked during the development of the new feature?

Can somebody point me to useful online ressources about package development?

0 Likes

#4

There is a package called PackageResourceViewer to unpack files and whole packages.

If you are looking forward to create a PR you can fork the package and clone it into your Packages folder with git.

I recommend to install the PackageDev package and enable prereleases (even if you are just editing you build and setting files)

overview: http://www.sublimetext.com/support
inofficial documentation: https://docs.sublimetext.info/en/latest/index.html
python api: https://www.sublimetext.com/docs/3/api_reference.html

0 Likes