Wexus2 0.20
|
00001 00002 /* 00003 * Copyright (c) 2011 Aleksander B. Demko 00004 * This source code is distributed under the MIT license. 00005 * See the accompanying file LICENSE.MIT.txt for details. 00006 */ 00007 00008 #ifndef __INCLUDED_WEXUS_MARKDOWN_H__ 00009 #define __INCLUDED_WEXUS_MARKDOWN_H__ 00010 00011 #include <QByteArray> 00012 00013 #include <wexus/HTMLString.h> 00014 00015 namespace wexus 00016 { 00017 class MarkDown; 00018 } 00019 00020 /** 00021 * A Markdown like formatter. 00022 * 00023 * This needs work. 00024 * Currently supports: 00025 * 00026 * *bold* _italics_ =title= 00027 * [wikilink] [[reallink]] 00028 * *list item 00029 * 00030 * @author Aleksander Demko 00031 */ 00032 class wexus::MarkDown 00033 { 00034 public: 00035 enum { 00036 Format_Lists = 1, // numeric and non-numeric lists 00037 Format_Quotes = 2, // post quoting and code quote 00038 00039 Format_Links = 4, // normal and wiki links 00040 00041 Format_Titles = 8, // headings/titles 00042 00043 Format_None = 0, // html encoding and paragraph coding is ALWAYS ON 00044 Format_Basic = Format_Lists|Format_Quotes, 00045 Format_BlogPost = 0x7F, // ALL flags 00046 Format_Comment = Format_Basic, 00047 Format_WikiPage = Format_BlogPost, // ALL flags 00048 }; 00049 00050 /** 00051 * Format the given markdown code as HTML markup. 00052 * 00053 * As flags, either choose Format_Basic, Format_Post Format_Wiki, or if you 00054 * want total controler, the indiviual type flags. 00055 * 00056 * @author Aleksander Demko 00057 */ 00058 static QByteArray process(const QByteArray &markdown, int flags = Format_Basic); 00059 00060 /** 00061 * Returns the title, already rendered as an HTML string from the givenmarkdown code. 00062 * 00063 * @author Aleksander Demko 00064 */ 00065 static HTMLString title(const QByteArray &markdown); 00066 00067 /** 00068 * Returns the first paragraph, already rendered as an HTML string from the givenmarkdown code. 00069 * 00070 * @author Aleksander Demko 00071 */ 00072 static HTMLString firstPara(const QByteArray &markdown); 00073 }; 00074 00075 #endif 00076