[LyX/master] Support half und full line parskip class options (#12946)

Juergen Spitzmueller spitz at lyx.org
Sun Jun 2 09:43:10 UTC 2024


commit 2a7ec054be00fbac76efa8aefb4ae1531d981761
Author: Juergen Spitzmueller <spitz at lyx.org>
Date:   Sun Jun 2 11:41:54 2024 +0200

    Support half und full line parskip class options (#12946)
    
    Currently only employed by the KOMA classes.
    
    Layout format change.
---
 lib/doc/Customization.lyx    | 114 +++++++++++++++++++++++++++++++++++++++++++
 lib/doc/de/Customization.lyx |  80 ++++++++++++++++++++++++++++++
 lib/layouts/scrclass.inc     |   5 +-
 lib/scripts/layout2layout.py |   7 ++-
 src/BufferParams.cpp         |  12 ++++-
 src/TextClass.cpp            |  20 ++++++--
 src/TextClass.h              |   8 +++
 7 files changed, 238 insertions(+), 8 deletions(-)

diff --git a/lib/doc/Customization.lyx b/lib/doc/Customization.lyx
index 83784e8c2a..fa65bde11e 100644
--- a/lib/doc/Customization.lyx
+++ b/lib/doc/Customization.lyx
@@ -12201,6 +12201,108 @@ status collapsed
 \end_inset
 
 .
+\change_inserted -712698321 1717320820
+
+\end_layout
+
+\begin_layout Description
+
+\change_inserted -712698321 1717321090
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1717320831
+ParskipFull
+\end_layout
+
+\end_inset
+
+ [
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1717320820
+string
+\end_layout
+
+\end_inset
+
+] If the class has an option to set a full line paragraph skip,
+ specify it here (e.g.,
+ 
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1717320884
+parskip=full
+\change_unchanged
+
+\end_layout
+
+\end_inset
+
+).
+ This then outputs the option rather than using the 
+\emph on
+parskip
+\emph default
+ package.
+\end_layout
+
+\begin_layout Description
+
+\change_inserted -712698321 1717321094
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1717320913
+ParskipHalf
+\end_layout
+
+\end_inset
+
+ [
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1717320909
+string
+\end_layout
+
+\end_inset
+
+] If the class has an option to set a half line paragraph skip,
+ specify it here (e.g.,
+ 
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1717320920
+parskip=half
+\end_layout
+
+\end_inset
+
+).
+ This then outputs the option rather than using the 
+\emph on
+parskip
+\emph default
+ package.
+\change_unchanged
+
 \end_layout
 
 \begin_layout Description
@@ -20899,6 +21001,8 @@ status collapsed
 
 \change_inserted -712698321 1715685023
 -1
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -20944,6 +21048,8 @@ status collapsed
 
 \change_inserted -712698321 1715685031
 1
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -20979,6 +21085,8 @@ status collapsed
 
 \change_inserted -712698321 1715685008
 0
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -20994,6 +21102,8 @@ status collapsed
 
 \backslash
 cprotect
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -21007,6 +21117,8 @@ status collapsed
 
 \change_inserted -712698321 1715685008
 -1
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -21021,6 +21133,8 @@ status collapsed
 
 \backslash
 cprotect
+\change_unchanged
+
 \end_layout
 
 \end_inset
diff --git a/lib/doc/de/Customization.lyx b/lib/doc/de/Customization.lyx
index 3c671d525b..fe07aa404a 100644
--- a/lib/doc/de/Customization.lyx
+++ b/lib/doc/de/Customization.lyx
@@ -10755,6 +10755,86 @@ status collapsed
  getrennt.
 \end_layout
 
+\begin_layout Description
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+ParskipFull
+\end_layout
+
+\end_inset
+
+ [
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+string
+\end_layout
+
+\end_inset
+
+] Falls die Dokumentklasse eine Option zum Setzen eines ganzzeiligen Absatzabstandes bietet (bspw.
+ 
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+parskip=full
+\end_layout
+
+\end_inset
+
+),
+ geben Sie diese hier an.
+ Dann wird statt des Pakets 
+\emph on
+parskip
+\emph default
+ diese Option verwendet.
+\end_layout
+
+\begin_layout Description
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+ParskipHalf
+\end_layout
+
+\end_inset
+
+ [
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+string
+\end_layout
+
+\end_inset
+
+] Falls die Dokumentklasse eine Option zum Setzen eines halbzeiligen Absatzabstandes bietet (bspw.
+ 
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+parskip=half
+\end_layout
+
+\end_inset
+
+),
+ geben Sie diese hier an.
+ Dann wird statt des Pakets 
+\emph on
+parskip
+\emph default
+ diese Option verwendet.
+\end_layout
+
 \begin_layout Standard
 Der Abschnitt 
 \begin_inset Flex Code
diff --git a/lib/layouts/scrclass.inc b/lib/layouts/scrclass.inc
index 41ac90a91b..ab85a0f3af 100644
--- a/lib/layouts/scrclass.inc
+++ b/lib/layouts/scrclass.inc
@@ -8,7 +8,8 @@
 # Labeling is now used also in non-KOMA classes
 
 
-Format 104
+Format 105
+
 SecNumDepth             2
 TocDepth                2
 DefaultStyle            Standard
@@ -20,6 +21,8 @@ ClassOptions
 	FontSizeFormat       fontsize=$$s
 	PageSize             a0|a1|a2|a3|a4|a5|a6|b0|b1|b2|b3|b4|b5|b6|c0|c1|c2|c3|c4|c5|c6|executive|legal|letter
 	PageSizeFormat       paper=$$s
+	ParskipHalf          parskip=half
+	ParskipFull          parskip=full
 End
 
 Style Standard
diff --git a/lib/scripts/layout2layout.py b/lib/scripts/layout2layout.py
index 611639412a..665e717bfb 100644
--- a/lib/scripts/layout2layout.py
+++ b/lib/scripts/layout2layout.py
@@ -11,7 +11,7 @@
 # This script will update a .layout file to current format
 
 # The latest layout format is also defined in src/TextClass.cpp
-currentFormat = 104
+currentFormat = 105
 
 
 # Incremented to format 4, 6 April 2007, lasgouttes
@@ -351,6 +351,9 @@ currentFormat = 104
 # Incremented to format 104, 28 July 2023 by rikiheck
 # RefFormat for counters and PrettyFormat for floats
 
+# Incremented to format 105, 2 June 2024 by spitz
+# ParskipFull and ParskipHalf class options
+
 # Do not forget to document format change in Customization
 # Manual (section "Declaring a new text class").
 
@@ -598,7 +601,7 @@ def convert(lines, end_format):
                 i += 1
             continue
 
-        if 101 <= format <= 103:
+        if 101 <= format <= 104:
             # nothing to do.
             i += 1
             continue
diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp
index 2e000e29c4..892aff5867 100644
--- a/src/BufferParams.cpp
+++ b/src/BufferParams.cpp
@@ -1831,6 +1831,13 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
 	case DEFAULT:
 		break;
 	}
+	
+	if (paragraph_separation) {
+		if (!tclass.halfparskip().empty() && getDefSkip().kind() == VSpace::HALFLINE)
+			clsoptions << tclass.halfparskip() << ",";
+		if (!tclass.fullparskip().empty() && getDefSkip().kind() == VSpace::FULLLINE)
+			clsoptions << tclass.fullparskip() << ",";
+	}
 
 	// language should be a parameter to \documentclass
 	if (language->babel() == "hebrew"
@@ -2154,6 +2161,7 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
 		// when skip separation
 		string psopt;
 		bool default_skip = false;
+		bool by_class_option = false;
 		switch (getDefSkip().kind()) {
 		case VSpace::SMALLSKIP:
 			psopt = "\\smallskipamount";
@@ -2167,9 +2175,11 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
 		case VSpace::HALFLINE:
 			// default (no option)
 			default_skip = true;
+			by_class_option = !tclass.halfparskip().empty();
 			break;
 		case VSpace::FULLLINE:
 			psopt = "\\baselineskip";
+			by_class_option = !tclass.fullparskip().empty();
 			break;
 		case VSpace::LENGTH:
 			psopt = getDefSkip().length().asLatexString();
@@ -2186,7 +2196,7 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
 				// explicitly reset default (might have been changed
 				// in a class or package)
 				os << "\\parskip=.5\\baselineskip plus 2pt\\relax\n";
-		} else {
+		} else if (!by_class_option) {
 			// load parskip package with required options
 			string psopts;
 			if (!psopt.empty()) {
diff --git a/src/TextClass.cpp b/src/TextClass.cpp
index 339d8c90cf..7170cc2f2c 100644
--- a/src/TextClass.cpp
+++ b/src/TextClass.cpp
@@ -59,7 +59,7 @@ namespace lyx {
 // You should also run the development/tools/updatelayouts.py script,
 // to update the format of all of our layout files.
 //
-int const LAYOUT_FORMAT = 104; // rkh: RefFormat for counters
+int const LAYOUT_FORMAT = 105; // spitz: ParskipHalf and ParskipFull class options
 
 
 // Layout format for the current lyx file format. Controls which format is
@@ -135,8 +135,8 @@ TextClass::TextClass()
 	  opt_enginetype_("authoryear|numerical"), opt_fontsize_("10|11|12"),
 	  opt_pagesize_("default|a4|a5|b5|letter|legal|executive"),
 	  opt_pagestyle_("empty|plain|headings|fancy"), fontsize_format_("$$spt"), pagesize_("default"),
-	  pagesize_format_("$$spaper"), pagestyle_("default"), tablestyle_("default"),
-	  docbookroot_("article"), docbookforceabstract_(false),
+	  pagesize_format_("$$spaper"), pagestyle_("default"), parskip_full_(""), parskip_half_(""),
+	  tablestyle_("default"), docbookroot_("article"), docbookforceabstract_(false),
 	  columns_(1), sides_(OneSide), secnumdepth_(3), tocdepth_(3), outputType_(LATEX),
 	  outputFormat_("latex"), has_output_format_(false), defaultfont_(sane_font), 
 	  titletype_(TITLE_COMMAND_AFTER), titlename_("maketitle"),
@@ -1027,6 +1027,8 @@ void TextClass::readClassOptions(Lexer & lexrc)
 		CO_PAGESIZE,
 		CO_PAGESIZE_FORMAT,
 		CO_PAGESTYLE,
+		CO_PARSKIP_FULL,
+		CO_PARSKIP_HALF,
 		CO_OTHER,
 		CO_END
 	};
@@ -1038,7 +1040,9 @@ void TextClass::readClassOptions(Lexer & lexrc)
 		{"other",     CO_OTHER },
 		{"pagesize",  CO_PAGESIZE },
 		{"pagesizeformat", CO_PAGESIZE_FORMAT },
-		{"pagestyle", CO_PAGESTYLE }
+		{"pagestyle", CO_PAGESTYLE },
+		{"parskipfull", CO_PARSKIP_FULL },
+		{"parskiphalf", CO_PARSKIP_HALF }
 	};
 
 	lexrc.pushTable(classOptionsTags);
@@ -1073,6 +1077,14 @@ void TextClass::readClassOptions(Lexer & lexrc)
 			lexrc.next();
 			opt_pagestyle_ = rtrim(lexrc.getString());
 			break;
+		case CO_PARSKIP_FULL:
+			lexrc.next();
+			parskip_full_ = rtrim(lexrc.getString());
+			break;
+		case CO_PARSKIP_HALF:
+			lexrc.next();
+			parskip_half_ = rtrim(lexrc.getString());
+			break;
 		case CO_OTHER:
 			lexrc.next();
 			if (options_.empty())
diff --git a/src/TextClass.h b/src/TextClass.h
index 2f42133491..5a7f4c45bd 100644
--- a/src/TextClass.h
+++ b/src/TextClass.h
@@ -288,6 +288,10 @@ protected:
 	std::string pagesize_format_;
 	///
 	std::string pagestyle_;
+	/// Option for full parskip
+	std::string parskip_full_;
+	/// Option for half parskip
+	std::string parskip_half_;
 	///
 	std::string tablestyle_;
 	///
@@ -480,6 +484,10 @@ public:
 	///
 	std::string const & pagesizeformat() const { return pagesize_format_; }
 	///
+	std::string const & fullparskip() const { return parskip_full_; }
+	///
+	std::string const & halfparskip() const { return parskip_half_; }
+	///
 	std::string const & pagestyle() const { return pagestyle_; }
 	///
 	std::string const & tablestyle() const { return tablestyle_; }


More information about the lyx-cvs mailing list