Giter VIP home page Giter VIP logo

Comments (22)

anmsh avatar anmsh commented on July 17, 2024 2

I have recently used plantuml heavily on both Linux and Windows especially with 1.2023.3 and 1.2023.5. I will document the behaviour in a few days.

from scripts.

pbek avatar pbek commented on July 17, 2024 1

Of course!
There are also script methods to check the OS if you need to do things differently on different OSes.

from scripts.

pbek avatar pbek commented on July 17, 2024

@nikhilw, @Beurt?

from scripts.

pbek avatar pbek commented on July 17, 2024

Is there any useful log output if you enable the log panel (see Window / Panels)? Please make sure you also enable debug logging in the log panel (by right-clicking on the panel and and selecting Debug in Options).

from scripts.

anmsh avatar anmsh commented on July 17, 2024

Log panel output with all options enabled:

[08:22:57] [debug] on_noteTreeWidget_itemSelectionChanged
[08:22:57] [debug] setCurrentNote - 'note': Note: <id>489 <name>"test" <fileName>"test.md" <noteSubFolderId>10 <relativePath>"learning/architecture-and-design" <hasDirtyData>false - 'updateNoteText': true - 'updateSelectedNote': false
[08:23:03] [debug] added to history: NoteHistoryItem: <noteName>"test" <noteSubFolderPathData>"learning\narchitecture-and-design" <cursorPosition>28 <relativeScrollBarPosition>0

The debug log does not seem to contain any action either:

[Jan 24 08:27:39] [debug]: Set proxy configuration to use NO proxy
[Jan 24 08:27:42] [scripting]: loading script file: C:/Users/animesh/AppData/Roaming/PBE/QOwnNotes/scripts/list-maker/list-maker.qml
[Jan 24 08:27:42] [scripting]: loading script file: C:/Users/animesh/AppData/Roaming/PBE/QOwnNotes/scripts/sort-lines/sort-lines.qml
[Jan 24 08:27:42] [scripting]: loading script file: C:/Users/animesh/AppData/Roaming/PBE/QOwnNotes/scripts/render-plantuml/render-plantuml.qml
[Jan 24 08:27:42] [debug]: initShortcuts  - 'menuBarIsVisible':  true
[Jan 24 08:27:42] [debug]: cloudConnection:  CloudConnection: <id>1 <name>"Default" <serverUrl>"" <username>"" <priority>1
[Jan 24 08:27:42] [debug]: buildNotesIndex  - 'noteSubFolderId':  0
[Jan 24 08:27:42] [debug]: storing note file:  "test.md"
[Jan 24 08:27:42] [debug]: stored note:  Note: <id>489 <name>"test" <fileName>"test.md" <noteSubFolderId>10 <relativePath>"learning/architecture-and-design" <hasDirtyData>false
[Jan 24 08:27:42] [debug]: storeUpdatedNotesToDisk  - 'count':  1
[Jan 24 08:27:42] [status]: Stored 1 note(s) to disk
[Jan 24 08:27:43] [debug]: setupNoteFolderTables  - 'database version':  14
[Jan 24 08:27:43] [debug]: cloudConnection:  CloudConnection: <id>1 <name>"Default" <serverUrl>"" <username>"" <priority>1
[Jan 24 08:27:43] [debug]: loadNoteDirectoryList
[Jan 24 08:27:44] [debug]: reloadTagTree
[Jan 24 08:27:44] [debug]: reloadTagTree  - 'noteSubFolderIds':  QVector(10)
[Jan 24 08:27:44] [debug]: filterNotesByNoteSubFolders  - 'noteSubFolderIds':  QVector(10)
[Jan 24 08:27:44] [debug]: reloadNoteSubFolderTree
[Jan 24 08:27:44] [debug]: filterNotesByNoteSubFolders  - 'noteSubFolderIds':  QVector(10)
[Jan 24 08:27:44] [debug]: reloadNoteSubFolderTree
[Jan 24 08:27:44] [debug]: loadNoteDirectoryList
[Jan 24 08:27:44] [debug]: reloadTagTree
[Jan 24 08:27:44] [debug]: reloadTagTree  - 'noteSubFolderIds':  QVector(10)
[Jan 24 08:27:44] [debug]: filterNotesByNoteSubFolders  - 'noteSubFolderIds':  QVector(10)
[Jan 24 08:27:44] [debug]: reloadNoteSubFolderTree
[Jan 24 08:27:44] [debug]: filterNotesByNoteSubFolders  - 'noteSubFolderIds':  QVector(10)
[Jan 24 08:27:47] [debug]: on_noteTreeWidget_itemSelectionChanged
[Jan 24 08:27:47] [debug]: setCurrentNote  - 'note':  Note: <id>488 <name>"design-patterns" <fileName>"design-patterns.md" <noteSubFolderId>10 <relativePath>"learning/architecture-and-design" <hasDirtyData>false  - 'updateNoteText':  true  - 'updateSelectedNote':  false
[Jan 24 08:27:47] [debug]:  added to history:  NoteHistoryItem: <noteName>"design-patterns" <noteSubFolderPathData>"learning\narchitecture-and-design" <cursorPosition>166 <relativeScrollBarPosition>0
[Jan 24 08:27:51] [debug]: on_noteTreeWidget_itemSelectionChanged
[Jan 24 08:27:51] [debug]: setCurrentNote  - 'note':  Note: <id>489 <name>"test" <fileName>"test.md" <noteSubFolderId>10 <relativePath>"learning/architecture-and-design" <hasDirtyData>false  - 'updateNoteText':  true  - 'updateSelectedNote':  false
[Jan 24 08:27:51] [debug]:  added to history:  NoteHistoryItem: <noteName>"test" <noteSubFolderPathData>"learning\narchitecture-and-design" <cursorPosition>445 <relativeScrollBarPosition>0

