Added back md parsing support for the rest of the WebNodes that used to support it.

This commit is contained in:
Relintai 2022-07-23 02:44:55 +02:00
parent 0f39a8f6ac
commit 05fd41c5ac
4 changed files with 21 additions and 8 deletions

View File

@ -5,6 +5,7 @@
#include "core/os/file_access.h"
#include "../../html/html_builder.h"
#include "../../html/markdown_renderer.h"
#include "../../html/paginator.h"
#include "../../http/http_server_enums.h"
#include "../../http/web_permission.h"
@ -141,6 +142,9 @@ void ListWebPage::load() {
files.sort();
Ref<MarkdownRenderer> r;
r.instance();
Vector<String> list_entries;
for (int i = 0; i < files.size(); ++i) {
@ -151,7 +155,9 @@ void ListWebPage::load() {
memdelete(f);
//Utils::markdown_to_html(&fd);
if (files[i].get_extension() == "md") {
fd = r->render_to_html(fd);
}
list_entries.push_back(fd);
}

View File

@ -5,6 +5,7 @@
#include "core/project_settings.h"
#include "../../file_cache.h"
#include "../../html/markdown_renderer.h"
#include "../../html/paginator.h"
#include "../../http/http_server_enums.h"
#include "../../http/web_permission.h"
@ -116,6 +117,9 @@ void PagedArticleWebPage::load() {
files.sort();
Ref<MarkdownRenderer> r;
r.instance();
for (int i = 0; i < files.size(); ++i) {
String file_path = _articles_folder_abs;
file_path += files[i];
@ -130,7 +134,9 @@ void PagedArticleWebPage::load() {
f->close();
memdelete(f);
//Utils::markdown_to_html(&fd);
if (files[i].get_extension() == "md") {
fd = r->render_to_html(fd);
}
if (files[i].get_file().get_basename() == "summary") {
summary = fd;

View File

@ -65,9 +65,6 @@ void StaticWebPage::load_and_process_file(const String &path) {
_data = "";
}
//todo prcess
//could support bbcode easily
//should probably support md -> I should probably write a parser
if (path.get_extension() == "md") {
Ref<MarkdownRenderer> r;
r.instance();

View File

@ -1,5 +1,6 @@
#include "static_web_page_folder_files.h"
#include "../../html/markdown_renderer.h"
#include "core/os/dir_access.h"
#include "core/os/file_access.h"
@ -27,6 +28,9 @@ void StaticWebPageFolderFiles::load() {
ERR_FAIL_COND_MSG(!da, "Dir Path = " + _dir_path);
if (da) {
Ref<MarkdownRenderer> r;
r.instance();
da->list_dir_begin();
while (true) {
@ -47,9 +51,9 @@ void StaticWebPageFolderFiles::load() {
f->close();
memdelete(f);
//if (process_if_can && d->current_get_extension() == "md") {
// Utils::markdown_to_html(&str);
//}
if (_process_if_can && (fn.get_extension()) == "md") {
str = r->render_to_html(str);
}
append_data(str);
}