[PATCH] Semantic Linefeeds
Yuriy Skalko
yuriy.skalko at gmail.com
Sun Nov 27 16:45:23 UTC 2022
> This looks good to me.
>
> JMarc
Ok, here is an updated patch with dummy format change.
Yuriy
-------------- next part --------------
From 945e020306df7ea595e792284c3e427f32682fb0 Mon Sep 17 00:00:00 2001
From: Yuriy Skalko <yuriy.skalko at gmail.com>
Date: Sun, 27 Nov 2022 18:30:26 +0200
Subject: [PATCH] Add "semantic linefeeds" after punctuation marks.
We already had such breaks for dot.
File format change.
---
development/FORMAT | 4 ++++
lib/lyx2lyx/lyx_2_4.py | 6 ++++--
src/Paragraph.cpp | 26 ++++++++++++++++++++++----
src/version.h | 4 ++--
4 files changed, 32 insertions(+), 8 deletions(-)
diff --git a/development/FORMAT b/development/FORMAT
index 0c41d8801c..5fcf13ebf1 100644
--- a/development/FORMAT
+++ b/development/FORMAT
@@ -7,6 +7,10 @@ changes happened in particular if possible. A good example would be
-----------------------
+2022-11-27 Yuriy Skalko <yuriy.skalko at gmail.com>
+ * Format incremented to 611: Implement "semantic linefeeds" after punctuation marks.
+ Dummy format change for now.
+
2022-10-29 Jürgen Spitzmüller <spitz at lyx.org>
* Format incremented to 610: InsetIndexMacros and new IndexInset params:
- \begin_inset IndexMacro [see|seealso|subentry|sortkey], relating to
diff --git a/lib/lyx2lyx/lyx_2_4.py b/lib/lyx2lyx/lyx_2_4.py
index 73826a5f59..5c0507a5af 100644
--- a/lib/lyx2lyx/lyx_2_4.py
+++ b/lib/lyx2lyx/lyx_2_4.py
@@ -4621,10 +4621,12 @@ convert = [
[607, []],
[608, []],
[609, []],
- [610, []]
+ [610, []],
+ [611, []]
]
-revert = [[609, [revert_index_macros]],
+revert = [[610, []],
+ [609, [revert_index_macros]],
[608, [revert_document_metadata]],
[607, [revert_docbook_mathml_prefix]],
[606, [revert_spellchecker_ignore]],
diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp
index 3b3bc3913e..453b1e1bb5 100644
--- a/src/Paragraph.cpp
+++ b/src/Paragraph.cpp
@@ -1746,16 +1746,34 @@ void Paragraph::write(ostream & os, BufferParams const & bparams,
column = 0;
break;
case '.':
+ case '!':
+ case '?':
+ case ':':
+ case ';':
+ case ',':
+ case 0x061F: // ؟ U+061F ARABIC QUESTION MARK
+ case 0x061B: // ؛ U+061B ARABIC SEMICOLON
+ case 0x060C: // ، U+060C ARABIC COMMA
flushString(os, write_buffer);
if (i + 1 < size() && d->text_[i + 1] == ' ') {
- os << ".\n";
+ os << to_utf8(docstring(1, c)) << '\n';
column = 0;
} else
- os << '.';
+ os << to_utf8(docstring(1, c));
+ break;
+ case 0x2014: // — U+2014 EM DASH
+ case 0x3002: // 。 U+3002 IDEOGRAPHIC FULL STOP
+ case 0xFF01: // ! U+FF01 FULLWIDTH EXCLAMATION MARK
+ case 0xFF1F: // ? U+FF1F FULLWIDTH QUESTION MARK
+ case 0xFF1A: // : U+FF1A FULLWIDTH COLON
+ case 0xFF1B: // ; U+FF1B FULLWIDTH SEMICOLON
+ case 0xFF0C: // , U+FF0C FULLWIDTH COMMA
+ flushString(os, write_buffer);
+ os << to_utf8(docstring(1, c)) << '\n';
+ column = 0;
break;
default:
- if ((column > 70 && c == ' ')
- || column > 79) {
+ if (column > 500) {
flushString(os, write_buffer);
os << '\n';
column = 0;
diff --git a/src/version.h b/src/version.h
index b496d1045d..bfcd9869ae 100644
--- a/src/version.h
+++ b/src/version.h
@@ -32,8 +32,8 @@ extern char const * const lyx_version_info;
// Do not remove the comment below, so we get merge conflict in
// independent branches. Instead add your own.
-#define LYX_FORMAT_LYX 610 // spitz: inset index macros
-#define LYX_FORMAT_TEX2LYX 610
+#define LYX_FORMAT_LYX 611 // Yuriy Skalko: semantic linefeeds
+#define LYX_FORMAT_TEX2LYX 611
#if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX
#ifndef _MSC_VER
--
2.28.0.windows.1
More information about the lyx-devel
mailing list