Giter Site home page Giter Site logo

Comments (6)

nxtruong avatar nxtruong commented on May 30, 2024 1

The fix worked perfectly. Thanks. Perhaps you can incorporate this change into the code.

from el-easydraw.

misohena avatar misohena commented on May 30, 2024

nxtruongさんこんにちは。
ご報告ありがとうございます。

小さな白い箱が表示されるということはオーバーレイの作成はうまくいっていて、しかしオーバーレイのdisplayプロパティに問題がある可能性が高いです。

edraw-org-link-image-create がdisplayプロパティ(画像)を構築している関数です。この関数の中において、create-imageの引数(file-or-data変数)に問題があるとたいてい小さな白い箱が表示されます。

file-or-dataの値はedraw-org-link-props-image-data-or-file関数で作成します。
データはgzipされた後base64エンコードされたSVGです。なのでこの関数はbase64-decode-stringを呼び出して……この関数がgzipを展開していないのは私の環境ではそのままで表示できたからです。gzipされたSVGはsvgzと呼ばれています。ひょっとしたらこのsvgzが表示できないのでしょうか?

だとすれば次の変更で表示できるようになるかもしれません。

- (ignore-errors (cons (base64-decode-string data) t))
+ (ignore-errors (cons (edraw-decode-svg data t) t))

edraw-decode-svgはedraw.elに含まれています。edraw-org.elは編集開始までedraw.elの読み込みを先送りしているので、上の変更は読み込み前はエラーになる可能性があります。読み込み時間を気にしないなら最初から(require 'edraw)すれば回避できます。

また、速度は変更前の方が速いと思うので恒久的にこの変更をするかは迷います。

Google Translate:
Hello nxtruong.
Thank you for your report.

If you see a small white box, the overlay was created successfully, but it is likely that there is a problem with the overlay's display property.

edraw-org-link-image-create is the function that builds the display property (image). Inside this function, if there is a problem with the create-image argument (file-or-data variable), you will usually see a small white box.

The value of file-or-data is created by the edraw-org-link-props-image-data-or-file function.
The data is gzipped and then base64 encoded SVG. So this function calls base64-decode-string ... This function doesn't ungzip because it could be displayed as is in my environment. The gzipped SVG is called svgz. Maybe this svgz can't be displayed?

If so, it may be possible to display it with the next change. I'm sorry. see next comment.

- (ignore-errors (cons (base64-decode-string data) t))
+ (ignore-errors (cons (edraw-decode-svg data t) t))

edraw-decode-svg is included in edraw.el. Since edraw-org.el postpones loading edraw.el until the start of editing, the above changes may result in an error before loading. If you don't care about loading time, you can avoid it by (require 'edraw) from the beginning.

Also, I think the speed is faster before the change, so I'm wondering whether to make this change permanently.

from el-easydraw.

misohena avatar misohena commented on May 30, 2024

すみません、上の変更はダメです。xmlをパースしてしまうので。
次のような関数を作って試してみてください。

I'm sorry, the above change is useless. Because it parses xml.
Create a function like the following and try it out.

(defun edraw-decode-svg-string (data base64-p)
  (with-temp-buffer
    (insert data)
    (when base64-p
      (base64-decode-region (point-min) (point-max))
      (unless (edraw-buffer-gzip-p)
        (decode-coding-region (point-min) (point-max) 'utf-8)))
    (when (edraw-buffer-gzip-p)
      (edraw-gunzip-buffer))
    (buffer-string)))
- (ignore-errors (cons (base64-decode-string data) t))
+ (ignore-errors (cons (edraw-decode-svg-string data t) t))

from el-easydraw.

misohena avatar misohena commented on May 30, 2024

確認して頂いてありがとうございます。動いたようで良かったです。

今旅行に出ているので帰ったら組み込んでみようと思います。
デフォルトでgunzipして、オプションでgunzipしないようにするのが安全かもしれません。

Thank you for checking. I'm glad it worked.

I'm on a trip now, so I'll try to incorporate it when I get home.
It may be safe to gunzip by default and optionally not gunzip.

from el-easydraw.

nxtruong avatar nxtruong commented on May 30, 2024

I reopened this issue because the same problem reappeared when [[edraw:]] was used with a file name instead of embedded data (i.e., [[edraw:file=filename.svg]]). I tracked the problem to the file edraw-org.el, function edraw-org-link-props-image-data-or-file, line (if (file-exists-p file) (cons file nil))))). The file name is used with create-image, however, the docs of create-image states that:

Image file names that are not absolute are searched for in the "images" sub-directory of ‘data-directory’ and ‘x-bitmap-file-path’ (in that order).

It turns out that the relative file name used is not an absolute path, therefore it's not found by create-image. I fixed this problem by converting the relative path to an absolute path so that create-image can find the file. I changed the above line to: (if (file-exists-p file) (cons (expand-file-name file) nil))))) where expand-file-name does the conversion. It now works properly for both embedded SVG data ([[edraw:data=...]]) and file name ([[edraw:file=...]]).

from el-easydraw.

misohena avatar misohena commented on May 30, 2024

create-image を何度も使用してきましたが、そのことを知りませんでした。動いていたのは x-bitmap-file-path が (".")だからだったのですね! 教えて頂きありがとうございます。

Pull Requestもありがとうございます。マージしました。

Google Translate:
I've used create-image many times, but didn't know that. It worked because x-bitmap-file-path was (".")! Thank you for telling me.

Thank you for Pull Request. Merged.

from el-easydraw.

Related Issues (19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.