#!/bin/bash # "highlight-help2md.sh" v1.1.0 | 2019/03/02 | by Tristano Ajmone | MIT License # ****************************************************************************** # * * # * Highlight Languages 2 Markdown Page * # * * # ****************************************************************************** # The script queries Highlight for help instructions and its version, it then # creates a well formatted GFM markdown document with the acquired information. # # Created for autoupdating the Highlight Wiki page that lists all the supported # languages by the latest Highlight version: # # https://gitlab.com/saalen/highlight/wiki/CLI-Help # https://gitlab.com/saalen/highlight/wikis/CLI-Help # # You're free to adapt this script to your own needs, but please do honour its # license terms and duely credit me! # ------------------------------------------------------------------------------ echo "=========================================" echo "Autogenerating Highlight cli help page..." echo "=========================================" # =========================== # Setup Environment Variables # =========================== # The output markdown file: OUT_FILE="./CLI-Help.md" # ========================= # Retrive Highlight Version # ========================= HL_VER="$(highlight --version | grep -P -o -m1 '\d\.\d\d')" echo "Highlight version found: ${HL_VER}" # ================================= # Write Document Chunk #1 -- Header # ================================= cat << EOF > $OUT_FILE Highlight v${HL_VER} For a quick-reference, this page reproduces all the Help texts available via Highlight command line tool. ----- **Table of Contents** - [Command Line Help](#command-line-help) - [Topic-Specific Help](#topic-specific-help) - [Syntax Help](#syntax-help) - [Themes Help](#themes-help) - [Plugins Help](#plugins-help) - [Config Help](#config-help) - [Tests Help](#tests-help) - [Highlight Version Info](#highlight-version-info) ----- # Command Line Help Here’s the text output of the \`highlight --help\` command: \`\`\` EOF # =================================== # Write Document Chunk #2 -- CLI Help # =================================== highlight --help >> $OUT_FILE # =========================================== # Write Document Chunk #3 -- CLI Help: Syntax # =========================================== cat << "EOF" >> $OUT_FILE ``` # Topic-Specific Help Highlight v3.49 introduced topic-specific help via the `--help=` option, where `` can be one of following: `syntax`, `theme`, `plugin`, `config` or `test`. ## Syntax Help Here’s the text output of the `highlight --help=syntax` command: ``` EOF highlight --help=syntax >> $OUT_FILE # ========================================== # Write Document Chunk #4 -- CLI Help: Theme # ========================================== cat << "EOF" >> $OUT_FILE ``` ## Themes Help Here’s the text output of the `highlight --help=theme` command: ``` EOF highlight --help=theme >> $OUT_FILE # =========================================== # Write Document Chunk #5 -- CLI Help: Plugin # =========================================== cat << "EOF" >> $OUT_FILE ``` ## Plugins Help Here’s the text output of the `highlight --help=plugin` command: ``` EOF highlight --help=plugin >> $OUT_FILE # =========================================== # Write Document Chunk #6 -- CLI Help: Config # =========================================== cat << "EOF" >> $OUT_FILE ``` ## Config Help Here’s the text output of the `highlight --help=config` command: ``` EOF highlight --help=config >> $OUT_FILE # ========================================= # Write Document Chunk #7 -- CLI Help: Test # ========================================= cat << "EOF" >> $OUT_FILE ``` ## Tests Help Here’s the text output of the `highlight --help=test` command: ``` EOF highlight --help=test >> $OUT_FILE # ========================================== # Write Document Chunk #8 -- HL Version Info # ========================================== cat << "EOF" >> $OUT_FILE ``` # Highlight Version Info And here’s the text output of the `highlight --version` command: ``` EOF highlight --version >> $OUT_FILE # ================================= # Write Document Chunk #9 -- Footer # ================================= cat << "EOF" >> $OUT_FILE ``` -------------- > **NOTE** — This page is autogenerated via a [script]. > Any manual edits to the page will be lost when the page is updated. -------------- [script]: https://gitlab.com/saalen/highlight/wikis/highlight-help2md.sh "View script source" EOF # ============================ # Normalize all EOL to Unix LF # ============================ # This is required under Windows, for the output of Highlight will produce CRLF # end-of-lines under Git Bash. dos2unix $OUT_FILE # ------------------------------------------------------------------------------ # MIT License # # Copyright (c) 2018 Tristano Ajmone # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # ------------------------------------------------------------------------------