brrd / abricotine

Markdown editor with inline preview
GNU General Public License v3.0
2.63k stars 156 forks source link

Browser preview #343

Closed Dibal closed 1 year ago

Dibal commented 1 year ago

Are there any settings I have to adopt for "browser preview"? In the moment I get the answer: file not found file:///tmp/Abricotine/123/preview.html

Or is there a different option to have a better preview for my tables? The option "beautify" has no effect (i wished it would rearrange the table formaters "|").

Dibal commented 1 year ago

Solved issue about "beautify": the program expects full format table like |--|--|, short form like --|-- does not work.

brrd commented 1 year ago

Thanks for reporting but we will need more information. What is your OS? Can you give a screenshot of the error message? Is there any error logged in the console (View > Development > Developer Tools > Console)?

Dibal commented 1 year ago

I found the reason: unfortunately under Ubuntu Firefox is running in a Snap-environment, see eg here: https://superuser.com/questions/1748689/file-tmp-in-firefox-does-not-show-contents-of-tmp

Suggestion for solutions:

  1. define destination for tmp-files in "peferences". If destination is part of user space snap-firefox should find them.
  2. define a simple API which run a self written script. It may call a different browser together with the tmp-file.

Solution 2. might be extended to a simple plugin: press a button and call a self written script. If this script knows the directory where abricotine is running, then it may copy clipboard images to subfolder and insert link into text.

Example: write image to subfolder "image/" + insert into clipboard ""

mynam="p$(uuidgen).png"
myfile="images/$mynam"
xclip -selection clipboard -t image/png -o > $myfile
echo "![]($myfile)" | xclip -selection clipboard
brrd commented 1 year ago

define a simple API which run a self written script. It may call a different browser together with the tmp-file.

You already can do this with tasks: https://github.com/brrd/abricotine/blob/master/docs/configuration.md#tasks

{
    "name": "My custom preview",
    "exec": "path/to/your/custom/browser %inputFilepath%"
}

Does this solve your issue?

Dibal commented 1 year ago

Great, thank you!

Questions:

brrd commented 1 year ago

Is it possible to assign shortcuts to the task submenu entries?

I don't think so.

Is it possible to add several commands inline, separated by ";"?

Try with &&:

pandoc -s %inputFilepath% -o temp.html && firefox temp.html
Dibal commented 1 year ago

"&&" did the job and saved me from writing another script file. Thanks again