ParserMarkdown: Begin new markdown parser
Tá an tiomantas seo le fáil i:
		
							
								
								
									
										26
									
								
								parsermarkdown.cpp
									
									
									
									
									
										Comhad gnáth
									
								
							
							
						
						
									
										26
									
								
								parsermarkdown.cpp
									
									
									
									
									
										Comhad gnáth
									
								
							| @@ -0,0 +1,26 @@ | |||||||
|  | #include "parsermarkdown.h" | ||||||
|  |  | ||||||
|  | ParserMarkdown::ParserMarkdown() | ||||||
|  | { | ||||||
|  |  | ||||||
|  | } | ||||||
|  |  | ||||||
|  | std::vector<Headline> ParserMarkdown::extractHeadlines(std::string content) const | ||||||
|  | { | ||||||
|  | 	std::vector<Headline> result; | ||||||
|  | 	utils::regex_callback_extractor(std::regex(R"((#{1,6}) (.*))"), content, [&](std::smatch &smatch) { | ||||||
|  | 		Headline h; | ||||||
|  | 		h.level = smatch.str(1).length(); | ||||||
|  | 		h.title = smatch.str(2); | ||||||
|  | 		result.push_back(h); | ||||||
|  | 	}); | ||||||
|  | 	return result; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | std::string ParserMarkdown::parse(const PageDao &pagedao, UrlProvider &provider, std::string content) const | ||||||
|  | { | ||||||
|  | 	std::shared_ptr<maddy::ParserConfig> config = std::make_shared<maddy::ParserConfig>(); | ||||||
|  | 	auto maddy = std::make_shared<maddy::Parser>(config); | ||||||
|  | 	std::stringstream s { content }; | ||||||
|  | 	return maddy->Parse(s); | ||||||
|  | } | ||||||
							
								
								
									
										16
									
								
								parsermarkdown.h
									
									
									
									
									
										Comhad gnáth
									
								
							
							
						
						
									
										16
									
								
								parsermarkdown.h
									
									
									
									
									
										Comhad gnáth
									
								
							| @@ -0,0 +1,16 @@ | |||||||
|  | #ifndef PARSER_MARKDOWN_H | ||||||
|  | #define PARSER_MARKDOWN_H | ||||||
|  |  | ||||||
|  | #include "parser.h" | ||||||
|  | #include "maddy/parser.h" | ||||||
|  | class ParserMarkdown : public Parser | ||||||
|  | { | ||||||
|  | public: | ||||||
|  | 	ParserMarkdown(); | ||||||
|  |  | ||||||
|  | public: | ||||||
|  | 	std::vector<Headline> extractHeadlines(std::string content) const; | ||||||
|  | 	std::string parse(const PageDao &pagedao, UrlProvider &provider, std::string content) const; | ||||||
|  | }; | ||||||
|  |  | ||||||
|  | #endif // PARSER_MARKDOWN_H | ||||||
		Tagairt in Eagrán Nua
	
	Cuir bac ar úsáideoir