qownnotes / scripts

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

undefined error when loading script #42

Closed close2infinity closed 6 years ago

close2infinity commented 6 years ago

@milan-rusev

Expected behaviour

Script should be able to render content

Actual behaviour

Steps to reproduce

Output from the debug section in the settings dialog

QOwnNotes Debug Information

General Info

Current Date: Mi. Sep. 12 13:52:22 2018 Version: 18.09.1 Build date: Sep 9 2018 Build number: 476 Platform: linux Operating System: Ubuntu 16.04.4 LTS Build architecture: x86_64 Current architecture: x86_64 Release: Launchpad PPA Qt Version (build): 5.5.1 Qt Version (runtime): 5.6.1 Portable mode: no Settings path / key: /home/fschoenh/.config/PBE/QOwnNotes.conf Application database path: /home/fschoenh/.local/share/PBE/QOwnNotes/QOwnNotes.sqlite Application arguments: /usr/bin/QOwnNotes Qt Debug: 0 Locale (system): en_US Locale (interface): empty Icon theme: breeze-dark-qownnotes Notes in current note folder: 23 Enabled scripts: 1

Server Info

serverUrl: https://www.the-anvil.net/nxtc appIsValid: yes notesPathExists: yes serverVersion: 12.0.4.3 appVersion: empty

Note folders

currentNoteFolderId: 1

Note folder default

id: 1 isCurrent: yes activeTagId: 1 localPath: /home/fschoenh/ownCloud/work/cs/Notes remotePath: work/cs/Notes isShowSubfolders: yes isUseGit: yes activeNoteSubFolder name: empty database file: /home/fschoenh/ownCloud/work/cs/Notes/notes.sqlite

Note folder O2

id: 2 isCurrent: no activeTagId: -1 localPath: /home/fschoenh/work/projects/o2/Documents remotePath: empty isShowSubfolders: yes isUseGit: yes activeNoteSubFolder name: empty database file: /home/fschoenh/work/projects/o2/Documents/notes.sqlite

Enabled scripts

Script Markdown-it markdown parser

id: 11 path: /home/fschoenh/.local/share/PBE/QOwnNotes/scripts/markdown-it/markdown-it.qml variablesJson: empty identifier: markdown-it version: 1.0.1 minAppVersion: 17.08.2

Settings

