Go to file
Shawn Rutledge 7dd71e8125 Markdown: blockquotes, code blocks, and generalized nesting
Can now detect nested quotes and code blocks inside quotes, and can
rewrite the markdown too.

QTextHtmlParser sets hard-coded left and right margins, so we need to do
the same to be able to read HTML and write markdown, or vice-versa,
and to ensure that all views (QTextEdit, QTextBrowser, QML Text etc.)
will render it with margins.  But now we add a semantic memory too:
BlockQuoteLevel is similar to HeadingLevel, which was added in
310daae539 to preserve H1..H6 heading
levels, because detecting it via font size didn't make sense in
QTextMarkdownWriter.  Likewise detecting quote level by its margins
didn't make sense; markdown supports nesting quotes; and indenting
nested quotes via 40 pixels may be a bit too much, so we should consider
it subject to change (and perhaps be able to change it via CSS later on).
Since we're adding BlockQuoteLevel and depending on it in QTextMarkdownWriter,
it's necessary to set it in QTextHtmlParser to enable HTML->markdown
conversion.  (But so far, nested blockquotes in HTML are not supported.)

Quotes (and nested quotes) can contain indented code blocks, but it seems
the reverse is not true (according to https://spec.commonmark.org/0.29/#example-201 )

Quotes can contain fenced code blocks.

Quotes can contain lists.  Nested lists can be interrupted with
nested code blocks and nested quotes.

So far the writer assumes all code blocks are the indented type.
It will be necessary to add another attribute to remember whether the
code block is indented or fenced (assuming that's necessary).
Fenced code blocks would work better for writing inside block quotes
and list items because the fence is less ambiguous than the indent.

Postponing cursor->insertBlock() as long as possible helps with nesting.
cursor->insertBlock() needs to be done "just in time" before inserting
text that will go in the block.  The block and char formats aren't
necessarily known until that time.  When a nested block (such as a
nested quote) ends, the context reverts to the previous block format,
which then needs to be re-determined and set before we insert text
into the outer block; but if no text will be inserted, no new block
is necessary.  But we can't use QTextBlockFormat itself as storage,
because for some reason bullets become very "sticky" and it becomes
impossible to have plain continuation paragraphs inside list items:
they all get bullets.  Somehow QTextBlockFormat remembers, if we copy it.
But we can create a new one each time and it's OK.

Change-Id: Icd0529eb90d2b6a3cb57f0104bf78a7be81ede52
Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
2019-05-08 20:28:53 +00:00
bin syncqt: Fix resolution of injected headers for external modules 2019-04-23 09:09:33 +00:00
config.tests x86: Disable AVX support on 64-bit MinGW 2019-02-06 08:11:29 +00:00
dist Merge remote-tracking branch 'origin/5.12' into 5.13 2019-04-24 01:00:13 +02:00
doc Merge remote-tracking branch 'origin/5.12' into 5.13 2019-04-26 01:00:13 +02:00
examples Migrate Windows system libs to external dependencies 2019-05-08 08:30:02 +00:00
lib
mkspecs Merge remote-tracking branch 'origin/5.13' into dev 2019-05-07 11:58:30 +02:00
qmake Deprecate conversion functions between QList and QSet 2019-05-07 14:15:44 +00:00
src Markdown: blockquotes, code blocks, and generalized nesting 2019-05-08 20:28:53 +00:00
tests Markdown: blockquotes, code blocks, and generalized nesting 2019-05-08 20:28:53 +00:00
util Merge remote-tracking branch 'origin/5.13' into dev 2019-04-24 09:52:30 +02:00
.gitattributes
.gitignore Remove support for qml1 plugins and modules 2018-11-15 19:52:13 +00:00
.qmake.conf Bump version 2019-03-22 05:35:40 +00:00
.tag
config_help.txt Merge remote-tracking branch 'origin/5.13' into dev 2019-05-07 11:58:30 +02:00
configure configure: Treat win32-clang-g++ the same as win32-g++ 2018-10-10 04:10:40 +00:00
configure.bat Configure: simplify logic 2019-03-14 12:13:58 +00:00
configure.json Add qmake support for c++2a 2019-04-19 08:14:25 +00:00
configure.pri Add qmake support for c++2a 2019-04-19 08:14:25 +00:00
header.BSD
header.COMM
header.FDL
header.GPL
header.GPL-EXCEPT
header.LGPL
header.LGPL3
header.LGPL3-COMM
header.LGPL-NOGPL2
header.LGPL-ONLY
header.MIT qsimd: add support for new x86 CPU features 2018-05-05 06:20:07 +00:00
INSTALL INSTALL: Remove outdated reference to Windows CE 2019-02-13 13:01:57 +00:00
LICENSE.FDL
LICENSE.GPL2
LICENSE.GPL3
LICENSE.GPL3-EXCEPT
LICENSE.LGPL3
LICENSE.LGPLv3
LICENSE.QT-LICENSE-AGREEMENT-4.0 Replace commercial preview license with Qt License Agreement 4.0 2018-06-21 11:39:15 +00:00
qtbase.pro
sync.profile platformsupport/input: add xkbcommon utilities lib 2019-03-01 14:31:28 +00:00