Skip to content

How to add custom character code entity entries

Drew Naylor edited this page Dec 4, 2020 · 3 revisions

NB: This page is out of date as the current version of the XML document uses aliases to make searching easier and eliminate duplicate entries. Even though the below information won't directly apply anymore, the general idea of copying a part and changing the text should still work. Duplicated aliases are untested, so it may be a good idea to avoid that. See here: https://github.com/DrewNaylor/HTML-Character-Code-Acquisition-Program/blob/master/xmlFiles/searchXml.xml

Original text:
The HTML character codes/entities are stored in xmlFiles\searchXml.xml, and this file is placed in the build directory after a successful build (which means that any changes to the same file in the build directory will be overwritten). The element names may change at any time, but for now below is what's in this file as of July 13, 2019:

<root>
<version>1.0</version>
	<characterCodeSection>
		<characterCode>Ampersand/and symbol: _amp;</characterCode>
		<characterCode>Bullet: _bull;</characterCode>
		<characterCode>Cent: _cent;</characterCode>
		<characterCode>Copyright: _copy;</characterCode>
		<characterCode>Euro: _euro;</characterCode>
		<characterCode>Non-breaking space: _nbsp;</characterCode>
		<characterCode>Pound: _pound;</characterCode>
		<characterCode>Registered trademark: _reg;</characterCode>
		<characterCode>Yen: _yen;</characterCode>
	</characterCodeSection>
</root>

For now, any & symbols must be manually replaced with underscores (_), otherwise the XML reading code will complain. If an automatic workaround is found, it'll be implemented, but this is how it works for now. A side effect of this is that typing the & symbol into html-ccap won't show anything, while typing the underscore into it will show everything like usual. Underscores are replaced by & symbols in the output at runtime so that it looks correct to the end user.

If you want to add your own entries, copy one of the <characterCode> lines to a new line and replace the text in the middle. For example, if you wanted to add the greater than sign (>), you'd do the following:

  1. Make a copy of this line: <characterCode>Yen: _yen;</characterCode>
  2. Change the text for the description: <characterCode>Greater than: _yen;</characterCode>
  3. Change the text for the actual code/entity: <characterCode>Greater than: _gt;</characterCode>
  4. Plug it back into the file, save it, and rebuild:
<root>
<version>1.0</version>
	<characterCodeSection>
		<characterCode>Ampersand/and symbol: _amp;</characterCode>
		<characterCode>Bullet: _bull;</characterCode>
		<characterCode>Cent: _cent;</characterCode>
		<characterCode>Copyright: _copy;</characterCode>
		<characterCode>Euro: _euro;</characterCode>
		<characterCode>Non-breaking space: _nbsp;</characterCode>
		<characterCode>Pound: _pound;</characterCode>
		<characterCode>Registered trademark: _reg;</characterCode>
		<characterCode>Yen: _yen;</characterCode>
                <characterCode>Greater than: _gt;</characterCode>
	</characterCodeSection>
</root>

The custom entry was placed at the bottom, but that shouldn't matter other than not being alphabetized.

Clone this wiki locally