pbek / QOwnNotes

QOwnNotes is a plain-text file notepad and todo-list manager with Markdown support and Nextcloud / ownCloud integration.
https://www.qownnotes.org/
GNU General Public License v2.0
4.65k stars 411 forks source link

[BUG] Markdown is not correct in the preview (or at least compared to other markdown editors online) #2961

Closed Haiderahandali closed 6 months ago

Haiderahandali commented 8 months ago

Expected behaviour

To not a skip a slash and make the comment appears like a comment

Actual behaviour

somehow a slash is being skipped and that line is not correctly preview in the markdown preview panel

Steps to reproduce

Open a code block for any language, hit enter, type some code and then follow that by a comment (double forward slash "//") make sure the last three backtick are on the same line and not on a separate line. Somehow one of the slashes is being skipped. See the attached video. The website I am comparing to is stackedit.io I have tried multiple ones online, most of them seems to not have the behavior I am seeing in QOwnNotes. (Though, to be honest, I am not sure what markdown specs says).

Please note while trying to make a minimal example for this bug, I encountered yet (I believe) two different bugs

2962 #2963

this is why I am not providing a minimal example of it, because I want to separate it from the next two bug reports.

https://github.com/pbek/QOwnNotes/assets/53301143/c82d90d9-4de0-4fe2-ae92-802c89c127d0

Output from the debug section in the settings dialog

QOwnNotes Debug Information

General Info

Current Date: Sat Feb 17 07:01:26 2024 Version: 24.2.4 Build date: Feb 16 2024 Build number: 1081 Platform: windows Operating System: Windows 10 Version 2009 Build architecture: x86_64 Current architecture: x86_64 Release: GitHub Actions Qt Version (build): 5.15.2 Qt Version (runtime): 5.15.2 Portable mode: no Settings path / key: \HKEY_CURRENT_USER\Software\PBE\QOwnNotes Application database path: C:\Users\Ali\AppData\Roaming\PBE\QOwnNotes\QOwnNotes.sqlite Application arguments: C:\Users\Ali\BinApp\QOwnNotes\QOwnNotes.exe Qt Debug: 0 Locale (system): en_US Locale (interface): empty Primary screen resolution: 1920x1080 Icon theme: breeze-dark-qownnotes Notes in current note folder: 3 Calendar items: 0 Enabled scripts: 0

Server Info

serverUrl: empty appIsValid: yes notesPathExists: empty serverVersion: empty appVersion: empty

Spellchecking

Enabled: false Selected language: empty Language codes: empty Language names: empty Application dictionaries path: C:\Users\Ali\AppData\Roaming\PBE\QOwnNotes\dicts

Note folders

currentNoteFolderId: 1

Note folder default

id: 1 isCurrent: yes activeTagId: 0 localPath: C:\Users\Ali\Notes remotePath: Notes cloudConnectionId: 1 isShowSubfolders: no isUseGit: no allowDifferentNoteFileName: no activeNoteSubFolder name: empty database file: C:\Users\Ali\Notes\notes.sqlite

Cloud connections

Cloud connection Default

id: 1 isCurrent: yes serverUrl: empty username: empty accountId: empty

Enabled scripts

Settings

