### Markdown Blockquote Syntax Source: https://github.com/tim-gromeyer/html2md/blob/main/tests/blockquote.md Illustrates the basic syntax for creating Markdown blockquotes using the '>' character. Shows single-line and multi-line examples. ```markdown > This is a simple blockquote. > It can span multiple lines. ``` -------------------------------- ### Python Function Example Source: https://github.com/tim-gromeyer/html2md/blob/main/tests/blockquote.md A simple Python function that prints a greeting. This snippet is shown within a Markdown blockquote example. ```python def greet(name): print(f"Hello, {name}!") ``` -------------------------------- ### Install pyhtml2md using pip Source: https://github.com/tim-gromeyer/html2md/blob/main/python/README.md This snippet shows the command to install the pyhtml2md library using pip, the standard package installer for Python. Ensure you have Python and pip installed on your system. ```bash pip3 install pyhtml2md ``` -------------------------------- ### Java HelloWorld Class Example Source: https://github.com/tim-gromeyer/html2md/blob/main/tests/code.md This Java code defines a simple class with a main method that prints "Hello, World!" to the standard output. It serves as a basic entry point for Java applications and demonstrates console output. ```java public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, World!"); } } ``` -------------------------------- ### C++ html2md::Convert Function Example Source: https://github.com/tim-gromeyer/html2md/blob/main/README.md Provides a basic C++ example of using the `html2md::Convert` function to transform a simple HTML string into its markdown equivalent. This requires including the `html2md.h` header. ```cpp #include //... std::cout << html2md::Convert("

foo

"); // # foo ``` -------------------------------- ### Markdown Blockquote with List Source: https://github.com/tim-gromeyer/html2md/blob/main/tests/blockquote.md Demonstrates including a Markdown unordered list within a blockquote. ```markdown > Here's a list: > - Item 1 > - Item 2 > - Item 3 ``` -------------------------------- ### Python Factorial Function Example Source: https://github.com/tim-gromeyer/html2md/blob/main/tests/code.md This Python code defines a recursive function to calculate the factorial of a non-negative integer. It takes an integer as input and returns its factorial. The example demonstrates calling the function and printing the result. ```python def factorial(n): if n == 0: return 1 else: return n * factorial(n - 1) result = factorial(5) print("Factorial of 5:", result) ``` -------------------------------- ### Inline Code Example Source: https://github.com/tim-gromeyer/html2md/blob/main/tests/escaping.md An example of using backticks to display inline code in Markdown, showing a simple variable assignment. ```javascript var x = 5; ``` -------------------------------- ### Install html2md with CMake Source: https://github.com/tim-gromeyer/html2md/blob/main/docs/index.md Demonstrates how to find and link the html2md C++ library in your CMake project. This is the recommended method for integrating the library. ```cmake find_package(html2md) target_link_library(your_target PRIVATE html2md) ``` -------------------------------- ### Convert HTML to Markdown with pyhtml2md Source: https://github.com/tim-gromeyer/html2md/blob/main/python/README.md Demonstrates the basic usage of the pyhtml2md library. The `convert` function takes an HTML string as input and returns the equivalent Markdown string. This is the simplest way to get started with HTML to Markdown conversion. ```python import pyhtml2md markdown = pyhtml2md.convert("

Hello, world!

