Skip to content

Commit

Permalink
#3181 links: support heading 1
Browse files Browse the repository at this point in the history
Signed-off-by: Patrizio Bekerle <[email protected]>
  • Loading branch information
pbek committed Dec 22, 2024
1 parent 57b286c commit f9f73a4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# QOwnNotes Changelog

## 24.12.5
- Both note links and the link dialog are now supporting also heading 1, not only
heading 2 and up, as long `#` headings are used (for [#3181](https://github.com/pbek/QOwnNotes/issues/3181))

## 24.12.4
- The welcome wizard will now be shown again when the application runs for the first time,
this was a regression from 24.12.3 (for [#3179](https://github.com/pbek/QOwnNotes/issues/3179))
Expand Down
4 changes: 2 additions & 2 deletions src/entities/note.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4109,14 +4109,14 @@ QVector<CommandSnippet> Note::getParsedCommandSnippets() const {
void Note::resetNoteTextHtmlConversionHash() { _noteTextHtmlConversionHash = QLatin1String(""); }

/**
* Get a list of all headings in a note starting with ##
* Get a list of all headings in a note starting with #
*
* @return
*/
QStringList Note::getHeadingList() {
QStringList headingList;

static const QRegularExpression re(QStringLiteral(R"(^##+ (.+)$)"),
static const QRegularExpression re(QStringLiteral(R"(^#+ (.+)$)"),
QRegularExpression::MultilineOption);
QRegularExpressionMatchIterator i = re.globalMatch(_noteText);

Expand Down
2 changes: 1 addition & 1 deletion src/utils/urlhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ void UrlHandler::handleNoteUrl(QString urlString, const QString &fragment) {
// Search with a regular expression for the fragment to make sure
// we are searching for the full heading
auto searchTerm =
QStringLiteral("## ") + QRegularExpression::escape(fragment) + QStringLiteral("$");
QStringLiteral("# ") + QRegularExpression::escape(fragment) + QStringLiteral("$");
mw->activeNoteTextEdit()->doSearch(searchTerm,
QPlainTextEditSearchWidget::RegularExpressionMode);
mw->activeNoteTextEdit()->searchWidget()->deactivate();
Expand Down

0 comments on commit f9f73a4

Please sign in to comment.