AboutDialog/geometry: <binary data> ActionDialog/geometry: <binary data> ActiveNoteHistoryItem: empty Debug/fakeOldVersionNumber: false Debug/fileLogging: false DistractionFreeMode/editorWidthMode: 3 DistractionFreeMode/isEnabled: false DistractionFreeMode/menuBarGeometry: <binary data> DistractionFreeMode/menuBarHeight: 30 DistractionFreeMode/windowState: <binary data> Editor/CurrentSchemaKey: EditorColorSchema-cdbf28fc-1ddc-4d13-bb21-6a4043316a2f Editor/autoBracketClosing: true Editor/autoBracketRemoval: true Editor/editorWidthInDFMOnly: true Editor/highlightCurrentLine: true Editor/vimMode: false LastUpdateCheck: 2018-09-12T13:50:22 LogWidget/showAtStartup: false MainWindow/geometry: <binary data> MainWindow/mainToolBar.iconSize: 22 MainWindow/menuBarGeometry: <binary data> MainWindow/noteSubFolderTreeWidgetExpandState-2: O2 Shop, O2 Shop/infrastructure, O2 Shop/shop-infrastructure, Review-MCE_IF_R18.5 MainWindow/noteTextEdit.code.font: Source Code Pro,9,-1,0,50,0,0,0,0,0 MainWindow/noteTextEdit.font: Arial,10,-1,0,50,0,0,0,0,0 MainWindow/noteTextView.code.font: Hasklig,10,-1,0,75,0,0,0,0,0 MainWindow/noteTextView.font: Arial,12,-1,0,50,0,0,0,0,0 MainWindow/noteTextView.rtl: false MainWindow/showNotesFromAllNoteSubFolders: false PiwikClientId: <hidden> ScriptRepositoryDialog/geometry: <binary data> ScriptRepositoryDialog/mainSplitterState: <binary data> SearchEngineId: 0 SettingsDialog/geometry: <binary data> SettingsDialog/mainSplitterState: <binary data> ShareDialog/geometry: <binary data> Shortcuts/MainWindow-action_DuplicateText: Ctrl+Shift+D ShowSystemTray: true StartHidden: false TodoDialog/geometry: <binary data> TodoDialog/mainSplitterState: <binary data> TodoDialog/showCompletedItems: 2 TodoDialog/todoListSelectorSelectedItem: project UpdateDialog/geometry: <binary data> WelcomeDialog/geometry: <binary data> acceptAllExternalModifications: true allowDifferentNoteFileName: true allowNoteEditing: true allowOnlyOneAppInstance: true appMetrics/disableAppHeartbeat: false appMetrics/disableTracking: true appMetrics/notificationShown: true automaticNoteFolderDatabaseClosing: false closeTodoListAfterSave: false cryptoKey: <hidden> currentNoteFolderId: 1 currentWorkspace: 6b252e98-a5d3-44ba-a033-32648d25d8d2 cursorWidth: 1 customNoteFileExtensionList: empty darkMode: true darkModeColors: true darkModeTrayIcon: true defaultNoteFileExtension: md demoNotesCreated: true disableAutomaticUpdateDialog: true dockWasInitializedOnce: true externalEditorPath: /usr/bin/atom fullyHighlightedBlockquotes: true gitCommitInterval: 30 gitExecutablePath: empty gitLogCommand: empty ignoreAllExternalModifications: false ignoreAllExternalNoteFolderChanges: false imageScaleDown: false imageScaleDownMaximumHeight: 1024 imageScaleDownMaximumWidth: 1024 insertTimeFormat: empty interfaceLanguage: empty internalIconTheme: false itemHeight: 26 localTrash/autoCleanupDays: 30 localTrash/autoCleanupEnabled: true localTrash/supportEnabled: true markdownHighlightingEnabled: true networking/ignoreSSLErrors: true networking/proxyHostName: proxy.muc1.device-insight.de networking/proxyNeedsAuth: false networking/proxyPassword: <hidden> networking/proxyPort: 3128 networking/proxyType: 2 networking/proxyUser: empty newNoteAskHeadline: false noteEditIsCentralWidget: false noteListPreview: false noteSaveIntervalTime: 10 noteSubfoldersPanelDisplayAsFullTree: true noteSubfoldersPanelHideSearch: false noteSubfoldersPanelOrder: 0 noteSubfoldersPanelShowFullPath: false noteSubfoldersPanelShowNotesRecursively: true noteSubfoldersPanelShowRootFolderName: true noteSubfoldersPanelSort: 0 notesPanelOrder: 0 notesPanelSort: 0 notesPath: /home/fschoenh/ownCloud/work/cs/Notes notifyAllExternalModifications: false oneColumnModeEnabled: false ownCloud/ignoreNonTodoCalendars: false ownCloud/password: <hidden> ownCloud/serverUrl: https://www.the-anvil.net/nxtc ownCloud/supportEnabled: true ownCloud/todoCalendarBackend: 3 ownCloud/todoCalendarCalDAVPassword: <hidden> ownCloud/todoCalendarCalDAVServerUrl: empty ownCloud/todoCalendarCalDAVUsername: empty ownCloud/todoCalendarDisplayNameList: private, comsysto, project-optional, project, binoflo, einkaufsliste, wunschzettel-bettina, wunschzettel-flo ownCloud/todoCalendarEnabledList: project ownCloud/todoCalendarEnabledUrlList: https://www.the-anvil.net/nxtc/remote.php/dav/calendars/flo/project/ ownCloud/todoCalendarUrlList: https://www.the-anvil.net/nxtc/remote.php/dav/calendars/flo/private/, https://www.the-anvil.net/nxtc/remote.php/dav/calendars/flo/comsysto/, https://www.the-anvil.net/nxtc/remote.php/dav/calendars/flo/project-optional/, https://www.the-anvil.net/nxtc/remote.php/dav/calendars/flo/project/, https://www.the-anvil.net/nxtc/remote.php/dav/calendars/flo/binoflo/, https://www.the-anvil.net/nxtc/remote.php/dav/calendars/flo/einkaufsliste/, https://www.the-anvil.net/nxtc/remote.php/dav/calendars/flo/wunschzettel-bettina/, https://www.the-anvil.net/nxtc/remote.php/dav/calendars/flo/wunschzettel-flo/ ownCloud/userName: flo ownCloudInfo/appIsValid: true ownCloudInfo/connectionErrorMessage: Unknown error ownCloudInfo/notesPathExistsText: yes ownCloudInfo/serverVersion: 12.0.4.3 previousWorkspace: 6d0e2c1a-dcf2-4cc5-a73e-0490a99106d1 recentNoteFolders: /home/fschoenh/work/projects/o2/Documents, /home/fschoenh/work/projects/o2/Documents/Notes, /home/fschoenh/work/truecrypt/projects/di/vaillant/documents, /home/fschoenh/ownCloud/Notes restoreCursorPosition: true savedSearches/noteFolder-1: scratch, mockito, Note 2017-04-18T10.29.04, bash, Postgres, docker, linux, junit, Agile savedSearches/noteFolder-2: Note 2018-02-26T17.12.31 showMenuBar: true showStatusBar: true skipVersion: 16.10.0 taggingShowNotesRecursively: true tagsPanelHideSearch: false tagsPanelOrder: 0 tagsPanelSort: 0 toolbar/1/items: action_New_note, action_Find_note, action_Remove_note, action_Open_note_in_external_editor, , 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, , actionOpen_List toolbar/1/name: mainToolBar toolbar/1/title: main toolbar toolbar/2/items: actionFormat_text_bold, actionFormat_text_italic, actionStrike_out_text toolbar/2/name: formattingToolbar toolbar/2/title: formatting toolbar toolbar/3/items: actionInsert_Link_to_note, actionInsert_image, actionInsert_current_time toolbar/3/name: insertingToolbar toolbar/3/title: inserting toolbar toolbar/4/items: action_Encrypt_note, actionEdit_encrypted_note, actionDecrypt_note toolbar/4/name: encryptionToolbar toolbar/4/title: encryption toolbar toolbar/5/items: 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: windowToolbar toolbar/5/title: window toolbar toolbar/6/items: action_Quit toolbar/6/name: quitToolbar toolbar/6/title: quit toolbar toolbar/size: 6 useSoftWrapInNoteEditor: true useUNIXNewline: false workspace-6b252e98-a5d3-44ba-a033-32648d25d8d2/name: default workspace-6b252e98-a5d3-44ba-a033-32648d25d8d2/noteSubFolderDockWidgetVisible: true workspace-6b252e98-a5d3-44ba-a033-32648d25d8d2/windowState: <binary data> workspace-6d0e2c1a-dcf2-4cc5-a73e-0490a99106d1/noteSubFolderDockWidgetVisible: true workspace-6d0e2c1a-dcf2-4cc5-a73e-0490a99106d1/windowState: <binary data> workspaces: 6b252e98-a5d3-44ba-a033-32648d25d8d2

