1 package org.jetbrains.dokka
2 
3 import java.net.URI
4 
5 
6 /**
7  * Replaces symbols reserved in HTML with their respective entities.
8  * Replaces & with &amp;, < with &lt; and > with &gt;
9  */
htmlEscapenull10 fun String.htmlEscape(): String = replace("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;")
11 
12 // A URI consists of several parts (as described in https://docs.oracle.com/javase/7/docs/api/java/net/URI.html ):
13 // [scheme:][//authority][path][?query][#fragment]
14 //
15 // The anchorEnchoded() function encodes the given string to make it a legal value for <fragment>
16 fun String.anchorEncoded(): String {
17     return URI(null, null, this).getRawFragment()
18 }
19