src/main/java/com/ruleoftech/markdown/page/generator/plugin/MdPageGeneratorMojo.java
private String getTitle(List<String> raw) {
        if (raw == null) {
            return defaultTitle;
        }
        String previousLine = "";
        for (String line : raw) {
            line = line.trim();
            if (line.startsWith("#")) {
                line = line.replace("#", "");
                return line;
            }
            //Checking for Setext style headers.
            //Line is considered a match if it passes:
            //Starts with either = or -
            //It has the same number of characters as the previous line
            //It only contains - or = and nothing else.
            //
            //If there is a match we consider the previous line to be the title.
            if ((line.startsWith("=") && StringUtils.countMatches(line, "=") == previousLine.length() && line.matches("^=+$"))
                    || (line.startsWith("-") && StringUtils.countMatches(line, "-") == previousLine.length() && line.matches("^-+$"))) {
                return previousLine;
            }
            previousLine = line;
        }
        return defaultTitle;
    }
private String getTitle(List<String> raw) {
        if (raw == null) {
            return defaultTitle;
        }
        String previousLine = "";
        for (String line : raw) {
            line = line.trim();
            if (line.startsWith("#")) {
                line = line.replace("#", "");
                return line;
            }
            //Checking for Setext style headers.
            //Line is considered a match if it passes:
            //Starts with either = or -
            //It has the same number of characters as the previous line
            //It only contains - or = and nothing else.
            //
            //If there is a match we consider the previous line to be the title.
            if ((line.startsWith("=") && StringUtils.countMatches(line, "=") == previousLine.length() && line.matches("^=+$"))
                    || (line.startsWith("-") && StringUtils.countMatches(line, "-") == previousLine.length() && line.matches("^-+$"))) {
                return previousLine;
            }
            previousLine = line;
        }
        return defaultTitle;
    }
private String getTitle ( List < String > raw ) { if ( raw == null ) { return defaultTitle ; } String previousLine = "" ; for ( String line : raw ) { line = line . trim ( ) ; if ( line . startsWith ( "#" ) ) { line = line . replace ( "#" , "" ) ; return line ; } //Checking for Setext style headers. //Line is considered a match if it passes: //Starts with either = or - //It has the same number of characters as the previous line //It only contains - or = and nothing else. // //If there is a match we consider the previous line to be the title. if ( ( line . startsWith ( "=" ) && StringUtils . countMatches ( line , "=" ) == previousLine . length ( ) && line . matches ( "^=+$" ) ) || ( line . startsWith ( "-" ) && StringUtils . countMatches ( line , "-" ) == previousLine . length ( ) && line . matches ( "^-+$" ) ) ) { return previousLine ; } previousLine = line ; } return defaultTitle ; }
Get the first h1 for the title.

@param raw The markdown as a list of strings
@return The first # h1 in the Markdown file
Get the first h1 for the title .