// Path: readline/src/main/java/org/aesh/extensions/manual/parser/ManParserUtil.java
// public class ManParserUtil {
// 
//     private static Pattern boldRegex = Pattern.compile("(\\*[^']+\\*)|(\'\\S+\')|(::$)");
// 
//     public static String convertStringToAnsi(String line) {
//         StringBuilder builder = new StringBuilder();
//         Matcher matcher = boldRegex.matcher(line);
//         while(matcher.find()) {
//             if(matcher.group(1) != null) {
//                 builder.append(line.substring(0,matcher.start(1)))
//                         .append(ANSI.BOLD)
//                         .append(line.substring(matcher.start(1)+1,matcher.end(1)-1))
//                         .append(ANSI.DEFAULT_TEXT);
//                         //.append(line.substring(matcher.end(1)));
//                 line = line.substring(matcher.end(1));
//                 matcher = boldRegex.matcher(line);
//             }
//             else if(matcher.group(2) != null) {
//                 builder.append(line.substring(0,matcher.start(2)))
//                         .append(ANSI.UNDERLINE)
//                         .append(line.substring(matcher.start(2)+1,matcher.end(2)-1))
//                         .append(ANSI.DEFAULT_TEXT);
//                         //.append(line.substring(matcher.end(2)));
//                 line = line.substring(matcher.end(2));
//                 matcher = boldRegex.matcher(line);
//             }
//             else if(matcher.group(3) != null) {
//                 builder.append(line.substring(0,matcher.start(3)));
//                 line = line.substring(matcher.end(3));
//                 matcher = boldRegex.matcher(line);
//             }
//         }
//         if(line.length() > 0)
//             builder.append(line);
// 
//         if(builder.length() < 1)
//             return line;
//         else
//             return builder.toString();
//     }
// }


import org.aesh.extensions.manual.parser.ManParserUtil;
import org.aesh.terminal.utils.ANSI;
import org.junit.Test;
import static org.junit.Assert.*;
/*
 * JBoss, Home of Professional Open Source
 * Copyright 2014 Red Hat Inc. and/or its affiliates and other contributors
 * as indicated by the @authors tag. All rights reserved.
 * See the copyright.txt in the distribution for a
 * full listing of individual contributors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * http://www.apache.org/licenses/LICENSE-2.0
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.aesh.extensions.man;



/**
 * @author <a href="mailto:stale.pedersen@jboss.org">Ståle W. Pedersen</a>
 */
public class ManParserUtilTester {

    @Test
    public void testBoldParser() {
        assertEquals(ANSI.BOLD+"foo"+ANSI.DEFAULT_TEXT,
                ManParserUtil.convertStringToAnsi("*foo*"));

        assertEquals("12"+ANSI.BOLD+"foo"+ANSI.DEFAULT_TEXT,
                ManParserUtil.convertStringToAnsi("12*foo*"));

        assertEquals("12"+ANSI.BOLD+"foo"+ANSI.DEFAULT_TEXT+"34",
                ManParserUtil.convertStringToAnsi("12*foo*34"));

        assertEquals("12"+ANSI.UNDERLINE+"foo"+ANSI.DEFAULT_TEXT+"34",
                ManParserUtil.convertStringToAnsi("12'foo'34"));

        assertEquals("Define or delete document attribute. "+
// Path: readline/src/main/java/org/aesh/extensions/manual/parser/ManParserUtil.java
// public class ManParserUtil {
// 
//     private static Pattern boldRegex = Pattern.compile("(\\*[^']+\\*)|(\'\\S+\')|(::$)");
// 
//     public static String convertStringToAnsi(String line) {
//         StringBuilder builder = new StringBuilder();
//         Matcher matcher = boldRegex.matcher(line);
//         while(matcher.find()) {
//             if(matcher.group(1) != null) {
//                 builder.append(line.substring(0,matcher.start(1)))
//                         .append(ANSI.BOLD)
//                         .append(line.substring(matcher.start(1)+1,matcher.end(1)-1))
//                         .append(ANSI.DEFAULT_TEXT);
//                         //.append(line.substring(matcher.end(1)));
//                 line = line.substring(matcher.end(1));
//                 matcher = boldRegex.matcher(line);
//             }
//             else if(matcher.group(2) != null) {
//                 builder.append(line.substring(0,matcher.start(2)))
//                         .append(ANSI.UNDERLINE)
//                         .append(line.substring(matcher.start(2)+1,matcher.end(2)-1))
//                         .append(ANSI.DEFAULT_TEXT);
//                         //.append(line.substring(matcher.end(2)));
//                 line = line.substring(matcher.end(2));
//                 matcher = boldRegex.matcher(line);
//             }
//             else if(matcher.group(3) != null) {
//                 builder.append(line.substring(0,matcher.start(3)));
//                 line = line.substring(matcher.end(3));
//                 matcher = boldRegex.matcher(line);
//             }
//         }
//         if(line.length() > 0)
//             builder.append(line);
// 
//         if(builder.length() < 1)
//             return line;
//         else
//             return builder.toString();
//     }
// }


// Path: readline/src/test/java/org.aesh.extensions/man/ManParserUtilTester.java
import org.aesh.extensions.manual.parser.ManParserUtil;
import org.aesh.terminal.utils.ANSI;
import org.junit.Test;
import static org.junit.Assert.*;

/*
 * JBoss, Home of Professional Open Source
 * Copyright 2014 Red Hat Inc. and/or its affiliates and other contributors
 * as indicated by the @authors tag. All rights reserved.
 * See the copyright.txt in the distribution for a
 * full listing of individual contributors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * http://www.apache.org/licenses/LICENSE-2.0
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.aesh.extensions.man;



/**
 * @author <a href="mailto:stale.pedersen@jboss.org">Ståle W. Pedersen</a>
 */
public class ManParserUtilTester {

    @Test
    public void testBoldParser() {
        assertEquals(ANSI.BOLD+"foo"+ANSI.DEFAULT_TEXT,
                ManParserUtil.convertStringToAnsi("*foo*"));

        assertEquals("12"+ANSI.BOLD+"foo"+ANSI.DEFAULT_TEXT,
                ManParserUtil.convertStringToAnsi("12*foo*"));

        assertEquals("12"+ANSI.BOLD+"foo"+ANSI.DEFAULT_TEXT+"34",
                ManParserUtil.convertStringToAnsi("12*foo*34"));

        assertEquals("12"+ANSI.UNDERLINE+"foo"+ANSI.DEFAULT_TEXT+"34",
                ManParserUtil.convertStringToAnsi("12'foo'34"));

        assertEquals("Define or delete document attribute. "+
                ANSI.UNDERLINE+