diff --git a/README.md b/README.md index a50792a..6ebf15b 100644 --- a/README.md +++ b/README.md @@ -29,15 +29,17 @@ cargo install mdbook # Clone this repository git clone https://github.com/hyperreal64/zsh-manual-mdbook -# Install Python dependencies +# Install Perl dependencies +# Ensure cpanminus is installed from your distro's repos +# e.g. sudo apt install cpanminus or sudo dnf install cpanminus cd zsh-manual-mdbook -pip install -r requirements.txt +sudo cpanm Archive::Extract File::Basename HTTP::Simple IPC::Cmd Mojo::DOM Mojo::UserAgent # Ensure DocToc is installed sudo npm -g install doctoc # Return to repository clone and run the make-mdbook script -./make-mdbook.sh +./make-mdbook.pl # Serve locally cd zsh_manual/ diff --git a/gen_summ_manual.py b/gen_summ_manual.py deleted file mode 100644 index 5e6a75c..0000000 --- a/gen_summ_manual.py +++ /dev/null @@ -1,39 +0,0 @@ -import re -import requests -from bs4 import BeautifulSoup - - -# Check if input contains integer substring -def hasInteger(input): - return bool(re.search(r"(?new( archive => $dest ); +my $ok = $ae->extract( to => $zsh_doc_tmp_dir ) + or die $ae->error; + +# Extra files are added to the archive that have no content besides aliases to +# pages that do. They are all less than 4k, and they are just clutter for mdbook, so +# we remove them here along with the Index pages. +my @files = <$zsh_html_src_dir/*.html>; + +foreach my $file (@files) { + unlink $file if ( -s $file < 4000 ); + + my $bname = qx(basename $file); + unlink $file if ( $bname =~ /-Index/ ); + unlink $file if ( $bname =~ /^zsh_[\w]+/ ); +} + +# Remove HTML noise +@files = <$zsh_html_src_dir/*.html>; +foreach my $file (@files) { + system("perl -i -ne 'print unless m/valign/' $file") == 0 or die "$?"; + system("perl -i -ne 'print unless m/table/' $file") == 0 or die "$?"; +} + +# Convert html to md with pandoc +foreach my $file (@files) { + my $basename = basename( $file, ".html" ); + my @pandoc_cmd = ( + "pandoc", "$file", "-f", "html", "-t", "gfm", "-o", + "$mdbook_src_dir/$basename.md" + ); + + system(@pandoc_cmd) == 0 or die "system @pandoc_cmd failed: $?"; +} + +# Rename Jobs-_0026-Signals.md to Jobs-&-Signals.md +rename( + "$mdbook_src_dir/Jobs-_0026-Signals.md", + "$mdbook_src_dir/Jobs-&-Signals.md" +) or die "$?"; + +# Generate TOC with doctoc +my $result = run_forked("doctoc $mdbook_src_dir/"); +print $result->{'stdout'} if ( $result->{'exit_code'} == 0 ); +print $result->{'stderr'} if ( $result->{'exit_code'} != 0 ); + +# Generate SUMMARY.md from table of contents +my $ua = Mojo::UserAgent->new; + +my $dom = + $ua->get("https://zsh.sourceforge.io/Doc/Release/zsh_toc.html")->res->dom; + +my $summary_file = "$mdbook_src_dir/SUMMARY.md"; +open( FH, ">", $summary_file ) or die $?; +print FH "# Summary\n\n"; + +my @toc = $dom->find('a')->map('text')->each; +foreach my $toc (@toc) { + if ( $toc =~ /(? "${_mdbook_src_dir}/SUMMARY.md" - -# Copy md files to mdbook src -# First ensure the src directory is empty -rm -rf "${PWD}/zsh_manual/src" -mkdir "${PWD}/zsh_manual/src" -cp -rf "${_mdbook_src_dir}"/* "${PWD}/zsh_manual/src/" - -# Cleanup zsh_doc_tmp -rm -rf "${_zsh_doc_tmp_dir}" diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index a125e87..0000000 --- a/requirements.txt +++ /dev/null @@ -1,19 +0,0 @@ -appdirs==1.4.4 -beautifulsoup4==4.9.3 -black==21.5b0 -bs4==0.0.1 -certifi==2020.12.5 -chardet==4.0.0 -click==7.1.2 -flake8==3.9.2 -idna==2.10 -mccabe==0.6.1 -mypy-extensions==0.4.3 -pathspec==0.8.1 -pycodestyle==2.7.0 -pyflakes==2.3.1 -regex==2021.4.4 -requests==2.25.1 -soupsieve==2.2.1 -toml==0.10.2 -urllib3==1.26.4 diff --git a/zsh_manual/src/Jobs-_0026-Signals.md b/zsh_manual/src/Jobs-&-Signals.md similarity index 100% rename from zsh_manual/src/Jobs-_0026-Signals.md rename to zsh_manual/src/Jobs-&-Signals.md diff --git a/zsh_manual/src/Parameters.md b/zsh_manual/src/Parameters.md index 60a86c6..27992f1 100644 --- a/zsh_manual/src/Parameters.md +++ b/zsh_manual/src/Parameters.md @@ -1546,7 +1546,8 @@ lists and for the line editor. `LISTMAX` -In the line editor, the number of matches to list without asking most as +In the line editor, the number of matches to list without asking first. +If the value is negative, the list will be shown if it spans at most as many lines as given by the absolute value. If set to zero, the shell asks only if the top of the listing would scroll off the screen. diff --git a/zsh_manual/src/SUMMARY.md b/zsh_manual/src/SUMMARY.md index dfa3214..f925681 100644 --- a/zsh_manual/src/SUMMARY.md +++ b/zsh_manual/src/SUMMARY.md @@ -9,7 +9,7 @@ - [Redirection](./Redirection.md) - [Command Execution](./Command-Execution.md) - [Functions](./Functions.md) -- [Jobs & Signals](./Jobs-_0026-Signals.md) +- [Jobs & Signals](./Jobs-&-Signals.md) - [Arithmetic Evaluation](./Arithmetic-Evaluation.md) - [Conditional Expressions](./Conditional-Expressions.md) - [Prompt Expansion](./Prompt-Expansion.md)