[LyX features/feature/docbook] XHTML: restore sections.
Thibaut Cuvelier
tcuvelier at lyx.org
Wed Sep 16 01:46:54 UTC 2020
The branch, feature/docbook, has been updated.
- Log -----------------------------------------------------------------
commit 34769eb2f96517a3c09b5b8a9258e81b06d24e0d
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date: Wed Sep 16 04:13:42 2020 +0200
XHTML: restore sections.
diff --git a/src/output_xhtml.cpp b/src/output_xhtml.cpp
index f8cd53e..fe396f8 100644
--- a/src/output_xhtml.cpp
+++ b/src/output_xhtml.cpp
@@ -675,7 +675,7 @@ void xhtmlParagraphs(Text const & text,
// If need be, close <section>s, but only at the end of the document (otherwise, dealt with at the beginning
// of the loop).
- while (!headerLevels.empty() && headerLevels.top() > Layout::NOT_IN_TOC) {
+ while (!headerLevels.empty() && headerLevels.top() != Layout::NOT_IN_TOC && headerLevels.top() > 1) {
docstring tag = from_utf8("</section>");
headerLevels.pop();
xs << XMLStream::ESCAPE_NONE << tag;
commit b783fb811c92c54f81952c0df1a7133b4eab9bf5
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date: Wed Sep 16 04:12:26 2020 +0200
Converters: always set version to something.
Otherwise, it's common to compare "None >= (6,2,6)", which makes no sense. Set it to (0,0,0) so that any comparison fails (without an error message).
diff --git a/lib/scripts/convertDefault.py b/lib/scripts/convertDefault.py
index 5287e96..be1b263 100644
--- a/lib/scripts/convertDefault.py
+++ b/lib/scripts/convertDefault.py
@@ -53,6 +53,8 @@ else:
gm = True
# we need version to be a valid integer 3-tuple
version = (1,0,0)
+ else:
+ version = (0,0,0)
# IM >= 5.5.8 separates options for source and target files
# See http://www.imagemagick.org/Usage/basics/#why
@@ -63,6 +65,7 @@ elif sys.platform == 'darwin':
command = 'lyxconvert'
# If supported, add the -define option for pdf source formats
+print(version)
if sys.argv[1] == 'pdf' and (version >= (6,2,6) or gm):
sopts = '-define pdf:use-cropbox=true ' + sopts
commit fb5f2595a94c8a2e4aa4b87a4c78cfe2e74f530f
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date: Wed Sep 16 04:02:51 2020 +0200
Converters: slightly more pythonic code.
diff --git a/lib/scripts/convertDefault.py b/lib/scripts/convertDefault.py
index c927713..5287e96 100644
--- a/lib/scripts/convertDefault.py
+++ b/lib/scripts/convertDefault.py
@@ -25,7 +25,7 @@ re_version = re.compile(r'^Version:.*ImageMagick\s*(\d*)\.(\d*)\.(\d*).*$')
command = 'magick'
fout = os.popen('magick -version 2>&1')
output = fout.readline()
-if fout.close() != None:
+if fout.close() is not None:
# older versions
# caution: windows has a convert.exe for converting file systems
command = 'convert'
@@ -39,7 +39,7 @@ version = re_version.match(output)
im = False
gm = False
-if version != None:
+if version is not None:
major = int(version.group(1))
minor = int(version.group(2))
patch = int(version.group(3))
@@ -49,7 +49,7 @@ else:
# Try GraphicsMagick
re_version = re.compile(r'^GraphicsMagick.*http:..www.GraphicsMagick.org.*$')
version = re_version.match(output)
- if version != None:
+ if version is not None:
gm = True
# we need version to be a valid integer 3-tuple
version = (1,0,0)
@@ -72,10 +72,10 @@ if sys.argv[3] == 'ppm' and (im and version >= (6,3,5) or gm):
# print (command, sys.argv[2], sys.argv[4], file= sys.stdout)
if (im or gm) and os.system(r'%s %s "%s" %s "%s"' % (command, sopts, sys.argv[2], topts, sys.argv[3] + ':' + sys.argv[4])) != 0:
- print (sys.argv[0], 'ERROR', file= sys.stderr)
- print ('Execution of "%s" failed.' % command, file= sys.stderr)
+ print(sys.argv[0], 'ERROR', file= sys.stderr)
+ print('Execution of "%s" failed.' % command, file= sys.stderr)
sys.exit(1)
elif not im and not gm and sys.platform == 'darwin' and os.system(r'%s "%s" "%s"' % (command, sys.argv[2], sys.argv[4])) != 0:
- print (sys.argv[0], 'ERROR', file= sys.stderr)
- print ('Execution of "%s" failed.' % command, file= sys.stderr)
+ print(sys.argv[0], 'ERROR', file= sys.stderr)
+ print('Execution of "%s" failed.' % command, file=sys.stderr)
sys.exit(1)
commit e0c2060445100c6572544d00d1691e0ee356908c
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date: Wed Sep 16 04:02:08 2020 +0200
XHTML: fixed section implementation (?).
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9085355..f337501 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -11,6 +11,21 @@ set(GNUWIN32_DIR D:/LyX/lyx-unstable/lyx-windows-deps-msvc2017)
set(LYX_USE_QT "QT5")
set(LYX_REQUIRE_SPELLCHECK true)
+set(QT_DIR D:/Qt/5.15.0/msvc2019_64)
+set(QT5_DIR D:/Qt/5.15.0/msvc2019_64)
+set(QT_MKSPECS_DIR D:/Qt/5.15.0/msvc2019_64/mkspecs)
+set(Qt5Concurrent_DIR D:/Qt/5.15.0/msvc2019_64/lib/cmake/Qt5Concurrent)
+set(Qt5Core_DIR D:/Qt/5.15.0/msvc2019_64/lib/cmake/Qt5Core)
+set(Qt5Gui_DIR D:/Qt/5.15.0/msvc2019_64/lib/cmake/Qt5Gui)
+set(Qt5Svg_DIR D:/Qt/5.15.0/msvc2019_64/lib/cmake/Qt5Svg)
+set(Qt5Widgets_DIR D:/Qt/5.15.0/msvc2019_64/lib/cmake/Qt5Widgets)
+set(Qt5WinExtras_DIR D:/Qt/5.15.0/msvc2019_64/lib/cmake/Qt5WinExtras)
+
+set(CMAKE_CXX_STANDARD 20)
+set(GNUWIN32_DIR D:/LyX/lyx-unstable/lyx-windows-deps-msvc2017)
+set(LYX_USE_QT "QT5")
+set(LYX_REQUIRE_SPELLCHECK true)
+
set(LYX_PROJECT LyX)
# Instruct cmake to not use gnu extensions,
commit 2cb7050d010435c1b4345e7924699c6cfb0042da
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date: Wed Sep 16 03:37:46 2020 +0200
Revert "XHTML: remove <section> support."
This reverts commit 52216b73
diff --git a/src/output_xhtml.cpp b/src/output_xhtml.cpp
index 99d425e..f8cd53e 100644
--- a/src/output_xhtml.cpp
+++ b/src/output_xhtml.cpp
@@ -590,6 +590,7 @@ void xhtmlParagraphs(Text const & text,
ParagraphList::const_iterator const pend =
(epit == (int) paragraphs.size()) ?
paragraphs.end() : paragraphs.iterator_at(epit);
+ std::stack<int> headerLevels;
while (bpit < epit) {
ParagraphList::const_iterator par = paragraphs.iterator_at(bpit);
@@ -608,6 +609,33 @@ void xhtmlParagraphs(Text const & text,
ParagraphList::const_iterator const lastpar = par;
ParagraphList::const_iterator send;
+ // Think about adding <section> and/or </section>s.
+ if (style.category() == from_utf8("Sectioning")) {
+ int level = style.toclevel;
+
+ // Need to close a previous section if it has the same level or a higher one (close <section> if opening a
+ // <h2> after a <h2>, <h3>, <h4>, <h5> or <h6>). More examples:
+ // - current: h2; back: h1; do not close any <section>
+ // - current: h1; back: h2; close two <section> (first the <h2>, then the <h1>, so a new <h1> can come)
+ while (!headerLevels.empty() && level <= headerLevels.top()) {
+ // Output the tag only if it corresponds to a legit section.
+ int stackLevel = headerLevels.top();
+ if (stackLevel != Layout::NOT_IN_TOC && level > 1) { // <h1> is the document title.
+ xs << xml::EndTag("section");
+ xs << xml::CR();
+ }
+ headerLevels.pop();
+ }
+
+ // Open the new section: first push it onto the stack, then output it in XHTML.
+ headerLevels.push(level);
+ // Some sectioning-like elements should not be output (such as FrontMatter).
+ if (level != Layout::NOT_IN_TOC && level > 1) { // <h1> is the document title.
+ xs << xml::StartTag("section");
+ xs << xml::CR();
+ }
+ }
+
switch (style.latextype) {
case LATEX_COMMAND: {
// The files with which we are working never have more than
@@ -644,6 +672,15 @@ void xhtmlParagraphs(Text const & text,
}
bpit += distance(lastpar, par);
}
+
+ // If need be, close <section>s, but only at the end of the document (otherwise, dealt with at the beginning
+ // of the loop).
+ while (!headerLevels.empty() && headerLevels.top() > Layout::NOT_IN_TOC) {
+ docstring tag = from_utf8("</section>");
+ headerLevels.pop();
+ xs << XMLStream::ESCAPE_NONE << tag;
+ xs << xml::CR();
+ }
}
-----------------------------------------------------------------------
Summary of changes:
CMakeLists.txt | 15 +++++++++++++++
lib/scripts/convertDefault.py | 17 ++++++++++-------
src/output_xhtml.cpp | 37 +++++++++++++++++++++++++++++++++++++
3 files changed, 62 insertions(+), 7 deletions(-)
hooks/post-receive
--
Repository for new features
More information about the lyx-cvs
mailing list