mvdkwast / obsidian-copy-as-html

Obsidian plugin: copy document as HTML, including images
MIT License
42 stars 11 forks source link

If possible, it is hoped that support can be provided for format conversion using Pandoc. #25

Closed MiV1N closed 9 months ago

MiV1N commented 1 year ago

Is your feature request related to a problem? Please describe. No

Describe the solution you'd like markdown -> html --pandoc-->docx

Describe alternatives you've considered

Using the "obsidian-copy-as-html" plugin, convert Markdown to HTML and copy it to the clipboard. Then, use the following Windows script to convert it to the desired format, such as DOCX. The script will be bound to a shortcut key for easy use.

@echo off

REM 从剪贴板读取内容并写入temp.html文件(使用UTF-8编码)然后将其通过pandoc转换成docx,方便分享后二次编辑

REM 从剪贴板读取内容并写入temp.html文件(使用UTF-8编码)
REM powershell -command "Add-Type -AssemblyName PresentationCore; [Windows.Clipboard]::GetText()" | Out-File -Encoding utf8 temp.html
powershell -command "Add-Type -AssemblyName PresentationCore; [Windows.Clipboard]::GetText() | Set-Content -Path temp.html -Encoding utf8"

REM 使用文件浏览器选择模板文件
set "template="
for /f "delims=" %%i in ('powershell -Command "Add-Type -AssemblyName System.Windows.Forms; $OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog; $OpenFileDialog.Filter = 'Word files (*.docx)|*.docx|All files (*.*)|*.*'; $OpenFileDialog.Title = 'Select a template file'; $OpenFileDialog.ShowDialog() | Out-Null; $OpenFileDialog.FileName"') do set "template=%%i"

REM 检查模板文件是否存在
if not exist "%template%" (
    echo Template file not found.
    exit /b 1
)

REM 调用pandoc进行转换
pandoc temp.html -o output.docx --reference-doc="%template%" --variable mainfont="宋体"

REM 打开转换后的文件目录
start "" "%SystemRoot%\explorer.exe" /select,"%cd%\output.docx"

REM 删除中间的临时文件
del temp.html

Additional context The purpose of this requirement is to export files edited with Obsidian, along with some plugins such as PlantUML and Excalidraw, into more common formats such as DOCX, so that they can be shared with people who do not use Obsidian for further editing. The existing export plugins cannot handle the added features of the PlantUML and Excalidraw plugins, as well as the default image link format in Obsidian.

mvdkwast commented 1 year ago

Hi @MiV1N, thanks for your report. While this sounds like a great feature, unfortunately I don't think I will have enough time soon to work on it as it will considerably widen the scope of this plugin. Marking it as "help wanted", you never know :)

mvdkwast commented 9 months ago

It doesn't seem anyone wants to pick this up, and it's clearly outside the scope of my goals for this plugin, so closing this issue. I might consider PRs if anyone volunteers.