") print(markdown) ``` -------------------------------- ### JavaScript Fibonacci Function Example Source: https://github.com/tim-gromeyer/html2md/blob/main/tests/code.md This JavaScript code implements a recursive function to compute Fibonacci numbers. It accepts an integer 'n' and returns the nth Fibonacci number. The example shows how to call the function and log the output to the console. ```javascript function fibonacci(n) { if (n <= 1) { return n; } else { return fibonacci(n - 1) + fibonacci(n - 2); } } const fibResult = fibonacci(6); console.log(`Fibonacci of 6: ${fibResult}`); ``` -------------------------------- ### Markdown Blockquote with Link and Image Source: https://github.com/tim-gromeyer/html2md/blob/main/tests/blockquote.md Shows how to embed hyperlinks and images within a Markdown blockquote. ```markdown > Check out the [Markdown Guide](https://www.markdownguide.org/) for more information. > > ![Markdown Logo](https://markdown-here.com/img/icon256.png) ``` -------------------------------- ### Configure html2md Project with CMake Source: https://github.com/tim-gromeyer/html2md/blob/main/CMakeLists.txt This CMakeLists.txt file defines the build configuration for the html2md project. It sets project metadata, manages build options like executable, documentation, and Python bindings, and defines library and executable targets. It also handles installation rules and package configuration for the project. ```cmake cmake_minimum_required(VERSION 3.8...3.31) project(html2md VERSION 1.7.0 LANGUAGES CXX) set(PROJECT_HOMEPAGE_URL "https://tim-gromeyer.github.io/html2md/") set(html2md_HOMEPAGE_URL "${PROJECT_HOMEPAGE_URL}") set(PROJECT_DESCRIPTION "Transform your HTML into clean, easy-to-read markdown with html2md") set(html2md_DESCRIPTION "${PROJECT_DESCRIPTION}") # If build type not specified we use release if (NOT CMAKE_BUILD_TYPE) message(STATUS "Build type not specified. Release is used.") set(CMAKE_BUILD_TYPE "Release") endif() # Improve performance if(CMAKE_BUILD_TYPE STREQUAL "Release") string(REPLACE "-O2" "-O3" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") string(REPLACE "-O2" "-O3" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") endif() # Check if it was included via `add_subdirectory` get_directory_property(subproject PARENT_DIRECTORY) # Create HTML for webassembly if(EMSCRIPTEN) set(CMAKE_EXECUTABLE_SUFFIX ".html") endif() # Some options if (subproject) option(BUILD_EXE "Build a executable to convert html to markdown." OFF) else() option(BUILD_EXE "Build a executable to convert html to markdown." ON) endif() option(BUILD_DOC "Build documentation" OFF) option(BUILD_TEST "Build tests" OFF) option(PYTHON_BINDINGS "Build python bindings" OFF) set(SOURCES src/html2md.cpp src/table.cpp ) set(HEADERS include/html2md.h include/table.h ) if(PYTHON_BINDINGS) add_subdirectory(python/pybind11) pybind11_add_module(pyhtml2md python/bindings.cpp ${SOURCES} ${HEADER}) target_compile_features(pyhtml2md PUBLIC cxx_auto_type # auto keyword cxx_constexpr # constexpr support cxx_range_for # for (auto test : tests) cxx_std_11 # Require at least c++11 ) target_compile_definitions(pyhtml2md PRIVATE PYTHON_BINDINGS) target_include_directories(pyhtml2md PRIVATE include) if (SKBUILD) install(TARGETS pyhtml2md DESTINATION "${SKBUILD_PLATLIB_DIR}") endif() return() endif() add_library(html2md ${SOURCES}) set_target_properties(html2md PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR} PUBLIC_HEADER "${HEADERS}" ) target_include_directories(html2md PUBLIC $) target_compile_features(html2md PUBLIC cxx_std_11) # Require at least c++11 if ((subproject AND BUILD_SHARED_LIBS) OR BUILD_EXE) add_library(html2md-static STATIC ${HEADERS} ${SOURCES}) target_include_directories(html2md-static PUBLIC include) target_compile_features(html2md-static PUBLIC cxx_std_11) # Require at least c++11 endif() if(BUILD_EXE) add_executable(html2md-exe cli/main.cpp) target_link_libraries(html2md-exe html2md-static) set_target_properties(html2md-exe PROPERTIES OUTPUT_NAME "html2md") target_compile_definitions(html2md-exe PUBLIC VERSION="${PROJECT_VERSION}") target_compile_features(html2md-exe PUBLIC cxx_std_11) # Require at least c++11 endif() if(BUILD_TEST) add_subdirectory(tests) endif() if(BUILD_DOC) include(cmake/Doc.cmake) endif() # Don't install as a subproject if(subproject) return() endif() include(GNUInstallDirs) include(CMakePackageConfigHelpers) install(TARGETS html2md EXPORT html2mdTargets ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/html2md ) install(EXPORT html2mdTargets FILE html2mdTargets.cmake DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/html2md" ) configure_file(html2md.pc.in html2md.pc @ONLY) install(FILES ${CMAKE_BINARY_DIR}/html2md.pc DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig) write_basic_package_version_file( "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake" VERSION ${PROJECT_VERSION} COMPATIBILITY SameMajorVersion ) configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}Config.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/html2md NO_CHECK_REQUIRED_COMPONENTS_MACRO ) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake" DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/html2md ) if (BUILD_EXE) install(TARGETS html2md-exe DESTINATION bin) endif() include(cmake/Packaging.cmake) ``` -------------------------------- ### Markdown Blockquote with Inline Code Source: https://github.com/tim-gromeyer/html2md/blob/main/tests/blockquote.md Illustrates embedding inline code using backticks within a Markdown blockquote. ```markdown > And here's inline code: `print("Markdown is great!")` ``` -------------------------------- ### Markdown Nested Blockquotes Source: https://github.com/tim-gromeyer/html2md/blob/main/tests/blockquote.md Demonstrates how to create nested blockquotes in Markdown by increasing the number of '>' characters for each subsequent level. ```markdown > This is a level 1 blockquote. > > > This is a nested level 2 blockquote. > > > > > This is a nested level 3 blockquote. ``` -------------------------------- ### CMake Integration for html2md Source: https://github.com/tim-gromeyer/html2md/blob/main/README.md Demonstrates how to find and link the html2md library using CMake in a C++ project. This assumes html2md has been installed or is available in the CMake search path. ```cmake find_package(html2md) target_link_library(your_target PRIVATE html2md) ``` -------------------------------- ### Customize HTML to Markdown conversion with pyhtml2md Options Source: https://github.com/tim-gromeyer/html2md/blob/main/python/README.md This example illustrates advanced usage by customizing the conversion process using the `Options` class. You can control various aspects of the conversion, such as line splitting. It also shows how to use the `Converter` class directly and check its operational status. ```python import pyhtml2md options = pyhtml2md.Options() options.splitLines = False converter = pyhtml2md.Converter("

