diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-03-16 12:35:49 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-03-16 12:35:49 +0200 |
commit | ce1ac1ba801d6f09ec028838d5fed863ffce6a9a (patch) | |
tree | 7e7e25f9480130f8f479efe5a0396c41eadb6a0f /src/gmdocument.c | |
parent | ee495092d59f5d5cda9491ebdaa7ef7f107341a3 (diff) |
Translation: More reliable markup preservation
Diffstat (limited to 'src/gmdocument.c')
-rw-r--r-- | src/gmdocument.c | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/src/gmdocument.c b/src/gmdocument.c index bade99ce..2c01290e 100644 --- a/src/gmdocument.c +++ b/src/gmdocument.c | |||
@@ -89,22 +89,14 @@ struct Impl_GmDocument { | |||
89 | 89 | ||
90 | iDefineObjectConstruction(GmDocument) | 90 | iDefineObjectConstruction(GmDocument) |
91 | 91 | ||
92 | enum iGmLineType { | ||
93 | text_GmLineType, | ||
94 | bullet_GmLineType, | ||
95 | preformatted_GmLineType, | ||
96 | quote_GmLineType, | ||
97 | heading1_GmLineType, | ||
98 | heading2_GmLineType, | ||
99 | heading3_GmLineType, | ||
100 | link_GmLineType, | ||
101 | max_GmLineType, | ||
102 | }; | ||
103 | |||
104 | static enum iGmLineType lineType_GmDocument_(const iGmDocument *d, const iRangecc line) { | 92 | static enum iGmLineType lineType_GmDocument_(const iGmDocument *d, const iRangecc line) { |
105 | if (d->format == plainText_GmDocumentFormat) { | 93 | if (d->format == plainText_GmDocumentFormat) { |
106 | return text_GmLineType; | 94 | return text_GmLineType; |
107 | } | 95 | } |
96 | return lineType_Rangecc(line); | ||
97 | } | ||
98 | |||
99 | enum iGmLineType lineType_Rangecc(const iRangecc line) { | ||
108 | if (isEmpty_Range(&line)) { | 100 | if (isEmpty_Range(&line)) { |
109 | return text_GmLineType; | 101 | return text_GmLineType; |
110 | } | 102 | } |
@@ -132,7 +124,7 @@ static enum iGmLineType lineType_GmDocument_(const iGmDocument *d, const iRangec | |||
132 | return text_GmLineType; | 124 | return text_GmLineType; |
133 | } | 125 | } |
134 | 126 | ||
135 | static void trimLine_Rangecc_(iRangecc *line, enum iGmLineType type, iBool normalize) { | 127 | void trimLine_Rangecc(iRangecc *line, enum iGmLineType type, iBool normalize) { |
136 | static const unsigned int skip[max_GmLineType] = { 0, 2, 3, 1, 1, 2, 3, 0 }; | 128 | static const unsigned int skip[max_GmLineType] = { 0, 2, 3, 1, 1, 2, 3, 0 }; |
137 | line->start += skip[type]; | 129 | line->start += skip[type]; |
138 | if (normalize || (type >= heading1_GmLineType && type <= heading3_GmLineType)) { | 130 | if (normalize || (type >= heading1_GmLineType && type <= heading3_GmLineType)) { |
@@ -400,7 +392,7 @@ static void doLayout_GmDocument_(iGmDocument *d) { | |||
400 | d->size.x /*- indents[preformatted_GmLineType] * gap_Text*/) { | 392 | d->size.x /*- indents[preformatted_GmLineType] * gap_Text*/) { |
401 | preFont = preformattedSmall_FontId; | 393 | preFont = preformattedSmall_FontId; |
402 | } | 394 | } |
403 | trimLine_Rangecc_(&line, type, isNormalized); | 395 | trimLine_Rangecc(&line, type, isNormalized); |
404 | preAltText = line; | 396 | preAltText = line; |
405 | /* TODO: store and link the alt text to this run */ | 397 | /* TODO: store and link the alt text to this run */ |
406 | continue; | 398 | continue; |
@@ -412,7 +404,7 @@ static void doLayout_GmDocument_(iGmDocument *d) { | |||
412 | type = text_GmLineType; | 404 | type = text_GmLineType; |
413 | } | 405 | } |
414 | } | 406 | } |
415 | trimLine_Rangecc_(&line, type, isNormalized); | 407 | trimLine_Rangecc(&line, type, isNormalized); |
416 | run.font = fonts[type]; | 408 | run.font = fonts[type]; |
417 | /* Remember headings for the document outline. */ | 409 | /* Remember headings for the document outline. */ |
418 | if (type == heading1_GmLineType || type == heading2_GmLineType || type == heading3_GmLineType) { | 410 | if (type == heading1_GmLineType || type == heading2_GmLineType || type == heading3_GmLineType) { |