Skip to content

Commit 75ddfcc

Browse files
committed
Add new REML character entities in UREMLDataIO unit
Remove REML docs from comments: they are in a separate unit and fix other header comments.
1 parent 24cf048 commit 75ddfcc

File tree

1 file changed

+37
-59
lines changed

1 file changed

+37
-59
lines changed

Src/UREMLDataIO.pas

Lines changed: 37 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
* Implements classes that render and parse Routine Extra Markup Language (REML)
99
* code. This markup is used to read and store active text objects as used by
10-
* the Extra property of a TSnippet object. Also includes helper classes.
10+
* some properties of a TSnippet object. Also includes helper classes.
1111
}
1212

1313

@@ -139,59 +139,8 @@ implementation
139139
It comprises plain text with limited inline and block level formatting and
140140
hyperlink specified by HTML like tags.
141141
142-
Supported tags are as follows. Unless otherwise specified, no tags may have
143-
any attributes:
144-
145-
Inline:
146-
<a href="url">xxxx</a> - Hyperlink: must have an href attribute that
147-
specifies the link destination as a valid URL.
148-
URLs must not be URL encoded. No other attributes
149-
may be specified.
150-
<strong>..</strong> - Renders enclosed text with strong emphasis.
151-
<em>..</em> - Renders enclosed text emphasised.
152-
<var>..</var> - Renders enclosed text as a programming variable.
153-
<warning>..</warning> - Renders enclosed text as a warning.
154-
<mono>..</mono> - Renders enclosed text as mono spaced.
155-
156-
Block:
157-
<p>..</p> - Enclosed text is formatted as a paragraph.
158-
<heading>..</heading> - Enclosed text is formatted as a heading.
159-
160-
Certain characters in plain text or in attribute values must be encoded as
161-
HTML-like character entities. Attribute names must not contain any of these
162-
characters. The characters that must be encoded are:
163-
164-
Character Entity
165-
> &gt;
166-
< &lt;
167-
" &quot;
168-
& &amp;
169-
� &copy;
170-
171-
No other entities are supported. Any other character can be encoded using its
172-
unicode or ascii value. For example, the @ symbol (ascii 64) is encoded as
173-
&#64;
174-
175-
Example:
176-
<heading>Hello</heading>
177-
<p>&quot;<strong>Hello</strong>&quot; to
178-
<a href="https://example.com">you</a></p>
179-
180-
This example specifes a heading "Hello" followed by a single paragraph. In the
181-
paragraph, "Hello" will be bold, "to" should be plain text and "you" should
182-
hyperlink to "example.com".
183-
184-
There are two versions of REML as follows:
185-
v1 - supported tags: <strong> and <a>.
186-
- supported entities: &gt;, &lt, &quot;, &amp;.
187-
v2 - added tags: <em>, <var>, <warning>, <mono>, <p> and <heading>.
188-
- added entity: &copy;.
189-
190-
The implementation of active text's link element changed over time. At first
191-
it supported only the http:// protocol for URLs. This limited REML v1 <a> tags
192-
to using just that protocol. CodeSnip v3.0.1 added support to active text for
193-
the file:// protocol. From CodeSnip v4.0 active text was extended to support
194-
the https:// protocol.
142+
Valid REML tags and character entities are documented in the file reml.html in
143+
the Docs/Design directory.
195144
}
196145

197146

@@ -841,13 +790,42 @@ class function TREMLEntities.CharToMnemonicEntity(const Ch: Char): string;
841790
{Class constructor. Creates map of mnemonic entities to equivalent characters.
842791
}
843792
begin
844-
SetLength(fEntityMap, 5);
845-
// Record all supported character entities
846-
fEntityMap[0] := TREMLEntity.Create('amp', '&');
793+
SetLength(fEntityMap, 34);
794+
// Supported character entities. All are optional unless otherwise stated
795+
fEntityMap[0] := TREMLEntity.Create('amp', '&'); // required in REML
847796
fEntityMap[1] := TREMLEntity.Create('quot', DOUBLEQUOTE);
848-
fEntityMap[2] := TREMLEntity.Create('gt', '>');
849-
fEntityMap[3] := TREMLEntity.Create('lt', '<');
797+
fEntityMap[2] := TREMLEntity.Create('gt', '>');
798+
fEntityMap[3] := TREMLEntity.Create('lt', '<'); // required in REML
850799
fEntityMap[4] := TREMLEntity.Create('copy', '©');
800+
fEntityMap[5] := TREMLEntity.Create('times', '×');
801+
fEntityMap[6] := TREMLEntity.Create('divide', '÷');
802+
fEntityMap[7] := TREMLEntity.Create('div', '÷');
803+
fEntityMap[8] := TREMLEntity.Create('plusmn', '±');
804+
fEntityMap[9] := TREMLEntity.Create('ne', '');
805+
fEntityMap[10] := TREMLEntity.Create('neq', '');
806+
fEntityMap[11] := TREMLEntity.Create('sum', '');
807+
fEntityMap[12] := TREMLEntity.Create('infin', '');
808+
fEntityMap[13] := TREMLEntity.Create('pound', '£');
809+
fEntityMap[14] := TREMLEntity.Create('curren', '¤');
810+
fEntityMap[15] := TREMLEntity.Create('yen', '¥');
811+
fEntityMap[16] := TREMLEntity.Create('euro', '');
812+
fEntityMap[17] := TREMLEntity.Create('dagger', '');
813+
fEntityMap[18] := TREMLEntity.Create('ddagger', '');
814+
fEntityMap[19] := TREMLEntity.Create('Dagger', '');
815+
fEntityMap[20] := TREMLEntity.Create('hellip', '');
816+
fEntityMap[21] := TREMLEntity.Create('para', '');
817+
fEntityMap[22] := TREMLEntity.Create('sect', '§');
818+
fEntityMap[23] := TREMLEntity.Create('reg', '®');
819+
fEntityMap[24] := TREMLEntity.Create('frac14', '¼');
820+
fEntityMap[25] := TREMLEntity.Create('frac12', '½');
821+
fEntityMap[26] := TREMLEntity.Create('half', '½');
822+
fEntityMap[27] := TREMLEntity.Create('frac34', '¾');
823+
fEntityMap[28] := TREMLEntity.Create('micro', 'µ');
824+
fEntityMap[29] := TREMLEntity.Create('deg', '°');
825+
fEntityMap[30] := TREMLEntity.Create('cent', '¢');
826+
fEntityMap[31] := TREMLEntity.Create('laquo', '«');
827+
fEntityMap[32] := TREMLEntity.Create('raquo', '»');
828+
fEntityMap[33] := TREMLEntity.Create('iquest', '¿');
851829
end;
852830

853831
class destructor TREMLEntities.Destroy;

0 commit comments

Comments
 (0)