diff --git a/CMakeLists.txt b/CMakeLists.txt index 5595b22..f51d94c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,12 +18,12 @@ cmake_minimum_required(VERSION 2.9) set (My_Project_Title "libMultiMarkdown") set (My_Project_Description "Lightweight markup processor to produce HTML, LaTeX, and more.") set (My_Project_Author "Fletcher T. Penney") -set (My_Project_Revised_Date "2020-10-28") +set (My_Project_Revised_Date "2023-06-10") set (My_Project_Version_Major 6) -set (My_Project_Version_Minor 6) +set (My_Project_Version_Minor 7) set (My_Project_Version_Patch 0) -set (My_Project_Copyright_Date "2016 - 2020") +set (My_Project_Copyright_Date "2016 - 2023") set (My_Project_Identifier "net.fletcherpenney.multimarkdown") diff --git a/DevelopmentNotes/DevelopmentNotes.epub b/DevelopmentNotes/DevelopmentNotes.epub index f2356f9..125db92 100644 Binary files a/DevelopmentNotes/DevelopmentNotes.epub and b/DevelopmentNotes/DevelopmentNotes.epub differ diff --git a/DevelopmentNotes/DevelopmentNotes.fodt b/DevelopmentNotes/DevelopmentNotes.fodt index 56a783f..eeec30f 100644 --- a/DevelopmentNotes/DevelopmentNotes.fodt +++ b/DevelopmentNotes/DevelopmentNotes.fodt @@ -276,7 +276,7 @@ office:mimetype="application/vnd.oasis.opendocument.text"> MultiMarkdown v6 Development Notes Fletcher T. Penney - 2020-10-28 + 2023-06-10 dd2d8e76-dc2d-416d-9acd-5395d20871c2 @@ -763,6 +763,227 @@ TextBundle/TextPack, OpenDocument, etc. Changelog + +2023–06–10 - v 6.7.0: + + + + +ADDED: Add OBJECT_REPLACEMENT_CHARACTER token (fixes #216) + + + +ADDED: Add compiler flag (DISABLE_OBJECT_POOL) to disable token pools + + + +ADDED: Add more token types + + + +Add Swift support + + + +Avoid space to be eaten aways after a slash in latex export + + + +CHANGED: Add additional TOC tests + + + +CHANGED: Astyle + + + +CHANGED: Reformat comment + + + +FIXED: Centralize html fix + + + +FIXED: Don’t output empty figure captions + + + +FIXED: Fix Glossaries test + + + +FIXED: Fix ambidextrous tokens inside of footnotes and other definitions + + + +FIXED: Fix architecture issue when running multimarkdown from Xcode + + + +FIXED: Fix edge case where table separator without leading pipe is treated as a list item + + + +FIXED: Fix error detecting tables when indented in list items – Thanks, @wnm3! + + + +FIXED: Fix flow control error + + + +FIXED: Fix issue with certain nested lists + + + +FIXED: Fix issue with escaping in URLs + + + +FIXED: Fix issue with reference links with leading space instead of tab + + + +FIXED: Fix regression from pull request that breaks build + + + +FIXED: Fix style issue with ODT output format + + + +FIXED: Fix trailing whitespace issues in headers/TOC + + + +FIXED: Fix typo in xml.c + + + +FIXED: Fix typos in error messages + + + +FIXED: Improve README install path + + + +FIXED: Improve edge cases around fenced code blocks and setext headers + + + +FIXED: Improve markup handling around definition lists and colons + + + +FIXED: Improve token mapping in header blocks + + + +FIXED: Left out file + + + +FIXED: Re-enable token object pools in default configuration + + + +FIXED: Reset stack sizes before freeing temporary engine + + + +FIXED: Restore prior label_counter after {{TOC}} + + + +FIXED: Updated argtable3 now needs to link to math + + + +FIXED: Use MultiMarkdown instead of libMultiMarkdown as title in version.h + + + +FIXED: Use UTC for timestamp + + + +FIXED: bibtex metadata should be raw + + + +Merge branch ‘develop’ of github.com:fletcher/MultiMarkdown-6 into develop + + + +Merge branch ‘release/6.6.0’ into develop + + + +Merge pull request #210 from DivineDominion/swift-framework + + + +Merge pull request #233 from DivineDominion/patch-4 + + + +Merge pull request #243 from alexban011/githubCi + + + +Merge pull request #245 from hvellyr/develop + + + +UPDATED: Apply astyle to all files + + + +UPDATED: Include definition list colons as markup token + + + +UPDATED: Project clean up + + + +UPDATED: Update CMakeLists.txt for Universal Binary + + + +UPDATED: Update astyle config + + + +UPDATED: Update github CI for multiple platforms + + + +UPDATED: Update lexers with newer version of re2c + + + +UPDATED: Update to latest argtable3 code + + + +UPDATED: standardize common source files + + + +ci: added github CI + + + +specify unsigned short for functions in token.h + + +use unsigned short in implementation, too + + + 2020–10–28 - v 6.6.0: diff --git a/DevelopmentNotes/DevelopmentNotes.html b/DevelopmentNotes/DevelopmentNotes.html index f20b42f..ded9352 100644 --- a/DevelopmentNotes/DevelopmentNotes.html +++ b/DevelopmentNotes/DevelopmentNotes.html @@ -4,7 +4,7 @@ MultiMarkdown v6 Development Notes - + @@ -433,6 +433,64 @@

Dependencies/Libraries

Changelog

    +
  • 2023–06–10 - v 6.7.0:

    + +
      +
    • ADDED: Add OBJECT_REPLACEMENT_CHARACTER token (fixes #216)
    • +
    • ADDED: Add compiler flag (DISABLE_OBJECT_POOL) to disable token pools
    • +
    • ADDED: Add more token types
    • +
    • Add Swift support
    • +
    • Avoid space to be eaten aways after a slash in latex export
    • +
    • CHANGED: Add additional TOC tests
    • +
    • CHANGED: Astyle
    • +
    • CHANGED: Reformat comment
    • +
    • FIXED: Centralize html fix
    • +
    • FIXED: Don’t output empty figure captions
    • +
    • FIXED: Fix Glossaries test
    • +
    • FIXED: Fix ambidextrous tokens inside of footnotes and other definitions
    • +
    • FIXED: Fix architecture issue when running multimarkdown from Xcode
    • +
    • FIXED: Fix edge case where table separator without leading pipe is treated as a list item
    • +
    • FIXED: Fix error detecting tables when indented in list items – Thanks, @wnm3!
    • +
    • FIXED: Fix flow control error
    • +
    • FIXED: Fix issue with certain nested lists
    • +
    • FIXED: Fix issue with escaping in URLs
    • +
    • FIXED: Fix issue with reference links with leading space instead of tab
    • +
    • FIXED: Fix regression from pull request that breaks build
    • +
    • FIXED: Fix style issue with ODT output format
    • +
    • FIXED: Fix trailing whitespace issues in headers/TOC
    • +
    • FIXED: Fix typo in xml.c
    • +
    • FIXED: Fix typos in error messages
    • +
    • FIXED: Improve README install path
    • +
    • FIXED: Improve edge cases around fenced code blocks and setext headers
    • +
    • FIXED: Improve markup handling around definition lists and colons
    • +
    • FIXED: Improve token mapping in header blocks
    • +
    • FIXED: Left out file
    • +
    • FIXED: Re-enable token object pools in default configuration
    • +
    • FIXED: Reset stack sizes before freeing temporary engine
    • +
    • FIXED: Restore prior label_counter after {{TOC}}
    • +
    • FIXED: Updated argtable3 now needs to link to math
    • +
    • FIXED: Use MultiMarkdown instead of libMultiMarkdown as title in version.h
    • +
    • FIXED: Use UTC for timestamp
    • +
    • FIXED: bibtex metadata should be raw
    • +
    • Merge branch ‘develop’ of github.com:fletcher/MultiMarkdown-6 into develop
    • +
    • Merge branch ‘release/6.6.0’ into develop
    • +
    • Merge pull request #210 from DivineDominion/swift-framework
    • +
    • Merge pull request #233 from DivineDominion/patch-4
    • +
    • Merge pull request #243 from alexban011/githubCi
    • +
    • Merge pull request #245 from hvellyr/develop
    • +
    • UPDATED: Apply astyle to all files
    • +
    • UPDATED: Include definition list colons as markup token
    • +
    • UPDATED: Project clean up
    • +
    • UPDATED: Update CMakeLists.txt for Universal Binary
    • +
    • UPDATED: Update astyle config
    • +
    • UPDATED: Update github CI for multiple platforms
    • +
    • UPDATED: Update lexers with newer version of re2c
    • +
    • UPDATED: Update to latest argtable3 code
    • +
    • UPDATED: standardize common source files
    • +
    • ci: added github CI
    • +
    • specify unsigned short for functions in token.h
    • +
    • use unsigned short in implementation, too
    • +
  • 2020–10–28 - v 6.6.0:

      diff --git a/DevelopmentNotes/DevelopmentNotes.pdf b/DevelopmentNotes/DevelopmentNotes.pdf index f7f19a9..8259971 100644 Binary files a/DevelopmentNotes/DevelopmentNotes.pdf and b/DevelopmentNotes/DevelopmentNotes.pdf differ diff --git a/DevelopmentNotes/DevelopmentNotes.txt b/DevelopmentNotes/DevelopmentNotes.txt index 14c7708..e0175dd 100644 --- a/DevelopmentNotes/DevelopmentNotes.txt +++ b/DevelopmentNotes/DevelopmentNotes.txt @@ -1,6 +1,6 @@ Title: MultiMarkdown v6 Development Notes Author: Fletcher T. Penney -Date: 2020-10-28 +Date: 2023-06-10 LaTeX Config: tufte-handout Base Header Level: 3 uuid: dd2d8e76-dc2d-416d-9acd-5395d20871c2 @@ -472,6 +472,64 @@ TextBundle/TextPack, OpenDocument, etc. # Changelog # +* 2023-06-10 - v 6.7.0: + + * ADDED: Add OBJECT_REPLACEMENT_CHARACTER token (fixes #216) + * ADDED: Add compiler flag (DISABLE_OBJECT_POOL) to disable token pools + * ADDED: Add more token types + * Add Swift support + * Avoid space to be eaten aways after a slash in latex export + * CHANGED: Add additional TOC tests + * CHANGED: Astyle + * CHANGED: Reformat comment + * FIXED: Centralize html fix + * FIXED: Don't output empty figure captions + * FIXED: Fix Glossaries test + * FIXED: Fix ambidextrous tokens inside of footnotes and other definitions + * FIXED: Fix architecture issue when running multimarkdown from Xcode + * FIXED: Fix edge case where table separator without leading pipe is treated as a list item + * FIXED: Fix error detecting tables when indented in list items -- Thanks, @wnm3! + * FIXED: Fix flow control error + * FIXED: Fix issue with certain nested lists + * FIXED: Fix issue with escaping in URLs + * FIXED: Fix issue with reference links with leading space instead of tab + * FIXED: Fix regression from pull request that breaks build + * FIXED: Fix style issue with ODT output format + * FIXED: Fix trailing whitespace issues in headers/TOC + * FIXED: Fix typo in xml.c + * FIXED: Fix typos in error messages + * FIXED: Improve README install path + * FIXED: Improve edge cases around fenced code blocks and setext headers + * FIXED: Improve markup handling around definition lists and colons + * FIXED: Improve token mapping in header blocks + * FIXED: Left out file + * FIXED: Re-enable token object pools in default configuration + * FIXED: Reset stack sizes before freeing temporary engine + * FIXED: Restore prior label_counter after {{TOC}} + * FIXED: Updated argtable3 now needs to link to math + * FIXED: Use MultiMarkdown instead of libMultiMarkdown as title in version.h + * FIXED: Use UTC for timestamp + * FIXED: bibtex metadata should be raw + * Merge branch 'develop' of github.com:fletcher/MultiMarkdown-6 into develop + * Merge branch 'release/6.6.0' into develop + * Merge pull request #210 from DivineDominion/swift-framework + * Merge pull request #233 from DivineDominion/patch-4 + * Merge pull request #243 from alexban011/githubCi + * Merge pull request #245 from hvellyr/develop + * UPDATED: Apply astyle to all files + * UPDATED: Include definition list colons as markup token + * UPDATED: Project clean up + * UPDATED: Update CMakeLists.txt for Universal Binary + * UPDATED: Update astyle config + * UPDATED: Update github CI for multiple platforms + * UPDATED: Update lexers with newer version of re2c + * UPDATED: Update to latest argtable3 code + * UPDATED: standardize common source files + * ci: added github CI + * specify unsigned short for functions in token.h + * use unsigned short in implementation, too + + * 2020-10-28 - v 6.6.0: * UPDATED: Restructure source code organization; Restructure Cmake configuration file; restructure Makefile diff --git a/QuickStart/QuickStart.epub b/QuickStart/QuickStart.epub index ef6bd26..338e3e9 100644 Binary files a/QuickStart/QuickStart.epub and b/QuickStart/QuickStart.epub differ diff --git a/QuickStart/QuickStart.fodt b/QuickStart/QuickStart.fodt index 7a698f4..8076d7d 100644 --- a/QuickStart/QuickStart.fodt +++ b/QuickStart/QuickStart.fodt @@ -276,7 +276,7 @@ office:mimetype="application/vnd.oasis.opendocument.text"> MultiMarkdown v6 Quick Start Guide Fletcher T. Penney - 6.5.2 + 6.7.0 0d6313fa-9135-477e-9c14-7d62c1977833 @@ -289,39 +289,39 @@ office:mimetype="application/vnd.oasis.opendocument.text"> Table of Contents -Introduction 1 -Performance 1 -Parse Tree 1 -Features 1 -Abbreviations (Or Acronyms) 1 -Citations 1 -CriticMarkup 1 -Embedded Images 1 -Emph and Strong 1 -EPUB 3 Support 1 -Fenced Code Blocks 1 -Footnotes 1 -Glossary Terms 1 -HTML Comments 1 -Internationalization 1 -LaTeX Changes 1 -Metadata 1 -Output Formats 1 -Raw Source 1 -Table of Contents 1 -Tables 1 -Transclusion 1 -Developer Notes 1 -Object Pools 1 -HTML Boolean Attributes 1 -Future Steps 1 +Introduction 1 +Performance 1 +Parse Tree 1 +Features 1 +Abbreviations (Or Acronyms) 1 +Citations 1 +CriticMarkup 1 +Embedded Images 1 +Emph and Strong 1 +EPUB 3 Support 1 +Fenced Code Blocks 1 +Footnotes 1 +Glossary Terms 1 +HTML Comments 1 +Internationalization 1 +LaTeX Changes 1 +Metadata 1 +Output Formats 1 +Raw Source 1 +Table of Contents 1 +Tables 1 +Transclusion 1 +Developer Notes 1 +Object Pools 1 +HTML Boolean Attributes 1 +Future Steps 1 Introduction -Version: 6.5.2 +Version: 6.7.0 This document serves as a description of MultiMarkdown (MMD) v6, as well as a sample document to demonstrate the various features. Specifically, differences from MMD v5 will be pointed out. diff --git a/QuickStart/QuickStart.html b/QuickStart/QuickStart.html index d949e50..28437b2 100644 --- a/QuickStart/QuickStart.html +++ b/QuickStart/QuickStart.html @@ -4,7 +4,7 @@ MultiMarkdown v6 Quick Start Guide - + @@ -12,44 +12,44 @@

      Introduction

      -

      Version: 6.5.2

      +

      Version: 6.7.0

      This document serves as a description of MultiMarkdown (MMD) v6, as well as a sample document to demonstrate the various features. Specifically, differences from MMD v5 will be pointed out.

      @@ -411,15 +411,15 @@

      Future Steps

      1. -PEG:

        Parsing Expression Grammar https://en.wikipedia.org/wiki/Parsing_expression_grammar  ↩

        +PEG:

        Parsing Expression Grammar https://en.wikipedia.org/wiki/Parsing_expression_grammar  ↩︎

      2. -AST:

        Abstract Syntax Tree https://en.wikipedia.org/wiki/Abstract_syntax_tree  ↩

        +AST:

        Abstract Syntax Tree https://en.wikipedia.org/wiki/Abstract_syntax_tree  ↩︎

      3. -glossary:

        The glossary collects information about important terms used in your document  ↩

        +glossary:

        The glossary collects information about important terms used in your document  ↩︎

      diff --git a/QuickStart/QuickStart.pdf b/QuickStart/QuickStart.pdf index 24a468e..1a931dc 100644 Binary files a/QuickStart/QuickStart.pdf and b/QuickStart/QuickStart.pdf differ diff --git a/QuickStart/QuickStart.txt b/QuickStart/QuickStart.txt index d3da1cd..801208d 100644 --- a/QuickStart/QuickStart.txt +++ b/QuickStart/QuickStart.txt @@ -1,6 +1,6 @@ Title: MultiMarkdown v6 Quick Start Guide Author: Fletcher T. Penney -Version: 6.5.2 +Version: 6.7.0 LaTeX Config: tufte-handout Base Header Level: 3 uuid: 0d6313fa-9135-477e-9c14-7d62c1977833 diff --git a/README.md b/README.md index 8104abb..b874de5 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,9 @@ | ---------- | ------------------------- | | Title: | libMultiMarkdown | | Author: | Fletcher T. Penney | -| Date: | 2020-10-28 | -| Copyright: | Copyright © 2016 - 2020 Fletcher T. Penney. | -| Version: | 6.6.0 | +| Date: | 2023-06-10 | +| Copyright: | Copyright © 2016 - 2023 Fletcher T. Penney. | +| Version: | 6.7.0 | master branch: [![Build Status](https://travis-ci.org/fletcher/MultiMarkdown-6.svg?branch=master)](https://travis-ci.org/fletcher/MultiMarkdown-6) develop branch: [![Build Status](https://travis-ci.org/fletcher/MultiMarkdown-6.svg?branch=develop)](https://travis-ci.org/fletcher/MultiMarkdown-6) diff --git a/src/argtable3.c b/src/argtable3.c index d1ec8b5..aa9a9b7 100644 --- a/src/argtable3.c +++ b/src/argtable3.c @@ -118,7 +118,7 @@ extern void * xrealloc(void * ptr, size_t size); extern void xfree(void * ptr); struct arg_hashtable_entry { - void * k, *v; + void * k, * v; unsigned int h; struct arg_hashtable_entry * next; }; @@ -708,7 +708,7 @@ void arg_hashtable_remove(arg_hashtable_t * h, const void * k) { void arg_hashtable_destroy(arg_hashtable_t * h, int free_values) { unsigned int i; - struct arg_hashtable_entry * e, *f; + struct arg_hashtable_entry * e, * f; struct arg_hashtable_entry ** table = h->table; if (free_values) { @@ -1577,7 +1577,7 @@ permute_args(int panonopt_start, int panonopt_end, int opt_end, static int parse_long_options(char * const * nargv, const char * options, const struct option * long_options, int * idx, int short_too, int flags) { - char * current_argv, *has_equal; + char * current_argv, * has_equal; #ifdef GNU_COMPATIBLE char * current_dash; #endif @@ -3102,7 +3102,7 @@ static void arg_file_resetfn(struct arg_file * parent) { /* Returns ptr to the base filename within *filename */ static const char * arg_basename(const char * filename) { - const char * result = NULL, *result1, *result2; + const char * result = NULL, * result1, * result2; /* Find the last occurrence of eother file separator character. */ /* Two alternative file separator chars are supported as legal */ @@ -4616,7 +4616,7 @@ static const TRexChar * trex_matchnode(TRex * exp, TRexNode * node, const TRexCh /* TRexNode *greedystop = (node->next != -1) ? &exp->_nodes[node->next] : NULL; */ TRexNode * greedystop = NULL; int p0 = (node->right >> 16) & 0x0000FFFF, p1 = node->right & 0x0000FFFF, nmaches = 0; - const TRexChar * s = str, *good = str; + const TRexChar * s = str, * good = str; if (node->next != -1) { greedystop = &exp->_nodes[node->next]; @@ -6163,7 +6163,7 @@ void arg_print_syntax_ds(arg_dstr_t ds, void ** argtable, const char * suffix) { /* print remaining options in abbreviated style */ for (tabindex = 0; table[tabindex] && !(table[tabindex]->flag & ARG_TERMINATOR); tabindex++) { char syntax[200] = ""; - const char * shortopts, *longopts, *datatype; + const char * shortopts, * longopts, * datatype; /* skip short options without arg values (they were printed by arg_print_gnu_switch) */ if (table[tabindex]->shortopts && !(table[tabindex]->flag & ARG_HASVALUE)) { @@ -6230,7 +6230,7 @@ void arg_print_syntaxv_ds(arg_dstr_t ds, void ** argtable, const char * suffix) /* print remaining options in abbreviated style */ for (tabindex = 0; table[tabindex] && !(table[tabindex]->flag & ARG_TERMINATOR); tabindex++) { char syntax[200] = ""; - const char * shortopts, *longopts, *datatype; + const char * shortopts, * longopts, * datatype; shortopts = table[tabindex]->shortopts; longopts = table[tabindex]->longopts; diff --git a/src/epub.c b/src/epub.c index 8e33b29..37e152f 100644 --- a/src/epub.c +++ b/src/epub.c @@ -69,7 +69,7 @@ #elif TARGET_OS_MAC // Other kinds of Mac OS #else - # error "Unknown Apple platform" + #error "Unknown Apple platform" #endif #endif diff --git a/src/latex.c b/src/latex.c index f2ed907..6538a89 100644 --- a/src/latex.c +++ b/src/latex.c @@ -150,6 +150,23 @@ void mmd_print_string_latex(DString * out, const char * str) { } +void mmd_print_label_latex(DString * out, const char * str) { + if (str == NULL) { + return; + } + + while (*str != '\0') { + if (*str == '_') { + print_char(*str); + } else { + mmd_print_char_latex(out, *str); + } + + str++; + } +} + + void mmd_print_localized_char_latex(DString * out, unsigned short type, scratch_pad * scratch) { switch (type) { case DASH_N: @@ -272,18 +289,18 @@ void mmd_export_link_latex(DString * out, const char * source, token * text, lin if (temp_char && temp_char[0] != '\0') { mmd_export_token_tree_latex(out, source, text->child, scratch); print_const(" (\\autoref{"); - mmd_print_string_latex(out, &(link->url)[1]); + mmd_print_label_latex(out, &(link->url)[1]); print_const("})"); } else { print_const("\\autoref{"); - mmd_print_string_latex(out, &(link->url)[1]); + mmd_print_label_latex(out, &(link->url)[1]); print_const("}"); } free(temp_char); } else { print_const("\\autoref{"); - mmd_print_string_latex(out, &(link->url)[1]); + mmd_print_label_latex(out, &(link->url)[1]); print_const("}"); } diff --git a/src/main.c b/src/main.c index 49a8452..6ba9c90 100644 --- a/src/main.c +++ b/src/main.c @@ -74,13 +74,13 @@ #define kBUFFERSIZE 4096 // How many bytes to read at a time // argtable structs -struct arg_lit * a_help, *a_version, *a_compatibility, *a_nolabels, *a_batch, - *a_accept, *a_reject, *a_full, *a_snippet, *a_random, *a_unique, *a_meta, - *a_notransclude, *a_nosmart, *a_opml, *a_itmz; -struct arg_str * a_format, *a_lang, *a_extract; -struct arg_file * a_file, *a_o; +struct arg_lit * a_help, * a_version, * a_compatibility, * a_nolabels, * a_batch, + * a_accept, * a_reject, * a_full, * a_snippet, * a_random, * a_unique, * a_meta, + * a_notransclude, * a_nosmart, * a_opml, * a_itmz; +struct arg_str * a_format, * a_lang, * a_extract; +struct arg_file * a_file, * a_o; struct arg_end * a_end; -struct arg_rem * a_rem1, *a_rem2, *a_rem3, *a_rem4, *a_rem5, *a_rem6; +struct arg_rem * a_rem1, * a_rem2, * a_rem3, * a_rem4, * a_rem5, * a_rem6; /// strdup() not available on all platforms diff --git a/src/miniz.c b/src/miniz.c index afdec38..44959fa 100644 --- a/src/miniz.c +++ b/src/miniz.c @@ -730,7 +730,7 @@ typedef struct { } tdefl_sym_freq; static tdefl_sym_freq * tdefl_radix_sort_syms(mz_uint num_syms, tdefl_sym_freq * pSyms0, tdefl_sym_freq * pSyms1) { mz_uint32 total_passes = 2, pass_shift, pass, i, hist[256 * 2]; - tdefl_sym_freq * pCur_syms = pSyms0, *pNew_syms = pSyms1; + tdefl_sym_freq * pCur_syms = pSyms0, * pNew_syms = pSyms1; MZ_CLEAR_OBJ(hist); for (i = 0; i < num_syms; i++) { @@ -869,7 +869,7 @@ static void tdefl_optimize_huffman_table(tdefl_compressor * d, int table_num, in num_codes[d->m_huff_code_sizes[table_num][i]]++; } } else { - tdefl_sym_freq syms0[TDEFL_MAX_HUFF_SYMBOLS], syms1[TDEFL_MAX_HUFF_SYMBOLS], *pSyms; + tdefl_sym_freq syms0[TDEFL_MAX_HUFF_SYMBOLS], syms1[TDEFL_MAX_HUFF_SYMBOLS], * pSyms; int num_used_syms = 0; const mz_uint16 * pSym_count = &d->m_huff_count[table_num][0]; @@ -1391,7 +1391,7 @@ static inline mz_uint16 TDEFL_READ_UNALIGNED_WORD2(const mz_uint16 * p) { static MZ_FORCEINLINE void tdefl_find_match(tdefl_compressor * d, mz_uint lookahead_pos, mz_uint max_dist, mz_uint max_match_len, mz_uint * pMatch_dist, mz_uint * pMatch_len) { mz_uint dist, pos = lookahead_pos & TDEFL_LZ_DICT_SIZE_MASK, match_len = *pMatch_len, probe_pos = pos, next_probe_pos, probe_len; mz_uint num_probes_left = d->m_max_probes[match_len >= 32]; - const mz_uint16 * s = (const mz_uint16 *)(d->m_dict + pos), *p, *q; + const mz_uint16 * s = (const mz_uint16 *)(d->m_dict + pos), * p, * q; mz_uint16 c01 = TDEFL_READ_UNALIGNED_WORD(&d->m_dict[pos + match_len - 1]), s01 = TDEFL_READ_UNALIGNED_WORD2(s); MZ_ASSERT(max_match_len <= TDEFL_MAX_MATCH_LEN); @@ -1453,7 +1453,7 @@ static MZ_FORCEINLINE void tdefl_find_match(tdefl_compressor * d, mz_uint lookah static MZ_FORCEINLINE void tdefl_find_match(tdefl_compressor * d, mz_uint lookahead_pos, mz_uint max_dist, mz_uint max_match_len, mz_uint * pMatch_dist, mz_uint * pMatch_len) { mz_uint dist, pos = lookahead_pos & TDEFL_LZ_DICT_SIZE_MASK, match_len = *pMatch_len, probe_pos = pos, next_probe_pos, probe_len; mz_uint num_probes_left = d->m_max_probes[match_len >= 32]; - const mz_uint8 * s = d->m_dict + pos, *p, *q; + const mz_uint8 * s = d->m_dict + pos, * p, * q; mz_uint8 c0 = d->m_dict[pos + match_len], c1 = d->m_dict[pos + match_len - 1]; MZ_ASSERT(max_match_len <= TDEFL_MAX_MATCH_LEN); @@ -1509,7 +1509,7 @@ static MZ_FORCEINLINE void tdefl_find_match(tdefl_compressor * d, mz_uint lookah static mz_bool tdefl_compress_fast(tdefl_compressor * d) { /* Faster, minimally featured LZRW1-style match+parse loop with better register utilization. Intended for applications where raw throughput is valued more highly than ratio. */ mz_uint lookahead_pos = d->m_lookahead_pos, lookahead_size = d->m_lookahead_size, dict_size = d->m_dict_size, total_lz_bytes = d->m_total_lz_bytes, num_flags_left = d->m_num_flags_left; - mz_uint8 * pLZ_code_buf = d->m_pLZ_code_buf, *pLZ_flags = d->m_pLZ_flags; + mz_uint8 * pLZ_code_buf = d->m_pLZ_code_buf, * pLZ_flags = d->m_pLZ_flags; mz_uint cur_pos = lookahead_pos & TDEFL_LZ_DICT_SIZE_MASK; while ((d->m_src_buf_left) || ((d->m_flush) && (lookahead_size))) { @@ -2433,8 +2433,8 @@ tinfl_status tinfl_decompress(tinfl_decompressor * r, const mz_uint8 * pIn_buf_n tinfl_status status = TINFL_STATUS_FAILED; mz_uint32 num_bits, dist, counter, num_extra; tinfl_bit_buf_t bit_buf; - const mz_uint8 * pIn_buf_cur = pIn_buf_next, *const pIn_buf_end = pIn_buf_next + *pIn_buf_size; - mz_uint8 * pOut_buf_cur = pOut_buf_next, *const pOut_buf_end = pOut_buf_next + *pOut_buf_size; + const mz_uint8 * pIn_buf_cur = pIn_buf_next, * const pIn_buf_end = pIn_buf_next + *pIn_buf_size; + mz_uint8 * pOut_buf_cur = pOut_buf_next, * const pOut_buf_end = pOut_buf_next + *pOut_buf_size; size_t out_buf_size_mask = (decomp_flags & TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF) ? (size_t) -1 : ((pOut_buf_next - pOut_buf_start) + *pOut_buf_size) - 1, dist_from_out_buf_start; /* Ensure the output buffer's size is a power of 2, unless the output buffer is large enough to hold the entire output file (in which case it doesn't matter). */ @@ -2933,7 +2933,7 @@ tinfl_status tinfl_decompress(tinfl_decompressor * r, const mz_uint8 * pIn_buf_n /* Higher level helper functions. */ void * tinfl_decompress_mem_to_heap(const void * pSrc_buf, size_t src_buf_len, size_t * pOut_len, int flags) { tinfl_decompressor decomp; - void * pBuf = NULL, *pNew_buf; + void * pBuf = NULL, * pNew_buf; size_t src_buf_ofs = 0, out_buf_capacity = 0; *pOut_len = 0; tinfl_init(&decomp); @@ -3510,7 +3510,7 @@ static mz_bool mz_zip_reader_init_internal(mz_zip_archive * pZip, mz_uint flags) } static MZ_FORCEINLINE mz_bool mz_zip_reader_filename_less(const mz_zip_array * pCentral_dir_array, const mz_zip_array * pCentral_dir_offsets, mz_uint l_index, mz_uint r_index) { - const mz_uint8 * pL = &MZ_ZIP_ARRAY_ELEMENT(pCentral_dir_array, mz_uint8, MZ_ZIP_ARRAY_ELEMENT(pCentral_dir_offsets, mz_uint32, l_index)), *pE; + const mz_uint8 * pL = &MZ_ZIP_ARRAY_ELEMENT(pCentral_dir_array, mz_uint8, MZ_ZIP_ARRAY_ELEMENT(pCentral_dir_offsets, mz_uint32, l_index)), * pE; const mz_uint8 * pR = &MZ_ZIP_ARRAY_ELEMENT(pCentral_dir_array, mz_uint8, MZ_ZIP_ARRAY_ELEMENT(pCentral_dir_offsets, mz_uint32, r_index)); mz_uint l_len = MZ_READ_LE16(pL + MZ_ZIP_CDH_FILENAME_LEN_OFS), r_len = MZ_READ_LE16(pR + MZ_ZIP_CDH_FILENAME_LEN_OFS); mz_uint8 l = 0, r = 0; @@ -4346,7 +4346,7 @@ static MZ_FORCEINLINE mz_bool mz_zip_string_equal(const char * pA, const char * } static MZ_FORCEINLINE int mz_zip_filename_compare(const mz_zip_array * pCentral_dir_array, const mz_zip_array * pCentral_dir_offsets, mz_uint l_index, const char * pR, mz_uint r_len) { - const mz_uint8 * pL = &MZ_ZIP_ARRAY_ELEMENT(pCentral_dir_array, mz_uint8, MZ_ZIP_ARRAY_ELEMENT(pCentral_dir_offsets, mz_uint32, l_index)), *pE; + const mz_uint8 * pL = &MZ_ZIP_ARRAY_ELEMENT(pCentral_dir_array, mz_uint8, MZ_ZIP_ARRAY_ELEMENT(pCentral_dir_offsets, mz_uint32, l_index)), * pE; mz_uint l_len = MZ_READ_LE16(pL + MZ_ZIP_CDH_FILENAME_LEN_OFS); mz_uint8 l = 0, r = 0; pL += MZ_ZIP_CENTRAL_DIR_HEADER_SIZE; diff --git a/src/miniz.h b/src/miniz.h index 6cf009c..36babb3 100644 --- a/src/miniz.h +++ b/src/miniz.h @@ -682,13 +682,13 @@ typedef struct { mz_uint m_flags, m_max_probes[2]; int m_greedy_parsing; mz_uint m_adler32, m_lookahead_pos, m_lookahead_size, m_dict_size; - mz_uint8 * m_pLZ_code_buf, *m_pLZ_flags, *m_pOutput_buf, *m_pOutput_buf_end; + mz_uint8 * m_pLZ_code_buf, * m_pLZ_flags, * m_pOutput_buf, * m_pOutput_buf_end; mz_uint m_num_flags_left, m_total_lz_bytes, m_lz_code_buf_dict_pos, m_bits_in, m_bit_buffer; mz_uint m_saved_match_dist, m_saved_match_len, m_saved_lit, m_output_flush_ofs, m_output_flush_remaining, m_finished, m_block_index, m_wants_to_finish; tdefl_status m_prev_return_status; const void * m_pIn_buf; void * m_pOut_buf; - size_t * m_pIn_buf_size, *m_pOut_buf_size; + size_t * m_pIn_buf_size, * m_pOut_buf_size; tdefl_flush m_flush; const mz_uint8 * m_pSrc; size_t m_src_buf_left, m_out_buf_ofs; diff --git a/src/opendocument.c b/src/opendocument.c index 5da60ac..8f25656 100644 --- a/src/opendocument.c +++ b/src/opendocument.c @@ -112,7 +112,7 @@ #elif TARGET_OS_MAC // Other kinds of Mac OS #else - # error "Unknown Apple platform" + #error "Unknown Apple platform" #endif #endif diff --git a/src/rng.c b/src/rng.c index 27a9188..6156e04 100644 --- a/src/rng.c +++ b/src/rng.c @@ -79,18 +79,15 @@ long * ran_arr_ptr = &ran_arr_dummy; /* the next random number, or -1 */ ss <<= 1; if (ss >= MM) { - ss -= MM - 2; /* cyclic shift 29 bits */ + ss -= MM - 2; /* cyclic shift 29 bits */ } } x[1]++; /* make x[1] (and only x[1]) odd */ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wcomma" - for (ss = seed & (MM - 1), t = TT - 1; t; ) { for (j = KK - 1; j > 0; j--) { - x[j + j] = x[j], x[j + j - 1] = 0; /* "square" */ + x[j + j] = x[j], x[j + j - 1] = 0; /* "square" */ } for (j = KK + KK - 2; j >= KK; j--) @@ -113,8 +110,6 @@ long * ran_arr_ptr = &ran_arr_dummy; /* the next random number, or -1 */ } } -#pragma clang diagnostic pop - for (j = 0; j < LL; j++) { ran_x[j + KK - LL] = x[j]; } @@ -124,7 +119,7 @@ long * ran_arr_ptr = &ran_arr_dummy; /* the next random number, or -1 */ } for (j = 0; j < 10; j++) { - ran_array(x, KK + KK - 1); /* warm things up */ + ran_array(x, KK + KK - 1); /* warm things up */ } ran_arr_ptr = &ran_arr_started; @@ -142,22 +137,37 @@ long ran_arr_cycle() { return ran_arr_buf[0]; } -/* Tweaked to include as a library - Fletcher T. Penney */ -/*#include -int main() -{ - register int m; long a[2009]; - ran_start(310952L); - for (m=0;m<=2009;m++) ran_array(a,1009); - printf("%ld\n", a[0]); *//* 995235265 */ -/* ran_start(310952L); - for (m=0;m<=1009;m++) ran_array(a,2009); - printf("%ld\n", a[0]); *//* 995235265 */ -/* printf("%ld\n",ran_arr_next()); - return 0; -} */ +/* this main program corrected on 14 September 2019 to agree with TAOCP */ +/* + Modified by Fletcher T. Penney to allow this code to be used as a library within other programs. + * made main() static + * added wrapper function ran_num_next() for external use + + I did not make any changes that affect the algorithm. +*/ + +#include +static int main() { + register int m; + long a[2009]; + ran_start(310952L); + + for (m = 0; m < 2009; m++) { + ran_array(a, 1009); + } + + printf("%ld\n", ran_x[0]); /* 995235265 */ + ran_start(310952L); + + for (m = 0; m < 1009; m++) { + ran_array(a, 2009); + } + + printf("%ld\n", ran_x[0]); /* 995235265 */ + return 0; +} + long ran_num_next(void) { return ran_arr_next(); } - diff --git a/src/textbundle.c b/src/textbundle.c index 246e2fd..4a70526 100644 --- a/src/textbundle.c +++ b/src/textbundle.c @@ -116,7 +116,7 @@ #elif TARGET_OS_MAC // Other kinds of Mac OS #else - # error "Unknown Apple platform" + #error "Unknown Apple platform" #endif #endif diff --git a/src/writer.c b/src/writer.c index b076aef..8d230ad 100644 --- a/src/writer.c +++ b/src/writer.c @@ -1830,15 +1830,23 @@ void automatic_search_text(mmd_engine * e, token * t, trie * ac) { token * tok = t; + char * source = e->dstr->str; + if (m) { walker = m->next; while (walker) { - token_split(tok, walker->start, walker->len, walker->match_type); - - // Advance token to next token - while (tok && (tok->start < walker->start + walker->len)) { - tok = tok->next; + // Only if we match a full word + if ( + (walker->start + walker->len == tok->start + tok->len) || + (char_is_whitespace_or_line_ending_or_punctuation(source[walker->start + walker->len])) + ) { + token_split(tok, walker->start, walker->len, walker->match_type); + + // Advance token to next token + while (tok && (tok->start < walker->start + walker->len)) { + tok = tok->next; + } } // Advance to next match (if present) @@ -1912,13 +1920,19 @@ void identify_global_search_terms(mmd_engine * e, scratch_pad * scratch) { // Add abbreviations to search trie for (int i = 0; i < e->abbreviation_stack->size; ++i) { f = stack_peek_index(e->abbreviation_stack, i); - trie_insert(ac, f->label_text, PAIR_BRACKET_ABBREVIATION); + + if (f->label_text && strlen(f->label_text) > 1) { + trie_insert(ac, f->label_text, PAIR_BRACKET_ABBREVIATION); + } } // Add glossary to search trie (without leading '?') for (int i = 0; i < e->glossary_stack->size; ++i) { f = stack_peek_index(e->glossary_stack, i); - trie_insert(ac, f->clean_text, PAIR_BRACKET_GLOSSARY); + + if (f->clean_text && strlen(f->clean_text) > 1) { + trie_insert(ac, f->clean_text, PAIR_BRACKET_GLOSSARY); + } } ac_trie_prepare(ac); diff --git a/tests/MMD6Tests/Abbreviations.fodt b/tests/MMD6Tests/Abbreviations.fodt index 74564c1..88ebcf8 100644 --- a/tests/MMD6Tests/Abbreviations.fodt +++ b/tests/MMD6Tests/Abbreviations.fodt @@ -375,6 +375,10 @@ foo foo + +Abbr (Ab) Abbr (A) [>a]. + +Abc abc Ab.
      diff --git a/tests/MMD6Tests/Abbreviations.html b/tests/MMD6Tests/Abbreviations.html index 3cae759..91cc194 100644 --- a/tests/MMD6Tests/Abbreviations.html +++ b/tests/MMD6Tests/Abbreviations.html @@ -90,6 +90,10 @@

      foo bar

    • foo
    +

    Abbr (Ab) Abbr (A) [>a].

    + +

    Abc abc Ab.

    +

      diff --git a/tests/MMD6Tests/Abbreviations.htmlc b/tests/MMD6Tests/Abbreviations.htmlc index b715d64..8f73d13 100644 --- a/tests/MMD6Tests/Abbreviations.htmlc +++ b/tests/MMD6Tests/Abbreviations.htmlc @@ -65,6 +65,10 @@ bar

    1. foo
+

Ab >A >a.

+ +

Abc abc Ab.

+

[>foo bar]: FOO BAR

[^note]: foo and bar

diff --git a/tests/MMD6Tests/Abbreviations.opml b/tests/MMD6Tests/Abbreviations.opml index d5e2197..5075814 100644 --- a/tests/MMD6Tests/Abbreviations.opml +++ b/tests/MMD6Tests/Abbreviations.opml @@ -5,7 +5,7 @@ - + diff --git a/tests/MMD6Tests/Abbreviations.tex b/tests/MMD6Tests/Abbreviations.tex index 6be7739..2bac7e2 100644 --- a/tests/MMD6Tests/Abbreviations.tex +++ b/tests/MMD6Tests/Abbreviations.tex @@ -22,6 +22,10 @@ \newacronym{foo bar}{foo bar}{FOO BAR} +\newacronym{A}{A}{Abbr} + +\newacronym{Ab}{Ab}{Abbr} + \input{mmd6-article-begin} \gls{foo} \gls{foo} @@ -111,5 +115,9 @@ \part{foo bar} \end{itemize} +\gls{Ab} \gls{A} {[>a]}. + +Abc abc \gls{Ab}. + \input{mmd6-article-footer} \end{document} diff --git a/tests/MMD6Tests/Abbreviations.text b/tests/MMD6Tests/Abbreviations.text index dab36ca..5f0592e 100644 --- a/tests/MMD6Tests/Abbreviations.text +++ b/tests/MMD6Tests/Abbreviations.text @@ -62,6 +62,9 @@ foo bar * foo * foo +Ab [>A] [>a]. + +Abc abc Ab. [>foo]: FOO [>f.o.o.]: F.O.O. @@ -78,3 +81,6 @@ foo bar [>foo bar]: FOO BAR [^note]: foo and bar + +[>A]: Abbr +[>Ab]: Abbr diff --git a/tests/MMD6Tests/Cross-References.fodt b/tests/MMD6Tests/Cross-References.fodt index 8423327..9296d1a 100644 --- a/tests/MMD6Tests/Cross-References.fodt +++ b/tests/MMD6Tests/Cross-References.fodt @@ -299,6 +299,10 @@ office:mimetype="application/vnd.oasis.opendocument.text"> Test 的 Multibyte 10 + +Test_Underscore + +Link to Test_Underscore.
diff --git a/tests/MMD6Tests/Cross-References.html b/tests/MMD6Tests/Cross-References.html index 27b4249..c71eac7 100644 --- a/tests/MMD6Tests/Cross-References.html +++ b/tests/MMD6Tests/Cross-References.html @@ -28,6 +28,10 @@

Test 的 Multibyte

10

+

Test_Underscore

+ +

Link to Test_Underscore.

+ diff --git a/tests/MMD6Tests/Cross-References.htmlc b/tests/MMD6Tests/Cross-References.htmlc index 8a690db..59d9b51 100644 --- a/tests/MMD6Tests/Cross-References.htmlc +++ b/tests/MMD6Tests/Cross-References.htmlc @@ -22,3 +22,7 @@ latexconfig: article

Test 的 Multibyte

10

+ +

Test_Underscore

+ +

Link to [Test_Underscore].

diff --git a/tests/MMD6Tests/Cross-References.opml b/tests/MMD6Tests/Cross-References.opml index c99261e..4a26669 100644 --- a/tests/MMD6Tests/Cross-References.opml +++ b/tests/MMD6Tests/Cross-References.opml @@ -8,7 +8,8 @@ - + + diff --git a/tests/MMD6Tests/Cross-References.tex b/tests/MMD6Tests/Cross-References.tex index b58a8aa..79d8e56 100644 --- a/tests/MMD6Tests/Cross-References.tex +++ b/tests/MMD6Tests/Cross-References.tex @@ -30,5 +30,10 @@ \part{Test 的 Multibyte} 10 +\part{Test\_Underscore} +\label{test_underscore} + +Link to Test\_Underscore (\autoref{test_underscore}). + \input{mmd6-article-footer} \end{document} diff --git a/tests/MMD6Tests/Cross-References.text b/tests/MMD6Tests/Cross-References.text index 657234d..01ec0c9 100644 --- a/tests/MMD6Tests/Cross-References.text +++ b/tests/MMD6Tests/Cross-References.text @@ -22,3 +22,7 @@ And now, link to [1 Cross-References: Special Characters!@#$%&*()<>^][] # Test 的 Multibyte # 10 + +# Test_Underscore # + +Link to [Test_Underscore].