-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
use server exec-mode,this error:the plugin you are using seems to generated a bad URL. #146
Comments
|
Here the PlantUML team gives a more detailed explanation why this happens. |
@kasimirmoilanen do you find that prefixing data with I just tried that (by patching line 432 in plantuml-mode.el), but I still get error saying:
|
@natrys I tried this as a quick fix, but I also still get the error. I just changed plantuml-default-exec-mode to jar as specified in the readme, I think that or executable mode are better anyway as you don't need to connect to external servers. |
@kasimirmoilanen Yeah you are right. I was looking to avoid java things in all my machines, but I suppose it is what it is. Anyway, looking at the elisp function, it appears that the function was merely doing base64 encoding, without performing the compression (hoffman or deflate) required before that, so no wonder it doesn't work. As for fixing the issue, Emacs sadly doesn't have compression primitives like zlib or brotli, which appears to be the server's recommendation now. Emacs actually builds with zlib, but the FFI only exposes decompression. I found that someone sent patch to add compression too in mailing list, but somewhat true to form it got lost in discussion without actually getting merged: https://lists.gnu.org/r/emacs-devel/2020-03/msg00802.html We could just shell out to gzip I guess. But as I try this, it appears that the bigger problem is that the server seems to expect a modified base64 encoding for legacy reasons: https://plantuml.com/en/text-encoding So off the shelf base64 from coreutils or That page also lists that now API also accepts hex encoding, which is finally something that's doable in pure elisp. This of course increases size 2x from plaintext, which is kind of terrible. But for now I don't really care: (defun hex-encode (str)
(string-join (mapcar (lambda (c) (format "%02x" c)) str)))
(defun plantuml-server-encode-url (string)
"Encode the string STRING into a URL suitable for PlantUML server interactions."
(let* ((encoded-string (hex-encode string)))
(concat plantuml-server-url "/" plantuml-output-type "/~h" encoded-string))) And this worked. (well the server |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Previously it generated the preview through the online API, which failed since a while. Seems to be a problem of plantuml-mode. See skuro/plantuml-mode#146
FYI while server mode no longer works out of the box because of this issue, jar mode works. |
@natrys method does work for me (thanks for sharing), but special/accented characters are not rendered correctly: Does anyone know a workaround for that? |
@jjnilton yeah I failed to account for multi byte code points. I am not really knowledgeable around these APIs in Emacs, but this might solve your issue: (defun hex-encode (str)
(string-join (mapcar (lambda (c) (format "%02x" c)) (string-as-unibyte str)))) On a tangential note, I had discovered https://kroki.io/ who provide a unified API for quite a number of backends including plantuml. I have brushed up my old wrapper code that shows preview using it, in case it's useful to anyone: diagram-preview. |
That solved it, thanks @natrys. Good to know about kroki.io, looks great, thanks for sharing your package. |
Summary
Checklist for pull requests
develop
branch instead ofmaster
The text was updated successfully, but these errors were encountered: