1 package org.simantics.scl.compiler.internal.parsing.documentation;
\r
3 public class Preformatted extends DocumentationElement {
\r
7 public Preformatted(String content) {
\r
8 lines = content.split("\n");
\r
9 int indentation = Integer.MAX_VALUE;
\r
10 for(int i=0;i<lines.length;++i) {
\r
11 String line = lines[i];
\r
12 for(int j=line.length();j>0;--j) {
\r
13 char c = line.charAt(j-1);
\r
14 if(c != '\n' && c != '\r' && c != ' ') {
\r
15 line = line.substring(0, j);
\r
21 for(String line : lines) {
\r
22 for(int i=1;i<line.length()&&i<indentation;++i)
\r
23 if(line.charAt(i) != ' ') {
\r
28 for(int i=0;i<lines.length;++i) {
\r
29 String line = lines[i];
\r
30 lines[i] = indentation > line.length() ? "" : line.substring(indentation);
\r
35 public void toHtml(HtmlUnparsingContext context) {
\r
37 StringBuilder b = context.getStringBuilder();
\r
38 b.append("<pre>\n");
\r
39 for(String line : lines)
\r
40 b.append(line).append('\n');
\r
41 b.append("</pre>\n");
\r