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.68k stars 414 forks source link

[I] PHP comment block breaks code block highlighter #1547

Closed solarchemist closed 4 years ago

solarchemist commented 4 years ago

Expected behaviour

Text surrounded by two lines of triple tick-marks should behave as a code block.

Actual behaviour

If the code block happens to contain a PHP comment block, the closing triple-ticks are not recognised, and the rest of the document acts as if it was part of the code block. This breaks highlighting (in the editor window, at least) and breaks the note's automatic table of contents.

This code block breaks QownNotes as described above:

`` ``` ``
/**
** comments
** comments
*/
$settings['install_profile'] = 'standard';
$config_directories['sync'] = 'sites/default/files/';
`` ``` ``

This behaviour was not observed until recently. I am not sure which release exactly introduced this behaviour, but sometime last month probably.

Steps to reproduce

It seems a slash followed by a star inside a code block is enough to produce this odd behaviour:

`` ``` ``
/*
`` ``` ``

The rest of the text in the document will now behave as if it was still inside the code block.

Relevant log output in the Log panel

Expand ``` [09:11:22] [status] Stored 1 note(s) to disk ```

Information about the application, settings and environment

Expand QOwnNotes Debug Information =========================== ## General Info **Current Date**: `Mon Jan 6 09:11:51 2020` **Version**: `20.1.2` **Build date**: `Jan 3 2020` **Build number**: `649` **Platform**: `linux` **Operating System**: `Ubuntu 18.04.3 LTS` **Build architecture**: `x86_64` **Current architecture**: `x86_64` **Release**: `Launchpad PPA` **Qt Version (build)**: `5.9.5` **Qt Version (runtime)**: `5.9.5` **Portable mode**: `no` **Settings path / key**: `/home/user/.config/PBE/QOwnNotes.conf` **Application database path**: `/home/user/.local/share/PBE/QOwnNotes/QOwnNotes.sqlite` **Application arguments**: `QOwnNotes` **Qt Debug**: `0` **Locale (system)**: `en_US` **Locale (interface)**: *empty* **Primary screen resolution**: `1920x1200` **Screen resolution(s)**: **Icon theme**: `hicolor` **Notes in current note folder**: `537` **Calendar items**: `2` **Enabled scripts**: `0` ## Server Info **serverUrl**: `https://nc.domain.se` **appIsValid**: `yes` **notesPathExists**: `yes` **serverVersion**: `15.0.11.1` **appVersion**: *empty* ## Spellchecking **Enabled**: `true` **Selected language**: `en_US` **Language codes**: `en_US` **Language names**: `American English (United States)` **Application dictionaries path**: `/home/user/.local/share/PBE/QOwnNotes/dicts` ## Note folders **currentNoteFolderId**: `1` ### Note folder `default` **id**: `1` **isCurrent**: `yes` **activeTagId**: `0` **localPath**: `/home/user/nextcloud/Notes` **remotePath**: `Notes` **cloudConnectionId**: `1` **isShowSubfolders**: `yes` **isUseGit**: `no` **activeNoteSubFolder name**: `FM` **database file**: `/home/user/nextcloud/Notes/notes.sqlite` ## Cloud connections ### Cloud connection `Default` **id**: `1` **isCurrent**: `yes` **serverUrl**: `https://nc.domain.se` **username**: `user` ## Enabled scripts ## Settings **ActiveNoteHistoryItem** (NoteHistoryItem): `` **Debug/fakeOldVersionNumber** (QString): `false` **Debug/fileLogging** (QString): `false` **DistractionFreeMode/editorWidthMode** (QString): `3` **DistractionFreeMode/isEnabled** (QString): `false` **DistractionFreeMode/menuBarGeometry** (QByteArray): `` **DistractionFreeMode/menuBarHeight** (QString): `20` **DistractionFreeMode/menuBarVisible** (QString): `true` **DistractionFreeMode/windowState** (QByteArray): `` **Editor/CurrentSchemaKey** (QString): `EditorColorSchema-6033d61b-cb96-46d5-a3a8-20d5172017eb` **Editor/autoBracketClosing** (QString): `true` **Editor/autoBracketRemoval** (QString): `true` **Editor/disableCursorBlinking** (QString): `false` **Editor/editorWidthInDFMOnly** (QString): `true` **Editor/highlightCurrentLine** (QString): `true` **Editor/indentSize** (QString): `4` **Editor/useTabIndent** (QString): `false` **Editor/vimMode** (QString): `false` **IssueAssistantDialog/geometry** (QByteArray): `` **LastUpdateCheck** (QDateTime): `2020-01-06T08:55:13` **LinkDialog/geometry** (QByteArray): `` **LogWidget/criticalLog** (bool): `true` **LogWidget/debugLog** (bool): `true` **LogWidget/fatalLog** (bool): `true` **LogWidget/infoLog** (bool): `true` **LogWidget/scriptingLog** (bool): `true` **LogWidget/statusLog** (bool): `true` **LogWidget/warningLog** (bool): `true` **MainWindow/geometry** (QByteArray): `` **MainWindow/mainToolBar.iconSize** (QString): `24` **MainWindow/menuBarGeometry** (QByteArray): `` **MainWindow/noteTextEdit.code.font** (QString): `monospace,9,-1,2,50,0,0,0,0,0` **MainWindow/noteTextEdit.font** (QString): `Sans Serif,9,-1,5,50,0,0,0,0,0` **MainWindow/noteTextView.code.font** (QString): `monospace,9,-1,2,50,0,0,0,0,0` **MainWindow/noteTextView.font** (QString): `Sans Serif,9,-1,5,50,0,0,0,0,0` **MainWindow/noteTextView.ignoreCodeFontSize** (QString): `true` **MainWindow/noteTextView.rtl** (QString): `false` **MainWindow/noteTextView.underline** (QString): `true` **MainWindow/noteTextView.useEditorStyles** (QString): `true` **MainWindow/noteTextView.useInternalExportStyling** (QString): `true` **MainWindow/showNotesFromAllNoteSubFolders** (bool): `false` **NoteHistory-1** (QVariantList): `` **NoteHistoryCurrentIndex-1** (QString): `199` **PiwikClientId** (QString): `` **SearchEngineId** (QString): `0` **SettingsDialog/geometry** (QByteArray): `` **SettingsDialog/mainSplitterState** (QByteArray): `` **ShowSystemTray** (QString): `false` **StartHidden** (QString): `false` **acceptAllExternalModifications** (QString): `false` **allowDifferentNoteFileName** (QString): `false` **allowNoteEditing** (bool): `true` **allowOnlyOneAppInstance** (QString): `false` **appMetrics/disableAppHeartbeat** (QString): `false` **appMetrics/disableTracking** (QString): `false` **appMetrics/notificationShown** (QString): `true` **automaticNoteFolderDatabaseClosing** (QString): `false` **checkSpelling** (bool): `true` **closeTodoListAfterSave** (QString): `false` **cryptoKey** (QString): `` **currentNoteFolderId** (QString): `1` **currentWorkspace** (QString): `initial` **cursorWidth** (QString): `1` **customNoteFileExtensionList**: *empty* **darkMode** (QString): `false` **darkModeColors** (QString): `false` **darkModeIconTheme** (QString): `false` **darkModeTrayIcon** (QString): `false` **defaultNoteFileExtension** (QString): `md` **disableAutomaticUpdateDialog** (QString): `true` **disableSavedSearchesAutoCompletion** (QString): `false` **dockWasInitializedOnce** (QString): `true` **enableNoteTree** (QString): `true` **enableSocketServer** (QString): `true` **externalEditorPath** (QString): *empty* **fullyHighlightedBlockquotes** (QString): `false` **gitCommitInterval** (QString): `30` **gitExecutablePath** (QString): *empty* **gitLogCommand** (QString): *empty* **guiFirstRunInit** (bool): `true` **ignoreAllExternalModifications** (QString): `false` **ignoreAllExternalNoteFolderChanges** (QString): `false` **ignoreNoteSubFolders** (QString): `^\.` **imageScaleDown** (QString): `false` **imageScaleDownMaximumHeight** (QString): `1024` **imageScaleDownMaximumWidth** (QString): `1024` **initialLayoutIdentifier** (QString): `full-vertical` **insertTimeFormat** (QString): *empty* **interfaceFontSize** (QString): `11` **interfaceLanguage** (QString): *empty* **internalIconTheme** (QString): `false` **itemHeight** (QString): `14` **legacyLinking** (QString): `false` **localTrash/autoCleanupDays** (QString): `30` **localTrash/autoCleanupEnabled** (QString): `true` **localTrash/supportEnabled** (QString): `true` **markdownHighlightingEnabled** (QString): `true` **navigationPanelHideSearch** (QString): `false` **networking/ignoreSSLErrors** (QString): `true` **networking/proxyType** (QString): `2` **newNoteAskHeadline** (QString): `false` **noteEditIsCentralWidget** (QString): `false` **noteListPreview** (QString): `false` **noteSaveIntervalTime** (QString): `10` **noteSubfoldersPanelDisplayAsFullTree** (QString): `true` **noteSubfoldersPanelHideSearch** (QString): `false` **noteSubfoldersPanelOrder** (QString): `0` **noteSubfoldersPanelShowFullPath** (QString): `false` **noteSubfoldersPanelShowNotesRecursively** (QString): `false` **noteSubfoldersPanelShowRootFolderName** (QString): `true` **noteSubfoldersPanelSort** (QString): `0` **notesPanelOrder** (QString): `0` **notesPanelSort** (QString): `0` **notesPath** (QString): `/home/user/nextcloud/Notes` **notifyAllExternalModifications** (QString): `false` **overrideInterfaceFontSize** (QString): `false` **ownCloud/supportEnabled** (QString): `true` **ownCloud/todoCalendarBackend** (QString): `3` **ownCloudInfo/appIsValid** (QString): `true` **ownCloudInfo/notesPathExistsText** (QString): `yes` **ownCloudInfo/serverVersion** (QString): `15.0.11.1` **restoreCursorPosition** (QString): `true` **showMatches** (QString): `true` **showMenuBar** (bool): `true` **showStatusBar** (bool): `true` **spellCheckLanguage** (QString): `en_US` **systemIconTheme** (QString): `false` **taggingShowNotesRecursively** (QString): `false` **tagsPanelHideSearch** (QString): `false` **tagsPanelOrder** (QString): `0` **tagsPanelSort** (QString): `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, , actionOpen_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_Link_to_note, 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** (QString): `action_Quit` **toolbar/6/name** (QString): `quitToolbar` **toolbar/6/title** (QString): `quit toolbar` **toolbar/size** (QString): `6` **useUNIXNewline** (QString): `false` **webSocketServerService/bookmarksNoteName** (QString): `Bookmarks` **webSocketServerService/bookmarksTag** (QString): `bookmarks` **webSocketServerService/port** (QString): `22222` **workspace-initial/name** (QString): `Full vertical` **workspace-initial/noteSubFolderDockWidgetVisible** (QString): `true` **workspace-initial/windowState** (QByteArray): `` **workspaces** (QString): `initial` ## System environment **PAM_KWALLET5_LOGIN**: `/run/user/1000/kwallet5.socket` **USER**: `user` **LANGUAGE**: `en` **XDG_SEAT**: `seat0` **XDG_SESSION_TYPE**: `x11` **SSH_AGENT_PID**: `2345` **SHLVL**: `0` **HOME**: `/home/user` **DESKTOP_SESSION**: `i3` **XDG_SEAT_PATH**: `/org/freedesktop/DisplayManager/Seat0` **DBUS_SESSION_BUS_ADDRESS**: `unix:path=/run/user/1000/bus` **MANDATORY_PATH**: `/usr/share/gconf/i3.mandatory.path` **LOGNAME**: `user` **DEFAULTS_PATH**: `/usr/share/gconf/i3.default.path` **XDG_SESSION_ID**: `c2` **GDM_LANG**: `en` **XDG_RUNTIME_DIR**: `/run/user/1000` **XDG_SESSION_PATH**: `/org/freedesktop/DisplayManager/Session0` **DISPLAY**: `:0` **LANG**: `en_US.UTF-8` **XDG_CURRENT_DESKTOP**: `i3` **XDG_SESSION_DESKTOP**: `i3` **XAUTHORITY**: `/home/user/.Xauthority` **XDG_GREETER_DATA_DIR**: `/var/lib/lightdm-data/user` **SSH_AUTH_SOCK**: `/tmp/ssh-7lbdEqnPhtEX/agent.2253` **SHELL**: `/bin/bash` **PAM_KWALLET_LOGIN**: `/run/user/1000/kwallet.socket` **QT_ACCESSIBILITY**: `1` **GDMSESSION**: `i3` **XDG_VTNR**: `7` **PWD**: `/home/user` **XDG_CONFIG_DIRS**: `/etc/xdg/xdg-i3:/etc/xdg` **I3SOCK**: `/run/user/1000/i3/ipc-socket.2253`
pbek commented 4 years ago

Confirmed. Thank you for reporting. @Waqar144, another code block regression. :grin:

pbek commented 4 years ago

It even breaks all following code blocks. :grin:

Waqar144 commented 4 years ago

The fix has sort of ripple effect. Fix it in one place, 2 others pop up.

Thanks for reporting. I am rethinking my decision to switch on codeBlock highlighting for ALL codeBlocks. Maybe we should just stick to highlighting only the ones with 'supported languages'

`` ``` ``
xxx
`` ``` ``

The above is not a valid Code Block. So it will still be rendered incorrectly. Use 3 backticks only(life is hard already :laughing: ) (Also we don't support tilde based code block ~~~) (yet) ;)

Use:

 ```php
//much better highlighting
 \``` (backslash here just for demonstrating)
pbek commented 4 years ago

20.1.4

There now is a new release, could you please test it and report if it works for you?

solarchemist commented 4 years ago

I upgraded to 20.1.6. I can confirm this issue has been resolved. Thanks! You guys run a tight ship :-)

pbek commented 4 years ago

Great, thank you for testing!