added a new item content type: markdown

- emacs editor has an option to select markdown, now it has two planes: one for content editing and the other to show preview
- CodeMirror editor updated to 5.64.0
- to convert markdown to html we use showdown https://github.com/showdownjs/showdown (conversion is done on the client side)
This commit is contained in:
2021-11-26 21:49:21 +01:00
parent 119497bb01
commit 35cb54324f
8 changed files with 355 additions and 73 deletions

View File

@@ -481,9 +481,26 @@ void ItemContent::print_content(HtmlTextStream & out, const std::wstring & conte
}
void ItemContent::print_content(HtmlTextStream & str)
{
Config * config = get_config();
bool is_html_filter_on = (config && config->html_filter);
if( content_raw_type == ct_markdown )
{
print_content(str, content_parsed, content_parsed_type, is_html_filter_on);
}
else
{
print_content(str, content_raw, content_raw_type, is_html_filter_on);
}
}
void ItemContent::print_content(EzcEnv & env)
{
print_content(env.out, content_raw, content_raw_type, true); // IMPROVE ME get the 'true' from the config (config->html_filter)
print_content(env.out);
}
@@ -549,6 +566,45 @@ void ItemContent::group(morm::Wrapper & wrapper)
}
ItemContent::ContentType ItemContent::get_content_type_from_str(const wchar_t * str)
{
struct Type
{
const wchar_t * str;
ContentType type;
};
static Type types[] = {
{L"0", ct_text},
{L"1", ct_formatted_text},
{L"2", ct_html},
{L"3", ct_bbcode},
{L"4", ct_other},
{L"5", ct_markdown},
};
size_t len = sizeof(types) / sizeof(Type);
for(size_t i=0 ; i<len ; ++i)
{
if( pt::is_equal(types[i].str, str) )
{
return types[i].type;
}
}
return ct_other;
}
ItemContent::ContentType ItemContent::get_content_type_from_str(const std::wstring & str)
{
return get_content_type_from_str(str.c_str());
}
bool ItemContent::content_type_is(const std::wstring & type)
{
if( content_raw_type == ItemContent::ct_text && type == L"text" )
@@ -565,6 +621,9 @@ bool ItemContent::content_type_is(const std::wstring & type)
else
if( content_raw_type == ItemContent::ct_other && type == L"other" )
return true;
else
if( content_raw_type == ItemContent::ct_markdown && type == L"markdown" )
return true;
return false;
}