Dave's Brain

Browse - Programming Tips - What's a nice way to make a heading in the Markdown language?

Date: 2015jan26
Language: Java


Q.  What's a nice way to make a heading in the Markdown language?

A.  I like this:

void putHeading(final String txt) { System.out.println(txt); System.out.println(txt.replaceAll(".","=")); }
void putSubHeading(final String txt) { System.out.println(txt); System.out.println(txt.replaceAll(".","-")); }
This works by turning every character in the heading to an equals (=). It uses the regular expression dot (.) which matches every character. The original string is not damaged. More info http://en.wikipedia.org/wiki/Markdown

Add a comment

Sign in to add a comment
Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.