From 2600d12fc2a20a1073d6dcbe2de9754a78c9c1d0 Mon Sep 17 00:00:00 2001 From: Le Tan Date: Sat, 26 Dec 2020 15:23:32 +0800 Subject: [PATCH] make the . after section number optional --- libs/vtextedit | 2 +- src/data/extra/web/css/globalstyles.css | 10 +++++----- src/widgets/editors/markdowneditor.cpp | 7 ++++++- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/libs/vtextedit b/libs/vtextedit index 47347580..96f56ccd 160000 --- a/libs/vtextedit +++ b/libs/vtextedit @@ -1 +1 @@ -Subproject commit 47347580cbcd460ebbbc8358e37b409530edaa2f +Subproject commit 96f56ccd3ca6c5037183690cb36b41f716fc0367 diff --git a/src/data/extra/web/css/globalstyles.css b/src/data/extra/web/css/globalstyles.css index 3a11411f..429bbe96 100644 --- a/src/data/extra/web/css/globalstyles.css +++ b/src/data/extra/web/css/globalstyles.css @@ -22,27 +22,27 @@ #vx-content.vx-section-number h2::before { counter-increment: section1; - content: counter(section1) ". "; + content: counter(section1) " "; } #vx-content.vx-section-number h3::before { counter-increment: section2; - content: counter(section1) "." counter(section2) ". "; + content: counter(section1) "." counter(section2) " "; } #vx-content.vx-section-number h4::before { counter-increment: section3; - content: counter(section1) "." counter(section2) "." counter(section3) ". "; + content: counter(section1) "." counter(section2) "." counter(section3) " "; } #vx-content.vx-section-number h5::before { counter-increment: section4; - content: counter(section1) "." counter(section2) "." counter(section3) "." counter(section4) ". "; + content: counter(section1) "." counter(section2) "." counter(section3) "." counter(section4) " "; } #vx-content.vx-section-number h6::before { counter-increment: section5; - content: counter(section1) "." counter(section2) "." counter(section3) "." counter(section4) "." counter(section5) ". "; + content: counter(section1) "." counter(section2) "." counter(section3) "." counter(section4) "." counter(section5) " "; } #vx-content.vx-constrain-image-width img { diff --git a/src/widgets/editors/markdowneditor.cpp b/src/widgets/editors/markdowneditor.cpp index c6af65a5..c339cfe3 100644 --- a/src/widgets/editors/markdowneditor.cpp +++ b/src/widgets/editors/markdowneditor.cpp @@ -1100,9 +1100,14 @@ static void increaseSectionNumber(QVector &p_sectionNumber, int p_level, in static QString joinSectionNumberStr(const QVector &p_sectionNumber) { QString res; + // TODO: make it configurable? 1.1 or 1.1.? for (auto sec : p_sectionNumber) { if (sec != 0) { - res = res + QString::number(sec) + '.'; + if (res.isEmpty()) { + res = QString::number(sec); + } else { + res += '.' + QString::number(sec); + } } else if (res.isEmpty()) { continue; } else {