Hello Python!

", options) markdown = converter.convert() print(markdown) print(converter.ok()) ``` -------------------------------- ### Markdown Blockquote with Code Block Source: https://github.com/tim-gromeyer/html2md/blob/main/tests/blockquote.md Shows how to embed a fenced code block within a Markdown blockquote. The code block itself is indented with '>' characters. ```markdown > Here's an example of a code block: > > ``` > def greet(name): > print(f"Hello, {name}!") > ``` ``` -------------------------------- ### CMake Build Configuration for html2md Source: https://github.com/tim-gromeyer/html2md/blob/main/tests/CMakeLists.txt This CMakeLists.txt file configures the build process for the html2md project. It defines the project name, handles Git submodules for md4c, creates static libraries (md4c-html), builds executables (test-exe, benchmark-exe), links them with necessary libraries, sets compile features to C++17, and defines custom targets for running tests and benchmarks. ```cmake project(tests LANGUAGES C CXX) if (NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/md4c/src/) include(FindGit) if(NOT GIT_FOUND) message(WARNING "git not found. Please download md4c manually or disable tests.") return() endif() get_directory_property(dir PARENT_DIRECTORY) execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --depth=1 WORKING_DIRECTORY ${dir}) endif() set(MD4C_FILES md4c/src/entity.c md4c/src/entity.h md4c/src/md4c-html.c md4c/src/md4c-html.h md4c/src/md4c.c md4c/src/md4c.h ) add_library(md4c-html STATIC ${MD4C_FILES}) target_include_directories(md4c-html PUBLIC md4c/src) # Existing test executable add_executable(test-exe main.cpp) target_link_libraries(test-exe md4c-html html2md-static) target_compile_definitions(test-exe PUBLIC DIR="${CMAKE_CURRENT_LIST_DIR}") set_target_properties(test-exe PROPERTIES OUTPUT_NAME "tests") target_compile_features(test-exe PUBLIC cxx_std_17) # New benchmark executable add_executable(benchmark-exe benchmark.cpp) target_link_libraries(benchmark-exe md4c-html html2md-static) target_compile_definitions(benchmark-exe PUBLIC DIR="${CMAKE_CURRENT_LIST_DIR}") set_target_properties(benchmark-exe PROPERTIES OUTPUT_NAME "benchmarks") target_compile_features(benchmark-exe PUBLIC cxx_std_17) if (CMAKE_VERSION VERSION_LESS 3.11.0) return() endif() add_custom_target(test COMMAND $ COMMENT Running tests.. DEPENDS test-exe ) add_custom_target(benchmark COMMAND $ COMMENT Running benchmarks.. DEPENDS benchmark-exe ) ``` -------------------------------- ### Create html2md Converter Instance Source: https://github.com/tim-gromeyer/html2md/wiki/Examples Demonstrates the process of creating an instance of the html2md::Converter class to perform HTML to Markdown conversion. This method involves initializing the converter with an HTML string and then calling its Convert method. ```c++ #include "html2md.hpp" #include int main() { std::string html = "