from scripts.

anmsh avatar anmsh commented on July 17, 2024

Within the exported HTML, I see the path of the image like this:

<img src="file://C:\Users\animesh\programs\tmp/488_2.png?t=1611457999586" alt="Wait for it..">

This image does not exist in this path.

I opened the tmp folder side by side to see if anything is being generated when I enter new PlantUML script and nothing seems to get generated

from scripts.

anmsh avatar anmsh commented on July 17, 2024

Did some poking around with console logs 😅 in the qml file. I don't know if this effort is any worth, but I had some fun.
This is from the log panel:

[09:59:23] [debug] filePath: C:\Users\animesh\programs\tmp/488_1
[09:59:24] [debug] params to node: [-e,require('fs').writeFileSync('C:\Users\animesh\programs\tmp/488_1', "@startuml\nBob -> Alice: Hello!\n@enduml\n", 'utf8');]
[09:59:24] [debug] plantumlFiles: [C:\Users\animesh\programs\tmp/488_1]
[09:59:24] [debug] plantumlJarPath: C:\Users\animesh\programs\plantuml\plantuml.jar

The node command when executed with the params on the command line throws an error:

node -e require('fs').writeFileSync('C:\Users\animesh\programs\tmp/488_1', "@startuml\nBob -> Alice: Hello!\n@enduml\n", 'utf8');

