Conversation
|
Is there a way to check if Pandoc and Asciidoctor are installed and only do the conversion if they are. Then it is not really necessary to install the tools if you only run it locally for testing. Or maybe add a new parameter to skip the conversion. |
|
Makes sense, will add this feature. |
engine/converter.ts
Outdated
| this.createTempFile("temp.adoc", asciidocString); | ||
|
|
||
| let markdownString = ""; | ||
| if(this.platform == ConsolePlatform.WINDOWS) { |
There was a problem hiding this comment.
Why is this if-else-block is needed? Both block execute the same commands
engine/converter.ts
Outdated
| this.executeCommand("pandoc -f docbook -t gfm temp.xml -o temp.md", this.getTempDir()); | ||
| markdownString = this.readTempFile("temp.md"); | ||
| }else { | ||
| markdownString = this.readTempFile("temp.adoc"); |
There was a problem hiding this comment.
Couldn't you use markdownString = asciidocString in this case? Then you do not need to call the function
engine/converter.ts
Outdated
|
|
||
| let markdownString = ""; | ||
| if(this.platform == ConsolePlatform.WINDOWS) { | ||
| if(this.commandAvailable("asciidoctor") && this.commandAvailable("pandoc")) { |
There was a problem hiding this comment.
It would be better to test if both commands are available in the constructor once. Otherwise you will always test and execute the commands when you want to convert something
engine/converter.ts
Outdated
| readTempFile(filename: string): string { | ||
| let file_path = path.join(this.getTempDir(), filename); | ||
| let fileContent = ""; | ||
| let file = fs.readFileSync(file_path); |
There was a problem hiding this comment.
If you pass the encoding parameter you dont have to convert it to a string afterwards.
| return process.status == 0; | ||
| } | ||
|
|
||
| executeCommand(command: string, directory: string) { |
There was a problem hiding this comment.
Can we use the function executeCommandSync() we already got in ConsoleUtils for this ?
There was a problem hiding this comment.
Technically yes, but the executeCommandSync() from ConsoleUtils requires parameteres that I cannot provide (e.g. RunResult, env)
| } | ||
| if("textAfter" in variables) { | ||
| variables["textAfter"] = this.converter.convertAsciidocToMarkdown(variables["textAfter"]); | ||
| } |
There was a problem hiding this comment.
Maybe also check for playbook.description and convert it to markdown. Now we don´t have a problem with that but somebody could also use asciidoc formating in the description in the future.
There was a problem hiding this comment.
If I implemented it correctly, the description conversion can be found here
This PR includes changes that convert AsciiDoc syntax into Markdown syntax at these locations:
Note: If this PR is merged, you'll have to install Pandoc and Asciidoctor on your local machine
Linux:
sudo wget https://github.com/jgm/pandoc/releases/download/2.14.0.2/pandoc-2.14.0.2-1-amd64.deb && sudo dpkg -i pandoc-2.14.0.2-1-amd64.debsudo apt install asciidoctorWindows:
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))choco install pandocchoco install rubygem install asciidoctor