Android Open Source - tldr-viewer Md File Content Parser






From Project

Back to project page tldr-viewer.

License

The source code is released under:

MIT License

If you think the Android project tldr-viewer listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/**
 * /*  w  w  w  .j  a v a2s.c  o  m*/
 */
package de.gianasista.tldr_viewer.util;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

import android.content.res.AssetManager;
import android.text.Html;
import android.text.Spanned;

/**
 * @author vera
 *
 */
public class MdFileContentParser 
{
  public String parseLine(String line)
  {
    String parsedLine = "";
    if(line.length()<1)
      parsedLine = line;
    else 
      {
      String trimmedLine = line.substring(1).trim();
      
      if(line.startsWith("#"))
        parsedLine = "<b><font color='#0000FF'>"+trimmedLine+"</font></b>";
      else if(line.startsWith(">"))
        parsedLine = "<i>"+trimmedLine+"</i>";
      else if(line.startsWith("-"))
        parsedLine = trimmedLine;
      else if(line.startsWith("`"))
        parsedLine = "<tt>"+trimmedLine+"</tt>";
      }
    
    return parsedLine.concat("<br/>");
  }
}




Java Source Code List

de.gianasista.tldr_viewer.CommandContentActivity.java
de.gianasista.tldr_viewer.CommandListActivity.java
de.gianasista.tldr_viewer.util.CommandContentDelegate.java
de.gianasista.tldr_viewer.util.MdFileContentParser.java
de.gianasista.tldr_viewer.util.TldrContentProvider.java