mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-05-28 17:16:29 +03:00
Minor fix in md2html. Better error report in XML loading.
This commit is contained in:
2
TODO.md
2
TODO.md
@@ -7,8 +7,6 @@
|
||||
|
||||
## UI Module
|
||||
|
||||
* Implement a better DropDownList (model/view approach)
|
||||
|
||||
* Implement TableView and TreeView properties.
|
||||
|
||||
* Add automatic font-fallback for lang scripts
|
||||
|
||||
@@ -443,6 +443,13 @@ void UISceneNode::setThreadPool( const std::shared_ptr<ThreadPool>& threadPool )
|
||||
mThreadPool = threadPool;
|
||||
}
|
||||
|
||||
static std::string getErrorContext( size_t offset, std::string_view content ) {
|
||||
static constexpr auto CONTEXT_LENGTH = 40;
|
||||
std::size_t left = std::max( 0ul, offset - CONTEXT_LENGTH );
|
||||
std::size_t right = std::min( content.size(), offset + 40 );
|
||||
return std::string{ content.substr( left, right - left ) };
|
||||
}
|
||||
|
||||
UIWidget* UISceneNode::loadLayoutFromFile( const std::string& layoutPath, Node* parent,
|
||||
const Uint32& marker ) {
|
||||
if ( FileSystem::fileExists( layoutPath ) ) {
|
||||
@@ -456,6 +463,9 @@ UIWidget* UISceneNode::loadLayoutFromFile( const std::string& layoutPath, Node*
|
||||
Log::error( "Couldn't load UI Layout: %s", layoutPath.c_str() );
|
||||
Log::error( "Error description: %s", result.description() );
|
||||
Log::error( "Error offset: %d", result.offset );
|
||||
std::string data;
|
||||
FileSystem::fileGet( layoutPath, data );
|
||||
Log::error( "Error context: %s", getErrorContext( result.offset, data ) );
|
||||
}
|
||||
} else if ( PackManager::instance()->isFallbackToPacksActive() ) {
|
||||
std::string path( layoutPath );
|
||||
@@ -493,6 +503,7 @@ UIWidget* UISceneNode::loadLayoutFromString( const char* layoutString, Node* par
|
||||
needsReplacements ? fixedLayout.c_str() : layoutString );
|
||||
Log::error( "Error description: %s", result.description() );
|
||||
Log::error( "Error offset: %d", result.offset );
|
||||
Log::error( "Error context: %s", getErrorContext( result.offset, layoutString ) );
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@@ -529,6 +540,10 @@ UIWidget* UISceneNode::loadLayoutFromMemory( const void* buffer, Int32 bufferSiz
|
||||
needsReplacements ? fixedLayout.c_str() : layoutString.data() );
|
||||
Log::error( "Error description: %s", result.description() );
|
||||
Log::error( "Error offset: %d", result.offset );
|
||||
Log::error( "Error context: %s",
|
||||
getErrorContext( result.offset,
|
||||
std::string_view{ static_cast<const char*>( buffer ),
|
||||
static_cast<std::size_t>( bufferSize ) } ) );
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@@ -551,14 +566,17 @@ UIWidget* UISceneNode::loadLayoutFromStream( IOStream& stream, Node* parent,
|
||||
std::string fixedLayout;
|
||||
bool needsReplacements =
|
||||
voidTagsRegex.matches( scopedBuffer.get(), 0, nullptr, scopedBuffer.length() );
|
||||
std::string_view contents;
|
||||
|
||||
if ( needsReplacements ) {
|
||||
fixedLayout = voidTagsRegex.gsub( layoutString.data(), "%1 />" );
|
||||
result = doc.load_buffer( fixedLayout.c_str(), fixedLayout.size(),
|
||||
pugi::parse_default | pugi::parse_ws_pcdata );
|
||||
contents = fixedLayout;
|
||||
} else {
|
||||
result = doc.load_buffer( scopedBuffer.get(), scopedBuffer.length(),
|
||||
pugi::parse_default | pugi::parse_ws_pcdata );
|
||||
contents = std::string_view( scopedBuffer.get(), scopedBuffer.length() );
|
||||
}
|
||||
|
||||
if ( result ) {
|
||||
@@ -568,6 +586,7 @@ UIWidget* UISceneNode::loadLayoutFromStream( IOStream& stream, Node* parent,
|
||||
needsReplacements ? fixedLayout.c_str() : layoutString.data() );
|
||||
Log::error( "Error description: %s", result.description() );
|
||||
Log::error( "Error offset: %d", result.offset );
|
||||
Log::error( "Error context: %s", getErrorContext( result.offset, contents ) );
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
||||
6
src/thirdparty/md4c/md4c-html.c
vendored
6
src/thirdparty/md4c/md4c-html.c
vendored
@@ -285,10 +285,10 @@ render_open_li_block(MD_HTML* r, const MD_BLOCK_LI_DETAIL* det)
|
||||
{
|
||||
if(det->is_task) {
|
||||
RENDER_VERBATIM(r, "<li class=\"task-list-item\">"
|
||||
"<input type=\"checkbox\" class=\"task-list-item-checkbox\" disabled");
|
||||
"<input type=\"checkbox\" class=\"task-list-item-checkbox\" disabled=\"true\"");
|
||||
if(det->task_mark == 'x' || det->task_mark == 'X')
|
||||
RENDER_VERBATIM(r, " checked");
|
||||
RENDER_VERBATIM(r, ">");
|
||||
RENDER_VERBATIM(r, " checked=\"true\"");
|
||||
RENDER_VERBATIM(r, " />");
|
||||
} else {
|
||||
RENDER_VERBATIM(r, "<li>");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user