ActiveNoteHistoryItem (NoteHistoryItem): <binary data> Debug/fakeOldVersionNumber (QString): false Debug/fileLogging (QString): false Editor/CurrentSchemaKey (QString): EditorColorSchema-cdbf28fc-1ddc-4d13-bb21-6a4043316a2f Editor/autoBracketClosing (QString): true Editor/autoBracketRemoval (QString): true Editor/disableCursorBlinking (QString): false Editor/editorWidthInDFMOnly (QString): true Editor/highlightCurrentLine (QString): true Editor/indentSize (int): 4 Editor/removeTrailingSpaces (QString): false Editor/showLineNumbers (QString): false Editor/useTabIndent (QString): false Editor/vimMode (QString): false LastUpdateCheck (QDateTime): 2024-02-17T06:51:04.979 MainWindow/geometry (QByteArray): <binary data> MainWindow/mainToolBar.iconSize (int): 30 MainWindow/menuBarGeometry (QByteArray): <binary data> MainWindow/noteTextEdit.code.font (QString): Courier New,14,-1,2,50,0,0,0,0,0 MainWindow/noteTextEdit.font (QString): MS Shell Dlg 2,13,-1,5,50,0,0,0,0,0 MainWindow/noteTextView.code.font (QString): Courier New,9,-1,2,50,0,0,0,0,0 MainWindow/noteTextView.font (QString): MS Shell Dlg 2,7.8,-1,5,50,0,0,0,0,0 MainWindow/noteTextView.ignoreCodeFontSize (QString): true MainWindow/noteTextView.refreshDebounceTime (int): 600 MainWindow/noteTextView.rtl (QString): false MainWindow/noteTextView.underline (QString): true MainWindow/noteTextView.useEditorStyles (QString): true MainWindow/noteTextView.useInternalExportStyling (QString): true NoteFolder-1/NoteTabNameList (QStringList): JavaScript Test NoteFolder-1/NoteTabStickinessList (QStringList): empty NoteFolder-1/NoteTabSubFolderPathDataList (QStringList): empty NoteHistory-1 (QVariantList): <variant list with 4 item(s)> NoteHistoryCurrentIndex-1 (int): 3 PiwikClientId (QString): <hidden> SearchEngineId (int): 2 SettingsDialog/geometry (QByteArray): <binary data> SettingsDialog/mainSplitterState (QByteArray): <binary data> ShowSystemTray (QString): false StartHidden (QString): false WelcomeDialog/geometry (QByteArray): <binary data> acceptAllExternalModifications (QString): false allowNoteEditing (QString): true allowOnlyOneAppInstance (QString): true appMetrics/disableAppHeartbeat (QString): false appMetrics/disableTracking (QString): false appMetrics/notificationShown (QString): true autoReadOnlyMode (QString): false autoReadOnlyModeTimeout (int): 30 automaticNoteFolderDatabaseClosing (QString): false checkSpelling (QString): false closeTodoListAfterSave (QString): false cryptoKey (qlonglong): <hidden> currentNoteFolderId (int): 1 currentWorkspace (QString): initial cursorWidth (int): 1 darkMode (QString): true darkModeColors (QString): true darkModeIconTheme (QString): true darkModeTrayIcon (QString): true defaultNoteFileExtension (QString): md demoNotesCreated (QString): true disableAutomaticUpdateDialog (QString): true disableSavedSearchesAutoCompletion (QString): false dockWasInitializedOnce (QString): true enableNoteTree (QString): false enableSocketServer (QString): true enableWebAppSupport (QString): false externalEditorPath (QString): empty fullyHighlightedBlockquotes (QString): false gitCommitInterval (int): 30 gitExecutablePath (QString): empty gitLogCommand (QString): empty guiFirstRunInit (QString): true ignoreAllExternalModifications (QString): false ignoreAllExternalNoteFolderChanges (QString): false ignoreNoteSubFolders (QString): ^\. ignoredNoteFiles (QString): empty imageScaleDown (QString): false imageScaleDownMaximumHeight (int): 1024 imageScaleDownMaximumWidth (int): 1024 initialLayoutIdentifier (QString): minimal insertTimeFormat (QString): empty interfaceFontSize (int): 11 interfaceLanguage (QString): empty internalIconTheme (QString): false itemHeight (int): 18 legacyLinking (QString): false localTrash/autoCleanupDays (int): 30 localTrash/autoCleanupEnabled (QString): true localTrash/supportEnabled (QString): true markdownHighlightingEnabled (QString): true navigationPanelAutoSelect (QString): true navigationPanelHideSearch (QString): false networking/ignoreSSLErrors (QString): true networking/proxyType (int): 2 newNoteAskHeadline (QString): false noteEditIsCentralWidget (QString): true noteFileExtensionList (QStringList): md, txt noteListPreview (QString): false noteSaveIntervalTime (int): 10 noteSubfoldersPanelDisplayAsFullTree (QString): true noteSubfoldersPanelHideSearch (QString): false noteSubfoldersPanelOrder (int): 0 noteSubfoldersPanelShowFullPath (QString): false noteSubfoldersPanelShowNotesRecursively (QString): false noteSubfoldersPanelShowRootFolderName (QString): true noteSubfoldersPanelSort (int): 0 noteSubfoldersPanelTabsUnsetAllNotesSelection (QString): false notesPanelOrder (int): 0 notesPanelSort (int): 1 notesPath (QString): C:/Users/Ali/Notes notifyAllExternalModifications (QString): false overrideInterfaceFontSize (QString): false ownCloud/supportEnabled (QString): false ownCloud/todoCalendarBackend (int): 3 ownCloud/todoCalendarCalDAVPassword (QString): <hidden> ownCloud/todoCalendarCalDAVServerUrl (QString): empty ownCloud/todoCalendarCalDAVUsername (QString): empty ownCloud/todoCalendarCloudConnectionId (int): 1 ownCloud/todoCalendarDisplayNameList (QStringList): empty ownCloud/todoCalendarEnabledList (QStringList): empty ownCloud/todoCalendarEnabledUrlList (QStringList): empty ownCloud/todoCalendarUrlList (QStringList): empty ownCloudInfo/appIsValid (QString): true ownCloudInfo/connectionErrorMessage (QString): empty ownCloudInfo/notesPathExistsText (QString): empty ownCloudInfo/serverVersion (QString): empty restoreCursorPosition (QString): true restoreLastNoteAtStartup (QString): true restoreNoteTabs (QString): true savedSearches/noteFolder-1 (QStringList): Note 2024-02-17T06.47.38, Note 2024-02-16T08.13.37 showMatches (QString): true showMenuBar (QString): true showStatusBar (QString): true startInReadOnlyMode (QString): false systemIconTheme (QString): false taggingShowNotesRecursively (QString): false tagsPanelHideNoteCount (QString): false tagsPanelHideSearch (QString): false tagsPanelOrder (int): 0 tagsPanelSort (int): 0 todoCalendarSupport (QString): 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 (QString): false useUNIXNewline (QString): false webAppClientService/serverUrl (QString): wss://app.qownnotes.org webAppClientService/token (QString): <hidden> webSocketServerService/bookmarksNoteName (QString): Bookmarks webSocketServerService/bookmarksTag (QString): bookmarks webSocketServerService/commandSnippetsNoteName (QString): Commands webSocketServerService/commandSnippetsTag (QString): commands webSocketServerService/port (int): 22222 workspace-initial/name (QString): Minimal workspace-initial/noteSubFolderDockWidgetVisible (QString): true workspace-initial/windowState (QByteArray): <binary data> workspaces (QStringList): initial

