qownnotes / scripts

QOwnNotes script repository
http://www.qownnotes.org
GNU General Public License v3.0
104 stars 79 forks source link

Mermaid script isn't working #144

Closed cyclops1982 closed 2 years ago

cyclops1982 commented 2 years ago

I'm not sure why this is not working. The code seems fine. There's very little output/logging on this one.

Script name

Mermaid

Script authors

pkeb

Expected behaviour

It shows a diagram...

Actual behaviour

It doesn't show a diagram :)

Steps to reproduce

Install qownnotes on debian 11.1 Install mermaid script via repository Add following text to note:

```mermaid
sequenceDiagram
    actor User
    actor webview as Browser/Webview
    participant GW as Configuration app
    participant GWS as Windows Service
    participant API as Nintex Gateway API (NWC)

    participant NWC
    User->>+GW: Type URL
    note right of GW: This happens while you type
    GW->>+API: Validate URL (anonymous call)
    API-->>-GW: Valid/Invalid response
    alt Valid response received
        GW->>GW: Enable "start gateway" button
    end
    GW->>-User: 
    User->>+GW: Press "start gateway"
    GW->>+webview: Open Webview to Authenticate URL
    note over GW: Simplified authentication request/response
    webview->>+NWC: Get Login page
    NWC-->>-webview: Login page
    User->>webview: Enter credentials
    webview->>+NWC: Validate Credentials
    NWC-->>-webview: Authentication Token
    webview-->>-GW: Authentication token
    GW->>GW: Store authentication token
    GW->>GWS: Start Windows Service
    GW-->>-User: Show current status


#### Output from the debug section in the settings dialog
None.

#### Relevant log output in the Log panel
None
pbek commented 2 years ago

Can you please post the output from the debug settings that you can copy when you get into the settings dialog in QOwnNotes and head over to the Debug section of it.

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).

pbek commented 2 years ago

@dohliam ?

cyclops1982 commented 2 years ago

QOwnNotes Debug Information

General Info

Current Date: Tue Nov 23 16:12:00 2021 Version: 21.11.8 Build date: Nov 20 2021 Build number: 915 Platform: linux Operating System: Debian GNU/Linux 11 (bullseye) Build architecture: x86_64 Current architecture: x86_64 Release: OBS Qt Version (build): 5.15.2 Qt Version (runtime): 5.15.2 Portable mode: no Settings path / key: /home/cyclops/.config/PBE/QOwnNotes.conf Application database path: /home/cyclops/.local/share/PBE/QOwnNotes/QOwnNotes.sqlite Application arguments: QOwnNotes Qt Debug: 0 Locale (system): en_GB Locale (interface): empty Primary screen resolution: 1920x1080 Screen resolution(s): 1920x1080, 1920x1200 Icon theme: Adwaita Notes in current note folder: 91 Calendar items: 0 Enabled scripts: 3

Server Info

serverUrl: https://redacted.prof-x.net appIsValid: yes notesPathExists: yes serverVersion: 20.0.9.1 appVersion: empty

Spellchecking

Enabled: true Selected language: auto Language codes: en_GB, en_US Language names: British English (United Kingdom), American English (United States) Application dictionaries path: /home/cyclops/.local/share/PBE/QOwnNotes/dicts

Note folders

currentNoteFolderId: 1

Note folder default

id: 1 isCurrent: yes activeTagId: 0 localPath: /home/cyclops/Nextcloud/Notes remotePath: Notes cloudConnectionId: 1 isShowSubfolders: yes isUseGit: no allowDifferentNoteFileName: no activeNoteSubFolder name: Days database file: /home/cyclops/Nextcloud/Notes/notes.sqlite

Cloud connections

Cloud connection redacted.prof-x.net

id: 1 isCurrent: yes serverUrl: https://REDACTED.prof-x.net username: cyclops

Enabled scripts

Script ATX Headline

id: 1 path: /home/cyclops/.local/share/PBE/QOwnNotes/scripts/atx-headline/atx-headline.qml variablesJson: empty identifier: atx-headline version: 0.0.1 minAppVersion: 20.6.0

Script Outline Numbering

id: 2 path: /home/cyclops/.local/share/PBE/QOwnNotes/scripts/outline-numbering/outline-numbering.qml variablesJson: empty identifier: outline-numbering version: 1.0.0 minAppVersion: 20.5.6

Script Mermaid Diagrams

id: 3 path: /home/cyclops/.local/share/PBE/QOwnNotes/scripts/mermaid/mermaid.qml variablesJson: empty identifier: mermaid version: 0.0.1 minAppVersion: 20.6.0

Settings

ActiveNoteHistoryItem (NoteHistoryItem): <binary data> Debug/fakeOldVersionNumber (bool): false Debug/fileLogging (bool): false Editor/CurrentSchemaKey (QString): EditorColorSchema-6033d61b-cb96-46d5-a3a8-20d5172017eb Editor/autoBracketClosing (bool): true Editor/autoBracketRemoval (bool): true Editor/centerCursor (QString): false Editor/disableCursorBlinking (bool): false Editor/editorWidthInDFMOnly (bool): true Editor/highlightCurrentLine (bool): true Editor/indentSize (int): 4 Editor/removeTrailingSpaces (bool): false Editor/showLineNumbers (bool): false Editor/useTabIndent (bool): false Editor/vimMode (bool): false LastUpdateCheck (QDateTime): 2021-11-23T15:32:34.073 MainWindow/geometry (QByteArray): <binary data> MainWindow/mainToolBar.iconSize (int): 24 MainWindow/menuBarGeometry (QByteArray): <binary data> MainWindow/noteSubFolderTreeWidgetExpandState-1 (QStringList): Work MainWindow/noteTextEdit.code.font (QString): monospace,10,-1,2,50,0,0,0,0,0 MainWindow/noteTextEdit.font (QString): Sans,10,-1,5,50,0,0,0,0,0 MainWindow/noteTextView.code.font (QString): monospace,10,-1,2,50,0,0,0,0,0 MainWindow/noteTextView.font (QString): Sans,10,-1,5,50,0,0,0,0,0 MainWindow/noteTextView.ignoreCodeFontSize (bool): true MainWindow/noteTextView.rtl (bool): false MainWindow/noteTextView.underline (bool): true MainWindow/noteTextView.useEditorStyles (bool): true MainWindow/noteTextView.useInternalExportStyling (bool): true MainWindow/showNotesFromAllNoteSubFolders (bool): false MessageBoxOverride/script-install-successful (QString): 1024 NoteFolder-1/NoteTabNameList (QStringList): REDACTED NoteFolder-1/NoteTabStickinessList (QStringList): 2 NoteFolder-1/NoteTabSubFolderPathDataList (QStringList):

Work
Days, Work
Writing, Work, Work, Work, Work, Work

NoteHistory-1 (QVariantList): <variant list with 13 item(s)> NoteHistoryCurrentIndex-1 (int): 12 PiwikClientId (QString): <hidden> ScriptRepositoryDialog/geometry (QByteArray): <binary data> ScriptRepositoryDialog/mainSplitterState (QByteArray): <binary data> SearchEngineId (int): 2 SettingsDialog/geometry (QByteArray): <binary data> SettingsDialog/mainSplitterState (QByteArray): <binary data> ShowSystemTray (bool): false StartHidden (bool): false WelcomeDialog/geometry (QByteArray): <binary data> acceptAllExternalModifications (bool): false allowNoteEditing (bool): true allowOnlyOneAppInstance (bool): true appMetrics/disableAppHeartbeat (bool): false appMetrics/disableTracking (bool): false appMetrics/notificationShown (QString): true automaticNoteFolderDatabaseClosing (bool): false checkSpelling (bool): true closeTodoListAfterSave (bool): false cryptoKey (QString): <hidden> currentNoteFolderId (QString): 1 currentWorkspace (QString): initial cursorWidth (int): 1 customNoteFileExtensionList (QStringList): md, txt darkMode (bool): false darkModeColors (bool): false darkModeIconTheme (bool): false darkModeTrayIcon (bool): false defaultNoteFileExtension (QString): md disableAutomaticUpdateDialog (bool): true disableSavedSearchesAutoCompletion (bool): false dockWasInitializedOnce (QString): true enableNoteTree (bool): false enableSocketServer (bool): true enableWebAppSupport (bool): false externalEditorPath (QString): empty fullyHighlightedBlockquotes (bool): false gitCommitInterval (int): 30 gitExecutablePath (QString): empty gitLogCommand (QString): empty guiFirstRunInit (bool): true ignoreAllExternalModifications (bool): false ignoreAllExternalNoteFolderChanges (bool): false ignoreNoteSubFolders (QString): ^\. imageScaleDown (bool): false imageScaleDownMaximumHeight (int): 1024 imageScaleDownMaximumWidth (int): 1024 initialLayoutIdentifier (QString): full insertTimeFormat (QString): empty interfaceFontSize (int): 11 interfaceLanguage (QString): empty internalIconTheme (bool): false itemHeight (int): 17 legacyLinking (bool): false localTrash/autoCleanupDays (int): 30 localTrash/autoCleanupEnabled (bool): true localTrash/supportEnabled (bool): true markdownHighlightingEnabled (bool): true navigationPanelHideSearch (bool): false networking/ignoreSSLErrors (bool): true networking/proxyType (int): 2 newNoteAskHeadline (bool): false noteEditIsCentralWidget (bool): true noteListPreview (bool): false noteSaveIntervalTime (int): 10 noteSubfoldersPanelDisplayAsFullTree (bool): true noteSubfoldersPanelHideSearch (bool): false noteSubfoldersPanelOrder (int): 0 noteSubfoldersPanelShowFullPath (bool): false noteSubfoldersPanelShowNotesRecursively (bool): false noteSubfoldersPanelShowRootFolderName (bool): true noteSubfoldersPanelSort (int): 0 notesPanelOrder (int): 0 notesPanelSort (int): 1 notesPath (QString): /home/cyclops/Nextcloud/Notes notifyAllExternalModifications (bool): false overrideInterfaceFontSize (bool): false ownCloud/supportEnabled (bool): true ownCloud/todoCalendarBackend (int): 3 ownCloud/todoCalendarCalDAVPassword (QString): <hidden> ownCloud/todoCalendarCalDAVServerUrl (QString): empty ownCloud/todoCalendarCalDAVUsername (QString): empty ownCloud/todoCalendarCloudConnectionId (int): 1 ownCloud/todoCalendarDisplayNameList (QStringList): REDACTED ownCloud/todoCalendarEnabledList (QStringList): REDACTED ownCloud/todoCalendarEnabledUrlList (QStringList): REDACTED ownCloud/todoCalendarUrlList (QStringList): REDACTED ownCloudInfo/appIsValid (bool): true ownCloudInfo/connectionErrorMessage (QString): Unknown error ownCloudInfo/notesPathExistsText (QString): yes ownCloudInfo/serverVersion (QString): 20.0.9.1 restoreCursorPosition (bool): true restoreLastNoteAtStartup (bool): true restoreNoteTabs (bool): true savedSearches/noteFolder-1 (QStringList): Note 2021-11-23T08.29.47, Note 2021-11-22T13.16.51, Note 2021-11-22T08.34.37 showMatches (bool): true showMenuBar (bool): true showStatusBar (bool): true spellCheckLanguage (QString): auto systemIconTheme (bool): false taggingShowNotesRecursively (bool): false tagsPanelHideNoteCount (bool): false tagsPanelHideSearch (bool): false tagsPanelOrder (int): 0 tagsPanelSort (int): 0 todoCalendarSupport (bool): true toolbar/1/items (QStringList): action_New_note, action_Find_note, action_Remove_note, action_Open_note_in_external_editor, actionShow_local_trash, actionAllow_note_editing, , action_Back_in_note_history, action_Forward_in_note_history, , action_Find_text_in_note, actionReplace_in_current_note, , actionShow_versions, actionShow_trash, actionShare_note, , actionShow_Todo_List toolbar/1/name (QString): mainToolBar toolbar/1/title (QString): main toolbar toolbar/2/items (QStringList): actionFormat_text_bold, actionFormat_text_italic, actionStrike_out_text, actionInsert_code_block, actionInsert_block_quote toolbar/2/name (QString): formattingToolbar toolbar/2/title (QString): formatting toolbar toolbar/3/items (QStringList): actionInsert_text_link, actionInsert_image, actionInsert_current_time toolbar/3/name (QString): insertingToolbar toolbar/3/title (QString): inserting toolbar toolbar/4/items (QStringList): action_Encrypt_note, actionEdit_encrypted_note, actionDecrypt_note toolbar/4/name (QString): encryptionToolbar toolbar/4/title (QString): encryption toolbar toolbar/5/items (QStringList): actionWorkspaceComboBox, actionStore_as_new_workspace, actionRemove_current_workspace, actionRename_current_workspace, actionSwitch_to_previous_workspace, actionUnlock_panels, , actionToggle_distraction_free_mode, action_Increase_note_text_size, action_Decrease_note_text_size, action_Reset_note_text_size toolbar/5/name (QString): windowToolbar toolbar/5/title (QString): window toolbar toolbar/6/items (QStringList): action_Quit toolbar/6/name (QString): quitToolbar toolbar/6/title (QString): quit toolbar toolbar/size (int): 6 useNoteFolderButtons (bool): false useSoftWrapInNoteEditor (QString): true useUNIXNewline (bool): false webAppClientService/serverUrl (QString): wss://app.qownnotes.org webAppClientService/token (QString): <hidden> webSocketServerService/bookmarksNoteName (QString): Bookmarks webSocketServerService/bookmarksTag (QString): bookmarks webSocketServerService/port (int): 22222 workspace-initial/name (QString): Full workspace-initial/noteSubFolderDockWidgetVisible (QString): true workspace-initial/windowState (QByteArray): <binary data> workspaces (QString): initial

System environment

GJS_DEBUG_TOPICS: JS ERROR;JS LOG LANGUAGE: en_GB:en USER: cyclops XDG_SESSION_TYPE: wayland SHLVL: 0 HOME: /home/cyclops DESKTOP_SESSION: gnome GIO_LAUNCHED_DESKTOP_FILE: /usr/share/applications/PBE.QOwnNotes.desktop GTK_MODULES: gail:atk-bridge MANAGERPID: 1412 DBUS_SESSION_BUS_ADDRESS: unix:path=/run/user/1000/bus IM_CONFIG_CHECK_ENV: 1 GIO_LAUNCHED_DESKTOP_FILE_PID: 15594 IM_CONFIG_PHASE: 1 WAYLAND_DISPLAY: wayland-0 LOGNAME: cyclops _: /usr/bin/gnome-session JOURNAL_STREAM: 8:81245 XDG_SESSION_CLASS: user USERNAME: cyclops GNOME_DESKTOP_SESSION_ID: this-is-deprecated PATH: /usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/snap/bin GDM_LANG: en_GB.UTF-8 SESSION_MANAGER: local/mimic:@/tmp/.ICE-unix/8735,unix/mimic:/tmp/.ICE-unix/8735 INVOCATION_ID: 9415d713308c46efb610a5dc5425a750 XDG_RUNTIME_DIR: /run/user/1000 XDG_MENU_PREFIX: gnome- GNOME_SETUP_DISPLAY: :1 DISPLAY: :0 LANG: en_GB.UTF-8 XDG_CURRENT_DESKTOP: GNOME XDG_SESSION_DESKTOP: gnome XMODIFIERS: @im=ibus XAUTHORITY: /run/user/1000/.mutter-Xwaylandauth.AW09C1 SSH_AGENT_LAUNCHER: openssh SSH_AUTH_SOCK: /run/user/1000/keyring/ssh SHELL: /bin/bash QT_ACCESSIBILITY: 1 GDMSESSION: gnome GJS_DEBUG_OUTPUT: stderr QT_IM_MODULE: ibus PWD: /home/cyclops XDG_DATA_DIRS: /usr/local/share/:/usr/share/:/var/lib/snapd/desktop

cyclops1982 commented 2 years ago

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).

There's a little, but not much:


[16:15:17] [debug] No scores for "```m```"
[16:15:17] [debug] No scores for "```me```"
[16:15:17] [debug] No scores for "```mer```"
[16:15:18] [debug] No scores for "```merm```"
[16:15:18] [debug] cloudConnection: CloudConnection: <id>1 <name>"redacted.prof-x.net" <serverUrl>"https://redacted.prof-x.net" <username>"cyclops" <priority>0
[16:15:18] [debug] No scores for "```merma```"
[16:15:18] [debug] No scores for "```mermai```"
[16:15:19] [debug] cloudConnection: CloudConnection: <id>1 <name>"redacted.prof-x.net" <serverUrl>"https://redacted.prof-x.net" <username>"cyclops" <priority>0
[16:15:22] [debug] Code block of lang detected: "mermaid" 0
[16:15:22] [debug] cloudConnection: CloudConnection: <id>1 <name>"redacted.prof-x.net" <serverUrl>"https://redacted.prof-x.net" <username>"cyclops" <priority>0
[16:15:26] [debug] storing note file: "Note 2021-11-23T08.29.47.md"
[16:15:26] [debug] stored note: Note: <id>91 <name>"Note 2021-11-23T08.29.47" <fileName>"Note 2021-11-23T08.29.47.md" <noteSubFolderId>3 <relativePath>"Work/Days" <hasDirtyData>false
[16:15:26] [debug] storeUpdatedNotesToDisk - 'count': 1
[16:15:26] [status] Stored 1 note(s) to disk
[16:15:48] [debug] Code block of lang detected: "mermaid" 0
[16:15:48] [debug] cloudConnection: CloudConnection: <id>1 <name>"redacted.prof-x.net" <serverUrl>"https://redacted.prof-x.net" <username>"cyclops" <priority>0
[16:15:49] [debug] Code block of lang detected: "mermaid" 0
[16:15:50] [debug] cloudConnection: CloudConnection: <id>1 <name>"redacted.prof-x.net" <serverUrl>"https://redacted.prof-x.net" <username>"cyclops" <priority>0
[16:15:56] [debug] storing note file: "Note 2021-11-23T08.29.47.md"
[16:15:56] [debug] stored note: Note: <id>91 <name>"Note 2021-11-23T08.29.47" <fileName>"Note 2021-11-23T08.29.47.md" <noteSubFolderId>3 <relativePath>"Work/Days" <hasDirtyData>false
[16:15:56] [debug] storeUpdatedNotesToDisk - 'count': 1
[16:15:56] [status] Stored 1 note(s) to disk
[16:16:00] [debug] storing note file: "Note 2021-11-23T08.29.47.md"
[16:16:00] [debug] stored note: Note: <id>91 <name>"Note 2021-11-23T08.29.47" <fileName>"Note 2021-11-23T08.29.47.md" <noteSubFolderId>3 <relativePath>"Work/Days" <hasDirtyData>false
[16:16:00] [debug] storeUpdatedNotesToDisk - 'count': 1
[16:16:00] [status] Stored 1 note(s) to disk
[16:16:01] [debug] Code block of lang detected: "mermaid" 0
[16:16:01] [debug] cloudConnection: CloudConnection: <id>1 <name>"redacted.prof-x.net" <serverUrl>"https://redacted.prof-x.net" <username>"cyclops" <priority>0
[16:16:15] [debug] openLinkAtCursorPosition - 'emit urlClicked( urlString )': ""
cyclops1982 commented 2 years ago

I don't know what happened, but now it's working!

pbek commented 2 years ago

Maybe the external API was down...

https://github.com/qownnotes/scripts/blob/11e942e8fe4a84481d5167a02e066e8463a881fd/mermaid/mermaid.qml#L24

cyclops1982 commented 2 years ago

So, it worked. Now it doesn't.

It's a bit strange and not consistent. Opened the issue again.

What can i do to troubleshoot this. Can i log the URL?

pbek commented 2 years ago

You can download the script I referenced above and edit it.

cyclops1982 commented 2 years ago

ok, did a console.log to output the URL. Hit that in the browser and get invalid encoded code

cyclops1982 commented 2 years ago

Ok, seems that the few .replace()'s are not catching everything: https://github.com/qownnotes/scripts/blob/11e942e8fe4a84481d5167a02e066e8463a881fd/mermaid/mermaid.qml#L22

Is there a way to replace that in a better way?

cyclops1982 commented 2 years ago

Pull request created.

This is quite ugly though. Is there maybe an option to change/update preNoteToMarkdownHtmlHook so it gives the plain-text markdown? That would (in this case) be better.

pbek commented 2 years ago

Is there maybe an option to change/update preNoteToMarkdownHtmlHook so it gives the plain-text markdown? That would (in this case) be better.

That is exactly was preNoteToMarkdownHtmlHook is getting in the 2nd parameter.

dohliam commented 2 years ago

@pbek I was going to suggest that this might be a diagram that is too large for the API (which has a size limit), but I see that isn't the case here.

@cyclops1982 Thanks for the elegant fix -- I updated the script to the latest version and can confirm that it works quite well!

dohliam commented 2 years ago

Also, just another quick note to add that #145 seems to have also fixed the issues with diagrams not working that I documented earlier here. Both of the example diagrams mentioned on that page are now displayed properly! :tada:

pbek commented 2 years ago

Awesome! 😀