1 package org.simantics.scl.compiler.markdown.nodes;
3 import org.simantics.scl.compiler.markdown.inlines.Entities;
4 import org.simantics.scl.compiler.markdown.inlines.Subject;
6 public class Reference {
7 public final String label;
8 public final String url;
9 public final String title;
11 public Reference(String label, String url, String title) {
17 public static String normalizeLabel(String label) {
18 StringBuilder b = new StringBuilder();
20 while(pos < label.length() && Character.isWhitespace(label.charAt(pos)))
23 while(pos < label.length()) {
24 char c = label.charAt(pos++);
25 if(Character.isWhitespace(c))
30 b.append(Character.toLowerCase(c));
36 public static String cleanUrl(String input) {
37 StringBuilder b = new StringBuilder();
39 while(pos < input.length()) {
40 char c = input.charAt(pos++);
41 if(c == '\\' && pos < input.length()) {
42 c = input.charAt(pos);
43 if(Subject.getCharType(c) == 2) {
51 int maxPos = Math.min(input.length(), pos+Entities.MAX_ENTITY_LENGTH+1);
58 c = input.charAt(p++);
60 String entity = input.substring(pos, p-1);
61 String character = Entities.ENTITY_MAP.get(entity);
62 if(character == null) {
80 public static String cleanTitle(String input) {
81 return cleanUrl(input);