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 41:- use_module(library(apply)). 42 43codes_html(Codes, Html) :- 44 codes_html(Codes, Html, []). 45 46codes_html(Codes) --> 47 foldl(code_html_nf, Codes). 48 49code_html_nf(Code) --> code_html(Code), !. 50code_html_nf(Code) --> [Code]. 51 52% escape characters taken from: 53% http://www.theukwebdesigncompany.com/articles/entity-escape-characters.php 54 55code_html(0'") --> """. % quotation mark 56code_html(0'') --> "'". % apostrophe 57code_html(0'&) --> "&". % ampersand 58code_html(0'<) --> "<". % less-than 59code_html(0'>) --> ">". % greater-than 60code_html(0' ) --> " ". % non-breaking space 61code_html(0'¡) --> "¡". % inverted exclamation mark 62code_html(0'¢) --> "¢". % cent 63code_html(0'£) --> "£". % pound sterling 64code_html(0'¤) --> "¤". % currency 65code_html(0'¥) --> "¥". % yen 66code_html(0'¦) --> "¦". % broken vertical bar 67code_html(0'§) --> "§". % section 68code_html(0'¨) --> "¨". % spacing diaeresis 69code_html(0'©) --> "©". % copyright 70code_html(0'ª) --> "ª". % feminine ordinal indicator 71code_html(0'«) --> "«". % angle quotation mark (left) 72code_html(0'¬) --> "¬". % negation 73code_html(0'&) --> "hy;". % soft hyphen 74code_html(0'®) --> "®". % registered trademark 75code_html(0'¯) --> "¯". % spacing macron 76code_html(0'°) --> "°". % degree 77code_html(0'±) --> "±". % plus-or-minus 78code_html(0'²) --> "²". % superscript 2 79code_html(0'³) --> "³". % superscript 3 80code_html(0'´) --> "´". % spacing acute 81code_html(0'µ) --> "µ". % micro 82code_html(0'¶) --> "¶". % paragraph 83code_html(0'·) --> "·". % middle dot 84code_html(0'¸) --> "¸". % spacing cedilla 85code_html(0'¹) --> "¹". % superscript 1 86code_html(0'º) --> "º". % masculine ordinal indicator 87code_html(0'») --> "»". % angle quotation mark (right) 88code_html(0'¼) --> "¼". % fraction 1/4 89code_html(0'½) --> "½". % fraction 1/2 90code_html(0'¾) --> "¾". % fraction 3/4 91code_html(0'¿) --> "¿". % inverted question mark 92code_html(0'×) --> "×". % multiplication 93code_html(0'÷) --> "÷". % division 94code_html(0'À) --> "À". % capital a, grave accent 95code_html(0'Á) --> "Á". % capital a, acute accent 96code_html(0'Â) --> "Â". % capital a, circumflex accent 97code_html(0'Ã) --> "Ã". % capital a, tilde 98code_html(0'Ä) --> "Ä". % capital a, umlaut mark 99code_html(0'Å) --> "Å". % capital a, ring 100code_html(0'Æ) --> "Æ". % capital ae 101code_html(0'Ç) --> "Ç". % capital c, cedilla 102code_html(0'È) --> "È". % capital e, grave accent 103code_html(0'É) --> "É". % capital e, acute accent 104code_html(0'Ê) --> "Ê". % capital e, circumflex accent 105code_html(0'Ë) --> "Ë". % capital e, umlaut mark 106code_html(0'Ì) --> "Ì". % capital i, grave accent 107code_html(0'Í) --> "Í". % capital i, acute accent 108code_html(0'Î) --> "Î". % capital i, circumflex accent 109code_html(0'Ï) --> "Ï". % capital i, umlaut mark 110code_html(0'Ð) --> "Ð". % capital eth, Icelandic 111code_html(0'Ñ) --> "Ñ". % capital n, tilde 112code_html(0'Ò) --> "Ò". % capital o, grave accent 113code_html(0'Ó) --> "Ó". % capital o, acute accent 114code_html(0'Ô) --> "Ô". % capital o, circumflex accent 115code_html(0'Õ) --> "Õ". % capital o, tilde 116code_html(0'Ö) --> "Ö". % capital o, umlaut mark 117code_html(0'Ø) --> "Ø". % capital o, slash 118code_html(0'Ù) --> "Ù". % capital u, grave accent 119code_html(0'Ú) --> "Ú". % capital u, acute accent 120code_html(0'Û) --> "Û". % capital u, circumflex accent 121code_html(0'Ü) --> "Ü". % capital u, umlaut mark 122code_html(0'Ý) --> "Ý". % capital y, acute accent 123code_html(0'Þ) --> "Þ". % capital THORN, Icelandic 124code_html(0'ß) --> "ß". % small sharp s, German 125code_html(0'à) --> "à". % small a, grave accent 126code_html(0'á) --> "á". % small a, acute accent 127code_html(0'â) --> "â". % small a, circumflex accent 128code_html(0'ã) --> "ã". % small a, tilde 129code_html(0'ä) --> "ä". % small a, umlaut mark 130code_html(0'å) --> "å". % small a, ring 131code_html(0'æ) --> "æ". % small ae 132code_html(0'ç) --> "ç". % small c, cedilla 133code_html(0'è) --> "è". % small e, grave accent 134code_html(0'é) --> "é". % small e, acute accent 135code_html(0'ê) --> "ê". % small e, circumflex accent 136code_html(0'ë) --> "ë". % small e, umlaut mark 137code_html(0'ì) --> "ì". % small i, grave accent 138code_html(0'í) --> "í". % small i, acute accent 139code_html(0'î) --> "î". % small i, circumflex accent 140code_html(0'ï) --> "ï". % small i, umlaut mark 141code_html(0'ð) --> "ð". % small eth, Icelandic 142code_html(0'ñ) --> "ñ". % small n, tilde 143code_html(0'ò) --> "ò". % small o, grave accent 144code_html(0'ó) --> "ó". % small o, acute accent 145code_html(0'ô) --> "ô". % small o, circumflex accent 146code_html(0'õ) --> "õ". % small o, tilde 147code_html(0'ö) --> "ö". % small o, umlaut mark 148code_html(0'ø) --> "ø". % small o, slash 149code_html(0'ù) --> "ù". % small u, grave accent 150code_html(0'ú) --> "ú". % small u, acute accent 151code_html(0'û) --> "û". % small u, circumflex accent 152code_html(0'ü) --> "ü". % small u, umlaut mark 153code_html(0'ý) --> "ý". % small y, acute accent 154code_html(0'þ) --> "þ". % small thorn, Icelandic 155code_html(0'ÿ) --> "ÿ". % small y, umlaut mark