html2md

"; html2md::Converter instance(html); std::string md = instance.Convert(); // # html2md\n return 0; } ``` -------------------------------- ### Use html2md Static Convert Function Source: https://github.com/tim-gromeyer/html2md/wiki/Examples Illustrates the usage of the static html2md::Convert function for a direct HTML to Markdown conversion. This approach offers a simpler way to convert HTML strings without explicitly creating a Converter object. ```c++ #include //... std::cout << html2md::Convert(html); ``` -------------------------------- ### Convert HTML to Markdown in C++ Source: https://github.com/tim-gromeyer/html2md/blob/main/docs/index.md Shows the basic usage of the html2md::Convert function to transform an HTML string into its Markdown equivalent. This function is the core of the library's functionality. ```cpp #include //... std::cout << html2md::Convert("

foo

"); // # foo ``` -------------------------------- ### Initialize Doxygen Awesome Features Source: https://github.com/tim-gromeyer/html2md/blob/main/docs/doxygen-awesome-css/doxygen-custom/header.html This JavaScript code initializes various Doxygen Awesome features upon document ready. It hides specific table rows in the directory based on icon classes and hides all elements marked as 'hidable-toc'. ```javascript $( document ).ready(function() { const directory = document.querySelector('.directory'); if (directory) { const table = directory.querySelector('table'); for (const row of table.rows) { if (row.querySelector('.iconfclosed') && !row.querySelector('.arrow')) { row.remove(); } } } const toc = document.querySelectorAll('.hidable-toc'); for (var i = 0; i < toc.length; i++) { toc[i].hidden = true; } }); ``` -------------------------------- ### Escape Asterisk in Markdown Source: https://github.com/tim-gromeyer/html2md/blob/main/tests/escaping.md Shows how to escape an asterisk (*) in Markdown using a backslash to display it literally instead of as a list item or emphasis marker. ```markdown \* ``` -------------------------------- ### Escape Backtick in Markdown Source: https://github.com/tim-gromeyer/html2md/blob/main/tests/escaping.md Demonstrates escaping a backtick (`) in Markdown using a backslash. This is useful for displaying literal backticks, often used for inline code. ```markdown \` ``` -------------------------------- ### Escape Backslash in Markdown Source: https://github.com/tim-gromeyer/html2md/blob/main/tests/escaping.md Explains how to display a literal backslash (\) in Markdown by escaping it with another backslash. This is necessary when the backslash itself is part of the content. ```markdown \\ ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.