Compiled
parent
0a390ad2a3
commit
120071b3cc
|
@ -3,5 +3,5 @@ cmake_minimum_required (VERSION 3.5)
|
||||||
project (browser LANGUAGES C CXX)
|
project (browser LANGUAGES C CXX)
|
||||||
|
|
||||||
add_subdirectory (lib/commonmarker/src)
|
add_subdirectory (lib/commonmarker/src)
|
||||||
# add_subdirectory (lib/commonmarker/extensions)
|
add_subdirectory (lib/commonmarker/extensions)
|
||||||
add_subdirectory (src)
|
add_subdirectory (src)
|
|
@ -61,12 +61,65 @@ include_directories(
|
||||||
${PROJECT_BINARY_DIR}/extensions
|
${PROJECT_BINARY_DIR}/extensions
|
||||||
)
|
)
|
||||||
|
|
||||||
configure_file (
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmark-gfm_version.h.in
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/cmark-gfm_version.h)
|
||||||
|
|
||||||
|
include (GenerateExportHeader)
|
||||||
|
|
||||||
|
# Disable the PUBLIC declarations when compiling the executable:
|
||||||
|
set_target_properties(${PROGRAM} PROPERTIES
|
||||||
|
COMPILE_FLAGS "-DCMARK_STATIC_DEFINE -DCMARKEXTENSIONS_STATIC_DEFINE")
|
||||||
|
|
||||||
|
# Check integrity of node structure when compiled as debug:
|
||||||
|
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DCMARK_DEBUG_NODES -DDEBUG")
|
||||||
|
set(CMAKE_LINKER_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG}")
|
||||||
|
|
||||||
|
set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE} -pg")
|
||||||
|
set(CMAKE_LINKER_PROFILE "${CMAKE_LINKER_FLAGS_RELEASE} -pg")
|
||||||
|
|
||||||
|
# Feature tests
|
||||||
|
include(CheckIncludeFile)
|
||||||
|
include(CheckCSourceCompiles)
|
||||||
|
include(CheckCSourceRuns)
|
||||||
|
include(CheckSymbolExists)
|
||||||
|
CHECK_INCLUDE_FILE(stdbool.h HAVE_STDBOOL_H)
|
||||||
|
CHECK_C_SOURCE_COMPILES(
|
||||||
|
"int main() { __builtin_expect(0,0); return 0; }"
|
||||||
|
HAVE___BUILTIN_EXPECT)
|
||||||
|
CHECK_C_SOURCE_COMPILES("
|
||||||
|
int f(void) __attribute__ (());
|
||||||
|
int main() { return 0; }
|
||||||
|
" HAVE___ATTRIBUTE__)
|
||||||
|
|
||||||
|
configure_file(
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/config.h.in
|
${CMAKE_CURRENT_SOURCE_DIR}/config.h.in
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/config.h)
|
${CMAKE_CURRENT_BINARY_DIR}/config.h)
|
||||||
|
|
||||||
|
# Always compile with warnings
|
||||||
|
if(MSVC)
|
||||||
|
# Force to always compile with W4
|
||||||
|
if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
|
||||||
|
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
|
||||||
|
else()
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4")
|
||||||
|
endif()
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX /wd4706 /wd4204 /wd4221 /wd4100 /D_CRT_SECURE_NO_WARNINGS")
|
||||||
|
elseif(CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wno-unused-parameter -std=c99 -pedantic")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Compile as C++ under MSVC older than 12.0
|
||||||
|
if(MSVC AND MSVC_VERSION LESS 1800)
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /TP")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(CMAKE_BUILD_TYPE STREQUAL "Ubsan")
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=undefined")
|
||||||
|
endif()
|
||||||
|
|
||||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmark-gfm_version.h.in
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmark-gfm_version.h.in
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/cmark-gfm_version.h)
|
${CMAKE_CURRENT_BINARY_DIR}/cmark-gfm_version.h)
|
||||||
|
|
||||||
add_library (CommonMarker ${LIBRARY_SOURCES})
|
add_library (CommonMarker ${LIBRARY_SOURCES})
|
||||||
target_include_directories(CommonMarker PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
target_include_directories(CommonMarker PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
|
||||||
|
|
|
@ -42,5 +42,5 @@ else()
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_link_libraries (browser LINK_PUBLIC CommonMarker)
|
target_link_libraries (browser LINK_PUBLIC CommonMarker CommonMarkerExtensions)
|
||||||
target_link_libraries (browser PRIVATE Qt5::Widgets)
|
target_link_libraries (browser PRIVATE Qt5::Widgets)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "markdown-render.h"
|
#include "markdown-render.h"
|
||||||
|
|
||||||
// #include <cmark-gfm-core-extensions.h>
|
#include <cmark-gfm-core-extensions.h>
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
|
@ -35,11 +35,9 @@ MarkdownRender::MarkdownRender()
|
||||||
* This is a function that will make enabling extensions easier
|
* This is a function that will make enabling extensions easier
|
||||||
*/
|
*/
|
||||||
void MarkdownRender::addMarkdownExtension(cmark_parser *parser, char *extName) {
|
void MarkdownRender::addMarkdownExtension(cmark_parser *parser, char *extName) {
|
||||||
/*
|
|
||||||
cmark_syntax_extension *ext = cmark_find_syntax_extension(extName);
|
cmark_syntax_extension *ext = cmark_find_syntax_extension(extName);
|
||||||
if ( ext )
|
if ( ext )
|
||||||
cmark_parser_attach_syntax_extension(parser, ext);
|
cmark_parser_attach_syntax_extension(parser, ext);
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// A function to convert HTML to markdown
|
// A function to convert HTML to markdown
|
||||||
|
@ -53,8 +51,8 @@ char * MarkdownRender::to_html(const char *markdown_string)
|
||||||
cmark_parser *parser = cmark_parser_new(options);
|
cmark_parser *parser = cmark_parser_new(options);
|
||||||
|
|
||||||
// Add extensions
|
// Add extensions
|
||||||
//addMarkdownExtension(parser, "strikethrough");
|
addMarkdownExtension(parser, "strikethrough");
|
||||||
//addMarkdownExtension(parser, "table");
|
addMarkdownExtension(parser, "table");
|
||||||
|
|
||||||
// cmark AST
|
// cmark AST
|
||||||
cmark_node *doc;
|
cmark_node *doc;
|
||||||
|
|
Loading…
Reference in New Issue