System environment

LC_PAPER: de_DE.UTF-8 XDG_VTNR: 7 LC_ADDRESS: de_DE.UTF-8 XDG_SESSION_ID: 2 SSH_AGENT_PID: 4838 PAM_KWALLET5_LOGIN: /tmp/kwallet5_fschoenh.socket LC_MONETARY: de_DE.UTF-8 GPG_AGENT_INFO: /home/fschoenh/.gnupg/S.gpg-agent:0:1 SHELL: /usr/bin/zsh XDG_SESSION_COOKIE: 9742ee653ae29e9bcba4c527568a5204-1536737523.795051-1122162687 QT_LINUX_ACCESSIBILITY_ALWAYS_ON: 1 GS_LIB: /home/fschoenh/.fonts LC_NUMERIC: de_DE.UTF-8 GTK_MODULES: gail:atk-bridge XDG_SESSION_CLASS: user KDE_FULL_SESSION: true USER: fschoenh QT_ACCESSIBILITY: 1 LC_TELEPHONE: de_DE.UTF-8 XCURSOR_SIZE: 0 XDG_SESSION_PATH: /org/freedesktop/DisplayManager/Session1 QT_AUTO_SCREEN_SCALE_FACTOR: 0 XDG_SEAT_PATH: /org/freedesktop/DisplayManager/Seat0 SSH_AUTH_SOCK: /tmp/ssh-S0TR2yKsRhaS/agent.4411 PLANTUML_HOME: /home/fschoenh/ownCloud/work/cs/resources/plantuml SESSION_MANAGER: local/fschoenh-ThinkPad-T550:@/tmp/.ICE-unix/5061,unix/fschoenh-ThinkPad-T550:/tmp/.ICE-unix/5061 DEFAULTS_PATH: /usr/share/gconf//usr/share/xsessions/plasma.default.path QT_SCREEN_SCALE_FACTORS: eDP1=1;DP1=1;DP2=1;HDMI1=1;HDMI2=1;VIRTUAL1=1; XDG_CONFIG_DIRS: /etc/xdg/xdg-/usr/share/xsessions/plasma:/etc/xdg:/usr/share/kubuntu-default-settings/kf5-settings PATH: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/fschoenh/bin/FDK/Tools/linux DESKTOP_SESSION: /usr/share/xsessions/plasma LC_IDENTIFICATION: de_DE.UTF-8 PWD: /home/fschoenh XDG_SESSION_TYPE: x11 KDE_SESSION_UID: 1000 LANG: de_DE.UTF-8 MANDATORY_PATH: /usr/share/gconf//usr/share/xsessions/plasma.mandatory.path LC_MEASUREMENT: de_DE.UTF-8 HOME: /home/fschoenh SHLVL: 1 XDG_SEAT: seat0 KDE_SESSION_VERSION: 5 LANGUAGE: en_US:de XCURSOR_THEME: Maya-Black XDG_SESSION_DESKTOP: KDE LOGNAME: fschoenh XDG_DATA_DIRS: /usr/share//usr/share/xsessions/plasma:/usr/local/share/:/usr/share/:/var/lib/snapd/desktop DBUS_SESSION_BUS_ADDRESS: unix:abstract=/tmp/dbus-f4afp0UTVN,guid=80566eba7098054082247d0b5b98c0f3 DISPLAY: :0 XDG_RUNTIME_DIR: /run/user/1000 XDG_CURRENT_DESKTOP: KDE FDK_EXE: /home/fschoenh/bin/FDK/Tools/linux PAM_KWALLET_LOGIN: /tmp/kwallet_fschoenh.socket LC_TIME: de_DE.UTF-8 LC_NAME: de_DE.UTF-8 XAUTHORITY: /home/fschoenh/.Xauthority _: /usr/bin/nohup