System environment

ALLUSERSPROFILE: C:\ProgramData APPDATA: C:\Users\Ali\AppData\Roaming CommonProgramFiles: C:\Program Files\Common Files CommonProgramFiles(x86): C:\Program Files (x86)\Common Files CommonProgramW6432: C:\Program Files\Common Files COMPUTERNAME: DESKTOP-3J3HJBO ComSpec: C:\Windows\system32\cmd.exe DriverData: C:\Windows\System32\Drivers\DriverData EMSDK: C:/Users/Ali/BinApp/emsdk-main EMSDK_NODE: C:\Users\Ali\BinApp\emsdk-main\node\16.20.0_64bit\bin\node.exe EMSDK_PYTHON: C:\Users\Ali\BinApp\emsdk-main\python\3.9.2-nuget_64bit\python.exe HOMEDRIVE: C: HOMEPATH: \Users\Ali IGCCSVC_DB: AQAAANCMnd8BFdERjHoAwE/Cl+sBAAAALcKI5Ln/lEiLVN42FZDf5wQAAAACAAAAAAAQZgAAAAEAACAAAAD6n2Kk+rOTvaIVIGxNdco4vCzkmcnRx5fNNABSmg1GjwAAAAAOgAAAAAIAACAAAAC7/MwweiOF70RjuFrgnI41xI3+7OQ2AAJ9DlwG5YoQcmAAAACKN3GPyOaRICgL8A135FRj53axeIxNZnrFCYWEON/r33YLtZZfMnjtmTTfXVBugWbUC6I89blTFmwZiEvaKkoEpMaaM7X59/XHAgXcXSkjzDKdYxQwsbhDanRtTyuD6JNAAAAAh4b4BJPQNn2POE2lzQXb4nAeDm9o3edBcYBwFRfZZYytoeexuwrrLBscjNVA72XuKrIXkrmZZgz1LbJshdcufg== JAVA_HOME: C:\Users\Ali\BinApp\emsdk-main\java\8.152_64bit LOCALAPPDATA: C:\Users\Ali\AppData\Local LOGONSERVER: \\DESKTOP-3J3HJBO NUMBER_OF_PROCESSORS: 20 OneDrive: C:\Users\Ali\OneDrive OS: Windows_NT Path: C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\;C:\Users\Ali\Work\;C:\Program Files\dotnet\;C:\Program Files\Git\cmd;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Users\Ali\BinApp;C:\Users\Ali\BinApp\Cmake\bin;C:\Program Files\Sublime Text;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Users\Ali\Work\;C:\Program Files\nodejs\;C:\Users\Ali\BinApp\ripgrep\;C:\Users\Ali\BinApp\emsdk-main\;C:\Users\Ali\BinApp\emsdk-main\upstream\emscripten\;C:\Users\Ali\Documents\emsdk-main\emsdk-main;C:\Users\Ali\Documents\emsdk-main\emsdk-main\upstream\emscripten;C:\Users\Ali\AppData\Local\Programs\Python\Python312\Scripts\;C:\Users\Ali\AppData\Local\Programs\Python\Python312\;C:\Users\Ali\AppData\Local\Programs\Python\Launcher\;C:\Users\Ali\AppData\Local\Microsoft\WindowsApps;C:\Users\Ali\.dotnet\tools;C:\Users\Ali\AppData\Roaming\npm PATHEXT: .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC PROCESSOR_ARCHITECTURE: AMD64 PROCESSOR_IDENTIFIER: Intel64 Family 6 Model 154 Stepping 3, GenuineIntel PROCESSOR_LEVEL: 6 PROCESSOR_REVISION: 9a03 ProgramData: C:\ProgramData ProgramFiles: C:\Program Files ProgramFiles(x86): C:\Program Files (x86) ProgramW6432: C:\Program Files PSModulePath: %ProgramFiles%\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules PUBLIC: C:\Users\Public RlsSvcPort: 22112 SystemDrive: C: SystemRoot: C:\Windows TEMP: C:\Users\Ali\AppData\Local\Temp TMP: C:\Users\Ali\AppData\Local\Temp USERDOMAIN: DESKTOP-3J3HJBO USERDOMAIN_ROAMINGPROFILE: DESKTOP-3J3HJBO USERNAME: Ali USERPROFILE: C:\Users\Ali VS110COMNTOOLS: C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Tools\ VS120COMNTOOLS: C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\ windir: C:\Windows ZES_ENABLE_SYSMAN: 1

