Skip to content

Commit a8e706c

Browse files
committed
Merge branch 'release/4.25.0'
Release v4.25.0
2 parents 131d602 + 1c0566e commit a8e706c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1276
-738
lines changed

Diff for: CHANGELOG.md

+18-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,23 @@ Releases are listed in reverse version number order.
66

77
> Note that _CodeSnip_ v4 was developed in parallel with v3 for a while. As a consequence some v3 releases have later release dates than early v4 releases.
88
9+
## Release v4.25.0 of 19 April 2025
10+
11+
* Added new feature to save snippet information to file in RTF format using the new _File | Save Snippet Information_ menu option [issue #140].
12+
* Added the option to save optionally highlighted annotated source code and units in HTML 5 format [issue #87].
13+
* Fixed malformed bullet character(s) in the list of imported snippets on the last page of the Snippets Import Wizard dialogue box [issue #147].
14+
* Improved the solution to the crash after hibernation bug, initially fixed in v4.24.1 and v4.24.2, with much improved and more stable code [issue #158]. Implemented by [@SirRufo](https://github.com/SirRufo).
15+
* Overhauled rich text format processing:
16+
* Fixed bug where Unicode characters that don't exist in the system code page were not being displayed correctly [issue #157].
17+
* Fixed potential bug where some reserved ASCII characters may not be escaped properly [issue #159].
18+
* Refactored and improved the rich text handling code [issue #100].
19+
* Corrected the copyright date displayed in the About Box to include 2025 [issue #149].
20+
* Documentation changes:
21+
* Fixed error in the export file formation documentation and related help topic [issue #151].
22+
* Corrected erroneous comments for the _TREMLEntities.MapToEntity_ method [issue #84].
23+
* Updated file format documentation with details the changes introduced when implementing issues #87 and #140.
24+
* Updated the help file with details of the new features added in this release.
25+
926
## Release v4.24.2 of 14 April 2025
1027

1128
Hotfix release.
@@ -16,7 +33,7 @@ Hotfix release.
1633
## Release v4.24.1 of 13 April 2025
1734

1835
* Fixed bug where CodeSnip occasionally crashes after a computer resumes from hibernation [issue #70].
19-
* Bumped some copyright dates for 2025.
36+
* Updated license copyright dates for 2025.
2037

2138
## Release v4.24.0 of 23 October 2024
2239

Diff for: Docs/Design/FileFormats/export.html

+41-34
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
66
* obtain one at https://mozilla.org/MPL/2.0/
77
*
8-
* Copyright (C) 2012-2024, Peter Johnson (gravatar.com/delphidabbler).
8+
* Copyright (C) 2012-2025, Peter Johnson (gravatar.com/delphidabbler).
99
*
1010
* CodeSnip File Format Documentation: Export
1111
-->
@@ -57,6 +57,9 @@ <h2>
5757
<li>
5858
<a href="#file-format">File Format</a>
5959
</li>
60+
<li>
61+
<a href="#erratum">Erratum</a>
62+
</li>
6063
<li>
6164
<a href="#changelog">Change Log</a>
6265
</li>
@@ -114,8 +117,8 @@ <h2>
114117
</h2>
115118

116119
<p>
117-
There have been seven different versions of the XML export file format &ndash; v1 to
118-
v7. Tags used by all versions are explained below, with notes describing
120+
There have been eight different versions of the XML export file format &ndash; v1 to
121+
v8. Tags used by all versions are explained below, with notes describing
119122
which versions a tag applies to. Where there is no note the tag is valid in
120123
all versions.
121124
</p>
@@ -176,7 +179,7 @@ <h2>
176179
</dt>
177180
<dd>
178181
Identifies major version of file. Determines which tags are valid and
179-
establishes rules concerning content. Valid versions are 1 to 7.
182+
establishes rules concerning content. Valid versions are 1 to 8.
180183
</dd>
181184
</dl>
182185
</dd>
@@ -198,7 +201,7 @@ <h2>
198201
<span class="highlight">versions 1 to 6:</span> Contains information about user who created the file &nbsp; used for submissions to the online database, omitted for other exports.
199202
</li>
200203
<li>
201-
<span class="highlight">version 7:</span> Not supported. Ignored if present.
204+
<span class="highlight">version 7 and later:</span> Not supported. Ignored if present.
202205
</li>
203206
</ul>
204207
</dd>
@@ -212,7 +215,7 @@ <h2>
212215
<span class="highlight">versions 1 to 6:</span> User's name or nickname.
213216
</li>
214217
<li>
215-
<span class="highlight">version 7:</span> Not supported. Ignored if present.
218+
<span class="highlight">version 7 and later:</span> Not supported. Ignored if present.
216219
</li>
217220
</ul>
218221
</dd>
@@ -226,7 +229,7 @@ <h2>
226229
<span class="highlight">versions 1 to 6:</span> User's email address.
227230
</li>
228231
<li>
229-
<span class="highlight">version 7:</span> Not supported. Ignored if present.
232+
<span class="highlight">version 7 and later:</span> Not supported. Ignored if present.
230233
</li>
231234
</ul>
232235
</dd>
@@ -240,7 +243,7 @@ <h2>
240243
<span class="highlight">versions 1 to 6:</span> Any comments provided by user.
241244
</li>
242245
<li>
243-
<span class="highlight">version 7:</span> Not supported. Ignored if present.
246+
<span class="highlight">version 7 and later:</span> Not supported. Ignored if present.
244247
</li>
245248
</ul>
246249
</dd>
@@ -687,33 +690,21 @@ <h2>
687690
</ul>
688691
</dd>
689692

690-
<dt>
691-
<strong>codesnip-export/routines/routine/xref</strong>
692-
</dt>
693-
<dd>
694-
List of cross-referenced snippets.
695-
</dd>
693+
</section>
696694

697-
<dt>
698-
<strong>codesnip-export/routines/routine/xref/pascal-name</strong>
699-
</dt>
700-
<dd>
701-
<div class="half-spaced">
702-
Name of a snippet within cross-reference list.
703-
</div>
704-
<ul class="squashed">
705-
<li>
706-
<span class="highlight">versions 1 to 4:</span> Name must begin with an
707-
English language letter or the underscore.
708-
</li>
709-
<li>
710-
<span class="highlight">version 5 and later:</span> Name can begin with
711-
any character that is valid as the first character of a Unicode Pascal
712-
identifier.
713-
</li>
714-
</ul>
715-
</dd>
716-
</dl>
695+
<section id="erratum">
696+
697+
<h2>
698+
Erratum
699+
</h2>
700+
701+
<p>
702+
The <em>codesnip-export/routines/routine/xref</em> and <em>codesnip-export/routines/routine/xref/pascal-name</em> tags were included in versions 1 to 7 of this specification in error. XRefs were never intended to be written to export files by any version of CodeSnip, as source code comments make clear.
703+
</p>
704+
705+
<p>
706+
These tags have been removed from this document entirely of specification version 8.
707+
</p>
717708

718709
</section>
719710

@@ -1008,6 +999,18 @@ <h2>
1008999
</dd>
10091000
</dl>
10101001
</dd>
1002+
1003+
<dt>
1004+
<strong>Version 8 - 15 April 2025</strong>
1005+
</dt>
1006+
<dd>
1007+
<p>
1008+
Introduced with CodeSnip v4.24.3.
1009+
</p>
1010+
<p>
1011+
The <em>codesnip-export/routines/routine/xref</em> and <em>codesnip-export/routines/routine/xref/pascal-name</em> tags were removed from the specification. See <a href="#erratum">Erratum</a> above for details.
1012+
</p>
1013+
</dd>
10111014
</dl>
10121015

10131016
</section>
@@ -1058,6 +1061,10 @@ <h2>
10581061
Readers of v2 files and later can parse REML as v6, since all versions of REML up to v6 are backwards compatible.
10591062
</p>
10601063

1064+
<p>
1065+
Readers of v1 to v7 files must ignore any <em>codesnip-export/routines/routine/xref</em> tags and sub tags in the unlikely event that they are found. For an explanation see <a href="#erratum">Erratum</a> above.
1066+
</p>
1067+
10611068
</section>
10621069

10631070
</body>

Diff for: Docs/Design/FileFormats/saved.html

+32-8
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
66
* obtain one at https://mozilla.org/MPL/2.0/
77
*
8-
* Copyright (C) 2012-2021, Peter Johnson (gravatar.com/delphidabbler).
8+
* Copyright (C) 2012-2025, Peter Johnson (gravatar.com/delphidabbler).
99
*
1010
* CodeSnip File Format Documentation: Saved Files
1111
-->
@@ -46,20 +46,27 @@ <h2>
4646
</h2>
4747

4848
<p>
49-
CodeSnip saves external files in two different ways:
49+
CodeSnip saves external files in three different ways:
5050
</p>
5151

5252
<ol>
5353
<li>
54-
By saving snippets to file from the <em>File | Save Snippet</em> menu.
54+
By saving snippet information to file from the <em>File | Save Snippet Information</em> menu option.
5555
</li>
5656
<li>
57-
By saving units to file from the <em>File | Save Unit</em> menu.
57+
By saving snippets to file from the <em>File | Save Snippet</em> menu option.
58+
</li>
59+
<li>
60+
By saving units to file from the <em>File | Save Unit</em> menu option.
5861
</li>
5962
</ol>
6063

6164
<p>
62-
In each case the following file types can be chosen by the user:
65+
In the first case the snippet is always saved in rich text format.
66+
</p>
67+
68+
<p>
69+
In the second two cases the following file types can be chosen by the user:
6370
</p>
6471

6572
<ul>
@@ -69,6 +76,9 @@ <h2>
6976
<li>
7077
Pascal source files (either .inc or .pas files).
7178
</li>
79+
<li>
80+
HTML 5 files.
81+
</li>
7282
<li>
7383
XHTML files.
7484
</li>
@@ -78,7 +88,7 @@ <h2>
7888
</ul>
7989

8090
<p>
81-
There is no specific file format for these files, except that XHTML and RTF
91+
There is no specific file format for these files, except that HTML 5, XHTML and RTF
8292
files conform to published specifications.
8393
</p>
8494

@@ -87,7 +97,11 @@ <h2>
8797
</h2>
8898

8999
<p>
90-
The encodings used depend on the file type and user choice. Different file
100+
In the first case the RTF is always saved in ASCII format.
101+
</p>
102+
103+
<p>
104+
In the 2nd and 3rd cases the encodings used depend on the file type and user choice. Different file
91105
types have different encoding choices, as follows:
92106
</p>
93107

@@ -124,6 +138,16 @@ <h2>
124138
</li>
125139
</ul>
126140
</dd>
141+
<dt>
142+
HTML 5 files
143+
</dt>
144+
<dd>
145+
<ul class="squashed">
146+
<li>
147+
UTF-8
148+
</li>
149+
</ul>
150+
</dd>
127151
<dt>
128152
XHTML files
129153
</dt>
@@ -140,7 +164,7 @@ <h2>
140164
<dd>
141165
<ul class="squashed">
142166
<li>
143-
ANSI (system default code page)
167+
ANSI (system default code page). ASCII format is actually used.
144168
</li>
145169
</ul>
146170
</dd>

Diff for: Src/ActiveText.UHTMLRenderer.pas

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
44
* obtain one at https://mozilla.org/MPL/2.0/
55
*
6-
* Copyright (C) 2009-2023, Peter Johnson (gravatar.com/delphidabbler).
6+
* Copyright (C) 2009-2025, Peter Johnson (gravatar.com/delphidabbler).
77
*
88
* Provides a class that renders active text as HTML.
99
}
@@ -145,7 +145,7 @@ procedure TActiveTextHTML.InitialiseTagInfoMap;
145145
function TActiveTextHTML.MakeClosingTag(const Elem: IActiveTextActionElem):
146146
string;
147147
begin
148-
Result := THTML.ClosingTag(fTagInfoMap[Elem.Kind].Name);
148+
Result := TXHTML.ClosingTag(fTagInfoMap[Elem.Kind].Name);
149149
end;
150150

151151
function TActiveTextHTML.MakeOpeningTag(const Elem: IActiveTextActionElem):
@@ -160,7 +160,7 @@ function TActiveTextHTML.MakeOpeningTag(const Elem: IActiveTextActionElem):
160160
Attrs := THTMLAttributes.Create;
161161
Attrs.Add('class', fCSSStyles.ElemClasses[Elem.Kind])
162162
end;
163-
Result := THTML.OpeningTag(fTagInfoMap[Elem.Kind].Name, Attrs);
163+
Result := TXHTML.OpeningTag(fTagInfoMap[Elem.Kind].Name, Attrs);
164164
end;
165165

166166
function TActiveTextHTML.Render(ActiveText: IActiveText): string;
@@ -242,7 +242,7 @@ function TActiveTextHTML.RenderText(const TextElem: IActiveTextTextElem):
242242
end
243243
else
244244
Result := '';
245-
Result := Result + THTML.Entities(TextElem.Text);
245+
Result := Result + TXHTML.Entities(TextElem.Text);
246246
end;
247247

248248
{ TActiveTextHTML.TCSSStyles }

Diff for: Src/Browser.UHighlighter.pas

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
44
* obtain one at https://mozilla.org/MPL/2.0/
55
*
6-
* Copyright (C) 2005-2021, Peter Johnson (gravatar.com/delphidabbler).
6+
* Copyright (C) 2005-2025, Peter Johnson (gravatar.com/delphidabbler).
77
*
88
* Class that highlights text in web browser that match a search criteria.
99
}
@@ -194,7 +194,7 @@ function TWBHighlighter.HighlightWord(const Word: string;
194194
begin
195195
// Apply highlight to found text by spanning it with highlight style
196196
SpanAttrs := THTMLAttributes.Create('style', fHighLightStyle);
197-
Range.pasteHTML(THTML.CompoundTag('span', SpanAttrs, Range.htmlText));
197+
Range.pasteHTML(TXHTML.CompoundTag('span', SpanAttrs, Range.htmlText));
198198
Inc(Result);
199199
end
200200
else

Diff for: Src/ClassHelpers.RichEdit.pas

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{
2+
* This Source Code Form is subject to the terms of the Mozilla Public License,
3+
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
4+
* obtain one at https://mozilla.org/MPL/2.0/
5+
*
6+
* Copyright (C) 2025, Peter Johnson (gravatar.com/delphidabbler).
7+
*
8+
* Class helper for TRichEdit.
9+
}
10+
11+
unit ClassHelpers.RichEdit;
12+
13+
interface
14+
15+
uses
16+
// Delphi
17+
ComCtrls,
18+
// Project
19+
URTFUtils;
20+
21+
type
22+
TRichEditHelper = class helper for TRichEdit
23+
public
24+
procedure Load(const ARTFMarkup: TRTFMarkup);
25+
end;
26+
27+
implementation
28+
29+
uses
30+
// Delphi
31+
SysUtils,
32+
Classes;
33+
34+
{ TRichEditHelper }
35+
36+
procedure TRichEditHelper.Load(const ARTFMarkup: TRTFMarkup);
37+
var
38+
Stream: TStream;
39+
begin
40+
PlainText := False;
41+
Stream := TMemoryStream.Create;
42+
try
43+
ARTFMarkup.ToStream(Stream);
44+
Stream.Position := 0;
45+
// must set MaxLength or long documents may not display
46+
MaxLength := Stream.Size;
47+
Lines.LoadFromStream(Stream, TEncoding.ASCII);
48+
finally
49+
Stream.Free;
50+
end;
51+
end;
52+
53+
end.

0 commit comments

Comments
 (0)