Relevant log output in the Log panel

[13:51:07] [scripting] loading script file: /home/fschoenh/.local/share/PBE/QOwnNotes/scripts/markdown-it/markdown-it.qml
[13:51:07] [warning] file:///home/fschoenh/.local/share/PBE/QOwnNotes/scripts/markdown-it/markdown-it.qml:59: TypeError: Type error
[13:51:07] [status] The scripting engine was reloaded
pbek commented 6 years ago

First please update to the latest version of QOwnNotes, then remove the script and install it again.

close2infinity commented 6 years ago

Sorry - I thought I had updated, but it seems the old version was still in memory. I updated to version 18.09.1 and reinstalled the script. However, the issue persists.

pbek commented 6 years ago

Then it's best to post that issue on https://github.com/qownnotes/scripts/issues and mention the authors of the script.

pbek commented 6 years ago

That's the line of the script: https://github.com/qownnotes/scripts/blob/master/markdown-it/markdown-it.qml#L59

close2infinity commented 6 years ago

Hi, thx for the comments. I originally missed that this issue list is for all scripts - I updated the issue and included @MilanRusev, who I assume is the author.

pbek commented 6 years ago

Then it's best to post that issue on https://github.com/qownnotes/scripts/issues

oh, sorry. we already are on https://github.com/qownnotes/scripts/issues :D

pbek commented 6 years ago

btw. can you please execute ls -hal /home/fschoenh/.local/share/PBE/QOwnNotes/scripts/markdown-it/ and post the result.

