1/* Part of Extended Libraries for SWI-Prolog 2 3 Author: Edison Mera 4 E-mail: efmera@gmail.com 5 WWW: https://github.com/edisonm/xlibrary 6 Copyright (C): 2016, Process Design Center, Breda, The Netherlands. 7 All rights reserved. 8 9 Redistribution and use in source and binary forms, with or without 10 modification, are permitted provided that the following conditions 11 are met: 12 13 1. Redistributions of source code must retain the above copyright 14 notice, this list of conditions and the following disclaimer. 15 16 2. Redistributions in binary form must reproduce the above copyright 17 notice, this list of conditions and the following disclaimer in 18 the documentation and/or other materials provided with the 19 distribution. 20 21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 24 FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 25 COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 26 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 27 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 31 ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 POSSIBILITY OF SUCH DAMAGE. 33*/ 34 35:- module(codes_html, 36 [code_html/3, % ?Code, ?Html, ?Tail 37 codes_html/2, % +Codes, ?Html 38 codes_html/3 % +Codes, ?Html, ?Tail 39 ]). 40 41codes_html(Codes, Html) :- 42 codes_html(Codes, Html, []). 43 44codes_html(Codes) --> 45 foldl(code_html_nf, Codes). 46 47code_html_nf(Code) --> code_html(Code), !. 48code_html_nf(Code) --> [Code]. 49 50% escape characters taken from: 51% http://www.theukwebdesigncompany.com/articles/entity-escape-characters.php 52 53code_html(0'") --> """. % quotation mark 54code_html(0'') --> "'". % apostrophe 55code_html(0'&) --> "&". % ampersand 56code_html(0'<) --> "<". % less-than 57code_html(0'>) --> ">". % greater-than 58code_html(0' ) --> " ". % non-breaking space 59code_html(0'¡) --> "¡". % inverted exclamation mark 60code_html(0'¢) --> "¢". % cent 61code_html(0'£) --> "£". % pound sterling 62code_html(0'¤) --> "¤". % currency 63code_html(0'¥) --> "¥". % yen 64code_html(0'¦) --> "¦". % broken vertical bar 65code_html(0'§) --> "§". % section 66code_html(0'¨) --> "¨". % spacing diaeresis 67code_html(0'©) --> "©". % copyright 68code_html(0'ª) --> "ª". % feminine ordinal indicator 69code_html(0'«) --> "«". % angle quotation mark (left) 70code_html(0'¬) --> "¬". % negation 71code_html(0'&) --> "hy;". % soft hyphen 72code_html(0'®) --> "®". % registered trademark 73code_html(0'¯) --> "¯". % spacing macron 74code_html(0'°) --> "°". % degree 75code_html(0'±) --> "±". % plus-or-minus 76code_html(0'²) --> "²". % superscript 2 77code_html(0'³) --> "³". % superscript 3 78code_html(0'´) --> "´". % spacing acute 79code_html(0'µ) --> "µ". % micro 80code_html(0'¶) --> "¶". % paragraph 81code_html(0'·) --> "·". % middle dot 82code_html(0'¸) --> "¸". % spacing cedilla 83code_html(0'¹) --> "¹". % superscript 1 84code_html(0'º) --> "º". % masculine ordinal indicator 85code_html(0'») --> "»". % angle quotation mark (right) 86code_html(0'¼) --> "¼". % fraction 1/4 87code_html(0'½) --> "½". % fraction 1/2 88code_html(0'¾) --> "¾". % fraction 3/4 89code_html(0'¿) --> "¿". % inverted question mark 90code_html(0'×) --> "×". % multiplication 91code_html(0'÷) --> "÷". % division 92code_html(0'À) --> "À". % capital a, grave accent 93code_html(0'Á) --> "Á". % capital a, acute accent 94code_html(0'Â) --> "Â". % capital a, circumflex accent 95code_html(0'Ã) --> "Ã". % capital a, tilde 96code_html(0'Ä) --> "Ä". % capital a, umlaut mark 97code_html(0'Å) --> "Å". % capital a, ring 98code_html(0'Æ) --> "Æ". % capital ae 99code_html(0'Ç) --> "Ç". % capital c, cedilla 100code_html(0'È) --> "È". % capital e, grave accent 101code_html(0'É) --> "É". % capital e, acute accent 102code_html(0'Ê) --> "Ê". % capital e, circumflex accent 103code_html(0'Ë) --> "Ë". % capital e, umlaut mark 104code_html(0'Ì) --> "Ì". % capital i, grave accent 105code_html(0'Í) --> "Í". % capital i, acute accent 106code_html(0'Î) --> "Î". % capital i, circumflex accent 107code_html(0'Ï) --> "Ï". % capital i, umlaut mark 108code_html(0'Ð) --> "Ð". % capital eth, Icelandic 109code_html(0'Ñ) --> "Ñ". % capital n, tilde 110code_html(0'Ò) --> "Ò". % capital o, grave accent 111code_html(0'Ó) --> "Ó". % capital o, acute accent 112code_html(0'Ô) --> "Ô". % capital o, circumflex accent 113code_html(0'Õ) --> "Õ". % capital o, tilde 114code_html(0'Ö) --> "Ö". % capital o, umlaut mark 115code_html(0'Ø) --> "Ø". % capital o, slash 116code_html(0'Ù) --> "Ù". % capital u, grave accent 117code_html(0'Ú) --> "Ú". % capital u, acute accent 118code_html(0'Û) --> "Û". % capital u, circumflex accent 119code_html(0'Ü) --> "Ü". % capital u, umlaut mark 120code_html(0'Ý) --> "Ý". % capital y, acute accent 121code_html(0'Þ) --> "Þ". % capital THORN, Icelandic 122code_html(0'ß) --> "ß". % small sharp s, German 123code_html(0'à) --> "à". % small a, grave accent 124code_html(0'á) --> "á". % small a, acute accent 125code_html(0'â) --> "â". % small a, circumflex accent 126code_html(0'ã) --> "ã". % small a, tilde 127code_html(0'ä) --> "ä". % small a, umlaut mark 128code_html(0'å) --> "å". % small a, ring 129code_html(0'æ) --> "æ". % small ae 130code_html(0'ç) --> "ç". % small c, cedilla 131code_html(0'è) --> "è". % small e, grave accent 132code_html(0'é) --> "é". % small e, acute accent 133code_html(0'ê) --> "ê". % small e, circumflex accent 134code_html(0'ë) --> "ë". % small e, umlaut mark 135code_html(0'ì) --> "ì". % small i, grave accent 136code_html(0'í) --> "í". % small i, acute accent 137code_html(0'î) --> "î". % small i, circumflex accent 138code_html(0'ï) --> "ï". % small i, umlaut mark 139code_html(0'ð) --> "ð". % small eth, Icelandic 140code_html(0'ñ) --> "ñ". % small n, tilde 141code_html(0'ò) --> "ò". % small o, grave accent 142code_html(0'ó) --> "ó". % small o, acute accent 143code_html(0'ô) --> "ô". % small o, circumflex accent 144code_html(0'õ) --> "õ". % small o, tilde 145code_html(0'ö) --> "ö". % small o, umlaut mark 146code_html(0'ø) --> "ø". % small o, slash 147code_html(0'ù) --> "ù". % small u, grave accent 148code_html(0'ú) --> "ú". % small u, acute accent 149code_html(0'û) --> "û". % small u, circumflex accent 150code_html(0'ü) --> "ü". % small u, umlaut mark 151code_html(0'ý) --> "ý". % small y, acute accent 152code_html(0'þ) --> "þ". % small thorn, Icelandic 153code_html(0'ÿ) --> "ÿ". % small y, umlaut mark