Skip to content

Commit fdab605

Browse files
committed
#1662 highlighting: add option to hide Markdown formatting syntax
Signed-off-by: Patrizio Bekerle <patrizio@bekerle.com>
1 parent 0f0069c commit fdab605

File tree

5 files changed

+35
-2
lines changed

5 files changed

+35
-2
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
## 26.3.10
44

5+
- Added an option to hide Markdown formatting syntax (like `**`, `*`, `#`,
6+
backticks, link brackets) on lines that are not being edited, for a
7+
cleaner Typora-like editing experience (Editor settings, off by default)
8+
(for [#1662](https://github.com/pbek/QOwnNotes/issues/1662))
9+
- Disclaimer: Due to limitations of the QPlainTextEdit API, this is a best-effort
10+
implementation sets the font letter spacing to 0 and the font size to 0.01
11+
for the formatting syntax characters, so they are still present in the editor,
12+
just smaller. Especially for links with a lot of text between the brackets,
13+
gaps will be visible in the formatting syntax!
514
- Added a security token setting for the Homepage-compatible bookmark
615
suggestion API (with encrypted storage, settings dump masking, and
716
token-validated `GET /suggest` requests), and updated Homepage

src/dialogs/settingsdialog.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,8 @@ void SettingsDialog::storeSettings() {
603603
ui->showLineNumbersInEditorCheckBox->isChecked());
604604
settings.setValue(QStringLiteral("Editor/highlightCurrentLine"),
605605
ui->highlightCurrentLineCheckBox->isChecked());
606+
settings.setValue(QStringLiteral("Editor/hideFormattingSyntax"),
607+
ui->hideFormattingSyntaxCheckBox->isChecked());
606608
settings.setValue(QStringLiteral("Editor/hangingIndent"),
607609
ui->hangingIndentCheckBox->isChecked());
608610
settings.setValue(QStringLiteral("Editor/showMarkdownImagePreviews"),
@@ -1010,6 +1012,8 @@ void SettingsDialog::readSettings() {
10101012
settings.value(QStringLiteral("Editor/showLineNumbers")).toBool());
10111013
ui->highlightCurrentLineCheckBox->setChecked(
10121014
settings.value(QStringLiteral("Editor/highlightCurrentLine"), true).toBool());
1015+
ui->hideFormattingSyntaxCheckBox->setChecked(
1016+
settings.value(QStringLiteral("Editor/hideFormattingSyntax"), false).toBool());
10131017
ui->hangingIndentCheckBox->setChecked(
10141018
settings.value(QStringLiteral("Editor/hangingIndent"), false).toBool());
10151019
ui->showMarkdownImagePreviewsCheckBox->setChecked(

src/dialogs/settingsdialog.ui

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5702,6 +5702,16 @@ li.checked::marker { content: &quot;\2612&quot;; }
57025702
</property>
57035703
</widget>
57045704
</item>
5705+
<item row="11" column="0" colspan="4">
5706+
<widget class="QCheckBox" name="hideFormattingSyntaxCheckBox">
5707+
<property name="toolTip">
5708+
<string>Hides markdown formatting syntax (like **, *, #) on lines that are not being edited</string>
5709+
</property>
5710+
<property name="text">
5711+
<string>Hide markdown formatting syntax on inactive lines</string>
5712+
</property>
5713+
</widget>
5714+
</item>
57055715
</layout>
57065716
</widget>
57075717
</item>
@@ -7844,7 +7854,8 @@ Just test yourself if you get sync conflicts and set a higher value if so.</stri
78447854
<tabstop>autoBracketRemovalCheckBox</tabstop>
78457855
<tabstop>editorWidthInDFMOnlyCheckBox</tabstop>
78467856
<tabstop>highlightCurrentLineCheckBox</tabstop>
7847-
<tabstop>disableCursorBlinkingCheckBox</tabstop>
7857+
<tabstop>hideFormattingSyntaxCheckBox</tabstop>
7858+
<tabstop>disableCursorBlinkingCheckBox</tabstop>
78487859
<tabstop>gitCommitIntervalTime</tabstop>
78497860
<tabstop>gitLogCommandLineEdit</tabstop>
78507861
<tabstop>gitPathLineEdit</tabstop>

src/widgets/qownnotesmarkdowntextedit.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,6 +1295,15 @@ void QOwnNotesMarkdownTextEdit::updateSettings() {
12951295
const bool hlCurrLine =
12961296
settings.value(QStringLiteral("Editor/highlightCurrentLine"), true).toBool();
12971297
setHighlightCurrentLine(hlCurrLine);
1298+
1299+
// Hide formatting syntax on non-cursor blocks (Typora-like)
1300+
const bool hideFormattingSyntax =
1301+
settings.value(QStringLiteral("Editor/hideFormattingSyntax"), false).toBool();
1302+
if (_highlighter) {
1303+
_highlighter->setHideFormattingSyntax(hideFormattingSyntax);
1304+
_highlighter->setCurrentCursorBlockNumber(textCursor().blockNumber());
1305+
}
1306+
12981307
const bool hangingIndentEnabled =
12991308
settings.value(QStringLiteral("Editor/hangingIndent"), false).toBool();
13001309
setHangingIndentEnabled(hangingIndentEnabled);

0 commit comments

Comments
 (0)