close2infinity commented 6 years ago
drwxrwxr-x  2 fschoenh fschoenh 4,0K Sep 12 13:50 .
drwxrwxr-x 11 fschoenh fschoenh 4,0K Sep 12 15:01 ..
-rw-rw-r--  1 fschoenh fschoenh 253K Sep 12 15:24 markdown-it.js
-rw-rw-r--  1 fschoenh fschoenh 3,3K Sep 12 15:16 markdown-it.qml
close2infinity commented 6 years ago

I tried debugging this myself despite my very limited Javascript expertise.

pbek commented 6 years ago

It's really strange, it works flawlessly for me...

pbek commented 6 years ago

Operating System: KDE neon User Edition 5.13 Build architecture: x86_64 Current architecture: x86_64 Release: Launchpad PPA Qt Version (build): 5.5.1 Qt Version (runtime): 5.11.1

pbek commented 6 years ago

You could try downloading https://github.com/markdown-it/markdown-it/blob/master/dist/markdown-it.js directly...

close2infinity commented 6 years ago

I'll try that, thx for the support.

close2infinity commented 6 years ago

I found the issue. For some reason, on my system the imported script needs be referred to as 'this' instead of 'MarkdownIt'. I changed Line 59 to:

md = new this.markdownit(optionsObj);

... and now it works. I fear I know QML even less than I do know JavaScript - is there any explanation for this behavior?

pbek commented 6 years ago

so your system ignores the MarkdownIt part of import "markdown-it.js" as MarkdownIt, very strange

pbek commented 6 years ago

but according to https://doc.qt.io/qt-5/qtqml-syntax-imports.html the as should work

pbek commented 6 years ago

also in Qt 5.5 and 5.6: https://doc.qt.io/archives/qt-5.5/qtqml-syntax-imports.html

pbek commented 6 years ago

Do you use stock Ubuntu or some derivative distribution? Because you are using Qt 5.6.1 instead of the stock 5.5.1 of Ubuntu 16.04.

close2infinity commented 6 years ago

I have a Kubuntu 16.04

pbek commented 6 years ago

Interesting, I didn't know that the Qt version was getting updated by Kubuntu... or do you use a special repository for Qt?

close2infinity commented 6 years ago

I think I'm using the stock Kubuntu KDE, but this is a three years old dev system, so I might have added some PPAs I'm not aware of anymore.

pbek commented 6 years ago

Xenial is still at 5.5.1: https://packages.ubuntu.com/search?suite=xenial&searchon=names&keywords=qt

what does dpkg -s libqt5core5a say for you?

close2infinity commented 6 years ago
Package: libqt5core5a
Status: install ok installed
Priority: optional
Section: libs
Installed-Size: 5302
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Architecture: amd64
Multi-Arch: same
Source: qtbase-opensource-src
Version: 5.6.1+dfsg-3ubuntu1~xenialoverlay1~4+fix1
Replaces: libqt5core5 (<< 5.2.0+dfsg~)
Provides: qtbase-abi-5-6-1
Depends: libc6 (>= 2.15), libgcc1 (>= 1:3.4), libglib2.0-0 (>= 2.22.0), libicu55 (>= 55.1-1~), libpcre16-3 (>= 2:8.35-4), libstdc++6 (>= 5), zlib1g (>= 1:1.1.4)
Recommends: qttranslations5-l10n
Suggests: libthai0
Breaks: libqt5core5 (<< 5.2.0+dfsg~), libqt5scintilla2-12v5 (<< 2.9.2+dfsg-2~)
Description: Qt 5 core module
 Qt is a cross-platform C++ application framework. Qt's primary feature
 is its rich set of widgets that provide standard GUI functionality.
 .
 The QtCore module contains core non-GUI functionality.
Homepage: http://qt-project.org/
Original-Maintainer: Debian Qt/KDE Maintainers <debian-qt-kde@lists.debian.org>
pbek commented 6 years ago

xenialoverlay1, seems like an Ubuntu maintained overlay for Kubuntu...

In any case, I guess we can close that issue now. It "should" work on all systems according to the Qt documentation... :)

close2infinity commented 6 years ago

Yes, thx for the support :-)

pbek commented 6 years ago

Hehe, good you found a solution yourself. ;)