[eval]:1
require('fs').writeFileSync('C:\Users\animesh\programs\tmp/488_1',


SyntaxError: Unexpected end of input
←[90m    at new Script (vm.js:88:7)←[39m
←[90m    at createScript (vm.js:263:10)←[39m
←[90m    at Object.runInThisContext (vm.js:311:10)←[39m
    at Object.<anonymous> ([eval]-wrapper:10:26)
←[90m    at Module._compile (internal/modules/cjs/loader.js:1158:30)←[39m
←[90m    at evalScript (internal/process/execution.js:94:25)←[39m
←[90m    at internal/main/eval_string.js:23:3←[39m

This command works however:

node -e require('fs').writeFileSync('C:\\Users\\animesh\\programs\\tmp\\4887',"11111111111",'utf8');

I suspect it has to do with how node handles path on Windows.

from scripts.

Beurt avatar Beurt commented on July 17, 2024

Hi,

I think there is problems with slashes with Windows. In the code it is probably here:

var params = ["-e", "require('fs').writeFileSync('" + filePath + "', \"" + matchedUml + "\", 'utf8');"];

and here:

var imgElement = "<div><img src=\"file://" + plantumlFiles[index++] + ".png?t=" + +(new Date()) + "\" alt=\"Wait for it..\"/></div>";

I don't have Windows so I cannot test. But if you can try to modify the code, you should maybe try to use https://doc.qt.io/qt-5/qdir.html#toNativeSeparators. Since I did not write this code I am not sure about that!

from scripts.

pbek avatar pbek commented on July 17, 2024

There are scripting methods for separator conversion: https://www.qownnotes.org/scripting/methods-and-objects.html#converting-path-separators-to-native-ones

from scripts.

anmsh avatar anmsh commented on July 17, 2024

Hello @pbek and @Beurt, good day!

Apologies for the delay in responding to this issue. Today I got a chance to dig deeper than my previous attempt and after some testing got some progress. I realized that the workDir is the first culprit.

var filePath = workDir + "/" + note.id + "_" + (++index);

After replacing single slashes with double slashes using regex replace, I see that the plantuml images got generated in the workDir location.

var filePath = workDir.replace(/\\/gm,"\\\\") + "/" + note.id + "_" + (++index);

However, the markdown preview does not still display the images. The updatedHtml is as follows:

<div><img src="file://C:\\Users\\animesh\\programs\\tmp/519_1.png?t=1618234319478" alt="Wait for it.."/></div>
<div><img src="file://C:\\Users\\animesh\\programs\\tmp/519_2.png?t=1618234319478" alt="Wait for it.."/></div>

and I can export the html and preview it in external browser just fine.

Kindly advise next steps.

from scripts.

anmsh avatar anmsh commented on July 17, 2024

I noticed that when I right click and copy the image path directly from the preview panel, the path shows up as //c/519_2.png

from scripts.

pbek avatar pbek commented on July 17, 2024

You can always export the raw html in the preview panel to debug the script code more easily.

from scripts.

anmsh avatar anmsh commented on July 17, 2024

Yes, I did that. As in the code snippet above, the raw html exported has the paths properly injected and I can open html file with plantuml images in Firefox.

from scripts.

pbek avatar pbek commented on July 17, 2024
  • I'm not sure how file urls with url parameters like file://C:\\Users\\animesh\\programs\\tmp/519_2.png?t=1618234319478 are handled.
  • Im not sure about backslashes neither...

best use an url schema like stated in https://en.wikipedia.org/wiki/File_URI_scheme

e.g. file:///c:/WINDOWS/clock.avi (yes, 3 slashes at the beginning!)

from scripts.

anmsh avatar anmsh commented on July 17, 2024

Great, that fixed it.

If I can verify that it works on Linux and follow the contribution guidelines, can I raise a PR?

from scripts.

Beurt avatar Beurt commented on July 17, 2024

Hi @anmsh!

I've been working on some important changes on render-plantuml script. And, I just introduced on new PR (#158) that should solve your problem. It is working well on Linux. Can you Try on Windows?

from scripts.

anmsh avatar anmsh commented on July 17, 2024

I will check this @Beurt. Thank you.

from scripts.

github-actions avatar github-actions commented on July 17, 2024

This issue is stale because it has been open for 30 days with no activity.

from scripts.

github-actions avatar github-actions commented on July 17, 2024

This issue is stale because it has been open for 30 days with no activity.

from scripts.

github-actions avatar github-actions commented on July 17, 2024

This issue was closed because it has been inactive for 14 days since being marked as stale.

from scripts.

anmsh avatar anmsh commented on July 17, 2024

Apologies for not responding on time for this as specified on this issue.

Here are my observations on Windows 10, QOwnNotes 23.9.0, Support for plantuml plugin 0.1.5

Today I verified that it was working to my pleasant surprise. 😮😀

I have the plantuml-1.2023.5.jar installed directly from the plantuml website.

Settings:

Path to plantuml jar:
C:/Users/animesh/programs/plantuml/plantuml-1.2023.5.jar

Working directory:
C:/Users/animesh/programs/tmp/plantuml/

Hide plantuml markup:
Yes

No need for @startuml/@enduml:
Yes

Image output format:
PNG

image

image

@pbek, @cristianofromagio

from scripts.

pbek avatar pbek commented on July 17, 2024

Thank you for testing 😉

from scripts.

Related Issues (20)

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.