pbek commented 8 months ago

I'll try to reproduce that.

pbek commented 8 months ago

Hah, funny find. Seems like that's the way how the md4c library treats it. I tried to use the latest version, didn't help.

But in the end, what you did is not valid Markdown, so the result can be pretty undetermined. ️🤷🏻

pbek commented 8 months ago

Ah, that's even from the code highlighting @Waqar144 added, the md4c library doesn't support highlighting of code.

Haiderahandali commented 8 months ago

So, the problem was not hitting enter?

pbek commented 8 months ago

Exactly

Haiderahandali commented 8 months ago

I still feel it should not be like this, skipping and escape characters, IDK I feel like in some edge cases you will have: while(token.type != '//') token = token.next or something like that down in the parsing code, and that will lead to infinite loop or the like ( on large files) because you keep looking for the next token and it is never there. But if you think you don't need to handle those cases, then I will close the issue, as after all, you said many the main md4c don't handle it.

pbek commented 8 months ago

It's very complex code in https://github.com/pbek/QOwnNotes/blob/6824b56f22f7b0a44bac58896a81ed5fc5f02f3c/src/helpers/codetohtmlconverter.cpp, @Waqar144 did it. Maybe he wants to help out? 😉

github-actions[bot] commented 7 months ago

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

github-actions[bot] commented 6 months ago

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