From dbf8c5a985f043d3fc5838378f8422a31db0bb67 Mon Sep 17 00:00:00 2001 From: mooction <389094993@qq.com> Date: Thu, 17 Jun 2021 21:40:33 +0800 Subject: [PATCH] generate preview.html at markdown path --- .gitignore | 3 ++- CMakeLists.txt | 14 ++--------- README.md | 7 +++--- inc/main.h | 2 +- md2html/src/parser.cpp | 3 ++- src/main.cpp | 40 ++++++++++++++++-------------- static/style.css | 54 +++++++++++++++++++++++------------------ static/wx.rc | Bin 5002 -> 4698 bytes 8 files changed, 63 insertions(+), 60 deletions(-) diff --git a/.gitignore b/.gitignore index a0bc3c9..fa2f502 100644 --- a/.gitignore +++ b/.gitignore @@ -68,8 +68,9 @@ Makefile cmake_install.cmake /**/CMakeFiles -# CMake generated +.vscode inc/config.h install_manifest.txt static/mynotepad.desktop mynotepad +preview.html diff --git a/CMakeLists.txt b/CMakeLists.txt index 53b0358..91a4781 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,16 +1,6 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.0) project(mynotepad) -if (COMMAND cmake_policy) - # Works around warnings libraries linked against that don't - # have absolute paths (e.g. -lpthreads) - cmake_policy(SET CMP0003 NEW) - - # Qt5 qt5_use_modules usage was causing "Policy CMP0043 is not set: - # Ignore COMPILE_DEFINITIONS_ properties." warnings - cmake_policy(SET CMP0043 NEW) -endif() - set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG") #add_definitions("$<$:-D_DEBUG>") @@ -39,7 +29,7 @@ endif() set(MYNOTEPAD_VERSION_MAJOR 1) set(MYNOTEPAD_VERSION_MINOR 0) -set(MYNOTEPAD_VERSION_PATCH 5) +set(MYNOTEPAD_VERSION_PATCH 6) message(STATUS "MyNotePad version: ${MYNOTEPAD_VERSION_MAJOR}." "${MYNOTEPAD_VERSION_MINOR}.${MYNOTEPAD_VERSION_PATCH}") diff --git a/README.md b/README.md index c5df545..211cac9 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# MyNotePad +# MyNotePad -![logo](static/MyNotePad.ico) +![logo](static/mynotepad.ico) ## Synopsis @@ -40,7 +40,7 @@ That's all. Run `mynotepad` to launch the program. 2. Extract them to the same folder and merge the `lib/vc14x_x64_dll` folder. For example, the directory tree is like: -``` +```text D:\ |----wxWidgets-3.1.3 |---------------include @@ -55,6 +55,7 @@ D:\ |-------------wxrc.exe ...... ``` + See [CMakeLists.txt](CMakeLists.txt) for more detail. 3. Then open CMake-GUI, click `Browse Source` and `Browse Build` to choose a correct place. diff --git a/inc/main.h b/inc/main.h index 4bdfe45..f2d9656 100644 --- a/inc/main.h +++ b/inc/main.h @@ -5,7 +5,7 @@ const char* MNP_APPNAME_C = "MyNotePad"; const wchar_t* MNP_APPNAME = L"MyNotePad"; const char* MNP_DOC_TITLE = " - MyNotePad"; const char* MNP_DOC_NOTITLE = "Untitled"; -const wchar_t* MNP_COPYRIGHT = L"\nCopyright(c) moooc.cc 2020"; +const wchar_t* MNP_COPYRIGHT = L"\nCopyright(c) moooc.cc"; int MNP_PADDING_LEFT = 16; // space for line number const int MNP_LINENUM_MARGIN_LEFT = 4; diff --git a/md2html/src/parser.cpp b/md2html/src/parser.cpp index 5156069..89d0080 100644 --- a/md2html/src/parser.cpp +++ b/md2html/src/parser.cpp @@ -1,4 +1,5 @@ -#include "lex_parse.h" +#include +#include "lex_parse.h" bool isTableItem(const MD_TOKEN token) { return token == MD_TOKEN::TABLE_COLUMN_LEFT || diff --git a/src/main.cpp b/src/main.cpp index 4885b12..82e7665 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -200,9 +200,7 @@ void MyFrame::loadSettings() article->SetMarginWidth(wxSTC_MARGINOPTION_NONE, FromDIP(MNP_PADDING_LEFT * 2)); #ifdef _WIN32 - confFilePath = wxStandardPaths::Get().GetExecutablePath(); - while (confFilePath.back() != '\\') - confFilePath.pop_back(); + confFilePath = wxPathOnly(wxStandardPaths::Get().GetExecutablePath()) + '\\'; #else confFilePath = wxStandardPaths::Get().GetUserDataDir(); confFilePath += '/'; @@ -384,17 +382,15 @@ void MyFrame::saveHTML(const std::string pathname) return; } - f << ""; + f << ""; #ifdef WIN32 - f << R"raw( - - - -)raw"; + f << "\n" + << "\n" + << "\n"; #else - f << "\n"; - f << "\n"; - f << "\n"; + f << "\n" + << "\n" + << "\n"; #endif f << R"raw(