├── .gitignore ├── .rubocop.yml ├── .yardopts ├── Dockerfile ├── Gemfile ├── Gemfile.lock ├── LICENSE ├── README.md ├── Rakefile ├── bin └── pandocomatic ├── documentation ├── README.md ├── acknowledgements.md ├── config.yaml ├── configuration.md ├── convert_a_document.md ├── convert_a_series_of_documents.md ├── data-dir │ ├── filters │ │ ├── insert_code_block.rb │ │ ├── insert_document.rb │ │ ├── insert_pandocomatic_version.rb │ │ ├── number_all_the_things.rb │ │ ├── number_chapters_and_sections_and_figures.rb │ │ └── remove_pandocomatic_metadata.rb │ ├── postprocessors │ │ ├── linkchecker.sh │ │ ├── setup_for_website.rb │ │ └── tidy.sh │ └── preprocessors │ │ └── site_menu.rb ├── development.md ├── faq.md ├── glossary.md ├── images │ ├── complete_conversion.dot │ ├── complete_conversion.svg │ ├── simple_conversion.dot │ └── simple_conversion.svg ├── install.md ├── introduction.md ├── license.md ├── manual.md ├── pandocomatic.yaml ├── pandocomatic_cli.md ├── pandocomatic_configuration.md ├── pandocomatic_templates.md ├── static_site_generator.md ├── usage.md ├── usage_examples.md ├── use_pandocomatic_as_a_static_site_generator.md ├── use_pandocomatic_to_automate_pandoc.md ├── website-config.yaml ├── website-history-config.yaml └── why_pandocomatic.md ├── example ├── all_templates.yaml ├── all_templates_with_renaming.yaml ├── authored_wiki.yaml ├── blog.yaml ├── cleanup.yaml ├── data-dir │ ├── bib.bib │ ├── filters │ │ └── now.rb │ ├── includes │ │ └── red.css │ ├── postprocessors │ │ └── branding.rb │ ├── preprocessors │ │ ├── add argument with spaces.rb │ │ ├── add_argument_to_metadata.rb │ │ └── now.rb │ ├── scripts │ │ ├── create_temp_file.sh │ │ ├── prefix_name_with_RENAMED.rb │ │ └── remove_temp_file.sh │ └── templates │ │ ├── authored_wiki.html │ │ ├── blog.html │ │ ├── date.md │ │ ├── extended_wiki.html │ │ ├── footnote.css │ │ ├── page.css │ │ ├── site.css │ │ ├── wiki.css │ │ ├── wiki.html │ │ └── wiki_with_arguments.html ├── dos.html ├── dos.md ├── dos.tex ├── dst │ ├── all_templates │ │ ├── config.html │ │ ├── config.pdf │ │ ├── index.html │ │ └── index.pdf │ ├── all_templates_with_renaming │ │ ├── RENAMED-config.pdf │ │ ├── RENAMED-index.pdf │ │ ├── config.html │ │ └── index.html │ ├── authored_wiki │ │ ├── config.html │ │ └── index.html │ ├── blog │ │ ├── first_post.html │ │ └── on_using_pandocomatic.html │ ├── extended_wiki │ │ ├── config.html │ │ ├── config.md │ │ ├── index.html │ │ └── index.md │ ├── odt_with_images │ │ ├── file1.odt │ │ ├── file2.odt │ │ └── subdir │ │ │ ├── file1.odt │ │ │ └── file2.odt │ ├── setup-cleanup-wiki │ │ ├── config.html │ │ └── index.html │ ├── site │ │ ├── authored_wiki │ │ │ ├── config.html │ │ │ └── index.html │ │ ├── blog │ │ │ ├── first_post.html │ │ │ └── on_using_pandocomatic.html │ │ ├── extended_wiki │ │ │ ├── config.html │ │ │ └── index.html │ │ ├── odt_with_images │ │ │ ├── file1.odt │ │ │ ├── file2.odt │ │ │ └── subdir │ │ │ │ ├── file1.odt │ │ │ │ └── file2.odt │ │ ├── public │ │ │ ├── blog.css │ │ │ └── wiki.css │ │ ├── setup-cleanup-wiki │ │ │ ├── config.html │ │ │ └── index.html │ │ ├── twice_extended_wiki │ │ │ ├── another_page.html │ │ │ ├── config.html │ │ │ ├── config2.html │ │ │ └── index.html │ │ ├── wiki │ │ │ ├── config.html │ │ │ └── index.html │ │ └── wiki_with_arguments │ │ │ ├── config.html │ │ │ └── index.html │ ├── twice_extended_wiki │ │ ├── another_page.html │ │ ├── config.html │ │ ├── config2.html │ │ └── index.html │ ├── wiki │ │ ├── config.html │ │ └── index.html │ └── wiki_with_arguments │ │ ├── config.html │ │ └── index.html ├── empty-properties.html ├── empty-properties.md ├── extended_wiki.yaml ├── extending_templates │ ├── config.yaml │ ├── data │ │ └── pandocomatic.yaml │ ├── extended_template.md │ └── extended_template.tex ├── extensions │ ├── beamer_presentation.md │ ├── beamer_presentation_plus_min_extensions.md │ ├── beamer_presentation_to_pdf.md │ └── beamer_presentation_to_pdf_with_extension_option.md ├── extract_pandoc_metadata_from_docx.yaml ├── hello_vars.html ├── hello_vars.md ├── hello_verbose_world.md ├── hello_world.docx ├── hello_world.html ├── hello_world.md ├── hello_world_to_tex.md ├── include.yaml ├── include_in_header_hello.md ├── inheritance │ ├── broken.yaml │ ├── data-dir │ │ ├── pandocomatic.yaml │ │ └── template.html │ ├── first.yaml │ ├── second.html │ └── second.md ├── manual │ ├── example_configuration_file.yaml │ ├── extended_example_configuration_file.yaml │ ├── external_goodbye_world.html │ ├── external_goodbye_world.md │ ├── external_goodbye_world2.html │ ├── external_goodbye_world2.md │ ├── external_hello_world.html │ ├── external_hello_world.md │ ├── hello_world.html │ ├── hello_world.md │ ├── my-config.yaml │ ├── my-extended-config.yaml │ ├── my_data_dir │ │ └── hello-template.html │ ├── tidy.sh │ ├── use_my_webpage.md │ └── use_my_webpage_and_print.md ├── multiple_input_files │ ├── book.md │ ├── chapter01.md │ ├── chapter02.md │ └── multiple_inputs.html ├── odt_with_images.yaml ├── only-comment-in-metadata.html ├── only-comment-in-metadata.md ├── pandocomatic.yaml ├── root_paths │ ├── config.yaml │ ├── data │ │ └── without_root_path.css │ ├── src │ │ ├── assets │ │ │ ├── main.css │ │ │ ├── root_relative_path.css │ │ │ └── root_relative_path_from_template.css │ │ ├── index.md │ │ └── subdir │ │ │ └── index.md │ ├── www-with-non-subdir-root-path │ │ ├── assets │ │ │ ├── main.css │ │ │ ├── root_relative_path.css │ │ │ └── root_relative_path_from_template.css │ │ ├── index.html │ │ └── subdir │ │ │ └── index.html │ ├── www-with-root-path │ │ ├── assets │ │ │ ├── main.css │ │ │ ├── root_relative_path.css │ │ │ └── root_relative_path_from_template.css │ │ ├── index.html │ │ └── subdir │ │ │ └── index.html │ └── www-without-root-path │ │ ├── assets │ │ ├── main.css │ │ ├── root_relative_path.css │ │ └── root_relative_path_from_template.css │ │ ├── index.html │ │ └── subdir │ │ └── index.html ├── setup-cleanup.yaml ├── setup.yaml ├── simple_date_in_metadata.md ├── site.yaml ├── src │ ├── authored_wiki │ │ ├── config.md │ │ ├── index.md │ │ └── pandocomatic.yaml │ ├── blog │ │ ├── first_post.md │ │ ├── on_using_pandocomatic.md │ │ └── pandocomatic.yaml │ ├── extended_wiki │ │ ├── config.md │ │ ├── index.md │ │ └── pandocomatic.yaml │ ├── odt_with_images │ │ ├── file1.md │ │ ├── file2.md │ │ ├── image.png │ │ ├── img │ │ │ └── image.png │ │ ├── pandocomatic.yaml │ │ └── subdir │ │ │ ├── file1.md │ │ │ ├── file2.md │ │ │ ├── image.png │ │ │ └── img │ │ │ └── image.png │ ├── public │ │ ├── blog.css │ │ └── wiki.css │ ├── setup-cleanup-wiki │ │ ├── config.md │ │ ├── index.md │ │ └── pandocomatic.yaml │ ├── twice_extended_wiki │ │ ├── another_page.markdown │ │ ├── config.md │ │ ├── config2.markdown │ │ ├── index.md │ │ └── pandocomatic.yaml │ ├── wiki │ │ ├── config.md │ │ ├── index.md │ │ └── pandocomatic.yaml │ └── wiki_with_arguments │ │ ├── config.md │ │ ├── index.md │ │ └── pandocomatic.yaml ├── subdir │ └── include_in_header_hello.md ├── test.rb ├── twice_extended_wiki.yaml ├── vars.yaml ├── wiki.yaml └── wiki_with_arguments.yaml ├── index.md ├── lib └── pandocomatic │ ├── cli.rb │ ├── command │ ├── command.rb │ ├── convert_dir_command.rb │ ├── convert_file_command.rb │ ├── convert_file_multiple_command.rb │ ├── convert_list_command.rb │ ├── copy_file_command.rb │ ├── create_link_command.rb │ └── skip_command.rb │ ├── configuration.rb │ ├── default_configuration.yaml │ ├── error │ ├── cli_error.rb │ ├── configuration_error.rb │ ├── io_error.rb │ ├── pandoc_error.rb │ ├── pandoc_metadata_error.rb │ ├── pandocomatic_error.rb │ ├── processor_error.rb │ └── template_error.rb │ ├── input.rb │ ├── multiple_files_input.rb │ ├── pandoc_metadata.rb │ ├── pandocomatic.rb │ ├── pandocomatic_yaml.rb │ ├── path.rb │ ├── printer │ ├── command_printer.rb │ ├── configuration_errors_printer.rb │ ├── error_printer.rb │ ├── finish_printer.rb │ ├── help_printer.rb │ ├── printer.rb │ ├── summary_printer.rb │ ├── unknown_error_printer.rb │ ├── version_printer.rb │ ├── views │ │ ├── cli_error.txt │ │ ├── command.txt │ │ ├── configuration_error.txt │ │ ├── configuration_errors.txt │ │ ├── error.txt │ │ ├── finish.txt │ │ ├── help.txt │ │ ├── io_error.txt │ │ ├── pandoc_error.txt │ │ ├── pandoc_metadata_error.txt │ │ ├── processor_error.txt │ │ ├── summary.txt │ │ ├── template_error.txt │ │ ├── unknown_error.txt │ │ ├── version.txt │ │ └── warning.txt │ └── warning_printer.rb │ ├── processor.rb │ ├── processors │ ├── fileinfo_preprocessor.rb │ └── metadata_preprocessor.rb │ ├── template.rb │ ├── version.rb │ └── warning.rb ├── pandocomatic.gemspec ├── pandocomatic.yaml └── test ├── files ├── config.yaml ├── readable_test_dir │ └── some_file ├── readable_test_file ├── readable_test_file2 └── unwritable_test_dir │ └── some_file ├── pandocomatic.rb ├── simple_test.rb ├── test_helper.rb └── unit ├── cli.rb ├── configuration.rb ├── pandoc_metadata.rb ├── pandocomatic.rb └── pandocomatic_yaml.rb /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | ~* 3 | *.swp 4 | *.bak 5 | *.log 6 | 7 | documentation/api-doc 8 | .yardoc 9 | 10 | hello_world.html 11 | pandocomatic.log 12 | 13 | # Artifacts from running rake in docker 14 | .bash_history 15 | .texlive2020/ 16 | 17 | .cache 18 | 19 | *.code-workspace 20 | 21 | .local 22 | 23 | .bundle 24 | pkg 25 | -------------------------------------------------------------------------------- /.rubocop.yml: -------------------------------------------------------------------------------- 1 | AllCops: 2 | TargetRubyVersion: 3.2 3 | NewCops: enable 4 | StyleGuideBaseURL: https://rubystyle.guide 5 | Metrics/ClassLength: 6 | Max: 150 7 | Metrics/MethodLength: 8 | Max: 25 9 | -------------------------------------------------------------------------------- /.yardopts: -------------------------------------------------------------------------------- 1 | --title Pandocomatic API documentation 2 | --embed-mixins 3 | --output-dir documentation/api-doc 4 | --readme documentation/README.md 5 | --no-private 6 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ruby:3.4 2 | ENV LANG=C.UTF-8 3 | RUN apt-get update \ 4 | ; apt-get install -y --no-install-recommends wget groff ghostscript \ 5 | ; wget -q https://github.com/jgm/pandoc/releases/download/3.6.4/pandoc-3.6.4-1-amd64.deb \ 6 | ; apt-get install ./pandoc-3.6.4-1-amd64.deb \ 7 | ; useradd -ms /bin/bash pandocomatic-user 8 | USER pandocomatic-user 9 | SHELL ["/bin/bash", "-l", "-c"] 10 | COPY --chown=pandocomatic-user:pandocomatic-user . /home/pandocomatic-user/ 11 | WORKDIR /home/pandocomatic-user 12 | RUN gem install bundler \ 13 | ; bundler install 14 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | gemspec 3 | 4 | # Development dependencies 5 | gem 'minitest', '~> 5.25.1' 6 | gem 'minitest-reporters', '~> 1.7.1' 7 | gem 'rake', '~> 13.2.1' 8 | gem 'rdoc', '~> 6.13', '>= 6.13.1' 9 | gem 'rubocop', '~> 1.66.1' 10 | gem 'yard', '~> 0.9.37' 11 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | PATH 2 | remote: . 3 | specs: 4 | pandocomatic (2.0.1) 5 | logger 6 | optimist (~> 3.1, >= 3.1) 7 | paru (~> 1.1, >= 1.4.1) 8 | 9 | GEM 10 | remote: https://rubygems.org/ 11 | specs: 12 | ansi (1.5.0) 13 | ast (2.4.2) 14 | builder (3.3.0) 15 | csv (3.3.0) 16 | json (2.7.2) 17 | language_server-protocol (3.17.0.3) 18 | logger (1.6.1) 19 | minitest (5.25.1) 20 | minitest-reporters (1.7.1) 21 | ansi 22 | builder 23 | minitest (>= 5.0) 24 | ruby-progressbar 25 | optimist (3.1.0) 26 | parallel (1.26.3) 27 | parser (3.3.5.0) 28 | ast (~> 2.4.1) 29 | racc 30 | paru (1.4.1) 31 | csv (~> 3.3) 32 | psych (5.1.2) 33 | stringio 34 | racc (1.8.1) 35 | rainbow (3.1.1) 36 | rake (13.2.1) 37 | rdoc (6.6.3.1) 38 | psych (>= 4.0.0) 39 | regexp_parser (2.9.2) 40 | rubocop (1.66.1) 41 | json (~> 2.3) 42 | language_server-protocol (>= 3.17.0) 43 | parallel (~> 1.10) 44 | parser (>= 3.3.0.2) 45 | rainbow (>= 2.2.2, < 4.0) 46 | regexp_parser (>= 2.4, < 3.0) 47 | rubocop-ast (>= 1.32.2, < 2.0) 48 | ruby-progressbar (~> 1.7) 49 | unicode-display_width (>= 2.4.0, < 3.0) 50 | rubocop-ast (1.32.3) 51 | parser (>= 3.3.1.0) 52 | ruby-progressbar (1.13.0) 53 | stringio (3.1.1) 54 | unicode-display_width (2.6.0) 55 | yard (0.9.37) 56 | 57 | PLATFORMS 58 | ruby 59 | x86_64-linux 60 | 61 | DEPENDENCIES 62 | minitest (~> 5.25.1) 63 | minitest-reporters (~> 1.7.1) 64 | pandocomatic! 65 | rake (~> 13.2.1) 66 | rdoc 67 | rubocop (~> 1.66.1) 68 | yard (~> 0.9.37) 69 | 70 | BUNDLED WITH 71 | 2.5.16 72 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require 'bundler/gem_tasks' 2 | require 'rake/testtask' 3 | require 'rubocop/rake_task' 4 | require 'yard' 5 | 6 | Rake::TestTask.new do |t| 7 | t.libs << 'lib' 8 | t.libs << 'lib/pandocomatic' 9 | t.test_files = FileList['test/test_helper.rb', 'test/unit/*.rb'] 10 | t.warning = true 11 | t.verbose = true 12 | end 13 | 14 | RuboCop::RakeTask.new(:rubocop) do |t| 15 | t.patterns = ['lib/'] 16 | t.fail_on_error = true 17 | end 18 | 19 | YARD::Rake::YardocTask.new do |t| 20 | t.files = ['lib/**/*.rb'] 21 | t.stats_options = ['--list-undoc'] 22 | end 23 | 24 | task :generate_docs do 25 | sh %( 26 | cd documentation; 27 | ../test/pandocomatic.rb --data-dir data-dir --config config.yaml --input manual.md --output ../index.md; 28 | ../test/pandocomatic.rb --data-dir data-dir --config config.yaml --input README.md --output ../README.md 29 | ) 30 | end 31 | 32 | task :build do 33 | Rake::Task[:rubocop].execute 34 | Rake::Task[:test].execute 35 | Rake::Task[:yard].execute 36 | Rake::Task['generate_docs'].execute 37 | end 38 | 39 | task default: :test 40 | -------------------------------------------------------------------------------- /bin/pandocomatic: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require 'pandocomatic/pandocomatic' 3 | Pandocomatic::Pandocomatic.run ARGV 4 | -------------------------------------------------------------------------------- /documentation/README.md: -------------------------------------------------------------------------------- 1 | --- 2 | pandocomatic_: 3 | use-template: mddoc 4 | pandoc: 5 | to: gfm 6 | ... 7 | 8 | [![Gem Version](https://badge.fury.io/rb/pandocomatic.svg)](https://badge.fury.io/rb/pandocomatic) 9 | 10 | # Pandocomatic—Automate the use of pandoc 11 | 12 | ::paru::insert introduction.md 13 | 14 | **Note.** As I am a GNU/Linux user, I do not officially support other operating 15 | systems like Mac OSX or Windows. Fixes and patches for those operating systems 16 | are welcome. 17 | 18 | See [pandocomatic's 19 | manual](https://heerdebeer.org/Software/markdown/pandocomatic/) for an 20 | extensive description of pandocomatic. 21 | 22 | ::paru::insert why_pandocomatic.md 23 | 24 | ::paru::insert license.md 25 | 26 | ::paru::insert install.md 27 | 28 | ## Examples 29 | 30 | ::paru::insert usage_examples.md 31 | 32 | ## More information 33 | 34 | See [pandocomatic's 35 | manual](https://heerdebeer.org/Software/markdown/pandocomatic/) for more 36 | extensive examples of using pandocomatic. 37 | -------------------------------------------------------------------------------- /documentation/acknowledgements.md: -------------------------------------------------------------------------------- 1 | ## Acknowledgements 2 | 3 | Thanks to [Ian](https://github.com/iandol) for his contribution of patches, 4 | bug reports, fixes, and suggestions. With your help pandocomatic is growing 5 | beyond a simple tool for personal use into a useful addition to the pandoc 6 | ecosystem. 7 | -------------------------------------------------------------------------------- /documentation/config.yaml: -------------------------------------------------------------------------------- 1 | templates: 2 | mddoc: 3 | pandoc: 4 | from: markdown 5 | to: markdown 6 | standalone: true 7 | filter: 8 | - filters/insert_document.rb 9 | - filters/insert_code_block.rb 10 | - filters/remove_pandocomatic_metadata.rb 11 | - filters/insert_pandocomatic_version.rb 12 | indexdoc: 13 | extends: mddoc 14 | postprocessors: ['postprocessors/setup_for_website.rb'] 15 | -------------------------------------------------------------------------------- /documentation/configuration.md: -------------------------------------------------------------------------------- 1 | Pandocomatic is configured by a combination of command-line options and 2 | configuration files. 3 | 4 | Each input file that is converted by pandocomatic is processed as follows: 5 | 6 | 7 | START 8 | ⇢ setup₀ 9 | … 10 | setupᵣ 11 | input_file → preprocessor₀ 12 | … 13 | preprocessorₙ 14 | 15 | → pandoc 16 | 17 | → postprocessor₀ 18 | … 19 | output_file ← postprocessorₘ 20 | ⇢ cleanup₀ 21 | … 22 | cleanupₚ 23 | END 24 | 25 | You specify the cleanup script, the preprocessors scripts, postprocessors 26 | scripts, and cleanup scritps to use in the conversion process in pandocomatic 27 | templates. Besides processors, you can also specify pandoc options to use to 28 | convert an input file. You specify these templates in a configuration file. 29 | Templates can be used over and over, thus automating the use of pandoc. 30 | 31 | Write your configuration files in [YAML](http://www.yaml.org/). These 32 | configuration files contain the following properties: 33 | 34 | - **settings**: 35 | - **skip**: An array of 36 | [glob](https://en.wikipedia.org/wiki/Glob_(programming)) patterns of 37 | files and directories that pandocomatic will not touch or convert. By 38 | default, pandocomatic skips hidden files, i.e. files with a name 39 | starting with a ".", and the default pandocomatic configuration file 40 | "pandocomatic.yaml". 41 | - **recursive**: A boolean property instructing pandocomatic to convert 42 | the subdirectories of a directory as well. By default this setting is 43 | `true`. 44 | - **follow_links**: A boolean property telling pandocomatic to follow 45 | symbolic links. By default, this option is `true`. Note, pandocomatic 46 | will *never* visit links that point outside the input source's 47 | directory tree. 48 | - **templates**: 49 | - **glob**: An array of glob patterns of filenames that pandocomatic 50 | converts automatically using this template. 51 | - **setup**: An array of scripts to run before the preprocessors start 52 | working on the input. These startup scripts typically setup the 53 | environment wherein the conversion takes place. For example, creating 54 | a temporary working directory, copying static assets like images, and 55 | so on. 56 | - **preprocessors**: An array of scripts to run on an input file before 57 | converting the output of those scripts with pandoc. 58 | - **metadata**: 59 | - **pandoc**: Pandoc options to use when converting an input file using 60 | this template. 61 | - **postprocessors**: An array of scripts to run on the result of the 62 | pandoc conversion. The output of these scripts will be written to the 63 | output file. 64 | - **cleanup**: An array of scripts that run after the conversion process 65 | and postprocessors have finished. These cleanup scripts typically 66 | clean up the environment. 67 | 68 | Each file and directory that is converted can contain a configuration YAML 69 | metadata block or a YAML configuration file respectively. In a file, the 70 | property *use-template* tells pandocomatic which template to use to convert 71 | that file. 72 | 73 | See the next two chapters for more extensive examples of using and configuring 74 | pandocomatic. 75 | -------------------------------------------------------------------------------- /documentation/data-dir/filters/insert_code_block.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require 'paru/filter' 3 | 4 | Paru::Filter.run do 5 | with 'CodeBlock' do |code_block| 6 | command, path, *classes = code_block.string.strip.split ' ' 7 | if command == '::paru::insert' 8 | # prepend a space for each line to prevent pandocomatic to interpret 9 | # YAML code blocks as pandoc YAML metadata 10 | code_lines = File.readlines path.gsub('\\_', '_') 11 | code_block.string = code_lines.map { |l| ' ' + l }.join 12 | classes.each { |c| code_block.attr.classes.push c } 13 | end 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /documentation/data-dir/filters/insert_document.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require 'paru/filter' 3 | 4 | Paru::Filter.run do 5 | with 'Para' do |paragraph| 6 | if paragraph.inner_markdown.lines.length == 1 7 | command, path = paragraph.inner_markdown.strip.split ' ' 8 | if command == '::paru::insert' 9 | markdown = File.read path.gsub('\\_', '_') 10 | paragraph.outer_markdown = markdown 11 | end 12 | end 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /documentation/data-dir/filters/insert_pandocomatic_version.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # A filter to insert paru's version. All occurrences of 3 | # '::paru::version' are replaced by paru's version. 4 | require_relative '../../../lib/pandocomatic/pandocomatic' 5 | require 'paru/filter' 6 | 7 | # Get pandocomatic's version 8 | def version(str) 9 | str.gsub '::pandocomatic::version', Pandocomatic::VERSION.join('.') 10 | end 11 | 12 | Paru::Filter.run do 13 | with 'Str' do |str| 14 | str.string = version(str.string) 15 | end 16 | 17 | with 'CodeBlock' do |code| 18 | code.string = version(code.string) 19 | end 20 | 21 | with 'Link' do |link| 22 | link.target.url = version(link.target.url) 23 | link.target.title = version(link.target.title) 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /documentation/data-dir/filters/number_all_the_things.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require 'paru/filter' 3 | 4 | # Just a simple converter: only need about 4 or 5 at the moment 5 | def integer_to_roman(n) 6 | case n 7 | when 1 then 'I' 8 | when 2 then 'II' 9 | when 3 then 'III' 10 | when 4 then 'IV' 11 | when 5 then 'V' 12 | when 6 then 'VI' 13 | end 14 | end 15 | 16 | current_part = 0 17 | current_chapter = 0 18 | current_section = 0 19 | current_figure = 0 20 | 21 | Paru::Filter.run do 22 | with 'Header' do |header| 23 | if header.level == 1 24 | current_part += 1 25 | current_figure = 0 26 | current_section = 0 27 | 28 | header.inner_markdown = 29 | "Part #{integer_to_roman current_part}. #{header.inner_markdown}" 30 | end 31 | 32 | if header.level == 2 33 | current_chapter += 1 34 | current_figure = 0 35 | current_section = 0 36 | 37 | header.inner_markdown = 38 | "Chapter #{current_chapter}. #{header.inner_markdown}" 39 | end 40 | 41 | if header.level == 3 42 | current_section += 1 43 | header.inner_markdown = 44 | "#{current_chapter}.#{current_section} #{header.inner_markdown}" 45 | end 46 | end 47 | 48 | with 'Header + Image' do |image| 49 | current_figure += 1 50 | image.inner_markdown = 51 | "Figure #{current_chapter}.#{current_figure} #{image.inner_markdown}" 52 | end 53 | end 54 | -------------------------------------------------------------------------------- /documentation/data-dir/filters/number_chapters_and_sections_and_figures.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require 'paru/filter' 3 | 4 | current_chapter = 0 5 | current_section = 0 6 | current_figure = 0 7 | 8 | Paru::Filter.run do 9 | with 'Header' do |header| 10 | if header.level == 1 11 | current_chapter += 1 12 | current_figure = 0 13 | current_section = 0 14 | 15 | header.inner_markdown = "Chapter #{current_chapter}. #{header.inner_markdown}" 16 | end 17 | 18 | if header.level == 2 19 | current_section += 1 20 | header.inner_markdown = 21 | "#{current_chapter}.#{current_section} #{header.inner_markdown}" 22 | end 23 | end 24 | 25 | with 'Header + Image' do |image| 26 | current_figure += 1 27 | image.inner_markdown = 28 | "Figure #{current_chapter}.#{current_figure} #{image.inner_markdown}" 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /documentation/data-dir/filters/remove_pandocomatic_metadata.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require 'paru/filter' 3 | 4 | Paru::Filter.run do 5 | metadata.delete 'pandocomatic' if metadata.has_key? 'pandocomatic' 6 | metadata.delete 'pandocomatic_' if metadata.has_key? 'pandocomatic_' 7 | metadata.delete 'pandocomatic-fileinfo' if metadata.has_key? 'pandocomatic-fileinfo' 8 | end 9 | -------------------------------------------------------------------------------- /documentation/data-dir/postprocessors/linkchecker.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | INPUT=`cat` 3 | file_to_check="/tmp/FILE_TO_LINK_CHECK.html" 4 | echo "$INPUT" > $file_to_check 5 | linkchecker --no-status --anchors --check-extern $file_to_check 1>&2 6 | cat $file_to_check 7 | -------------------------------------------------------------------------------- /documentation/data-dir/postprocessors/setup_for_website.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | puts $stdin.read 4 | puts "\n" 5 | puts '---' 6 | puts 'pandocomatic_:' 7 | puts ' pandoc:' 8 | puts ' filter:' 9 | puts " - './documentation/data-dir/filters/number_all_the_things.rb'" 10 | puts ' number-sections: false' 11 | puts '...' 12 | -------------------------------------------------------------------------------- /documentation/data-dir/postprocessors/tidy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | tidy -quiet -clean -indent -wrap 78 -utf8 3 | -------------------------------------------------------------------------------- /documentation/data-dir/preprocessors/site_menu.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require 'yaml' 3 | require 'pandocomatic/pandoc_metadata' 4 | 5 | input = $stdin.read 6 | puts input 7 | 8 | metadata = YAML.load Pandocomatic::PandocMetadata.pandoc2yaml(input) 9 | if metadata['fileinfo'] and metadata['fileinfo']['path'] 10 | path = metadata['fileinfo']['path'] 11 | site_menu = { 'site-menu' => [] } 12 | uppath = '/' 13 | File.dirname(path).split('/')[1..-1].each do |updir| 14 | uppath += "#{updir}/" 15 | item = { 16 | 'name' => updir.split('_').join(' '), 17 | 'url' => uppath 18 | } 19 | site_menu['site-menu'].push item 20 | end 21 | puts YAML.dump(site_menu) 22 | puts '...' 23 | end 24 | -------------------------------------------------------------------------------- /documentation/development.md: -------------------------------------------------------------------------------- 1 | # Pandocomatic Development 2 | 3 | ## Using Docker 4 | 5 | For more information about using docker, you can read the official manual. I 6 | like the [Chowdhury's (2021) *The Docker 7 | Handbook*](https://www.freecodecamp.org/news/the-docker-handbook/) a lot as a short but 8 | complete introductory tutorial. Once you're up and running with Docker, you 9 | can use Docker for paru development. 10 | 11 | ### Common Docker Tasks 12 | 13 | - Create a new version of the Docker image with Ruby and Pandoc defined in 14 | `Dockerfile`: 15 | 16 | ```{.bash} 17 | docker image build --tag pandocomatic:dev . 18 | ``` 19 | 20 | - Run a command interactively (CLI options `-i`, `-t`) in the Docker container, and remove the container afterwards 21 | (CLI option `--rm`). Also attach pandocomatic's cloned repository to the container 22 | (CLI option `--volume $(pwd):/home/pandocomatic-user`): 23 | 24 | ```{.bash} 25 | docker container run --rm -it --volume $(pwd):/home/pandocomatic-user pandocomatic:dev bash 26 | ``` 27 | 28 | You can also run rake, for example, to run all pandocomatic's test suites. 29 | -------------------------------------------------------------------------------- /documentation/faq.md: -------------------------------------------------------------------------------- 1 | ## Frequently asked questions (FAQ) {#faq} 2 | 3 | ### How do I use pandoc2 with pandocomatic? 4 | 5 | Pandocomatic uses [paru](https://heerdebeer.org/Software/markdown/paru/) to 6 | run pandoc. Paru itself uses the `pandoc` executable in your `PATH`. If that 7 | already is pandoc2, you do not need to do anything. 8 | 9 | If you have pandoc1 installed by default, however, and you want to run a 10 | [nightly version of pandoc2](https://github.com/pandoc-extras/pandoc-nightly), 11 | you have to set the `PARU_PANDOC_PATH` to point to the pandoc2 executable. For 12 | example: 13 | 14 | ```{.bash} 15 | export PARU_PANDOC_PATH=~/Downloads/pandoc-amd64-7c20fab3/pandoc 16 | pandocomatic some-file-to-convert.md 17 | ``` 18 | 19 | ### Pandocomatic has too much output! How do I make pandocomatic more quiet? 20 | 21 | You can run pandoc in quiet mode by using the `--quiet` or `-q` command-line 22 | option. For example: 23 | 24 | ```{.bash} 25 | pandocomatic --quiet some-file-to-export.md 26 | ``` 27 | -------------------------------------------------------------------------------- /documentation/glossary.md: -------------------------------------------------------------------------------- 1 | ## Glossary 2 | 3 | pandocomatic template 4 | 5 | : A pandocomatic template specified the conversion process executed by 6 | pandocomatic. It can contain the following properties: 7 | 8 | - glob 9 | - extends 10 | - setup 11 | - preprocessors 12 | - metadata 13 | - pandoc 14 | - postprocessors 15 | - cleanup 16 | 17 | internal pandocomatic template 18 | 19 | : A pandocomatic template specified in a pandoc markdown file itself via the 20 | YAML metadata property `pandocomatic_`. 21 | 22 | external pandocomatic template 23 | 24 | : A pandocomatic template specified in a *pandocomatic configuration file*. 25 | 26 | preprocessors 27 | 28 | : A preprocessor applied to an input document before running pandoc. 29 | 30 | postprocessors 31 | 32 | : A postprocessor applied to an input document after running pandoc. 33 | 34 | pandocomatic data directory 35 | 36 | : The directory used by pandocomatic to resolve relative paths. Use this 37 | directory to store preprocessors, pandoc templates, pandoc filters, 38 | postprocessors, setup scripts, and cleanup scripts. It defaults to pandoc's data 39 | directory. 40 | 41 | pandocomatic configuration file 42 | 43 | : The configuration file specifying *external pandocomatic templates* as 44 | well as settings for converting a directory tree. Defaults to 45 | `pandocomatic.yaml`. 46 | 47 | extending pandocomatic templates 48 | 49 | : *External pandocomatic templates* can extend other *external pandocomatic 50 | templates*. By using multiple smaller *external pandocomatic templates* it is 51 | possible to setup your templates in a modular way. Pandocomatic supports 52 | extending from multiple *external pandocomatic templates*. 53 | 54 | static-site generator 55 | 56 | : Pandocomatic can be used as a static-site generator by running 57 | pandocomatic recursivel on a directory. Pandocomatic has some specific 58 | congiguration options to be used as a static-site generator. 59 | -------------------------------------------------------------------------------- /documentation/images/complete_conversion.dot: -------------------------------------------------------------------------------- 1 | digraph simple_conversion { 2 | rankdir="LR" 3 | { 4 | node [shape=diamond] 5 | setup 6 | cleanup 7 | node [shape=note] 8 | input 9 | output 10 | node [shape=doublecircle] 11 | pandoc 12 | node [shape=circle,labelangle=45] 13 | pre_1 [label=
]
14 |         pre_N [label=
]
15 |         post_1 [label=]
16 |         post_M [label=]
17 |         node [shape="none", label="..."]
18 |         dots1
19 |         dots2
20 |     }
21 |     
22 |     setup ->  input -> pre_1 -> dots1 -> pre_N -> pandoc -> post_1
23 |     -> dots2 -> post_M -> output -> cleanup
24 | }
25 | 


--------------------------------------------------------------------------------
/documentation/images/simple_conversion.dot:
--------------------------------------------------------------------------------
 1 | digraph simple_conversion {
 2 |     rankdir="LR"
 3 |     {
 4 |         node [shape=note]
 5 |         input
 6 |         output
 7 |         node [shape=doublecircle]
 8 |         pandoc
 9 |         node [shape=circle,labelangle=45]
10 |         pre_1 [label=
]
11 |         pre_N [label=
]
12 |         post_1 [label=]
13 |         post_M [label=]
14 |         node [shape="none", label="..."]
15 |         dots1
16 |         dots2
17 |     }
18 |     
19 |     input -> pre_1 -> dots1 -> pre_N -> pandoc -> post_1
20 |     -> dots2 -> post_M -> output
21 | }
22 | 


--------------------------------------------------------------------------------
/documentation/install.md:
--------------------------------------------------------------------------------
 1 | ## Installation
 2 | 
 3 | Pandocomatic is a [Ruby](https://www.ruby-lang.org/en/) program and can be
 4 | installed through [RubyGems](https://rubygems.org/) as follows:
 5 | 
 6 | ~~~{.bash}
 7 | gem install pandocomatic
 8 | ~~~
 9 | 
10 | This will install pandocomatic and
11 | [paru](https://heerdebeer.org/Software/markdown/paru/), a Ruby wrapper around
12 | pandoc. To use pandocomatic, you also need a working pandoc installation. See
13 | [pandoc's installation guide](https://pandoc.org/installing.html) for more
14 | information about installing pandoc.
15 | 
16 | ### Docker
17 | 
18 | You can also build and install the latest version yourself by running the
19 | following commands:
20 | 
21 | ~~~{.bash}
22 | cd /directory/you/downloaded/the/gem/to
23 | docker image build --tag pandocomatic:dev .
24 | docker container run --rm -it --volume $(pwd):/home/pandocomatic-user pandocomatic:dev bundle exec rake build
25 | gem install pkg/pandocomatic-::pandocomatic::version.gem
26 | ~~~ 
27 | 
28 | You only have to do the second step one time. Once you've created a docker
29 | image, you can reuse it as is until `Dockerfile` changes.
30 | 
31 | ### MacOS: Brew
32 | 
33 | Alternatively, MacOS users can install pandocomatic via
34 | [homebrew](https://formulae.brew.sh/formula/pandocomatic):
35 | 
36 | ~~~{.bash}
37 | brew install pandocomatic
38 | ~~~
39 | 
40 | 


--------------------------------------------------------------------------------
/documentation/introduction.md:
--------------------------------------------------------------------------------
 1 | Pandocomatic automates the use of [pandoc](https://pandoc.org/).  With
 2 | pandocomatic you can express common patterns of using pandoc for generating
 3 | your documents. Applied to a directory, pandocomatic acts as a static site
 4 | generator. For example, this manual is generated with pandocomatic!
 5 | 
 6 | Pandocomatic is [free
 7 | software](https://www.gnu.org/philosophy/free-sw.en.html); pandocomatic is
 8 | released under the [GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html).  You
 9 | will find the source code of pandocomatic in its
10 | [repository](https://github.com/htdebeer/pandocomatic) on
11 | [Github](https://github.com).
12 | 
13 | **Note.** Pandocomatic is build on top of
14 | [paru](https://github.com/htdebeer/paru), which is a wrapper around pandoc.
15 | 


--------------------------------------------------------------------------------
/documentation/license.md:
--------------------------------------------------------------------------------
1 | Pandocomatic is [free software](https://www.gnu.org/philosophy/free-sw.en.html); pandocomatic
2 | is released under the [GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html).
3 | You find pandocomatic's source code on [github](https://github.com/htdebeer/pandocomatic).
4 | 


--------------------------------------------------------------------------------
/documentation/manual.md:
--------------------------------------------------------------------------------
 1 | ---
 2 | title: Pandocomatic
 3 | subtitle: Automate the use of pandoc
 4 | author: Huub de Beer
 5 | date: April 6th, 2019
 6 | keywords:
 7 | - pandoc
 8 | - ruby
 9 | - paru
10 | - pandocomatic
11 | - static site generator
12 | pandocomatic_:
13 |   use-template: indexdoc
14 | ...
15 | 
16 | # Introduction {#introduction}
17 | 
18 | ::paru::insert introduction.md
19 | 
20 | ::paru::insert acknowledgements.md
21 | 
22 | ::paru::insert install.md
23 | 
24 | ::paru::insert why_pandocomatic.md
25 | 
26 | ------------------------------------------
27 | 
28 | # Using pandocomatic: Quick start and overview {#using-pandocomatic}
29 | 
30 | ::paru::insert convert_a_document.md
31 | 
32 | ::paru::insert convert_a_series_of_documents.md
33 | 
34 | ::paru::insert static_site_generator.md
35 | 
36 | ------------------------------------------
37 | 
38 | # Reference: All about pandocomatic {#reference}
39 | 
40 | ::paru::insert pandocomatic_cli.md
41 | 
42 | ::paru::insert pandocomatic_configuration.md
43 | 
44 | ::paru::insert pandocomatic_templates.md
45 | 
46 | ------------------------------------------
47 | 
48 | # Appendix {#appendix}
49 | 
50 | ::paru::insert faq.md
51 | 
52 | ::paru::insert glossary.md
53 | 


--------------------------------------------------------------------------------
/documentation/pandocomatic.yaml:
--------------------------------------------------------------------------------
1 | settings:
2 |     skip: ['*.md']
3 | 


--------------------------------------------------------------------------------
/documentation/static_site_generator.md:
--------------------------------------------------------------------------------
 1 | ## Converting a directory tree of documents
 2 | 
 3 | Once you have created a number of documents that can be converted by
 4 | pandocomatic and you change something significant in one of the *external
 5 | pandocomatic templates*, you have to run pandocomatic on all of the documents
 6 | again to propagate the changes. That is fine for a document or two, but more
 7 | than that and it becomes a chore.
 8 | 
 9 | For example, if you change the HTML template `hello-template.html` in the
10 | *pandocomatic data directory*, or switch to another template, you need to
11 | regenerate all documents you have already converted with the old HTML
12 | template. If you run pandocomatic on an input directory rather than on an input
13 | file, it will convert all files in that directory, recursively. 
14 | 
15 | Thus, to convert the example files used in this chapter, you can run
16 | 
17 | ```{.bash}
18 | pandocomatic -d my_data_dir -c my-extended-config.yaml -i manual -o output_dir
19 | ```
20 | 
21 | It will convert all files in the directory `manual` and place the generated
22 | documents in the output directory `output_dir`.
23 | 
24 | From here it is but a small step to use pandocomatic as a **static-site
25 | generator**. For that purpose some configuration options are available:
26 | 
27 | -   a settings property in a *pandocomatic configuration file* to control
28 |     -   running pandocomatic recursively or not
29 |     -   follow symbolic links or not
30 | -   a `glob` property in an *external pandocomatic template* telling
31 |     pandocomatic which files in the directory to apply the template to. As a
32 |     convention, a file named `pandocomatic.yaml` in a directory is used as the
33 |     *pandocomatic configuration file* to control the conversion of the files
34 |     in that directory
35 | -   a command-line option `--modified-only` to only convert the files that
36 |     have changes rather than to convert all files in the directory.
37 | 
38 | With these features, you can (re)generate a website with the pandocomatic
39 | invocation:
40 | 
41 | ```{.bash}
42 | pandocomatic -d data_dir -c intitial_config.yaml -i src -o www --modified-only
43 | ```
44 | 
45 | For more detailed information about pandocomatic, please see the
46 | [Reference](#reference) section of this manual.
47 | 


--------------------------------------------------------------------------------
/documentation/usage.md:
--------------------------------------------------------------------------------
 1 | You run pandocomatic like:
 2 | 
 3 | ~~~{.bash}
 4 | pandocomatic --dry-run --output index.html --input my_doc.md
 5 | ~~~
 6 | 
 7 | Pandocomatic takes a number of arguments which at the least should include the
 8 | input and output files or directories. The general form of a pandocomatic
 9 | invocation is:
10 | 
11 |     pandocomatic options [INPUT]
12 | 
13 | The required and optional arguments are discussed next, followed by some
14 | examples. See next chapter for a more in-depth coverage of the configuration
15 | of pandocomatic.
16 | 
17 | ## Required arguments
18 | 
19 | Two arguments are required when running pandocomatic: the input file or
20 | directory and the output file or directory:
21 | 
22 | `-i PATH, --input PATH`
23 | 
24 | :   Convert `PATH`. If this option is not given, `INPUT` is converted. `INPUT`
25 |     and `--input` or `-i` cannot be used together.
26 | 
27 | `-o PATH, --output PATH`
28 | 
29 | :   Create converted files and directories in `PATH`.
30 |   
31 |     Although inadvisable, you can specify the output file in the metadata of a
32 |     pandoc markdown input file. In that case, you can omit the output
33 |     argument.
34 | 
35 | The input and output should both be files or both be directories.
36 | 
37 | ## Optional arguments
38 | 
39 | Besides the two required arguments, there are two arguments to configure
40 | pandocomatic, three arguments to change how pandocomatic operates, and the
41 | conventional help and version arguments.
42 | 
43 | ### Arguments to configure pandocomatic
44 | 
45 | `-d DIR, --data-dir DIR`
46 | 
47 | :   Configure pandocomatic to use `DIR` as its data directory. The default
48 |     data directory is pandoc's data directory. (Run `pandoc --version` to find
49 |     pandoc's data directory on your system.)
50 | 
51 | `-c FILE, --config FILE`
52 | 
53 | :   Configure pandocomatic to use `FILE` as its configuration file to use
54 |     during the conversion process. Default is `DATA_DIR/pandocomatic.yaml`.
55 | 
56 | ### Arguments to change how pandocomatic operates
57 | 
58 | `-m, --modified-only`
59 | 
60 | :   Only convert files that have been modified since the last time
61 |     pandocomatic has been run. Or, more precisely, only those source files
62 |     that have been updated at later time than the corresponding destination
63 |     files will be converted, copied, or linked.  Default is `false`.
64 | 
65 | `-q, --quiet`
66 | 
67 | :   By default pandocomatic is quite verbose when you convert a directory. It
68 |     tells you about the number of commands to execute. When executing these
69 |     commands, pandocomatic tells you what it is doing, and how many commands
70 |     still have to be executed. Finally, when pandocomatic is finished, it
71 |     tells you how long it took to perform the conversion.
72 |   
73 |     If you do not like this verbose behavior, use the `--quiet` or `-q`
74 |     argument to run pandocomatic quietly. Default is `false`.
75 | 
76 | `-y, --dry-run`
77 | 
78 | :   Inspect the files and directories to convert, but do not actually run the
79 |     conversion. Default is `false`.
80 | 
81 | ### Conventional arguments: help and version
82 | 
83 | `-v, --version`
84 | 
85 | :   Show the version. If this option is used, all other options are ignored.
86 | 
87 | `-h, --help`
88 | 
89 | :   Show a short help message. If this options is used, all other options
90 |     except `--version` or `-v` are ignored.
91 | 


--------------------------------------------------------------------------------
/documentation/website-config.yaml:
--------------------------------------------------------------------------------
 1 | settings:
 2 |     recursive: true
 3 |     follow-links: false
 4 |     skip: ['.*', 'pandocomatic.yaml']
 5 | templates:
 6 |     page:
 7 |         glob: ['*.markdown', '*.md']
 8 |         preprocessors: ['preprocessors/site_menu.rb']
 9 |         pandoc:
10 |             from: markdown
11 |             to: html5
12 |             standalone: true
13 |             template: 'templates/page.html'
14 |             csl: 'apa.csl'
15 |             toc: true
16 |             mathjax: true
17 |         postprocessors: ['postprocessors/tidy.sh']
18 | 


--------------------------------------------------------------------------------
/documentation/website-history-config.yaml:
--------------------------------------------------------------------------------
1 | templates:
2 |     page:
3 |         pandoc:
4 |             csl: 'chicago-fullnote-bibliography.csl'
5 | 


--------------------------------------------------------------------------------
/example/all_templates.yaml:
--------------------------------------------------------------------------------
 1 | settings:
 2 |   recursive: true
 3 |   follow-links: false
 4 |   match-files: all
 5 | templates:
 6 |   wiki-page:
 7 |     glob: ['*.md']
 8 |     preprocessors:
 9 |       - 'preprocessors/now.rb'
10 |     pandoc:
11 |       from: markdown
12 |       to: html5
13 |       standalone: true
14 |       template: 'templates/wiki.html'
15 |     postprocessors:
16 |       - 'postprocessors/branding.rb'
17 |   pdf-page:
18 |     glob: ['*.md']
19 |     preprocessors:
20 |       - 'preprocessors/now.rb'
21 |     pandoc:
22 |       from: markdown
23 |       to: pdf
24 |       pdf-engine: pdfroff
25 |       use-extension: pdf
26 | 


--------------------------------------------------------------------------------
/example/all_templates_with_renaming.yaml:
--------------------------------------------------------------------------------
 1 | settings:
 2 |   recursive: true
 3 |   follow-links: false
 4 |   match-files: all
 5 | templates:
 6 |   wiki-page:
 7 |     glob: ['*.md']
 8 |     preprocessors:
 9 |       - 'preprocessors/now.rb'
10 |     pandoc:
11 |       from: markdown
12 |       to: html5
13 |       standalone: true
14 |       template: 'templates/wiki.html'
15 |     postprocessors:
16 |       - 'postprocessors/branding.rb'
17 |   pdf-page:
18 |     glob: ['*.md']
19 |     preprocessors:
20 |       - 'preprocessors/now.rb'
21 |     pandoc:
22 |       from: markdown
23 |       to: pdf
24 |       pdf-engine: pdfroff
25 |       use-extension: pdf
26 |       rename: 'scripts/prefix_name_with_RENAMED.rb'
27 | 


--------------------------------------------------------------------------------
/example/authored_wiki.yaml:
--------------------------------------------------------------------------------
 1 | settings:
 2 |   recursive: true
 3 |   follow-links: false
 4 | templates:
 5 |   wiki-page:
 6 |     glob: ['*.md']
 7 |     preprocessors:
 8 |       - 'preprocessors/now.rb'
 9 |     metadata:
10 |         author: Huub de Beer 
11 |     pandoc:
12 |       from: markdown
13 |       to: html5
14 |       standalone: true
15 |       template: 'templates/authored_wiki.html'
16 |     postprocessors:
17 |       - 'postprocessors/branding.rb'
18 | 


--------------------------------------------------------------------------------
/example/blog.yaml:
--------------------------------------------------------------------------------
 1 | settings:
 2 |   recursive: true
 3 |   follow-links: false
 4 | templates:
 5 |   blog:
 6 |     glob: ['*.md']
 7 |     pandoc:
 8 |       from: markdown
 9 |       to: html5
10 |       standalone: true
11 |       template: 'templates/blog.html'
12 | 


--------------------------------------------------------------------------------
/example/cleanup.yaml:
--------------------------------------------------------------------------------
 1 | settings:
 2 |   recursive: true
 3 |   follow-links: false
 4 | templates:
 5 |   wiki-page:
 6 |     glob: ['*.md']
 7 |     setup:
 8 |     preprocessors:
 9 |       - 'preprocessors/now.rb'
10 |     pandoc:
11 |       from: markdown
12 |       to: html5
13 |       standalone: true
14 |       template: 'templates/wiki.html'
15 |     postprocessors:
16 |       - 'postprocessors/branding.rb'
17 |     cleanup:
18 |       - 'scripts/remove_temp_file.sh'
19 | 


--------------------------------------------------------------------------------
/example/data-dir/bib.bib:
--------------------------------------------------------------------------------
1 | @book { Beer2022a,
2 |   title = {My book},
3 |   author = {Huub de Beer},
4 |   year = {2022}
5 | }
6 | 


--------------------------------------------------------------------------------
/example/data-dir/filters/now.rb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/htdebeer/pandocomatic/117253eabaf92d31c604b254220ec6cdeb338731/example/data-dir/filters/now.rb


--------------------------------------------------------------------------------
/example/data-dir/includes/red.css:
--------------------------------------------------------------------------------
1 | 
2 | 
7 | 


--------------------------------------------------------------------------------
/example/data-dir/postprocessors/branding.rb:
--------------------------------------------------------------------------------
 1 | #!/usr/bin/env ruby
 2 | 
 3 | # input is HTML. Let's add a generator metadata element to tell the world that
 4 | # this file has been generated by pandocomatic. Of course, it is easier to add
 5 | # that line to the template, but to test the postprocessor, we use this as an
 6 | # simple example.
 7 | #
 8 | # (Note, in a real situation, it is advisable to use a library
 9 | # like oga or nokogiri to change a HTML document in a postprocessor)
10 | puts $stdin.read.gsub('', "\n")
11 | 


--------------------------------------------------------------------------------
/example/data-dir/preprocessors/add argument with spaces.rb:
--------------------------------------------------------------------------------
 1 | #!/usr/bin/env ruby
 2 | # Set some metadata properties in a postprocessor is as easy as copying the
 3 | # stdin to stdout and then printing a yaml metadata block with the properties
 4 | # and their values. For testing purposes I just add the arguments to the
 5 | # script as an array to the metadata, which are then printed by a pandoc
 6 | # template.
 7 | 
 8 | puts $stdin.read
 9 | puts ''
10 | puts '---'
11 | puts "arguments_with_spaces: [#{ARGV.map { |a| "'#{a}'" }.join(', ')}]"
12 | puts '...'
13 | 


--------------------------------------------------------------------------------
/example/data-dir/preprocessors/add_argument_to_metadata.rb:
--------------------------------------------------------------------------------
 1 | #!/usr/bin/env ruby
 2 | # Set some metadata properties in a postprocessor is as easy as copying the
 3 | # stdin to stdout and then printing a yaml metadata block with the properties
 4 | # and their values. For testing purposes I just add the arguments to the
 5 | # script as an array to the metadata, which are then printed by a pandoc
 6 | # template.
 7 | 
 8 | puts $stdin.read
 9 | puts ''
10 | puts '---'
11 | puts "arguments: [#{ARGV.map { |a| "'#{a}'" }.join(', ')}]"
12 | puts '...'
13 | 


--------------------------------------------------------------------------------
/example/data-dir/preprocessors/now.rb:
--------------------------------------------------------------------------------
 1 | #!/usr/bin/env ruby
 2 | # Set some metadata properties in a postprocessor is as easy as copying the
 3 | # stdin to stdout and then printing a yaml metadata block with the properties
 4 | # and their values. For testing purposes I just print a date here, but
 5 | # normally you would use something like Date.today.to_s instead.
 6 | 
 7 | puts $stdin.read
 8 | puts '---'
 9 | puts 'date: 2017-01-28'
10 | puts '...'
11 | 


--------------------------------------------------------------------------------
/example/data-dir/scripts/create_temp_file.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # Create a temporary file
3 | touch /tmp/pandocomatic_temporary_file.txt
4 | 


--------------------------------------------------------------------------------
/example/data-dir/scripts/prefix_name_with_RENAMED.rb:
--------------------------------------------------------------------------------
 1 | #!/usr/bin/env ruby
 2 | 
 3 | current_dst = $stdin.read
 4 | current_dst_dir = File.dirname current_dst
 5 | current_dst_filename = File.basename current_dst
 6 | 
 7 | renamed_dst = File.join(current_dst_dir, "RENAMED-#{current_dst_filename}")
 8 | 
 9 | puts renamed_dst
10 | 


--------------------------------------------------------------------------------
/example/data-dir/scripts/remove_temp_file.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # Create a temporary file
3 | rm /tmp/pandocomatic_temporary_file.txt
4 | 


--------------------------------------------------------------------------------
/example/data-dir/templates/authored_wiki.html:
--------------------------------------------------------------------------------
 1 | 
 2 | 
 3 |   
 4 |     
 5 |     Pandocomatic Wiki—$title$
 6 |     
 7 |   
 8 |   
 9 |     
10 |

Pandocomatic Wiki

11 |

$title$

12 |

Written by: $author$

13 |
14 |
15 | $body$ 16 |
17 |
18 |

last updated: $date$

19 |

generated by pandocomatic!

20 |
21 | 22 | 23 | -------------------------------------------------------------------------------- /example/data-dir/templates/blog.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Pandocomatic BLOG 6 | 7 | 8 | 9 |
10 |

Pandocomatic BLOG

11 |
12 |
13 | $body$ 14 |
15 |
16 | created by pandocomatic 17 |
18 | 19 | 20 | -------------------------------------------------------------------------------- /example/data-dir/templates/date.md: -------------------------------------------------------------------------------- 1 | The date is: $date$ 2 | -------------------------------------------------------------------------------- /example/data-dir/templates/extended_wiki.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Pandocomatic Wiki—$title$ 6 | 7 | $for(css)$ 8 | 9 | $endfor$ 10 | 11 | 12 |
13 |

Pandocomatic Extended Wiki

14 |

$title$

15 |
16 |
17 | $body$ 18 |
19 |
20 | $if(date)$

last updated: $date$

$endif$ 21 |

generated by pandocomatic!

22 |
23 | 24 | 25 | -------------------------------------------------------------------------------- /example/data-dir/templates/footnote.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/htdebeer/pandocomatic/117253eabaf92d31c604b254220ec6cdeb338731/example/data-dir/templates/footnote.css -------------------------------------------------------------------------------- /example/data-dir/templates/page.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/htdebeer/pandocomatic/117253eabaf92d31c604b254220ec6cdeb338731/example/data-dir/templates/page.css -------------------------------------------------------------------------------- /example/data-dir/templates/site.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/htdebeer/pandocomatic/117253eabaf92d31c604b254220ec6cdeb338731/example/data-dir/templates/site.css -------------------------------------------------------------------------------- /example/data-dir/templates/wiki.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/htdebeer/pandocomatic/117253eabaf92d31c604b254220ec6cdeb338731/example/data-dir/templates/wiki.css -------------------------------------------------------------------------------- /example/data-dir/templates/wiki.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Pandocomatic Wiki—$title$ 6 | $for(css)$ 7 | 8 | $endfor$ 9 | 10 | 11 | 12 |
13 |

Pandocomatic Wiki

14 |

$title$

15 |
16 |
17 | $body$ 18 |
19 |
20 | $if(date)$

last updated: $date$

$endif$ 21 |

generated by pandocomatic!

22 |
23 | 24 | 25 | -------------------------------------------------------------------------------- /example/data-dir/templates/wiki_with_arguments.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Pandocomatic Wiki With Arguments—$title$ 6 | 7 | 8 | 9 |
10 |

Pandocomatic Wiki

11 |

$title$

12 | $if(arguments)$ 13 |

Command line arguments

14 |
    15 | $for(arguments)$ 16 |
  1. $arguments$
  2. 17 | $endfor$ 18 |
19 | $endif$ 20 | $if(arguments_with_spaces)$ 21 |

Command line arguments

22 |
    23 | $for(arguments_with_spaces)$ 24 |
  1. $arguments_with_spaces$
  2. 25 | $endfor$ 26 |
27 | $endif$ 28 |
29 |
30 | $body$ 31 |
32 |
33 |

last updated: $date$

34 |

generated by pandocomatic!

35 |
36 | 37 | 38 | -------------------------------------------------------------------------------- /example/dos.html: -------------------------------------------------------------------------------- 1 |

Hello world in LaTeX.

2 | -------------------------------------------------------------------------------- /example/dos.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Test for DOS line endings 3 | date: August 2017 4 | pandocomatic: 5 | pandoc: 6 | to: latex 7 | standalone: true 8 | ... 9 | 10 | Hello **world** in LaTeX. 11 | -------------------------------------------------------------------------------- /example/dos.tex: -------------------------------------------------------------------------------- 1 | \documentclass[]{article} 2 | \usepackage{lmodern} 3 | \usepackage{amssymb,amsmath} 4 | \usepackage{ifxetex,ifluatex} 5 | \usepackage{fixltx2e} % provides \textsubscript 6 | \ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex 7 | \usepackage[T1]{fontenc} 8 | \usepackage[utf8]{inputenc} 9 | \else % if luatex or xelatex 10 | \ifxetex 11 | \usepackage{mathspec} 12 | \else 13 | \usepackage{fontspec} 14 | \fi 15 | \defaultfontfeatures{Ligatures=TeX,Scale=MatchLowercase} 16 | \fi 17 | % use upquote if available, for straight quotes in verbatim environments 18 | \IfFileExists{upquote.sty}{\usepackage{upquote}}{} 19 | % use microtype if available 20 | \IfFileExists{microtype.sty}{% 21 | \usepackage[]{microtype} 22 | \UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts 23 | }{} 24 | \PassOptionsToPackage{hyphens}{url} % url is loaded by hyperref 25 | \usepackage[unicode=true]{hyperref} 26 | \hypersetup{ 27 | pdftitle={Test for DOS line endings}, 28 | pdfborder={0 0 0}, 29 | breaklinks=true} 30 | \urlstyle{same} % don't use monospace font for urls 31 | \IfFileExists{parskip.sty}{% 32 | \usepackage{parskip} 33 | }{% else 34 | \setlength{\parindent}{0pt} 35 | \setlength{\parskip}{6pt plus 2pt minus 1pt} 36 | } 37 | \setlength{\emergencystretch}{3em} % prevent overfull lines 38 | \providecommand{\tightlist}{% 39 | \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}} 40 | \setcounter{secnumdepth}{0} 41 | % Redefines (sub)paragraphs to behave more like sections 42 | \ifx\paragraph\undefined\else 43 | \let\oldparagraph\paragraph 44 | \renewcommand{\paragraph}[1]{\oldparagraph{#1}\mbox{}} 45 | \fi 46 | \ifx\subparagraph\undefined\else 47 | \let\oldsubparagraph\subparagraph 48 | \renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}} 49 | \fi 50 | 51 | % set default figure placement to htbp 52 | \makeatletter 53 | \def\fps@figure{htbp} 54 | \makeatother 55 | 56 | 57 | \title{Test for DOS line endings} 58 | \date{August 2017} 59 | 60 | \begin{document} 61 | \maketitle 62 | 63 | Hello \textbf{world} in LaTeX. 64 | 65 | \end{document} 66 | -------------------------------------------------------------------------------- /example/dst/all_templates/config.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Pandocomatic Wiki—Pandocomatic configuration 7 | 8 | 9 | 10 |
11 |

Pandocomatic Wiki

12 |

Pandocomatic configuration

13 |
14 |
15 |

To configure pandocomatic, either specify an initial 16 | configuration file or use the conventional configuration file 17 | pandocomatic.yaml.

18 |
19 |
20 |

last updated: 2017-01-28

21 |

generated by pandocomatic!

22 |
23 | 24 | 25 | -------------------------------------------------------------------------------- /example/dst/all_templates/config.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/htdebeer/pandocomatic/117253eabaf92d31c604b254220ec6cdeb338731/example/dst/all_templates/config.pdf -------------------------------------------------------------------------------- /example/dst/all_templates/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Pandocomatic Wiki—Pandocomatic wiki 7 | 8 | 9 | 10 |
11 |

Pandocomatic Wiki

12 |

Pandocomatic wiki

13 |
14 |
15 |

Welcome at the Pandocomatic wiki. Pandocomatic 16 | is a ruby program to 17 | automate the use of pandoc.

18 |

Given a pandocomatic configuration, 19 | pandocomatic converts an input file or an input directory tree as 20 | specified by that configuration.

21 |
22 |
23 |

last updated: 2017-01-28

24 |

generated by pandocomatic!

25 |
26 | 27 | 28 | -------------------------------------------------------------------------------- /example/dst/all_templates/index.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/htdebeer/pandocomatic/117253eabaf92d31c604b254220ec6cdeb338731/example/dst/all_templates/index.pdf -------------------------------------------------------------------------------- /example/dst/all_templates_with_renaming/RENAMED-config.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/htdebeer/pandocomatic/117253eabaf92d31c604b254220ec6cdeb338731/example/dst/all_templates_with_renaming/RENAMED-config.pdf -------------------------------------------------------------------------------- /example/dst/all_templates_with_renaming/RENAMED-index.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/htdebeer/pandocomatic/117253eabaf92d31c604b254220ec6cdeb338731/example/dst/all_templates_with_renaming/RENAMED-index.pdf -------------------------------------------------------------------------------- /example/dst/all_templates_with_renaming/config.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Pandocomatic Wiki—Pandocomatic configuration 7 | 8 | 9 | 10 |
11 |

Pandocomatic Wiki

12 |

Pandocomatic configuration

13 |
14 |
15 |

To configure pandocomatic, either specify an initial 16 | configuration file or use the conventional configuration file 17 | pandocomatic.yaml.

18 |
19 |
20 |

last updated: 2017-01-28

21 |

generated by pandocomatic!

22 |
23 | 24 | 25 | -------------------------------------------------------------------------------- /example/dst/all_templates_with_renaming/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Pandocomatic Wiki—Pandocomatic wiki 7 | 8 | 9 | 10 |
11 |

Pandocomatic Wiki

12 |

Pandocomatic wiki

13 |
14 |
15 |

Welcome at the Pandocomatic wiki. Pandocomatic 16 | is a ruby program to 17 | automate the use of pandoc.

18 |

Given a pandocomatic configuration, 19 | pandocomatic converts an input file or an input directory tree as 20 | specified by that configuration.

21 |
22 |
23 |

last updated: 2017-01-28

24 |

generated by pandocomatic!

25 |
26 | 27 | 28 | -------------------------------------------------------------------------------- /example/dst/authored_wiki/config.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Pandocomatic Wiki—Pandocomatic configuration made 7 | easy 8 | 9 | 10 | 11 |
12 |

Pandocomatic Wiki

13 |

Pandocomatic configuration made easy

14 |

Written by: Huub de Beer

16 |
17 |
18 |

To configure pandocomatic, either specify an initial 19 | configuration file or use the conventional configuration file 20 | pandocomatic.yaml.

21 |
22 |
23 |

last updated: 2017-01-28

24 |

generated by pandocomatic!

25 |
26 | 27 | 28 | -------------------------------------------------------------------------------- /example/dst/authored_wiki/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Pandocomatic Wiki—Authorized pandocomatic wiki 7 | 8 | 9 | 10 |
11 |

Pandocomatic Wiki

12 |

Authorized pandocomatic wiki

13 |

Written by: Huub de Beer

15 |
16 |
17 |

Welcome at the Pandocomatic wiki. Pandocomatic 18 | is a ruby program to 19 | automate the use of pandoc.

20 |

Given a pandocomatic configuration, 21 | pandocomatic converts an input file or an input directory tree as 22 | specified by that configuration.

23 |
24 |
25 |

last updated: 2017-01-28

26 |

generated by pandocomatic!

27 |
28 | 29 | 30 | -------------------------------------------------------------------------------- /example/dst/blog/first_post.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Pandocomatic BLOG 6 | 7 | 8 | 9 |
10 |

Pandocomatic BLOG

11 |
12 |
13 |

My first post

14 |

This is my first post on my new blog!

15 |
16 |
17 | created by pandocomatic 18 |
19 | 20 | 21 | -------------------------------------------------------------------------------- /example/dst/blog/on_using_pandocomatic.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Pandocomatic BLOG 6 | 7 | 8 | 9 |
10 |

Pandocomatic BLOG

11 |
12 |
13 |

On Using Pandocomatic

14 |

In my second blog post I want to talk about how to use 15 | pandocomatic, the program I use to generate this blog!

16 |
17 |
18 | created by pandocomatic 19 |
20 | 21 | 22 | -------------------------------------------------------------------------------- /example/dst/extended_wiki/config.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Pandocomatic Wiki—Pandocomatic configuration 7 | 8 | 9 | 10 |
11 |

Pandocomatic Wiki

12 |

Pandocomatic configuration

13 |
14 |
15 |

To configure pandocomatic, either specify an initial configuration file or use the conventional configuration file pandocomatic.yaml.

16 |
17 |
18 |

last updated: 2017-01-28

19 |

generated by pandocomatic!

20 |
21 | 22 | 23 | -------------------------------------------------------------------------------- /example/dst/extended_wiki/config.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Pandocomatic configuration 3 | ... 4 | 5 | To configure pandocomatic, either specify an initial configuration file or use 6 | the conventional configuration file `pandocomatic.yaml`. 7 | 8 | -------------------------------------------------------------------------------- /example/dst/extended_wiki/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Pandocomatic Wiki—Pandocomatic wiki 7 | 8 | 9 | 10 |
11 |

Pandocomatic Wiki

12 |

Pandocomatic wiki

13 |
14 |
15 |

Welcome at the Pandocomatic wiki. Pandocomatic is a ruby program to automate the use of pandoc.

16 |

Given a pandocomatic configuration, pandocomatic converts an input file or an input directory tree as specified by that configuration.

17 |
18 |
19 |

last updated: 2017-01-28

20 |

generated by pandocomatic!

21 |
22 | 23 | 24 | -------------------------------------------------------------------------------- /example/dst/extended_wiki/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Pandocomatic wiki 3 | ... 4 | Welcome at the [Pandocomatic wiki](/). Pandocomatic is a 5 | [ruby](https://www.ruby-lang.org/en/) program to automate the use of 6 | [pandoc](http://pandoc.org/). 7 | 8 | Given a [pandocomatic configuration](config), pandocomatic converts an input 9 | file or an input directory tree as specified by that configuration. 10 | -------------------------------------------------------------------------------- /example/dst/odt_with_images/file1.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/htdebeer/pandocomatic/117253eabaf92d31c604b254220ec6cdeb338731/example/dst/odt_with_images/file1.odt -------------------------------------------------------------------------------- /example/dst/odt_with_images/file2.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/htdebeer/pandocomatic/117253eabaf92d31c604b254220ec6cdeb338731/example/dst/odt_with_images/file2.odt -------------------------------------------------------------------------------- /example/dst/odt_with_images/subdir/file1.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/htdebeer/pandocomatic/117253eabaf92d31c604b254220ec6cdeb338731/example/dst/odt_with_images/subdir/file1.odt -------------------------------------------------------------------------------- /example/dst/odt_with_images/subdir/file2.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/htdebeer/pandocomatic/117253eabaf92d31c604b254220ec6cdeb338731/example/dst/odt_with_images/subdir/file2.odt -------------------------------------------------------------------------------- /example/dst/setup-cleanup-wiki/config.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Pandocomatic Wiki—Pandocomatic configuration 7 | 8 | 9 | 10 |
11 |

Pandocomatic Wiki

12 |

Pandocomatic configuration

13 |
14 |
15 |

To configure pandocomatic, either specify an initial 16 | configuration file or use the conventional configuration file 17 | pandocomatic.yaml.

18 |
19 |
20 |

last updated: 2017-01-28

21 |

generated by pandocomatic!

22 |
23 | 24 | 25 | -------------------------------------------------------------------------------- /example/dst/setup-cleanup-wiki/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Pandocomatic Wiki—Pandocomatic wiki 7 | 8 | 9 | 10 |
11 |

Pandocomatic Wiki

12 |

Pandocomatic wiki

13 |
14 |
15 |

Welcome at the Pandocomatic wiki. Pandocomatic 16 | is a ruby program to 17 | automate the use of pandoc.

18 |

Given a pandocomatic configuration, 19 | pandocomatic converts an input file or an input directory tree as 20 | specified by that configuration.

21 |
22 |
23 |

last updated: 2017-01-28

24 |

generated by pandocomatic!

25 |
26 | 27 | 28 | -------------------------------------------------------------------------------- /example/dst/site/authored_wiki/config.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Pandocomatic Wiki—Pandocomatic configuration made 7 | easy 8 | 9 | 10 | 11 |
12 |

Pandocomatic Wiki

13 |

Pandocomatic configuration made easy

14 |

Written by: Huub de Beer

16 |
17 |
18 |

To configure pandocomatic, either specify an initial 19 | configuration file or use the conventional configuration file 20 | pandocomatic.yaml.

21 |
22 |
23 |

last updated: 2017-01-28

24 |

generated by pandocomatic!

25 |
26 | 27 | 28 | -------------------------------------------------------------------------------- /example/dst/site/authored_wiki/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Pandocomatic Wiki—Authorized pandocomatic wiki 7 | 8 | 9 | 10 |
11 |

Pandocomatic Wiki

12 |

Authorized pandocomatic wiki

13 |

Written by: Huub de Beer

15 |
16 |
17 |

Welcome at the Pandocomatic wiki. Pandocomatic 18 | is a ruby program to 19 | automate the use of pandoc.

20 |

Given a pandocomatic configuration, 21 | pandocomatic converts an input file or an input directory tree as 22 | specified by that configuration.

23 |
24 |
25 |

last updated: 2017-01-28

26 |

generated by pandocomatic!

27 |
28 | 29 | 30 | -------------------------------------------------------------------------------- /example/dst/site/blog/first_post.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Pandocomatic BLOG 6 | 7 | 8 | 9 |
10 |

Pandocomatic BLOG

11 |
12 |
13 |

My first post

14 |

This is my first post on my new blog!

15 |
16 |
17 | created by pandocomatic 18 |
19 | 20 | 21 | -------------------------------------------------------------------------------- /example/dst/site/blog/on_using_pandocomatic.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Pandocomatic BLOG 6 | 7 | 8 | 9 |
10 |

Pandocomatic BLOG

11 |
12 |
13 |

On Using Pandocomatic

14 |

In my second blog post I want to talk about how to use 15 | pandocomatic, the program I use to generate this blog!

16 |
17 |
18 | created by pandocomatic 19 |
20 | 21 | 22 | -------------------------------------------------------------------------------- /example/dst/site/extended_wiki/config.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Pandocomatic Wiki—Pandocomatic configuration 7 | 8 | 9 | 10 |
11 |

Pandocomatic Wiki

12 |

Pandocomatic configuration

13 |
14 |
15 |

To configure pandocomatic, either specify an initial 16 | configuration file or use the conventional configuration file 17 | pandocomatic.yaml.

18 |
19 |
20 |

last updated: 2017-01-28

21 |

generated by pandocomatic!

22 |
23 | 24 | 25 | -------------------------------------------------------------------------------- /example/dst/site/extended_wiki/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Pandocomatic Wiki—Pandocomatic wiki 7 | 8 | 9 | 10 |
11 |

Pandocomatic Wiki

12 |

Pandocomatic wiki

13 |
14 |
15 |

Welcome at the Pandocomatic wiki. Pandocomatic 16 | is a ruby program to 17 | automate the use of pandoc.

18 |

Given a pandocomatic configuration, 19 | pandocomatic converts an input file or an input directory tree as 20 | specified by that configuration.

21 |
22 |
23 |

last updated: 2017-01-28

24 |

generated by pandocomatic!

25 |
26 | 27 | 28 | -------------------------------------------------------------------------------- /example/dst/site/odt_with_images/file1.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/htdebeer/pandocomatic/117253eabaf92d31c604b254220ec6cdeb338731/example/dst/site/odt_with_images/file1.odt -------------------------------------------------------------------------------- /example/dst/site/odt_with_images/file2.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/htdebeer/pandocomatic/117253eabaf92d31c604b254220ec6cdeb338731/example/dst/site/odt_with_images/file2.odt -------------------------------------------------------------------------------- /example/dst/site/odt_with_images/subdir/file1.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/htdebeer/pandocomatic/117253eabaf92d31c604b254220ec6cdeb338731/example/dst/site/odt_with_images/subdir/file1.odt -------------------------------------------------------------------------------- /example/dst/site/odt_with_images/subdir/file2.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/htdebeer/pandocomatic/117253eabaf92d31c604b254220ec6cdeb338731/example/dst/site/odt_with_images/subdir/file2.odt -------------------------------------------------------------------------------- /example/dst/site/public/blog.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-size: 14pt; 3 | line-height: 1.45; 4 | } 5 | 6 | header { 7 | background-color: crimson; 8 | color: ivory; 9 | border-bottom: 1px solid black; 10 | } 11 | 12 | main { 13 | text-align: justify; 14 | max-width: 45em; 15 | } 16 | 17 | main h1 { 18 | font-size: 20pt; 19 | text-align: left; 20 | } 21 | 22 | main h2 { 23 | font-size: 18pt; 24 | text-align: left; 25 | } 26 | 27 | -------------------------------------------------------------------------------- /example/dst/site/public/wiki.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-size: 14pt; 3 | font-family: sans-serif; 4 | } 5 | 6 | a.empty { 7 | color: red; 8 | } 9 | 10 | a.external { 11 | color: green; 12 | } 13 | -------------------------------------------------------------------------------- /example/dst/site/setup-cleanup-wiki/config.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Pandocomatic Wiki—Pandocomatic configuration 7 | 8 | 9 | 10 |
11 |

Pandocomatic Wiki

12 |

Pandocomatic configuration

13 |
14 |
15 |

To configure pandocomatic, either specify an initial 16 | configuration file or use the conventional configuration file 17 | pandocomatic.yaml.

18 |
19 |
20 |

last updated: 2017-01-28

21 |

generated by pandocomatic!

22 |
23 | 24 | 25 | -------------------------------------------------------------------------------- /example/dst/site/setup-cleanup-wiki/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Pandocomatic Wiki—Pandocomatic wiki 7 | 8 | 9 | 10 |
11 |

Pandocomatic Wiki

12 |

Pandocomatic wiki

13 |
14 |
15 |

Welcome at the Pandocomatic wiki. Pandocomatic 16 | is a ruby program to 17 | automate the use of pandoc.

18 |

Given a pandocomatic configuration, 19 | pandocomatic converts an input file or an input directory tree as 20 | specified by that configuration.

21 |
22 |
23 |

last updated: 2017-01-28

24 |

generated by pandocomatic!

25 |
26 | 27 | 28 | -------------------------------------------------------------------------------- /example/dst/site/twice_extended_wiki/another_page.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Pandocomatic Wiki—Another page 7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 |

Pandocomatic Extended Wiki

15 |

Another page

16 |
17 |
18 |

Another page with a custom template.

19 |
20 |
21 | 22 |

generated by pandocomatic!

23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /example/dst/site/twice_extended_wiki/config.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Pandocomatic Wiki—Pandocomatic configuration 7 | 8 | 9 | 10 | 11 | 12 |
13 |

Pandocomatic Wiki

14 |

Pandocomatic configuration

15 |
16 |
17 |

To configure pandocomatic, either specify an initial 18 | configuration file or use the conventional configuration file 19 | pandocomatic.yaml.

20 |
21 |
22 |

last updated: 2017-01-28

23 |

generated by pandocomatic!

24 |
25 | 26 | 27 | -------------------------------------------------------------------------------- /example/dst/site/twice_extended_wiki/config2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Pandocomatic Wiki—Pandocomatic configuration 7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 |

Pandocomatic Extended Wiki

15 |

Pandocomatic configuration

16 |
17 |
18 |

To configure pandocomatic, either specify an initial 19 | configuration file or use the conventional configuration file 20 | pandocomatic.yaml.

21 |
22 |
23 |

last updated: 2017-01-28

24 |

generated by pandocomatic!

25 |
26 | 27 | 28 | -------------------------------------------------------------------------------- /example/dst/site/twice_extended_wiki/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Pandocomatic Wiki—Pandocomatic wiki 7 | 8 | 9 | 10 | 11 | 12 |
13 |

Pandocomatic Wiki

14 |

Pandocomatic wiki

15 |
16 |
17 |

Welcome at the Pandocomatic wiki. Pandocomatic 18 | is a ruby program to 19 | automate the use of pandoc.

20 |

Given a pandocomatic configuration, 21 | pandocomatic converts an input file or an input directory tree as 22 | specified by that configuration.

23 |
24 |
25 |

last updated: 2017-01-28

26 |

generated by pandocomatic!

27 |
28 | 29 | 30 | -------------------------------------------------------------------------------- /example/dst/site/wiki/config.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Pandocomatic Wiki—Pandocomatic configuration 7 | 8 | 9 | 10 |
11 |

Pandocomatic Wiki

12 |

Pandocomatic configuration

13 |
14 |
15 |

To configure pandocomatic, either specify an initial 16 | configuration file or use the conventional configuration file 17 | pandocomatic.yaml.

18 |
19 |
20 |

last updated: 2017-01-28

21 |

generated by pandocomatic!

22 |
23 | 24 | 25 | -------------------------------------------------------------------------------- /example/dst/site/wiki/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Pandocomatic Wiki—Pandocomatic wiki 7 | 8 | 9 | 10 |
11 |

Pandocomatic Wiki

12 |

Pandocomatic wiki

13 |
14 |
15 |

Welcome at the Pandocomatic wiki. Pandocomatic 16 | is a ruby program to 17 | automate the use of pandoc.

18 |

Given a pandocomatic configuration, 19 | pandocomatic converts an input file or an input directory tree as 20 | specified by that configuration.

21 |
22 |
23 |

last updated: 2017-01-28

24 |

generated by pandocomatic!

25 |
26 | 27 | 28 | -------------------------------------------------------------------------------- /example/dst/site/wiki_with_arguments/config.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Pandocomatic Wiki With Arguments—Pandocomatic 7 | configuration 8 | 9 | 10 | 11 |
12 |

Pandocomatic Wiki

13 |

Pandocomatic configuration

14 |

Command line arguments

15 |
    16 |
  1. –arg1
  2. 17 |
  3. -arg2
  4. 18 |
  5. arg3
  6. 19 |
20 |

Command line arguments

21 |
    22 |
  1. with
  2. 23 |
  3. spaces
  4. 24 |
25 |
26 |
27 |

To configure pandocomatic, either specify an initial 28 | configuration file or use the conventional configuration file 29 | pandocomatic.yaml.

30 |
31 |
32 |

last updated: 2017-01-28

33 |

generated by pandocomatic!

34 |
35 | 36 | 37 | -------------------------------------------------------------------------------- /example/dst/site/wiki_with_arguments/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Pandocomatic Wiki With Arguments—Pandocomatic wiki 7 | 8 | 9 | 10 |
11 |

Pandocomatic Wiki

12 |

Pandocomatic wiki

13 |

Command line arguments

14 |
    15 |
  1. –arg1
  2. 16 |
  3. -arg2
  4. 17 |
  5. arg3
  6. 18 |
19 |

Command line arguments

20 |
    21 |
  1. with
  2. 22 |
  3. spaces
  4. 23 |
24 |
25 |
26 |

Welcome at the Pandocomatic wiki. Pandocomatic 27 | is a ruby program to 28 | automate the use of pandoc.

29 |

Given a pandocomatic configuration, 30 | pandocomatic converts an input file or an input directory tree as 31 | specified by that configuration.

32 |
33 |
34 |

last updated: 2017-01-28

35 |

generated by pandocomatic!

36 |
37 | 38 | 39 | -------------------------------------------------------------------------------- /example/dst/twice_extended_wiki/another_page.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Pandocomatic Wiki—Another page 7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 |

Pandocomatic Extended Wiki

15 |

Another page

16 |
17 |
18 |

Another page with a custom template.

19 |
20 |
21 | 22 |

generated by pandocomatic!

23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /example/dst/twice_extended_wiki/config.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Pandocomatic Wiki—Pandocomatic configuration 7 | 8 | 9 | 10 | 11 | 12 |
13 |

Pandocomatic Wiki

14 |

Pandocomatic configuration

15 |
16 |
17 |

To configure pandocomatic, either specify an initial 18 | configuration file or use the conventional configuration file 19 | pandocomatic.yaml.

20 |
21 |
22 |

last updated: 2017-01-28

23 |

generated by pandocomatic!

24 |
25 | 26 | 27 | -------------------------------------------------------------------------------- /example/dst/twice_extended_wiki/config2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Pandocomatic Wiki—Pandocomatic configuration 7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 |

Pandocomatic Extended Wiki

15 |

Pandocomatic configuration

16 |
17 |
18 |

To configure pandocomatic, either specify an initial 19 | configuration file or use the conventional configuration file 20 | pandocomatic.yaml.

21 |
22 |
23 |

last updated: 2017-01-28

24 |

generated by pandocomatic!

25 |
26 | 27 | 28 | -------------------------------------------------------------------------------- /example/dst/twice_extended_wiki/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Pandocomatic Wiki—Pandocomatic wiki 7 | 8 | 9 | 10 | 11 | 12 |
13 |

Pandocomatic Wiki

14 |

Pandocomatic wiki

15 |
16 |
17 |

Welcome at the Pandocomatic wiki. Pandocomatic 18 | is a ruby program to 19 | automate the use of pandoc.

20 |

Given a pandocomatic configuration, 21 | pandocomatic converts an input file or an input directory tree as 22 | specified by that configuration.

23 |
24 |
25 |

last updated: 2017-01-28

26 |

generated by pandocomatic!

27 |
28 | 29 | 30 | -------------------------------------------------------------------------------- /example/dst/wiki/config.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Pandocomatic Wiki—Pandocomatic configuration 7 | 8 | 9 | 10 |
11 |

Pandocomatic Wiki

12 |

Pandocomatic configuration

13 |
14 |
15 |

To configure pandocomatic, either specify an initial 16 | configuration file or use the conventional configuration file 17 | pandocomatic.yaml.

18 |
19 |
20 |

last updated: 2017-01-28

21 |

generated by pandocomatic!

22 |
23 | 24 | 25 | -------------------------------------------------------------------------------- /example/dst/wiki/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Pandocomatic Wiki—Pandocomatic wiki 7 | 8 | 9 | 10 |
11 |

Pandocomatic Wiki

12 |

Pandocomatic wiki

13 |
14 |
15 |

Welcome at the Pandocomatic wiki. Pandocomatic 16 | is a ruby program to 17 | automate the use of pandoc.

18 |

Given a pandocomatic configuration, 19 | pandocomatic converts an input file or an input directory tree as 20 | specified by that configuration.

21 |
22 |
23 |

last updated: 2017-01-28

24 |

generated by pandocomatic!

25 |
26 | 27 | 28 | -------------------------------------------------------------------------------- /example/dst/wiki_with_arguments/config.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Pandocomatic Wiki With Arguments—Pandocomatic 7 | configuration 8 | 9 | 10 | 11 |
12 |

Pandocomatic Wiki

13 |

Pandocomatic configuration

14 |

Command line arguments

15 |
    16 |
  1. –arg1
  2. 17 |
  3. -arg2
  4. 18 |
  5. arg3
  6. 19 |
20 |

Command line arguments

21 |
    22 |
  1. with
  2. 23 |
  3. spaces
  4. 24 |
25 |
26 |
27 |

To configure pandocomatic, either specify an initial 28 | configuration file or use the conventional configuration file 29 | pandocomatic.yaml.

30 |
31 |
32 |

last updated: 2017-01-28

33 |

generated by pandocomatic!

34 |
35 | 36 | 37 | -------------------------------------------------------------------------------- /example/dst/wiki_with_arguments/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Pandocomatic Wiki With Arguments—Pandocomatic wiki 7 | 8 | 9 | 10 |
11 |

Pandocomatic Wiki

12 |

Pandocomatic wiki

13 |

Command line arguments

14 |
    15 |
  1. –arg1
  2. 16 |
  3. -arg2
  4. 17 |
  5. arg3
  6. 18 |
19 |

Command line arguments

20 |
    21 |
  1. with
  2. 22 |
  3. spaces
  4. 23 |
24 |
25 |
26 |

Welcome at the Pandocomatic wiki. Pandocomatic 27 | is a ruby program to 28 | automate the use of pandoc.

29 |

Given a pandocomatic configuration, 30 | pandocomatic converts an input file or an input directory tree as 31 | specified by that configuration.

32 |
33 |
34 |

last updated: 2017-01-28

35 |

generated by pandocomatic!

36 |
37 | 38 | 39 | -------------------------------------------------------------------------------- /example/empty-properties.html: -------------------------------------------------------------------------------- 1 |

Hello world!, from pandocomatic.

2 | -------------------------------------------------------------------------------- /example/empty-properties.md: -------------------------------------------------------------------------------- 1 | --- 2 | pandocomatic: 3 | pandoc: 4 | from: markdown 5 | to: html 6 | filter: 7 | # - somefilterthatscommentedout.rb 8 | css: 9 | - style.css 10 | ... 11 | *Hello world!*, from **pandocomatic**. 12 | -------------------------------------------------------------------------------- /example/extended_wiki.yaml: -------------------------------------------------------------------------------- 1 | settings: 2 | recursive: true 3 | follow-links: false 4 | templates: 5 | now: 6 | preprocessors: 7 | - 'preprocessors/now.rb' 8 | branding: 9 | postprocessors: 10 | - 'postprocessors/branding.rb' 11 | wiki-page: 12 | extends: ['now', 'branding'] 13 | glob: ['*.md'] 14 | pandoc: 15 | from: markdown 16 | to: html5 17 | standalone: true 18 | template: 'templates/wiki.html' 19 | extended-wiki-page: 20 | extends: 'wiki-page' 21 | pandoc: 22 | template: 'templates/extended_wiki.html' 23 | -------------------------------------------------------------------------------- /example/extending_templates/config.yaml: -------------------------------------------------------------------------------- 1 | templates: 2 | title: 3 | metadata: 4 | title: Extended metadata 5 | doc: 6 | extends: title 7 | pandoc: 8 | from: markdown 9 | to: latex 10 | standalone: true 11 | -------------------------------------------------------------------------------- /example/extending_templates/data/pandocomatic.yaml: -------------------------------------------------------------------------------- 1 | templates: 2 | title: 3 | metadata: 4 | author: Huub de Beer 5 | -------------------------------------------------------------------------------- /example/extending_templates/extended_template.md: -------------------------------------------------------------------------------- 1 | --- 2 | pandocomatic: 3 | use-template: doc 4 | ... 5 | 6 | Hello, **World**! 7 | -------------------------------------------------------------------------------- /example/extending_templates/extended_template.tex: -------------------------------------------------------------------------------- 1 | % Options for packages loaded elsewhere 2 | \PassOptionsToPackage{unicode}{hyperref} 3 | \PassOptionsToPackage{hyphens}{url} 4 | \documentclass[ 5 | ]{article} 6 | \usepackage{xcolor} 7 | \usepackage{amsmath,amssymb} 8 | \setcounter{secnumdepth}{-\maxdimen} % remove section numbering 9 | \usepackage{iftex} 10 | \ifPDFTeX 11 | \usepackage[T1]{fontenc} 12 | \usepackage[utf8]{inputenc} 13 | \usepackage{textcomp} % provide euro and other symbols 14 | \else % if luatex or xetex 15 | \usepackage{unicode-math} % this also loads fontspec 16 | \defaultfontfeatures{Scale=MatchLowercase} 17 | \defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1} 18 | \fi 19 | \usepackage{lmodern} 20 | \ifPDFTeX\else 21 | % xetex/luatex font selection 22 | \fi 23 | % Use upquote if available, for straight quotes in verbatim environments 24 | \IfFileExists{upquote.sty}{\usepackage{upquote}}{} 25 | \IfFileExists{microtype.sty}{% use microtype if available 26 | \usepackage[]{microtype} 27 | \UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts 28 | }{} 29 | \makeatletter 30 | \@ifundefined{KOMAClassName}{% if non-KOMA class 31 | \IfFileExists{parskip.sty}{% 32 | \usepackage{parskip} 33 | }{% else 34 | \setlength{\parindent}{0pt} 35 | \setlength{\parskip}{6pt plus 2pt minus 1pt}} 36 | }{% if KOMA class 37 | \KOMAoptions{parskip=half}} 38 | \makeatother 39 | \setlength{\emergencystretch}{3em} % prevent overfull lines 40 | \providecommand{\tightlist}{% 41 | \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}} 42 | \usepackage{bookmark} 43 | \IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available 44 | \urlstyle{same} 45 | \hypersetup{ 46 | pdftitle={Extended metadata}, 47 | hidelinks, 48 | pdfcreator={LaTeX via pandoc}} 49 | 50 | \title{Extended metadata} 51 | \author{} 52 | \date{} 53 | 54 | \begin{document} 55 | \maketitle 56 | 57 | Hello, \textbf{World}! 58 | 59 | \end{document} 60 | -------------------------------------------------------------------------------- /example/extensions/beamer_presentation.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: This is a beamer presentation 3 | author: Huub de Beer 4 | pandocomatic_: 5 | pandoc: 6 | from: markdown 7 | to: beamer 8 | ... 9 | 10 | This is a beamer presentation that will be converted to a LaTex file with a tex extension. 11 | -------------------------------------------------------------------------------- /example/extensions/beamer_presentation_plus_min_extensions.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: This is a beamer presentation 3 | author: Huub de Beer 4 | pandocomatic_: 5 | pandoc: 6 | from: markdown 7 | to: beamer+smart 8 | ... 9 | 10 | This is a beamer presentation that will be converted to a LaTex file with a tex extension. 11 | -------------------------------------------------------------------------------- /example/extensions/beamer_presentation_to_pdf.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: This is a beamer presentation 3 | author: Huub de Beer 4 | pandocomatic_: 5 | pandoc: 6 | from: markdown 7 | to: beamer 8 | output: beamer_presentation_to_pdf.pdf 9 | ... 10 | 11 | This is a beamer presentation that will be converted to a LaTex file with a tex extension. 12 | -------------------------------------------------------------------------------- /example/extensions/beamer_presentation_to_pdf_with_extension_option.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: This is a beamer presentation 3 | author: Huub de Beer 4 | pandocomatic_: 5 | pandoc: 6 | from: markdown 7 | to: beamer 8 | use-extension: pdf 9 | ... 10 | 11 | This is a beamer presentation that will be converted to a LaTex file with a tex extension. 12 | -------------------------------------------------------------------------------- /example/extract_pandoc_metadata_from_docx.yaml: -------------------------------------------------------------------------------- 1 | settings: 2 | recursive: true 3 | follow-links: false 4 | extract-metadata-from: ['*.docx'] 5 | -------------------------------------------------------------------------------- /example/hello_vars.md: -------------------------------------------------------------------------------- 1 | --- 2 | pandocomatic_: 3 | use-template: var-template 4 | metadata: 5 | title: $(P_TITLE)$ 6 | ... 7 | 8 | Hello, variable world! 9 | -------------------------------------------------------------------------------- /example/hello_verbose_world.md: -------------------------------------------------------------------------------- 1 | --- 2 | pandocomatic: 3 | pandoc: 4 | from: markdown 5 | to: html5 6 | verbose: true 7 | ... 8 | *Hello world!*, from a ~verbose~ **pandoc**. 9 | -------------------------------------------------------------------------------- /example/hello_world.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/htdebeer/pandocomatic/117253eabaf92d31c604b254220ec6cdeb338731/example/hello_world.docx -------------------------------------------------------------------------------- /example/hello_world.html: -------------------------------------------------------------------------------- 1 |

Hello world!, from pandocomatic.

2 | -------------------------------------------------------------------------------- /example/hello_world.md: -------------------------------------------------------------------------------- 1 | --- 2 | pandocomatic: 3 | pandoc: 4 | from: markdown 5 | to: html5 6 | ... 7 | *Hello world!*, from **pandocomatic**. 8 | -------------------------------------------------------------------------------- /example/hello_world_to_tex.md: -------------------------------------------------------------------------------- 1 | --- 2 | pandocomatic: 3 | pandoc: 4 | from: markdown 5 | to: latex 6 | ... 7 | *Hello world!*, from **pandocomatic**. 8 | -------------------------------------------------------------------------------- /example/include.yaml: -------------------------------------------------------------------------------- 1 | templates: 2 | red: 3 | pandoc: 4 | from: markdown 5 | to: html 6 | standalone: true 7 | bibliography: data-dir/bib.bib 8 | citeproc: true 9 | # include-in-header: ./data-dir/includes/red.css 10 | -------------------------------------------------------------------------------- /example/include_in_header_hello.md: -------------------------------------------------------------------------------- 1 | --- 2 | pandocomatic_: 3 | use-template: red 4 | ... 5 | 6 | Hello, World! From [@Beer2022a] 7 | -------------------------------------------------------------------------------- /example/inheritance/broken.yaml: -------------------------------------------------------------------------------- 1 | templates: 2 | inherited-page: 3 | extends: ["mine", "non-existing"] 4 | pandoc: 5 | css: ["first.css"] 6 | -------------------------------------------------------------------------------- /example/inheritance/data-dir/pandocomatic.yaml: -------------------------------------------------------------------------------- 1 | templates: 2 | mine: 3 | metadata: 4 | author: Huub de Beer 5 | page: 6 | pandoc: 7 | from: markdown 8 | to: html 9 | template: "template.html" 10 | css: ["base.css"] 11 | -------------------------------------------------------------------------------- /example/inheritance/data-dir/template.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | $for(css)$ 6 | 7 | $endfor$ 8 | 9 | 10 | $if(title)$ 11 |
12 |

$title$

13 | $if(subtitle)$ 14 |

$subtitle$

15 | $endif$ 16 | $for(author)$ 17 |

$author$

18 | $endfor$ 19 | $if(date)$ 20 |

$date$

21 | $endif$ 22 |
23 | $endif$ 24 | $if(toc)$ 25 | 31 | $endif$ 32 | $body$ 33 | 34 | 35 | -------------------------------------------------------------------------------- /example/inheritance/first.yaml: -------------------------------------------------------------------------------- 1 | templates: 2 | inherited-page: 3 | extends: ["mine", "page"] 4 | pandoc: 5 | css: ["first.css"] 6 | -------------------------------------------------------------------------------- /example/inheritance/second.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 |

Second after first after base

12 |

Huub de Beer

13 |
14 |

Inherited templates!

15 | 16 | 17 | -------------------------------------------------------------------------------- /example/inheritance/second.md: -------------------------------------------------------------------------------- 1 | --- 2 | pandocomatic_: 3 | use-template: inherited-page 4 | pandoc: 5 | css: ["second.css"] 6 | standalone: true 7 | metadata: 8 | title: Second after first after base 9 | ... 10 | 11 | Inherited templates! 12 | -------------------------------------------------------------------------------- /example/manual/example_configuration_file.yaml: -------------------------------------------------------------------------------- 1 | settings: 2 | data-dir: ~/my_data_dir 3 | recursive: true 4 | follow-links: false 5 | skip: ['.*'] 6 | templates: 7 | webpage: 8 | glob: ['*.md'] 9 | pandoc: 10 | to: html 11 | toc: true 12 | css: 13 | - assets/style.css 14 | postprocessors: 15 | - postprocessors/tidy.sh 16 | -------------------------------------------------------------------------------- /example/manual/extended_example_configuration_file.yaml: -------------------------------------------------------------------------------- 1 | settings: 2 | data-dir: ~/my_data_dir 3 | recursive: true 4 | follow-links: false 5 | skip: ['.*'] 6 | templates: 7 | author: 8 | metadata: 9 | author: Huub de Beer 10 | today: 11 | preprocessors: 12 | - preprocessors/today.rb 13 | webpage: 14 | glob: ['*.md'] 15 | pandoc: 16 | to: html 17 | toc: true 18 | css: 19 | - assets/style.css 20 | postprocessors: 21 | - postprocessors/tidy.sh 22 | my-webpage: 23 | extends: ['author', 'today', 'webpage'] 24 | pandoc: 25 | to: html5 26 | bibliography: 'assets/my-bibliography.bib' 27 | -------------------------------------------------------------------------------- /example/manual/external_goodbye_world.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 7 | 8 | 9 | 10 | My third pandocomatic-converted document 11 | 16 | 17 | 18 | 19 | 22 |

Goodbye World!

23 | 24 | 25 | -------------------------------------------------------------------------------- /example/manual/external_goodbye_world.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: My third pandocomatic-converted document 3 | pandocomatic_: 4 | use-template: hello 5 | pandoc: 6 | toc: true 7 | css: 8 | remove: 9 | - './style.css' 10 | add: 11 | - './goodbye-style.css' 12 | ... 13 | 14 | Goodbye *World*! 15 | -------------------------------------------------------------------------------- /example/manual/external_goodbye_world2.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 7 | 8 | 9 | 10 | My third pandocomatic-converted document 11 | 16 | 17 | 18 | 19 | 20 | 23 |

Goodbye World!

24 | 25 | 26 | -------------------------------------------------------------------------------- /example/manual/external_goodbye_world2.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: My third pandocomatic-converted document 3 | pandocomatic_: 4 | use-template: goodbye 5 | ... 6 | 7 | Goodbye *World*! 8 | -------------------------------------------------------------------------------- /example/manual/external_hello_world.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 7 | 8 | 9 | 10 | My second pandocomatic-converted document 11 | 16 | 17 | 18 | 19 | 22 |

Hello World!

23 | 24 | 25 | -------------------------------------------------------------------------------- /example/manual/external_hello_world.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: My second pandocomatic-converted document 3 | pandocomatic_: 4 | use-template: hello 5 | ... 6 | 7 | Hello *World*! 8 | -------------------------------------------------------------------------------- /example/manual/hello_world.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | My first pandocomatic-converted document 8 | 9 | 10 | 11 | 14 |

Hello World!

15 | 16 | 17 | -------------------------------------------------------------------------------- /example/manual/hello_world.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: My first pandocomatic-converted document 3 | pandocomatic_: 4 | pandoc: 5 | to: html 6 | ... 7 | 8 | Hello *World*! 9 | -------------------------------------------------------------------------------- /example/manual/my-config.yaml: -------------------------------------------------------------------------------- 1 | templates: 2 | hello: 3 | pandoc: 4 | to: html 5 | css: 6 | - ./style.css 7 | template: hello-template.html 8 | postprocessors: 9 | - ./tidy.sh 10 | -------------------------------------------------------------------------------- /example/manual/my-extended-config.yaml: -------------------------------------------------------------------------------- 1 | templates: 2 | hello: 3 | pandoc: 4 | to: html 5 | css: 6 | - ./style.css 7 | template: hello-template.html 8 | postprocessors: 9 | - ./tidy.sh 10 | goodbye: 11 | extends: ['hello'] 12 | pandoc: 13 | toc: true 14 | css: 15 | - ./goodbye-style.css 16 | -------------------------------------------------------------------------------- /example/manual/my_data_dir/hello-template.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | $for(author-meta)$ 8 | 9 | $endfor$ 10 | $if(date-meta)$ 11 | 12 | $endif$ 13 | $if(keywords)$ 14 | 15 | $endif$ 16 | HELLO WORLD!! 17 | 18 | $if(quotes)$ 19 | 20 | $endif$ 21 | $if(highlighting-css)$ 22 | 25 | $endif$ 26 | $for(css)$ 27 | 28 | $endfor$ 29 | $if(math)$ 30 | $math$ 31 | $endif$ 32 | $for(header-includes)$ 33 | $header-includes$ 34 | $endfor$ 35 | 36 | 37 | $for(include-before)$ 38 | $include-before$ 39 | $endfor$ 40 | $if(title)$ 41 |
42 |

$title$

43 | $if(subtitle)$ 44 |

$subtitle$

45 | $endif$ 46 | $for(author)$ 47 |

$author$

48 | $endfor$ 49 | $if(date)$ 50 |

$date$

51 | $endif$ 52 |
53 | $endif$ 54 | $if(toc)$ 55 |
56 | $toc$ 57 |
58 | $endif$ 59 | $body$ 60 | $for(include-after)$ 61 | $include-after$ 62 | $endfor$ 63 | 64 | 65 | -------------------------------------------------------------------------------- /example/manual/tidy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | tidy -quiet -indent -wrap 78 -utf8 3 | -------------------------------------------------------------------------------- /example/manual/use_my_webpage.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: About using templates 3 | pandocomatic_: 4 | use-template: my-webpage 5 | pandoc: 6 | bibliography: ./a_different_bibliography.bib 7 | postprocessors: 8 | - postprocessors/check_links.sh 9 | ... 10 | 11 | # Introduction 12 | 13 | To use a template, ... 14 | -------------------------------------------------------------------------------- /example/manual/use_my_webpage_and_print.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: About using templates 3 | pandocomatic_: 4 | use-template: 5 | - my-webpage 6 | - my-pdf 7 | pandoc: 8 | bibliography: ./a_different_bibliography.bib 9 | postprocessors: 10 | - postprocessors/check_links.sh 11 | ... 12 | 13 | # Introduction 14 | 15 | To use a template, ... 16 | -------------------------------------------------------------------------------- /example/multiple_input_files/book.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Using multiple input files with pandocomatic 3 | author: Huub de Beer 4 | pandocomatic_: 5 | pandoc: 6 | from: markdown 7 | to: html 8 | standalone: true 9 | toc: true 10 | ... 11 | 12 | 1st 13 | -------------------------------------------------------------------------------- /example/multiple_input_files/chapter01.md: -------------------------------------------------------------------------------- 1 | 2nd 2 | 3 | # Introduction 4 | 5 | Like pandoc itself, pandocomatic does support multiple input files as long as 6 | they are files and not directories. 7 | -------------------------------------------------------------------------------- /example/multiple_input_files/chapter02.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Usage of multiple input files 3 | author: HT de Beer 4 | pandocomatic_: 5 | pandoc: 6 | to: tex 7 | toc: false 8 | ... 9 | 3rd 10 | 11 | # Usage 12 | 13 | To use multiple input files, make sure that: 14 | 15 | - Only files can be used, no directories 16 | - Do not mix `--input/-i` options and extra input paramters: 17 | 18 | - Good: 19 | 20 | ``` 21 | pandocomatic -i 1.md -i 2.md 22 | pandocomatic 1.md 2.md 23 | pandocomatic --input 1.md -i 2.md 24 | ``` 25 | 26 | - Bad: 27 | 28 | ``` 29 | pandocomatic -i somedir -i 1.md 30 | ``` 31 | -------------------------------------------------------------------------------- /example/odt_with_images.yaml: -------------------------------------------------------------------------------- 1 | settings: 2 | recursive: true 3 | templates: 4 | toodt: 5 | glob: ['*.md'] 6 | metadata: 7 | author: Huub de Beer 8 | pandoc: 9 | from: markdown 10 | to: odt 11 | -------------------------------------------------------------------------------- /example/only-comment-in-metadata.html: -------------------------------------------------------------------------------- 1 |

Look here!

2 | -------------------------------------------------------------------------------- /example/only-comment-in-metadata.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Only a comment in the pandoc section works as well 3 | pandocomatic_: 4 | pandoc: 5 | #from: md 6 | ... 7 | 8 | Look here! 9 | -------------------------------------------------------------------------------- /example/pandocomatic.yaml: -------------------------------------------------------------------------------- 1 | settings: 2 | recursive: false 3 | -------------------------------------------------------------------------------- /example/root_paths/config.yaml: -------------------------------------------------------------------------------- 1 | settings: 2 | recursive: true 3 | templates: 4 | web: 5 | glob: ["*.md"] 6 | pandoc: 7 | from: markdown 8 | to: html 9 | standalone: true 10 | css: 11 | - "without_root_path.css" 12 | - "/absolute/path/from/template.css" 13 | - "$ROOT$/assets/root_relative_path_from_template.css" 14 | - "datadir/relative/path/from/template.css" 15 | -------------------------------------------------------------------------------- /example/root_paths/data/without_root_path.css: -------------------------------------------------------------------------------- 1 | b { 2 | color: red; 3 | } 4 | -------------------------------------------------------------------------------- /example/root_paths/src/assets/main.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/htdebeer/pandocomatic/117253eabaf92d31c604b254220ec6cdeb338731/example/root_paths/src/assets/main.css -------------------------------------------------------------------------------- /example/root_paths/src/assets/root_relative_path.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/htdebeer/pandocomatic/117253eabaf92d31c604b254220ec6cdeb338731/example/root_paths/src/assets/root_relative_path.css -------------------------------------------------------------------------------- /example/root_paths/src/assets/root_relative_path_from_template.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/htdebeer/pandocomatic/117253eabaf92d31c604b254220ec6cdeb338731/example/root_paths/src/assets/root_relative_path_from_template.css -------------------------------------------------------------------------------- /example/root_paths/src/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Test links to external CSS files 3 | pandocomatic_: 4 | pandoc: 5 | to: html 6 | standalone: true 7 | css: 8 | - "without_root_path.css" 9 | - "/absolute/path.css" 10 | - "./assets/main.css" # relative path 11 | - "$ROOT$/assets/root_relative_path.css" 12 | ... 13 | 14 | This is a simple test with four different CSS options. 15 | -------------------------------------------------------------------------------- /example/root_paths/src/subdir/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Test links to external CSS files 3 | pandocomatic_: 4 | pandoc: 5 | to: html 6 | standalone: true 7 | css: 8 | - "without_root_path.css" 9 | - "/absolute/path.css" 10 | - "../assets/main.css" # relative path 11 | - "$ROOT$/assets/root_relative_path.css" 12 | ... 13 | 14 | This is a simple test with four different CSS options. 15 | -------------------------------------------------------------------------------- /example/root_paths/www-with-non-subdir-root-path/assets/main.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/htdebeer/pandocomatic/117253eabaf92d31c604b254220ec6cdeb338731/example/root_paths/www-with-non-subdir-root-path/assets/main.css -------------------------------------------------------------------------------- /example/root_paths/www-with-non-subdir-root-path/assets/root_relative_path.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/htdebeer/pandocomatic/117253eabaf92d31c604b254220ec6cdeb338731/example/root_paths/www-with-non-subdir-root-path/assets/root_relative_path.css -------------------------------------------------------------------------------- /example/root_paths/www-with-non-subdir-root-path/assets/root_relative_path_from_template.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/htdebeer/pandocomatic/117253eabaf92d31c604b254220ec6cdeb338731/example/root_paths/www-with-non-subdir-root-path/assets/root_relative_path_from_template.css -------------------------------------------------------------------------------- /example/root_paths/www-with-non-subdir-root-path/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Test links to external CSS files 8 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 |
35 |

Test links to external CSS files

36 |
37 |

This is a simple test with four different CSS options.

38 | 39 | 40 | -------------------------------------------------------------------------------- /example/root_paths/www-with-non-subdir-root-path/subdir/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Test links to external CSS files 8 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 |
35 |

Test links to external CSS files

36 |
37 |

This is a simple test with four different CSS options.

38 | 39 | 40 | -------------------------------------------------------------------------------- /example/root_paths/www-with-root-path/assets/main.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/htdebeer/pandocomatic/117253eabaf92d31c604b254220ec6cdeb338731/example/root_paths/www-with-root-path/assets/main.css -------------------------------------------------------------------------------- /example/root_paths/www-with-root-path/assets/root_relative_path.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/htdebeer/pandocomatic/117253eabaf92d31c604b254220ec6cdeb338731/example/root_paths/www-with-root-path/assets/root_relative_path.css -------------------------------------------------------------------------------- /example/root_paths/www-with-root-path/assets/root_relative_path_from_template.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/htdebeer/pandocomatic/117253eabaf92d31c604b254220ec6cdeb338731/example/root_paths/www-with-root-path/assets/root_relative_path_from_template.css -------------------------------------------------------------------------------- /example/root_paths/www-with-root-path/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Test links to external CSS files 8 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 |
35 |

Test links to external CSS files

36 |
37 |

This is a simple test with four different CSS options.

38 | 39 | 40 | -------------------------------------------------------------------------------- /example/root_paths/www-with-root-path/subdir/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Test links to external CSS files 8 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 |
35 |

Test links to external CSS files

36 |
37 |

This is a simple test with four different CSS options.

38 | 39 | 40 | -------------------------------------------------------------------------------- /example/root_paths/www-without-root-path/assets/main.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/htdebeer/pandocomatic/117253eabaf92d31c604b254220ec6cdeb338731/example/root_paths/www-without-root-path/assets/main.css -------------------------------------------------------------------------------- /example/root_paths/www-without-root-path/assets/root_relative_path.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/htdebeer/pandocomatic/117253eabaf92d31c604b254220ec6cdeb338731/example/root_paths/www-without-root-path/assets/root_relative_path.css -------------------------------------------------------------------------------- /example/root_paths/www-without-root-path/assets/root_relative_path_from_template.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/htdebeer/pandocomatic/117253eabaf92d31c604b254220ec6cdeb338731/example/root_paths/www-without-root-path/assets/root_relative_path_from_template.css -------------------------------------------------------------------------------- /example/root_paths/www-without-root-path/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Test links to external CSS files 8 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 |
35 |

Test links to external CSS files

36 |
37 |

This is a simple test with four different CSS options.

38 | 39 | 40 | -------------------------------------------------------------------------------- /example/root_paths/www-without-root-path/subdir/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Test links to external CSS files 8 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 |
35 |

Test links to external CSS files

36 |
37 |

This is a simple test with four different CSS options.

38 | 39 | 40 | -------------------------------------------------------------------------------- /example/setup-cleanup.yaml: -------------------------------------------------------------------------------- 1 | settings: 2 | recursive: true 3 | follow-links: false 4 | templates: 5 | wiki-page: 6 | glob: ['*.md'] 7 | setup: 8 | - 'scripts/create_temp_file.sh' 9 | preprocessors: 10 | - 'preprocessors/now.rb' 11 | pandoc: 12 | from: markdown 13 | to: html5 14 | standalone: true 15 | template: 'templates/wiki.html' 16 | postprocessors: 17 | - 'postprocessors/branding.rb' 18 | cleanup: 19 | -------------------------------------------------------------------------------- /example/setup.yaml: -------------------------------------------------------------------------------- 1 | settings: 2 | recursive: true 3 | follow-links: false 4 | templates: 5 | wiki-page: 6 | glob: ['*.md'] 7 | setup: 8 | - 'scripts/create_temp_file.sh' 9 | preprocessors: 10 | - 'preprocessors/now.rb' 11 | pandoc: 12 | from: markdown 13 | to: html5 14 | standalone: true 15 | template: 'templates/wiki.html' 16 | postprocessors: 17 | - 'postprocessors/branding.rb' 18 | cleanup: 19 | -------------------------------------------------------------------------------- /example/simple_date_in_metadata.md: -------------------------------------------------------------------------------- 1 | --- 2 | date: 2022-01-05 3 | pandocomatic_: 4 | pandoc: 5 | from: markdown 6 | to: markdown 7 | template: templates/date.md 8 | ... 9 | -------------------------------------------------------------------------------- /example/site.yaml: -------------------------------------------------------------------------------- 1 | settings: 2 | recursive: true 3 | follow-links: false 4 | -------------------------------------------------------------------------------- /example/src/authored_wiki/config.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Pandocomatic configuration made easy 3 | ... 4 | 5 | To configure pandocomatic, either specify an initial configuration file or use 6 | the conventional configuration file `pandocomatic.yaml`. 7 | 8 | -------------------------------------------------------------------------------- /example/src/authored_wiki/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Authorized pandocomatic wiki 3 | ... 4 | Welcome at the [Pandocomatic wiki](/). Pandocomatic is a 5 | [ruby](https://www.ruby-lang.org/en/) program to automate the use of 6 | [pandoc](http://pandoc.org/). 7 | 8 | Given a [pandocomatic configuration](config), pandocomatic converts an input 9 | file or an input directory tree as specified by that configuration. 10 | -------------------------------------------------------------------------------- /example/src/authored_wiki/pandocomatic.yaml: -------------------------------------------------------------------------------- 1 | settings: 2 | recursive: true 3 | follow-links: false 4 | templates: 5 | wiki-page: 6 | glob: ['*.md'] 7 | preprocessors: 8 | - 'preprocessors/now.rb' 9 | metadata: 10 | author: Huub de Beer 11 | pandoc: 12 | from: markdown 13 | to: html5 14 | standalone: true 15 | template: 'templates/authored_wiki.html' 16 | postprocessors: 17 | - 'postprocessors/branding.rb' 18 | -------------------------------------------------------------------------------- /example/src/blog/first_post.md: -------------------------------------------------------------------------------- 1 | # My first post 2 | 3 | This is my first post on my new blog! 4 | -------------------------------------------------------------------------------- /example/src/blog/on_using_pandocomatic.md: -------------------------------------------------------------------------------- 1 | # On Using Pandocomatic 2 | 3 | In my second blog post I want to talk about how to use pandocomatic, the 4 | program I use to generate this blog! 5 | -------------------------------------------------------------------------------- /example/src/blog/pandocomatic.yaml: -------------------------------------------------------------------------------- 1 | settings: 2 | recursive: true 3 | follow-links: false 4 | templates: 5 | blog: 6 | glob: ['*.md'] 7 | pandoc: 8 | from: markdown 9 | to: html5 10 | standalone: true 11 | template: 'templates/blog.html' 12 | -------------------------------------------------------------------------------- /example/src/extended_wiki/config.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Pandocomatic configuration 3 | ... 4 | 5 | To configure pandocomatic, either specify an initial configuration file or use 6 | the conventional configuration file `pandocomatic.yaml`. 7 | 8 | -------------------------------------------------------------------------------- /example/src/extended_wiki/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Pandocomatic wiki 3 | ... 4 | Welcome at the [Pandocomatic wiki](/). Pandocomatic is a 5 | [ruby](https://www.ruby-lang.org/en/) program to automate the use of 6 | [pandoc](http://pandoc.org/). 7 | 8 | Given a [pandocomatic configuration](config), pandocomatic converts an input 9 | file or an input directory tree as specified by that configuration. 10 | -------------------------------------------------------------------------------- /example/src/extended_wiki/pandocomatic.yaml: -------------------------------------------------------------------------------- 1 | settings: 2 | recursive: true 3 | follow-links: false 4 | templates: 5 | now: 6 | preprocessors: 7 | - 'preprocessors/now.rb' 8 | branding: 9 | postprocessors: 10 | - 'postprocessors/branding.rb' 11 | wiki-page: 12 | extends: ['now', 'branding'] 13 | glob: ['*.md'] 14 | pandoc: 15 | from: markdown 16 | to: html5 17 | standalone: true 18 | template: 'templates/wiki.html' 19 | extended-wiki-page: 20 | extends: 'wiki-page' 21 | pandoc: 22 | template: 'templates/extended_wiki.html' 23 | -------------------------------------------------------------------------------- /example/src/odt_with_images/file1.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: A first test file with images 3 | ... 4 | 5 | ![Image in this directory](./image.png) 6 | 7 | ![Image in a subdirectory](./img/image.png) 8 | -------------------------------------------------------------------------------- /example/src/odt_with_images/file2.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: A second test file with images 3 | ... 4 | 5 | It has actually the same images: 6 | 7 | ![Image in this directory](./image.png) 8 | 9 | ![Image in a subdirectory](./img/image.png) 10 | -------------------------------------------------------------------------------- /example/src/odt_with_images/image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/htdebeer/pandocomatic/117253eabaf92d31c604b254220ec6cdeb338731/example/src/odt_with_images/image.png -------------------------------------------------------------------------------- /example/src/odt_with_images/img/image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/htdebeer/pandocomatic/117253eabaf92d31c604b254220ec6cdeb338731/example/src/odt_with_images/img/image.png -------------------------------------------------------------------------------- /example/src/odt_with_images/pandocomatic.yaml: -------------------------------------------------------------------------------- 1 | settings: 2 | recursive: true 3 | skip: ['img', '*.png'] # Do not copy the images 4 | templates: 5 | toodt: 6 | glob: ['*.md'] 7 | metadata: 8 | author: Huub de Beer 9 | pandoc: 10 | from: markdown 11 | to: odt 12 | -------------------------------------------------------------------------------- /example/src/odt_with_images/subdir/file1.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: A first test file with images 3 | ... 4 | 5 | ![Image in this directory](./image.png) 6 | 7 | ![Image in a subdirectory](./img/image.png) 8 | -------------------------------------------------------------------------------- /example/src/odt_with_images/subdir/file2.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: A second test file with images 3 | ... 4 | 5 | It has actually the same images: 6 | 7 | ![Image in this directory](./image.png) 8 | 9 | ![Image in a subdirectory](./img/image.png) 10 | -------------------------------------------------------------------------------- /example/src/odt_with_images/subdir/image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/htdebeer/pandocomatic/117253eabaf92d31c604b254220ec6cdeb338731/example/src/odt_with_images/subdir/image.png -------------------------------------------------------------------------------- /example/src/odt_with_images/subdir/img/image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/htdebeer/pandocomatic/117253eabaf92d31c604b254220ec6cdeb338731/example/src/odt_with_images/subdir/img/image.png -------------------------------------------------------------------------------- /example/src/public/blog.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-size: 14pt; 3 | line-height: 1.45; 4 | } 5 | 6 | header { 7 | background-color: crimson; 8 | color: ivory; 9 | border-bottom: 1px solid black; 10 | } 11 | 12 | main { 13 | text-align: justify; 14 | max-width: 45em; 15 | } 16 | 17 | main h1 { 18 | font-size: 20pt; 19 | text-align: left; 20 | } 21 | 22 | main h2 { 23 | font-size: 18pt; 24 | text-align: left; 25 | } 26 | 27 | -------------------------------------------------------------------------------- /example/src/public/wiki.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-size: 14pt; 3 | font-family: sans-serif; 4 | } 5 | 6 | a.empty { 7 | color: red; 8 | } 9 | 10 | a.external { 11 | color: green; 12 | } 13 | -------------------------------------------------------------------------------- /example/src/setup-cleanup-wiki/config.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Pandocomatic configuration 3 | ... 4 | 5 | To configure pandocomatic, either specify an initial configuration file or use 6 | the conventional configuration file `pandocomatic.yaml`. 7 | 8 | -------------------------------------------------------------------------------- /example/src/setup-cleanup-wiki/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Pandocomatic wiki 3 | ... 4 | Welcome at the [Pandocomatic wiki](/). Pandocomatic is a 5 | [ruby](https://www.ruby-lang.org/en/) program to automate the use of 6 | [pandoc](http://pandoc.org/). 7 | 8 | Given a [pandocomatic configuration](config), pandocomatic converts an input 9 | file or an input directory tree as specified by that configuration. 10 | -------------------------------------------------------------------------------- /example/src/setup-cleanup-wiki/pandocomatic.yaml: -------------------------------------------------------------------------------- 1 | settings: 2 | recursive: true 3 | follow-links: false 4 | templates: 5 | wiki-page: 6 | glob: ['*.md'] 7 | preprocessors: 8 | - 'preprocessors/now.rb' 9 | pandoc: 10 | from: markdown 11 | to: html5 12 | standalone: true 13 | template: 'templates/wiki.html' 14 | postprocessors: 15 | - 'postprocessors/branding.rb' 16 | -------------------------------------------------------------------------------- /example/src/twice_extended_wiki/another_page.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | title: Another page 3 | pandocomatic_: 4 | use-template: twice-extended-wiki-page 5 | ... 6 | 7 | Another page with a custom template. 8 | -------------------------------------------------------------------------------- /example/src/twice_extended_wiki/config.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Pandocomatic configuration 3 | ... 4 | 5 | To configure pandocomatic, either specify an initial configuration file or use 6 | the conventional configuration file `pandocomatic.yaml`. 7 | 8 | -------------------------------------------------------------------------------- /example/src/twice_extended_wiki/config2.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | title: Pandocomatic configuration 3 | ... 4 | 5 | To configure pandocomatic, either specify an initial configuration file or use 6 | the conventional configuration file `pandocomatic.yaml`. 7 | 8 | -------------------------------------------------------------------------------- /example/src/twice_extended_wiki/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Pandocomatic wiki 3 | ... 4 | Welcome at the [Pandocomatic wiki](/). Pandocomatic is a 5 | [ruby](https://www.ruby-lang.org/en/) program to automate the use of 6 | [pandoc](http://pandoc.org/). 7 | 8 | Given a [pandocomatic configuration](config), pandocomatic converts an input 9 | file or an input directory tree as specified by that configuration. 10 | -------------------------------------------------------------------------------- /example/src/twice_extended_wiki/pandocomatic.yaml: -------------------------------------------------------------------------------- 1 | settings: 2 | recursive: true 3 | follow-links: false 4 | templates: 5 | now: 6 | preprocessors: 7 | - 'preprocessors/now.rb' 8 | branding: 9 | postprocessors: 10 | - 'postprocessors/branding.rb' 11 | wiki-page: 12 | extends: ['now', 'branding'] 13 | glob: ['*.md'] 14 | pandoc: 15 | from: markdown 16 | to: html5 17 | standalone: true 18 | template: 'templates/wiki.html' 19 | css: 20 | - './public/wiki.css' 21 | - './public/page.css' 22 | extended-wiki-page: 23 | glob: ['*.markdown'] 24 | extends: 'wiki-page' 25 | pandoc: 26 | template: 'templates/extended_wiki.html' 27 | old-dashes: true 28 | css: 29 | - './public/footnote.css' 30 | twice-extended-wiki-page: 31 | glob: 32 | remove: ['*.md', '*.markdown'] 33 | extends: 'extended-wiki-page' 34 | preprocessors: 35 | remove: 36 | - 'preprocessors/now.rb' 37 | pandoc: 38 | old-dashes: 39 | css: 40 | remove: 41 | - './public/page.css' 42 | add: 43 | - './public/site.css' 44 | -------------------------------------------------------------------------------- /example/src/wiki/config.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Pandocomatic configuration 3 | ... 4 | 5 | To configure pandocomatic, either specify an initial configuration file or use 6 | the conventional configuration file `pandocomatic.yaml`. 7 | 8 | -------------------------------------------------------------------------------- /example/src/wiki/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Pandocomatic wiki 3 | ... 4 | Welcome at the [Pandocomatic wiki](/). Pandocomatic is a 5 | [ruby](https://www.ruby-lang.org/en/) program to automate the use of 6 | [pandoc](http://pandoc.org/). 7 | 8 | Given a [pandocomatic configuration](config), pandocomatic converts an input 9 | file or an input directory tree as specified by that configuration. 10 | -------------------------------------------------------------------------------- /example/src/wiki/pandocomatic.yaml: -------------------------------------------------------------------------------- 1 | settings: 2 | recursive: true 3 | follow-links: false 4 | templates: 5 | wiki-page: 6 | glob: ['*.md'] 7 | preprocessors: 8 | - 'preprocessors/now.rb' 9 | pandoc: 10 | from: markdown 11 | to: html5 12 | standalone: true 13 | template: 'templates/wiki.html' 14 | postprocessors: 15 | - 'postprocessors/branding.rb' 16 | -------------------------------------------------------------------------------- /example/src/wiki_with_arguments/config.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Pandocomatic configuration 3 | ... 4 | 5 | To configure pandocomatic, either specify an initial configuration file or use 6 | the conventional configuration file `pandocomatic.yaml`. 7 | 8 | -------------------------------------------------------------------------------- /example/src/wiki_with_arguments/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Pandocomatic wiki 3 | ... 4 | Welcome at the [Pandocomatic wiki](/). Pandocomatic is a 5 | [ruby](https://www.ruby-lang.org/en/) program to automate the use of 6 | [pandoc](http://pandoc.org/). 7 | 8 | Given a [pandocomatic configuration](config), pandocomatic converts an input 9 | file or an input directory tree as specified by that configuration. 10 | -------------------------------------------------------------------------------- /example/src/wiki_with_arguments/pandocomatic.yaml: -------------------------------------------------------------------------------- 1 | settings: 2 | recursive: true 3 | follow-links: false 4 | templates: 5 | wiki-page: 6 | glob: ['*.md'] 7 | preprocessors: 8 | - 'preprocessors/now.rb' 9 | - 'preprocessors/add_argument_to_metadata.rb --arg1 -arg2 arg3' 10 | - 'preprocessors/add\ argument\ with\ spaces.rb with spaces' 11 | pandoc: 12 | from: markdown 13 | to: html5 14 | standalone: true 15 | template: 'templates/wiki_with_arguments.html' 16 | postprocessors: 17 | - 'postprocessors/branding.rb' 18 | -------------------------------------------------------------------------------- /example/subdir/include_in_header_hello.md: -------------------------------------------------------------------------------- 1 | --- 2 | pandocomatic_: 3 | use-template: red 4 | ... 5 | 6 | Hello, World! From [@Beer2022a] 7 | -------------------------------------------------------------------------------- /example/test.rb: -------------------------------------------------------------------------------- 1 | require_relative '../lib/pandocomatic/pandocomatic' 2 | 3 | Pandocomatic::Pandocomatic.run('-d data-dir -c blog.yaml -i src/blog -o /home/huub/test-blog') 4 | -------------------------------------------------------------------------------- /example/twice_extended_wiki.yaml: -------------------------------------------------------------------------------- 1 | settings: 2 | recursive: true 3 | follow-links: false 4 | templates: 5 | now: 6 | preprocessors: 7 | - 'preprocessors/now.rb' 8 | branding: 9 | postprocessors: 10 | - 'postprocessors/branding.rb' 11 | wiki-page: 12 | extends: ['now', 'branding'] 13 | glob: ['*.md'] 14 | pandoc: 15 | from: markdown 16 | to: html5 17 | standalone: true 18 | template: 'templates/wiki.html' 19 | css: 20 | - './public/wiki.css' 21 | - './public/page.css' 22 | extended-wiki-page: 23 | glob: ['*.markdown'] 24 | extends: 'wiki-page' 25 | pandoc: 26 | template: 'templates/extended_wiki.html' 27 | old-dashes: true 28 | css: 29 | - './public/footnote.css' 30 | twice-extended-wiki-page: 31 | glob: 32 | remove: ['*.md', '*.markdown'] 33 | extends: 'extended-wiki-page' 34 | preprocessors: 35 | remove: 36 | - 'preprocessors/now.rb' 37 | pandoc: 38 | old-dashes: 39 | css: 40 | remove: 41 | - './public/page.css' 42 | add: 43 | - './public/site.css' 44 | -------------------------------------------------------------------------------- /example/vars.yaml: -------------------------------------------------------------------------------- 1 | templates: 2 | var-template: 3 | pandoc: 4 | from: markdown 5 | to: $(P_OUTPUT_FORMAT)$ 6 | standalone: true 7 | metadata: 8 | author: $(P_AUTHOR)$ 9 | -------------------------------------------------------------------------------- /example/wiki.yaml: -------------------------------------------------------------------------------- 1 | settings: 2 | recursive: true 3 | follow-links: false 4 | templates: 5 | wiki-page: 6 | glob: ['*.md'] 7 | preprocessors: 8 | - 'preprocessors/now.rb' 9 | pandoc: 10 | from: markdown 11 | to: html5 12 | standalone: true 13 | template: 'templates/wiki.html' 14 | postprocessors: 15 | - 'postprocessors/branding.rb' 16 | -------------------------------------------------------------------------------- /example/wiki_with_arguments.yaml: -------------------------------------------------------------------------------- 1 | settings: 2 | recursive: true 3 | follow-links: false 4 | templates: 5 | wiki-page: 6 | glob: ['*.md'] 7 | preprocessors: 8 | - 'preprocessors/now.rb' 9 | - 'preprocessors/add_argument_to_metadata.rb --arg1 -arg2 arg3' 10 | - 'preprocessors/add\ argument\ with\ spaces.rb with spaces' 11 | pandoc: 12 | from: markdown 13 | to: html5 14 | standalone: true 15 | template: 'templates/wiki_with_arguments.html' 16 | postprocessors: 17 | - 'postprocessors/branding.rb' 18 | -------------------------------------------------------------------------------- /lib/pandocomatic/command/convert_list_command.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | #-- 4 | # Copyright 2017, 2022, Huub de Beer 5 | # 6 | # This file is part of pandocomatic. 7 | # 8 | # Pandocomatic is free software: you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by the 10 | # Free Software Foundation, either version 3 of the License, or (at your 11 | # option) any later version. 12 | # 13 | # Pandocomatic is distributed in the hope that it will be useful, but 14 | # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 15 | # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16 | # for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License along 19 | # with pandocomatic. If not, see . 20 | #++ 21 | module Pandocomatic 22 | require_relative '../error/io_error' 23 | 24 | require_relative 'command' 25 | require_relative 'create_link_command' 26 | require_relative 'convert_file_command' 27 | require_relative 'copy_file_command' 28 | require_relative 'skip_command' 29 | 30 | # A Command with sub commands 31 | # 32 | # @!attribute subcommands 33 | # @return [Command[]] the subcommands of this ConvertListCommand 34 | class ConvertListCommand < Command 35 | attr_reader :subcommands 36 | 37 | # Create a new ConvertListCommand 38 | def initialize 39 | super 40 | @subcommands = [] 41 | end 42 | 43 | # Push a command to this ConvertListCommand 44 | # 45 | # @param command [Command] command to add 46 | def push(command) 47 | @subcommands.push command 48 | end 49 | 50 | # Skip this ConvertListCommand when there are no sub commands 51 | # 52 | # @return [Boolean] 53 | def skip? 54 | @subcommands.empty? 55 | end 56 | 57 | # The number of commands to execute when this ConvertListCommand 58 | # is executed. 59 | def count 60 | @subcommands.reduce(0) do |total, subcommand| 61 | total + subcommand.count 62 | end 63 | end 64 | 65 | # Get a list of all errors generated while running this command 66 | # 67 | # @return [Error[]] 68 | def all_errors 69 | @subcommands.reduce(@errors) do |total, subcommand| 70 | total + subcommand.all_errors 71 | end 72 | end 73 | 74 | # A string representation of this ConvertListCommand 75 | # 76 | # @return [String] 77 | def to_s 78 | "converting #{@subcommands.size} items:" 79 | end 80 | 81 | # Can this command have multiple commands? 82 | # 83 | # @return [Boolean] true 84 | def multiple? 85 | true 86 | end 87 | 88 | # Execute this ConvertListCommand 89 | def execute 90 | return if @subcommands.empty? 91 | 92 | description = CommandPrinter.new(self) 93 | Pandocomatic::LOG.info description 94 | description.print unless quiet? 95 | run if !dry_run? && runnable? 96 | 97 | @subcommands.each(&:execute) 98 | end 99 | end 100 | end 101 | -------------------------------------------------------------------------------- /lib/pandocomatic/command/copy_file_command.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | #-- 4 | # Copyright 2017, Huub de Beer 5 | # 6 | # This file is part of pandocomatic. 7 | # 8 | # Pandocomatic is free software: you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by the 10 | # Free Software Foundation, either version 3 of the License, or (at your 11 | # option) any later version. 12 | # 13 | # Pandocomatic is distributed in the hope that it will be useful, but 14 | # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 15 | # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16 | # for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License along 19 | # with pandocomatic. If not, see . 20 | #++ 21 | module Pandocomatic 22 | require 'fileutils' 23 | 24 | require_relative '../error/io_error' 25 | require_relative 'command' 26 | 27 | # A command to copy a file 28 | # 29 | # @!attribute src 30 | # @return [String] path to the file to copy 31 | class CopyFileCommand < Command 32 | attr_reader :src 33 | 34 | # Create a new CopyFileCommand 35 | # 36 | # @param src [String] path to the file to copy 37 | # @param dst [String] path to the place to copy the source file to 38 | def initialize(src, dst) 39 | super() 40 | @src = src 41 | @dst = dst 42 | @errors.push IOError.new(:file_is_not_readable, nil, @src) unless File.readable? @src 43 | @errors.push IOError.new(:file_is_not_writable, nil, @dst) unless !File.exist?(@dst) || File.writable?(@dst) 44 | end 45 | 46 | # Run this CopyFileCommand 47 | def run 48 | if file_modified?(@src, @dst) 49 | Pandocomatic::LOG.info "Copying '#{@src}' → '#{@dst}'" 50 | FileUtils.cp(@src, @dst) 51 | end 52 | rescue StandardError => e 53 | raise IOError.new(:unable_to_copy_file, e, [@src, @dst]) 54 | end 55 | 56 | # A string representation of this CopyFileCommand 57 | # 58 | # @return [String] 59 | def to_s 60 | "copy #{File.basename @src}" 61 | end 62 | end 63 | end 64 | -------------------------------------------------------------------------------- /lib/pandocomatic/command/skip_command.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | #-- 4 | # Copyright 2017, Huub de Beer 5 | # 6 | # This file is part of pandocomatic. 7 | # 8 | # Pandocomatic is free software: you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by the 10 | # Free Software Foundation, either version 3 of the License, or (at your 11 | # option) any later version. 12 | # 13 | # Pandocomatic is distributed in the hope that it will be useful, but 14 | # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 15 | # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16 | # for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License along 19 | # with pandocomatic. If not, see . 20 | #++ 21 | module Pandocomatic 22 | require_relative 'command' 23 | 24 | # A command to skip a file or directory 25 | # 26 | # @!attribute src 27 | # @return [String] the file or directory to skip 28 | # 29 | # @!attribute message 30 | # @return [String] message explaining why the file or directory is being skipped. 31 | class SkipCommand < Command 32 | attr_reader :src, :message 33 | 34 | # Create a new SkipCommand 35 | # 36 | # @param src [String] path to the file to skip 37 | # @param message [String] the message explaining why this file is being 38 | # skipped 39 | def initialize(src, message) 40 | super() 41 | @src = src 42 | @message = message 43 | end 44 | 45 | # Has this SkipCommand a message? 46 | # 47 | # @return [Boolean] 48 | def message? 49 | !((@message.nil? or @message.empty?)) 50 | end 51 | 52 | # 'Run' this SkipCommand by doing nothing 53 | def run; end 54 | 55 | # Skip this command 56 | # 57 | # @return [Boolean] true 58 | def skip? 59 | true 60 | end 61 | 62 | # A string representation of this SkipCommand 63 | # 64 | # @return [String] 65 | def to_s 66 | "skipping #{File.basename @src}" + (": #{@message}" if message?) 67 | end 68 | end 69 | end 70 | -------------------------------------------------------------------------------- /lib/pandocomatic/default_configuration.yaml: -------------------------------------------------------------------------------- 1 | settings: 2 | recursive: true 3 | follow-symlinks: false 4 | skip: ['.*', 'pandocomatic.yaml'] 5 | extract-metadata-from: [] 6 | match-files: 'first' 7 | templates: 8 | empty: 9 | metadata: 10 | empty: true 11 | -------------------------------------------------------------------------------- /lib/pandocomatic/error/cli_error.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | #-- 4 | # Copyright 2017, Huub de Beer 5 | # 6 | # This file is part of pandocomatic. 7 | # 8 | # Pandocomatic is free software: you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by the 10 | # Free Software Foundation, either version 3 of the License, or (at your 11 | # option) any later version. 12 | # 13 | # Pandocomatic is distributed in the hope that it will be useful, but 14 | # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 15 | # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16 | # for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License along 19 | # with pandocomatic. If not, see . 20 | #++ 21 | module Pandocomatic 22 | require_relative 'pandocomatic_error' 23 | 24 | # A command-line error. 25 | class CLIError < PandocomaticError 26 | # Get the template used to print this CLIError 27 | def template 28 | 'cli_error.txt' 29 | end 30 | 31 | # :no_input_given, 32 | # :input_does_not_exist, 33 | # :input_is_not_readable, 34 | # :multiple_input_files_only, 35 | # :no_mixed_inputs 36 | 37 | # :no_output_given, 38 | # :output_is_not_a_directory, 39 | # :output_is_not_a_file, 40 | # :output_it_not_writable, 41 | 42 | # :cannot_use_stdout_with_directory 43 | # :cannot_use_both_output_and_stdout 44 | 45 | # :unknown_option, 46 | # :problematic_invocation, 47 | 48 | # :data_dir_does_not_exist, 49 | # :data_dir_is_not_a_directory, 50 | # :data_dir_is_not_readable, 51 | 52 | # :config_file_does_not_exist, 53 | # :config_file_is_not_a_file, 54 | # :config_file_is_not_readable 55 | end 56 | end 57 | -------------------------------------------------------------------------------- /lib/pandocomatic/error/configuration_error.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | #-- 4 | # Copyright 2017 Huub de Beer 5 | # 6 | # This file is part of pandocomatic. 7 | # 8 | # Pandocomatic is free software: you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by the 10 | # Free Software Foundation, either version 3 of the License, or (at your 11 | # option) any later version. 12 | # 13 | # Pandocomatic is distributed in the hope that it will be useful, but 14 | # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 15 | # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16 | # for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License along 19 | # with pandocomatic. If not, see . 20 | #++ 21 | module Pandocomatic 22 | require_relative 'pandocomatic_error' 23 | 24 | # A ConfigurationError 25 | class ConfigurationError < PandocomaticError 26 | # The template to print this ConfigurationError 27 | def template 28 | 'configuration_error.txt' 29 | end 30 | 31 | # :data_dir_does_not_exist, 32 | # :data_dir_is_not_a_directory, 33 | # :data_dir_is_not_readable, 34 | 35 | # :config_file_does_not_exist, 36 | # :config_file_is_not_a_file, 37 | # :config_file_is_not_readable, 38 | # :unable_to_load_config_file 39 | 40 | # :no_such_template 41 | end 42 | end 43 | -------------------------------------------------------------------------------- /lib/pandocomatic/error/io_error.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | #-- 4 | # Copyright 2017, Huub de Beer 5 | # 6 | # This file is part of pandocomatic. 7 | # 8 | # Pandocomatic is free software: you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by the 10 | # Free Software Foundation, either version 3 of the License, or (at your 11 | # option) any later version. 12 | # 13 | # Pandocomatic is distributed in the hope that it will be useful, but 14 | # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 15 | # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16 | # for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License along 19 | # with pandocomatic. If not, see . 20 | #++ 21 | module Pandocomatic 22 | require_relative 'pandocomatic_error' 23 | 24 | # An IOError 25 | class IOError < PandocomaticError 26 | # The template to use when printing this IOError 27 | def template 28 | 'io_error.txt' 29 | end 30 | 31 | # :file_does_not_exist file 32 | # :file_is_not_a_file file 33 | # :file_is_not_readable file 34 | # :file_is_not_writable file 35 | 36 | # :error_opening_file file 37 | # :error_writing_file file 38 | 39 | # :directory_does_not_exist dir 40 | # :directory_is_not_a_directory dir 41 | # :directory_is_not_readable dir 42 | # :directory_is_not_writable dir 43 | 44 | # :error_opening_directory dir 45 | # :error_creating_directory dir 46 | 47 | # :file_or_directory_does_not_exist src 48 | # :unable_to_copy_file [src, dst] 49 | # :unable_to_create_symbolic_link [src, dst] 50 | # :unable_to_read_symbolic_link [src] 51 | end 52 | end 53 | -------------------------------------------------------------------------------- /lib/pandocomatic/error/pandoc_error.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | #-- 4 | # Copyright 2017, Huub de Beer 5 | # 6 | # This file is part of pandocomatic. 7 | # 8 | # Pandocomatic is free software: you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by the 10 | # Free Software Foundation, either version 3 of the License, or (at your 11 | # option) any later version. 12 | # 13 | # Pandocomatic is distributed in the hope that it will be useful, but 14 | # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 15 | # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16 | # for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License along 19 | # with pandocomatic. If not, see . 20 | #++ 21 | module Pandocomatic 22 | require_relative 'pandocomatic_error' 23 | 24 | # An error when running pandoc 25 | class PandocError < PandocomaticError 26 | # The template to use to print this PandocError 27 | def template 28 | 'pandoc_error.txt' 29 | end 30 | 31 | # :error_running_pandoc 32 | end 33 | end 34 | -------------------------------------------------------------------------------- /lib/pandocomatic/error/pandoc_metadata_error.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | #-- 4 | # Copyright 2023 Huub de Beer 5 | # 6 | # This file is part of pandocomatic. 7 | # 8 | # Pandocomatic is free software: you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by the 10 | # Free Software Foundation, either version 3 of the License, or (at your 11 | # option) any later version. 12 | # 13 | # Pandocomatic is distributed in the hope that it will be useful, but 14 | # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 15 | # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16 | # for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License along 19 | # with pandocomatic. If not, see . 20 | #++ 21 | module Pandocomatic 22 | require_relative 'pandocomatic_error' 23 | 24 | # A PandocMetadataError 25 | class PandocMetadataError < PandocomaticError 26 | # The template to print this ConfigurationError 27 | def template 28 | 'pandoc_metadata_error.txt' 29 | end 30 | 31 | # :file_contains_horizontal_lines_with_three_dashes 32 | # :cannot_parse_YAML_metadata 33 | end 34 | end 35 | -------------------------------------------------------------------------------- /lib/pandocomatic/error/pandocomatic_error.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | #-- 4 | # Copyright 2017 Huub de Beer 5 | # 6 | # This file is part of pandocomatic. 7 | # 8 | # Pandocomatic is free software: you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by the 10 | # Free Software Foundation, either version 3 of the License, or (at your 11 | # option) any later version. 12 | # 13 | # Pandocomatic is distributed in the hope that it will be useful, but 14 | # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 15 | # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16 | # for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License along 19 | # with pandocomatic. If not, see . 20 | #++ 21 | module Pandocomatic 22 | require_relative '../printer/error_printer' 23 | 24 | # General pandocomatic error 25 | # 26 | # @!attribute type 27 | # @return [Symbol] type of error 28 | # 29 | # @!attribute error 30 | # @return [Error] the underlying error, if any 31 | # 32 | # @!attribute data 33 | # @return [Object] attached data, if any 34 | class PandocomaticError < StandardError 35 | attr_reader :type, :error, :data 36 | 37 | # Create a new PandocomaticError 38 | # 39 | # @param type [Symbol = :unknown] the type of error, defaults to :unknown 40 | # @param error [Error = nil] the underlying error, optional 41 | # @param data [Object = nil] extra information attached to this 42 | # PandocomaticError, if any; optional 43 | def initialize(type = :unknown, error = nil, data = nil) 44 | super(type.to_s.gsub('_', ' ').capitalize) 45 | @type = type 46 | @error = error 47 | @data = data 48 | end 49 | 50 | # Has this PandocomaticError an underlying error? 51 | # 52 | # @return [Boolean] 53 | def error? 54 | !@error.nil? 55 | end 56 | 57 | # Has this PandocomaticError extra information associated to it? 58 | # 59 | # @return [Boolean] 60 | def data? 61 | !@data.nil? 62 | end 63 | 64 | # Print this error. 65 | def print 66 | ErrorPrinter.new(self).print 67 | end 68 | 69 | # Show this error 70 | # 71 | # @return [String] a string representation of this PandocomaticError 72 | def show 73 | ErrorPrinter.new(self).to_s 74 | end 75 | end 76 | end 77 | -------------------------------------------------------------------------------- /lib/pandocomatic/error/processor_error.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | #-- 4 | # Copyright 2017, Huub de Beer 5 | # 6 | # This file is part of pandocomatic. 7 | # 8 | # Pandocomatic is free software: you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by the 10 | # Free Software Foundation, either version 3 of the License, or (at your 11 | # option) any later version. 12 | # 13 | # Pandocomatic is distributed in the hope that it will be useful, but 14 | # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 15 | # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16 | # for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License along 19 | # with pandocomatic. If not, see . 20 | #++ 21 | module Pandocomatic 22 | require_relative 'pandocomatic_error' 23 | 24 | # An error while running a processor 25 | class ProcessorError < PandocomaticError 26 | # The template to use when printing this ProcessorError 27 | def template 28 | 'processor_error.txt' 29 | end 30 | 31 | # :script_does_not_exist script 32 | # :script_is_not_executable script 33 | # :error_processing_script [script, src] 34 | end 35 | end 36 | -------------------------------------------------------------------------------- /lib/pandocomatic/error/template_error.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | #-- 4 | # Copyright 2022, Huub de Beer 5 | # 6 | # This file is part of pandocomatic. 7 | # 8 | # Pandocomatic is free software: you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by the 10 | # Free Software Foundation, either version 3 of the License, or (at your 11 | # option) any later version. 12 | # 13 | # Pandocomatic is distributed in the hope that it will be useful, but 14 | # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 15 | # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16 | # for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License along 19 | # with pandocomatic. If not, see . 20 | #++ 21 | module Pandocomatic 22 | require_relative 'pandocomatic_error' 23 | 24 | # A TemplateError 25 | class TemplateError < PandocomaticError 26 | # Create a new PandocomaticError 27 | # 28 | # @param type [Symbol = :unknown] the type of error, defaults to :unknown 29 | # @param data [Object = nil] extra information attached to this 30 | # TemplateError, if any; optional 31 | def initialize(type = :unknown, data = nil) 32 | super(type, nil, data) 33 | end 34 | 35 | # Represent this template error as a string. 36 | # @return [String] 37 | def to_s 38 | "Environment variable '#{@data[:key]}'" \ 39 | "#{" in '#{@data[:path]}'" unless @data[:path].nil?} " \ 40 | 'does not exist: No substitution possible.' 41 | end 42 | 43 | # The template to print this TemplateError 44 | def template 45 | 'template_error.txt' 46 | end 47 | 48 | # :environment_variable_does_not_exist 49 | end 50 | end 51 | -------------------------------------------------------------------------------- /lib/pandocomatic/input.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | #-- 4 | # Copyright 2019—2024 Huub de Beer 5 | # 6 | # This file is part of pandocomatic. 7 | # 8 | # Pandocomatic is free software: you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by the 10 | # Free Software Foundation, either version 3 of the License, or (at your 11 | # option) any later version. 12 | # 13 | # Pandocomatic is distributed in the hope that it will be useful, but 14 | # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 15 | # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16 | # for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License along 19 | # with pandocomatic. If not, see . 20 | #++ 21 | module Pandocomatic 22 | # Generic class to handle input files and directories in a general manner. 23 | class Input 24 | attr_reader :errors 25 | 26 | # Create a new Input 27 | # 28 | # @param input [String[]] a list of input files 29 | def initialize(input) 30 | @input_files = input 31 | @errors = [] 32 | end 33 | 34 | # The absolute path to this Input 35 | # 36 | # @return String 37 | def absolute_path 38 | File.absolute_path @input_files.first 39 | end 40 | 41 | # The base name of this Input 42 | # 43 | # @return String 44 | def base 45 | File.basename @input_files.first 46 | end 47 | 48 | # The name of this input 49 | # 50 | # @return String 51 | def name 52 | @input_files.first 53 | end 54 | 55 | # Is this input a directory? 56 | # 57 | # @return Boolean 58 | def directory? 59 | File.directory? @input_files.first 60 | end 61 | 62 | # Does this input have encountered any errors? 63 | # 64 | # @return Boolean 65 | def errors? 66 | !@errors.empty? 67 | end 68 | 69 | # A string representation of this Input 70 | # 71 | # @return String 72 | def to_s 73 | name 74 | end 75 | end 76 | end 77 | -------------------------------------------------------------------------------- /lib/pandocomatic/pandocomatic_yaml.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | #-- 4 | # Copyright 2022 Huub de Beer 5 | # 6 | # This file is part of pandocomatic. 7 | # 8 | # Pandocomatic is free software: you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by the 10 | # Free Software Foundation, either version 3 of the License, or (at your 11 | # option) any later version. 12 | # 13 | # Pandocomatic is distributed in the hope that it will be useful, but 14 | # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 15 | # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16 | # for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License along 19 | # with pandocomatic. If not, see . 20 | #++ 21 | module Pandocomatic 22 | require 'date' 23 | require 'yaml' 24 | 25 | require_relative 'error/template_error' 26 | 27 | # PandocomaticYAML is a wrapper around ruby's YAML library that replaces 28 | # occurrences of "$(X)$" in the YAML by the value of the evironment variable 29 | # X. If variable X cannot be found, an exception is thrown. 30 | module PandocomaticYAML 31 | # List of classes that are permitted in YAML 32 | PERMITTED_YAML_CLASSES = [Date].freeze 33 | 34 | # Regular expression representing environment variables in templates 35 | VAR_PATTERN = /\$\((?[a-zA-Z_][a-zA-Z0-9_]*)\)\$/ 36 | 37 | # Load a string, substitute any variables, and parse as YAML. 38 | # 39 | # @param str [String] String to parse as YAML 40 | # @param path [Path|Nil] Path of the source of the string, if any 41 | # @return [Hash] 42 | # @raise [TemplateError] when environment variable does not exist. 43 | def self.load(str, path = nil) 44 | YAML.safe_load substitute_variables(str, path), permitted_classes: PERMITTED_YAML_CLASSES 45 | end 46 | 47 | # Load a text file, substitute any variables, and parse as YAML. 48 | # 49 | # @param path [String] Path to text file to parse as YAML 50 | # @return [Hash] 51 | # @raise [TemplateError] when environment variable does not exist. 52 | def self.load_file(path) 53 | self.load File.read(path), path 54 | end 55 | 56 | # Substitute all environment variables in the str with the values of the 57 | # corresponding environment variables. 58 | # 59 | # @raise [TemplateError] when environment variable does not exist. 60 | private_class_method def self.substitute_variables(str, path = nil) 61 | str.gsub(VAR_PATTERN) do |_match| 62 | key = Regexp.last_match(1) 63 | 64 | raise TemplateError.new(:environment_variable_does_not_exist, { key:, path: }) unless ENV.key? key 65 | 66 | ENV.fetch(key, nil) 67 | end 68 | end 69 | end 70 | end 71 | -------------------------------------------------------------------------------- /lib/pandocomatic/printer/command_printer.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | #-- 4 | # Copyright 2017, Huub de Beer 5 | # 6 | # This file is part of pandocomatic. 7 | # 8 | # Pandocomatic is free software: you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by the 10 | # Free Software Foundation, either version 3 of the License, or (at your 11 | # option) any later version. 12 | # 13 | # Pandocomatic is distributed in the hope that it will be useful, but 14 | # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 15 | # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16 | # for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License along 19 | # with pandocomatic. If not, see . 20 | #++ 21 | module Pandocomatic 22 | require_relative 'printer' 23 | 24 | # Printer for Commands in non-quiet mode 25 | class CommandPrinter < Printer 26 | # Create a new CommandPrinter 27 | def initialize(command) 28 | super('command.txt') 29 | @command = command 30 | end 31 | end 32 | end 33 | -------------------------------------------------------------------------------- /lib/pandocomatic/printer/configuration_errors_printer.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | #-- 4 | # Copyright 2017—2024, Huub de Beer 5 | # 6 | # This file is part of pandocomatic. 7 | # 8 | # Pandocomatic is free software: you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by the 10 | # Free Software Foundation, either version 3 of the License, or (at your 11 | # option) any later version. 12 | # 13 | # Pandocomatic is distributed in the hope that it will be useful, but 14 | # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 15 | # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16 | # for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License along 19 | # with pandocomatic. If not, see . 20 | #++ 21 | module Pandocomatic 22 | require_relative 'printer' 23 | 24 | # Printer for ConfigurationErrors in non-quiet mode 25 | class ConfigurationErrorsPrinter < Printer 26 | # Create a new ConfigurationErrorsPrinter 27 | def initialize(errors) 28 | super('configuration_errors.txt') 29 | @errors = errors 30 | end 31 | 32 | # Print configuration errors to STDOUT 33 | def print 34 | Pandocomatic::LOG.warn self 35 | warn self 36 | end 37 | end 38 | end 39 | -------------------------------------------------------------------------------- /lib/pandocomatic/printer/error_printer.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | #-- 4 | # Copyright 2017—2024, Huub de Beer 5 | # 6 | # This file is part of pandocomatic. 7 | # 8 | # Pandocomatic is free software: you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by the 10 | # Free Software Foundation, either version 3 of the License, or (at your 11 | # option) any later version. 12 | # 13 | # Pandocomatic is distributed in the hope that it will be useful, but 14 | # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 15 | # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16 | # for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License along 19 | # with pandocomatic. If not, see . 20 | #++ 21 | module Pandocomatic 22 | require_relative 'printer' 23 | 24 | # Printer for Errors in non-quiet mode 25 | class ErrorPrinter < Printer 26 | # Create a new ErrorPrinter 27 | def initialize(error) 28 | template = if error.respond_to? :template 29 | error.template 30 | else 31 | 'error.txt' 32 | end 33 | super(template) 34 | @error = error 35 | end 36 | 37 | # Print an Error to STDERR rather than STDOUT 38 | def print 39 | Pandocomatic::LOG.error self 40 | warn self 41 | end 42 | end 43 | end 44 | -------------------------------------------------------------------------------- /lib/pandocomatic/printer/finish_printer.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | #-- 4 | # Copyright 2017, Huub de Beer 5 | # 6 | # This file is part of pandocomatic. 7 | # 8 | # Pandocomatic is free software: you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by the 10 | # Free Software Foundation, either version 3 of the License, or (at your 11 | # option) any later version. 12 | # 13 | # Pandocomatic is distributed in the hope that it will be useful, but 14 | # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 15 | # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16 | # for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License along 19 | # with pandocomatic. If not, see . 20 | #++ 21 | module Pandocomatic 22 | require_relative 'summary_printer' 23 | 24 | # Printer for the end of the conversion process in non-quiet mode 25 | class FinishPrinter < SummaryPrinter 26 | # A minute has 60 seconds 27 | MINUTE = 60 28 | 29 | # Create a new FinishPrinter 30 | # 31 | # @param command [Command] the command to finish 32 | # @param configuration [Configuration] the configuration of the 33 | # pandocomatic invokation 34 | # @param start_time [Time] the time the command was started 35 | def initialize(command, configuration, start_time) 36 | super(command, configuration) 37 | template 'finish.txt' 38 | 39 | @start_time = start_time 40 | @end_time = Time.now 41 | end 42 | 43 | # Calculate the duration of the whole conversion process 44 | # 45 | # @return [Number] 46 | def duration 47 | seconds = @end_time - @start_time 48 | if seconds > MINUTE 49 | minutes = (seconds / MINUTE).floor 50 | seconds -= (minutes * MINUTE) 51 | "#{minutes} minute#{'s' if minutes != 1} and #{seconds.round(1)} second#{'s' if seconds != 1}" 52 | else 53 | "#{seconds.round(1)} second#{'s' if seconds != 1}" 54 | end 55 | end 56 | end 57 | end 58 | -------------------------------------------------------------------------------- /lib/pandocomatic/printer/help_printer.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | #-- 4 | # Copyright 2017, Huub de Beer 5 | # 6 | # This file is part of pandocomatic. 7 | # 8 | # Pandocomatic is free software: you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by the 10 | # Free Software Foundation, either version 3 of the License, or (at your 11 | # option) any later version. 12 | # 13 | # Pandocomatic is distributed in the hope that it will be useful, but 14 | # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 15 | # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16 | # for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License along 19 | # with pandocomatic. If not, see . 20 | #++ 21 | module Pandocomatic 22 | require_relative 'printer' 23 | 24 | # Printer for pandocomatic's help 25 | class HelpPrinter < Printer 26 | # Create a new HelpPrinter 27 | def initialize 28 | super('help.txt') 29 | end 30 | end 31 | end 32 | -------------------------------------------------------------------------------- /lib/pandocomatic/printer/printer.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | #-- 4 | # Copyright 2017, Huub de Beer 5 | # 6 | # This file is part of pandocomatic. 7 | # 8 | # Pandocomatic is free software: you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by the 10 | # Free Software Foundation, either version 3 of the License, or (at your 11 | # option) any later version. 12 | # 13 | # Pandocomatic is distributed in the hope that it will be useful, but 14 | # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 15 | # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16 | # for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License along 19 | # with pandocomatic. If not, see . 20 | #++ 21 | module Pandocomatic 22 | require 'erb' 23 | 24 | # Printer base class for printing information from pandocomatic 25 | class Printer 26 | # Create a new Printer 27 | # 28 | # @param template_file [String = 'help.txt'] the template to use when 29 | # printing. 30 | def initialize(template_file = 'help.txt') 31 | template template_file 32 | end 33 | 34 | # Set the template used by this Printer 35 | # 36 | # @param template_file [String] the template to use 37 | def template(template_file) 38 | dir = File.dirname(__FILE__) 39 | @template = File.absolute_path(File.join(dir, 'views', template_file)) 40 | end 41 | 42 | # Create a string based on this printer's template 43 | # 44 | # @return [String] 45 | def to_s 46 | erb = ERB.new(File.read(@template), trim_mode: '>') 47 | erb.result(binding) 48 | end 49 | 50 | # Print to STDOUT 51 | def print 52 | Pandocomatic::LOG.info self 53 | puts self 54 | end 55 | end 56 | end 57 | -------------------------------------------------------------------------------- /lib/pandocomatic/printer/summary_printer.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | #-- 4 | # Copyright 2017, 2022, Huub de Beer 5 | # 6 | # This file is part of pandocomatic. 7 | # 8 | # Pandocomatic is free software: you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by the 10 | # Free Software Foundation, either version 3 of the License, or (at your 11 | # option) any later version. 12 | # 13 | # Pandocomatic is distributed in the hope that it will be useful, but 14 | # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 15 | # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16 | # for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License along 19 | # with pandocomatic. If not, see . 20 | #++ 21 | module Pandocomatic 22 | require_relative 'printer' 23 | 24 | # Printer for printing a summary of the conversion process in non-quiet mode 25 | class SummaryPrinter < Printer 26 | # Create a new SummaryPrinter 27 | # 28 | # @param command [Command] the command to summarize 29 | # @param configuration [Configuration] the configuration of the 30 | # pandocomatic invokation 31 | def initialize(command, configuration) 32 | super('summary.txt') 33 | @command = command 34 | @input = configuration.input.to_s 35 | @output = if configuration.stdout? 36 | nil 37 | else 38 | configuration.output 39 | end 40 | 41 | @config_files = configuration.config_files 42 | end 43 | 44 | # A string representation of the commands being executed 45 | # 46 | # @return [String] 47 | def commands 48 | "#{@command.count} command#{'s' if @command.count != 1}" 49 | end 50 | 51 | # Is there an output file? 52 | # 53 | # @return [Boolean] True if there is an output defined in this 54 | # SummaryPrinter, false otherwise 55 | def output? 56 | !@output.nil? and !@output.empty? 57 | end 58 | end 59 | end 60 | -------------------------------------------------------------------------------- /lib/pandocomatic/printer/unknown_error_printer.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | #-- 4 | # Copyright 2024, Huub de Beer 5 | # 6 | # This file is part of pandocomatic. 7 | # 8 | # Pandocomatic is free software: you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by the 10 | # Free Software Foundation, either version 3 of the License, or (at your 11 | # option) any later version. 12 | # 13 | # Pandocomatic is distributed in the hope that it will be useful, but 14 | # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 15 | # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16 | # for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License along 19 | # with pandocomatic. If not, see . 20 | #++ 21 | module Pandocomatic 22 | require_relative 'printer' 23 | 24 | # Printer for Errors in non-quiet mode 25 | class UnknownErrorPrinter < Printer 26 | # Create a new ErrorPrinter 27 | def initialize(error) 28 | template = 'unknown_error.txt' 29 | super(template) 30 | @error = error 31 | end 32 | 33 | # Print an Error to STDERR rather than STDOUT 34 | def print 35 | Pandocomatic::LOG.error self 36 | warn self 37 | end 38 | end 39 | end 40 | -------------------------------------------------------------------------------- /lib/pandocomatic/printer/version_printer.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | #-- 4 | # Copyright 2017, Huub de Beer 5 | # 6 | # This file is part of pandocomatic. 7 | # 8 | # Pandocomatic is free software: you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by the 10 | # Free Software Foundation, either version 3 of the License, or (at your 11 | # option) any later version. 12 | # 13 | # Pandocomatic is distributed in the hope that it will be useful, but 14 | # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 15 | # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16 | # for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License along 19 | # with pandocomatic. If not, see . 20 | #++ 21 | module Pandocomatic 22 | require_relative 'printer' 23 | 24 | # Printer to print pandocomatic's version 25 | class VersionPrinter < Printer 26 | # Create a new VersionPrinter 27 | def initialize(version) 28 | super('version.txt') 29 | @version = version 30 | end 31 | end 32 | end 33 | -------------------------------------------------------------------------------- /lib/pandocomatic/printer/views/cli_error.txt: -------------------------------------------------------------------------------- 1 | <%=@error.message%>: <% case @error.type 2 | when :no_input_given%> 3 | Specify the input file or directory with the option `--input PATH`. 4 | <% when :no_mixed_inputs%> 5 | Using both the `--input/-i` options and extra input parameters is not allowed. 6 | Use either only `--input/-i` options or only input parameters. 7 | <% when :multiple_input_files_only %> 8 | When specifying multiple inputs, only files are allowed. '<%= @error.data %>' is a directory. 9 | <% when :unknown_option %> 10 | See `pandocomatic --help` which options are allowed. 11 | <% when :too_many_options %> 12 | <%= @error.data.join(" ") %>. 13 | <% when :problematic_invocation %> 14 | <%=@error.error.message%>. 15 | <% when :cannot_use_stdout_with_directory %> 16 | Using `--stdout/-s` with an input directory is not allowed. 17 | <% when :cannot_use_both_output_and_stdout %> 18 | Using both `--output/-o` and `--stdout/-s` is not allowed. 19 | Use eiter a specific output file or directory, or standard out, not both. 20 | <% when :feature_toggle_does_not_exist %> 21 | '<%= @error.data %>'. 22 | Pandocomatic supports the following feature toggles: <%= Pandocomatic::FEATURES.map{|f| f.to_s}.join(", ") %>. 23 | <% else %> 24 | '<%= @error.data %>'. 25 | <% end %> 26 | -------------------------------------------------------------------------------- /lib/pandocomatic/printer/views/command.txt: -------------------------------------------------------------------------------- 1 | (<%=@command.index_to_s%>) <%=if @command.multiple? then "+ " else " - " end%><%= @command.to_s%> 2 | -------------------------------------------------------------------------------- /lib/pandocomatic/printer/views/configuration_error.txt: -------------------------------------------------------------------------------- 1 | <%=@error.message%>: '<%= @error.data %>'.<% if @error.error? %> <%= 2 | @error.error.to_s %><% end %> 3 | -------------------------------------------------------------------------------- /lib/pandocomatic/printer/views/configuration_errors.txt: -------------------------------------------------------------------------------- 1 | Pandocomatic has encountered the following errors while trying to configure 2 | the conversion process: 3 | 4 | <% @errors.each do |error| %> 5 | - <%= error.show %> 6 | <% end %> 7 | 8 | Pandocomatic will not start the conversion process before these errors are 9 | resolved. See `pandocomatic --help` for more information on how to use 10 | pandocomatic. 11 | -------------------------------------------------------------------------------- /lib/pandocomatic/printer/views/error.txt: -------------------------------------------------------------------------------- 1 | [ERROR] Pandocomatic encountered the following error(s): 2 | 3 | <%= @error.message %> 4 | <%= @error.data %> 5 | <%= @error.error %> 6 | -------------------------------------------------------------------------------- /lib/pandocomatic/printer/views/finish.txt: -------------------------------------------------------------------------------- 1 | Pandocomatic needed <%=duration%> to convert '<%= @input %>'<%if output?%> to '<%= @output %>'<%end%>. 2 | -------------------------------------------------------------------------------- /lib/pandocomatic/printer/views/io_error.txt: -------------------------------------------------------------------------------- 1 | <%=@error.message%>: <% case @error.type 2 | when :error_opening_file%> 3 | <%=@error.error.message %>. 4 | <% when :error_writing_file %> 5 | <%=@error.error.message%>. 6 | <% when :error_opening_directory %> 7 | <%=@error.error.message%>. 8 | <% when :error_creating_directory %> 9 | <%=@error.error.message%>. 10 | <% else %> 11 | '<%= @error.data %>'. 12 | <% end %> 13 | -------------------------------------------------------------------------------- /lib/pandocomatic/printer/views/pandoc_error.txt: -------------------------------------------------------------------------------- 1 | <%=@error.message%> => <%= @error.error.message %> 2 | -------------------------------------------------------------------------------- /lib/pandocomatic/printer/views/pandoc_metadata_error.txt: -------------------------------------------------------------------------------- 1 | Expected to extract YAML metadata blocks from file '<%= @error.data %>', but did not succeed. Make sure '<%= @error.data %>' is a pandoc markdown file. Check YAML syntax of all metadata blocks; make sure that all horizontal lines have at least four (4) dashes. 2 | 3 | <% if @error.error? %>Reported cause(s): 4 | <%= @error.error.to_s %><% end %> 5 | -------------------------------------------------------------------------------- /lib/pandocomatic/printer/views/processor_error.txt: -------------------------------------------------------------------------------- 1 | <%=@error.message%>: <% case @error.type 2 | when :error_processing_script%> 3 | <%= @error[0] %> (<%= @error[1] %>). 4 | <% else %> 5 | '<%= @error.data %>'. 6 | <% end %> 7 | -------------------------------------------------------------------------------- /lib/pandocomatic/printer/views/summary.txt: -------------------------------------------------------------------------------- 1 | Using configuration hierarchy: 2 | <% @config_files.each do |file| %> 3 | - <%= file %> 4 | 5 | <% end %> 6 | 7 | <% if @command.count <= 0 then%>Nothing to do<% else %><%= commands %> to execute to convert '<%= @input %>'<%if output?%> to '<%= @output %>'<%end%><% end %>. 8 | -------------------------------------------------------------------------------- /lib/pandocomatic/printer/views/template_error.txt: -------------------------------------------------------------------------------- 1 | <%=@error.message%> 2 | -------------------------------------------------------------------------------- /lib/pandocomatic/printer/views/unknown_error.txt: -------------------------------------------------------------------------------- 1 | [UNEXPECTED ERROR] An unexpected error has occurred. You can report this bug via https://github.com/htdebeer/pandocomatic/issues/new. 2 | Cause: <%= @error %> 3 | -------------------------------------------------------------------------------- /lib/pandocomatic/printer/views/version.txt: -------------------------------------------------------------------------------- 1 | Pandocomatic version <%=@version.join('.')%> 2 | 3 | © 2014—2024 Huub de Beer 4 | 5 | Pandocomatic is free software; pandocomatic is released under the GPLv3. 6 | 7 | For more information about pandocomatic run 'pandocomatic --help' or read 8 | pandocomatic's manual at https://heerdebeer.org/Software/markdown/pandocomatic/. 9 | -------------------------------------------------------------------------------- /lib/pandocomatic/printer/views/warning.txt: -------------------------------------------------------------------------------- 1 | [WARNING] <%=@warning.message.to_s%>: <%=@warning.src%> 2 | -------------------------------------------------------------------------------- /lib/pandocomatic/printer/warning_printer.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | #-- 4 | # Copyright 2017—2024, Huub de Beer 5 | # 6 | # This file is part of pandocomatic. 7 | # 8 | # Pandocomatic is free software: you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by the 10 | # Free Software Foundation, either version 3 of the License, or (at your 11 | # option) any later version. 12 | # 13 | # Pandocomatic is distributed in the hope that it will be useful, but 14 | # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 15 | # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16 | # for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License along 19 | # with pandocomatic. If not, see . 20 | #++ 21 | module Pandocomatic 22 | require_relative 'printer' 23 | 24 | # Printer for warnings 25 | class WarningPrinter < Printer 26 | # Create a new WarningPrinter 27 | # 28 | # @param warning [Warning] the warning to print 29 | def initialize(warning) 30 | template = 'warning.txt' 31 | super(template) 32 | @warning = warning 33 | end 34 | 35 | # Print warnings to STDERR rather than STDOUT 36 | def print 37 | Pandocomatic::LOG.warn self 38 | warn self 39 | end 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /lib/pandocomatic/processor.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | #-- 4 | # Copyright 2014, 2015, 2016, 2017, Huub de Beer 5 | # 6 | # This file is part of pandocomatic. 7 | # 8 | # Pandocomatic is free software: you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by the 10 | # Free Software Foundation, either version 3 of the License, or (at your 11 | # option) any later version. 12 | # 13 | # Pandocomatic is distributed in the hope that it will be useful, but 14 | # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 15 | # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16 | # for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License along 19 | # with pandocomatic. If not, see . 20 | #++ 21 | module Pandocomatic 22 | require 'open3' 23 | require_relative 'error/processor_error' 24 | 25 | # Generic class for processors used to preprocess, postproces, setup, and 26 | # cleanup with external scripts or programs during the conversion process. 27 | # 28 | # For preprocessors and postprocessors it is assumed that the input is the 29 | # contents of the file to convert and the output the processed input. In 30 | # the end, the output will be put through pandoc. 31 | class Processor 32 | # Run script on input and return captured output 33 | # 34 | # @param script [String] path to script to run 35 | # @param input [String] input to process in the script 36 | # 37 | # @return [String] output of script. 38 | def self.run(script, input) 39 | output, error, status = Open3.capture3(script, stdin_data: input) 40 | warn error unless error.empty? 41 | 42 | if status.exitstatus.positive? 43 | raise ProcessorError.new(:error_processing_script, StandardError.new(error), [script, input]) 44 | end 45 | 46 | output 47 | end 48 | end 49 | end 50 | -------------------------------------------------------------------------------- /lib/pandocomatic/processors/fileinfo_preprocessor.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | #-- 4 | # Copyright 2014—2024, Huub de Beer 5 | # 6 | # This file is part of pandocomatic. 7 | # 8 | # Pandocomatic is free software: you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by the 10 | # Free Software Foundation, either version 3 of the License, or (at your 11 | # option) any later version. 12 | # 13 | # Pandocomatic is distributed in the hope that it will be useful, but 14 | # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 15 | # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16 | # for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License along 19 | # with pandocomatic. If not, see . 20 | #++ 21 | module Pandocomatic 22 | require_relative '../processor' 23 | 24 | # FileInfoPreprocessor collects information about a file to be converted and 25 | # mixes that information into that file's metadata. It is a default 26 | # preprocessor. 27 | # 28 | class FileInfoPreprocessor < Processor 29 | # rubocop:disable Metrics/AbcSize 30 | 31 | # Run this FileInfoPreprocessor 32 | # 33 | # @param input [String] the contents of the document being preprocessed 34 | # @param path [String] the path to the input document 35 | # @param options [Hash] pandoc options collected by pandocomatic to run on 36 | # this file 37 | def self.run(input, path, src_path, options) 38 | created_at = File.stat(path).ctime 39 | modified_at = File.stat(path).mtime 40 | 41 | file_info = "\npandocomatic-fileinfo:\n" 42 | file_info += " from: #{options['from']}\n" if options.key? 'from' 43 | file_info += " to: #{options['to']}\n" if options.key? 'to' 44 | file_info += " template: #{options['template']}\n" if options.key? 'template' 45 | file_info += " path: '#{path}'\n" 46 | file_info += " src_path: '#{src_path}'\n" 47 | file_info += " created: #{created_at.strftime '%Y-%m-%d'}\n" 48 | file_info += " modified: #{modified_at.strftime '%Y-%m-%d'}" 49 | 50 | Pandocomatic::LOG.debug ' | FileInfoPreprocessor. Adding file information to metadata:' \ 51 | "#{Pandocomatic::LOG.indent( 52 | file_info, 37 53 | )}" 54 | 55 | "#{input}\n\n---#{file_info}\n...\n\n" 56 | end 57 | 58 | # rubocop:enable Metrics/AbcSize 59 | end 60 | end 61 | -------------------------------------------------------------------------------- /lib/pandocomatic/processors/metadata_preprocessor.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | #-- 4 | # Copyright 2017—2024, Huub de Beer 5 | # 6 | # This file is part of pandocomatic. 7 | # 8 | # Pandocomatic is free software: you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by the 10 | # Free Software Foundation, either version 3 of the License, or (at your 11 | # option) any later version. 12 | # 13 | # Pandocomatic is distributed in the hope that it will be useful, but 14 | # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 15 | # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16 | # for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License along 19 | # with pandocomatic. If not, see . 20 | #++ 21 | module Pandocomatic 22 | require 'yaml' 23 | require_relative '../processor' 24 | 25 | # MetadataPreprocessor mixes in the metadata section of a template into a 26 | # document before pandoc is run to convert that document. It is a default 27 | # preprocessor. 28 | class MetadataPreprocessor < Processor 29 | # Run this MetadataPreprocessor 30 | # 31 | # @param input [String] the contents of the document that is being 32 | # preprocessed 33 | # @param metadata [Hash = {}] the metadata to mix-in 34 | def self.run(input, metadata = {}) 35 | yaml = YAML.dump(metadata) 36 | Pandocomatic::LOG.debug ' | MetadataPreprocessor. Adding mined YAML blocks to metadata:' \ 37 | "#{Pandocomatic::LOG.indent( 38 | yaml.sub('---', ''), 37 39 | )}" 40 | "#{input}\n\n#{yaml}...\n\n" 41 | end 42 | end 43 | end 44 | -------------------------------------------------------------------------------- /lib/pandocomatic/version.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | #-- 4 | # Copyright 2023—2024 Huub de Beer 5 | # 6 | # This file is part of pandocomatic. 7 | # 8 | # Pandocomatic is free software: you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by the 10 | # Free Software Foundation, either version 3 of the License, or (at your 11 | # option) any later version. 12 | # 13 | # Pandocomatic is distributed in the hope that it will be useful, but 14 | # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 15 | # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16 | # for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License along 19 | # with pandocomatic. If not, see . 20 | #++ 21 | module Pandocomatic 22 | # Pandocomatic's current version. 23 | VERSION = [2, 1, 0].freeze 24 | end 25 | -------------------------------------------------------------------------------- /lib/pandocomatic/warning.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | #-- 4 | # Copyright 2017, Huub de Beer 5 | # 6 | # This file is part of pandocomatic. 7 | # 8 | # Pandocomatic is free software: you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by the 10 | # Free Software Foundation, either version 3 of the License, or (at your 11 | # option) any later version. 12 | # 13 | # Pandocomatic is distributed in the hope that it will be useful, but 14 | # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 15 | # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16 | # for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License along 19 | # with pandocomatic. If not, see . 20 | #++ 21 | module Pandocomatic 22 | # A warning given during the conversion process. 23 | class Warning 24 | # :skipping_link_because_it_points_outside_the_source_tree 25 | 26 | # Create a new Warning with message and some extra data 27 | # 28 | # @param message [Symbol = :unknown] the message translation key. 29 | # @param data [Object = nil] optional data attached to the message. 30 | def initialize(message = :unknown, data = nil) 31 | @message = message 32 | @data = data 33 | end 34 | 35 | # Does this Warning have any data associated with it? 36 | # 37 | # @return [Boolean] True if there is data attached, false otherwise. 38 | def data? 39 | !@data.nil? 40 | end 41 | end 42 | end 43 | -------------------------------------------------------------------------------- /pandocomatic.gemspec: -------------------------------------------------------------------------------- 1 | require_relative 'lib/pandocomatic/version' 2 | 3 | Gem::Specification.new do |s| 4 | s.name = 'pandocomatic' 5 | s.version = Pandocomatic::VERSION.join '.' 6 | s.license = 'GPL-3.0-or-later' 7 | s.summary = 'Automate the use of pandoc' 8 | s.description = 'Pandocomatic is a tool to automate using pandoc. With pandocomatic' 9 | s.description += ' you can express common patterns of using pandoc for generating' 10 | s.description += ' your documents. Applied to a directory, pandocomatic can act as a' 11 | s.description += ' static site generator.' 12 | s.author = ['Huub de Beer'] 13 | s.email = 'Huub@heerdebeer.org' 14 | s.required_ruby_version = '>= 3.1.0' 15 | s.files = Dir['lib/pandocomatic/*.rb'] 16 | s.files += Dir['lib/pandocomatic/default_configuration.yaml'] 17 | s.files += Dir['lib/pandocomatic/command/*.rb'] 18 | s.files += Dir['lib/pandocomatic/error/*.rb'] 19 | s.files += Dir['lib/pandocomatic/processors/*.rb'] 20 | s.files += Dir['lib/pandocomatic/printer/*.rb'] 21 | s.files += Dir['lib/pandocomatic/printer/views/*.txt'] 22 | s.add_dependency 'logger', '~> 1.7' 23 | s.add_dependency 'optimist', '~> 3.1', '>= 3.1' 24 | s.add_dependency 'paru', '~> 1.1', '>= 1.4.1' 25 | s.executables << 'pandocomatic' 26 | s.homepage = 'https://heerdebeer.org/Software/markdown/pandocomatic/' 27 | s.requirements << 'pandoc, a universal document converter' 28 | s.metadata['rubygems_mfa_required'] = 'true' 29 | end 30 | -------------------------------------------------------------------------------- /pandocomatic.yaml: -------------------------------------------------------------------------------- 1 | settings: 2 | skip: ['README.md', 'example'] 3 | -------------------------------------------------------------------------------- /test/files/config.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | pandocomatic_: 3 | pandoc: 4 | from: markdown 5 | to: html 6 | ... 7 | -------------------------------------------------------------------------------- /test/files/readable_test_dir/some_file: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/htdebeer/pandocomatic/117253eabaf92d31c604b254220ec6cdeb338731/test/files/readable_test_dir/some_file -------------------------------------------------------------------------------- /test/files/readable_test_file: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/htdebeer/pandocomatic/117253eabaf92d31c604b254220ec6cdeb338731/test/files/readable_test_file -------------------------------------------------------------------------------- /test/files/readable_test_file2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/htdebeer/pandocomatic/117253eabaf92d31c604b254220ec6cdeb338731/test/files/readable_test_file2 -------------------------------------------------------------------------------- /test/files/unwritable_test_dir/some_file: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/htdebeer/pandocomatic/117253eabaf92d31c604b254220ec6cdeb338731/test/files/unwritable_test_dir/some_file -------------------------------------------------------------------------------- /test/pandocomatic.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # frozen_string_literal: true 3 | 4 | require_relative '../lib/pandocomatic/pandocomatic' 5 | Pandocomatic::Pandocomatic.run ARGV 6 | -------------------------------------------------------------------------------- /test/simple_test.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # frozen_string_literal: true 3 | 4 | require_relative '../lib/pandocomatic/pandocomatic' 5 | 6 | Pandocomatic::Pandocomatic.run '-i files/src/hello.md -o hello2.html' 7 | -------------------------------------------------------------------------------- /test/test_helper.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'minitest/reporters' 4 | OPTIONS = { 5 | color: true 6 | }.freeze 7 | Minitest::Reporters.use! [ 8 | Minitest::Reporters::SpecReporter.new, 9 | Minitest::Reporters::DefaultReporter.new(OPTIONS) 10 | ] 11 | -------------------------------------------------------------------------------- /test/unit/pandocomatic_yaml.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'minitest/autorun' 4 | require 'tmpdir' 5 | require 'pandocomatic' 6 | 7 | class TestPandocomaticYAML < Minitest::Test 8 | def test_no_vars 9 | yaml = <<~YAML 10 | --- 11 | key: value 12 | ... 13 | YAML 14 | 15 | hash = Pandocomatic::PandocomaticYAML.load yaml 16 | 17 | assert hash.key? 'key' 18 | assert_equal hash['key'], 'value' 19 | end 20 | 21 | def test_existing_var 22 | yaml = <<~YAML 23 | --- 24 | key: $(PATH)$ 25 | ... 26 | YAML 27 | 28 | hash = Pandocomatic::PandocomaticYAML.load yaml 29 | 30 | assert hash.key? 'key' 31 | assert_equal hash['key'], ENV.fetch('PATH', nil) 32 | end 33 | 34 | def test_existing_vars 35 | yaml = <<~YAML 36 | --- 37 | key: $(PATH)$ 38 | another: $(HOME)$ 39 | ... 40 | YAML 41 | 42 | hash = Pandocomatic::PandocomaticYAML.load yaml 43 | 44 | assert hash.key? 'key' 45 | assert_equal hash['key'], ENV.fetch('PATH', nil) 46 | 47 | assert hash.key? 'another' 48 | assert_equal hash['another'], Dir.home 49 | end 50 | 51 | def test_non_existing_var 52 | yaml = <<~YAML 53 | --- 54 | key: $(NON_EXISTING_VARIABLE)$ 55 | ... 56 | YAML 57 | 58 | assert_raises( 59 | Pandocomatic::TemplateError, 60 | "Environment variable 'NON_EXISTING_VARIABLE' does not exist: No substitution possible." 61 | ) do 62 | Pandocomatic::PandocomaticYAML.load yaml 63 | end 64 | end 65 | 66 | def test_load_file_with_var 67 | Dir.mktmpdir('vars') do |dir| 68 | path = File.join [dir, 'config.yaml'] 69 | 70 | yaml = <<~YAML 71 | --- 72 | key: $(PATH)$ 73 | ... 74 | YAML 75 | 76 | File.write(path, yaml) 77 | 78 | hash = Pandocomatic::PandocomaticYAML.load_file path 79 | 80 | assert hash.key? 'key' 81 | assert_equal hash['key'], ENV.fetch('PATH', nil) 82 | end 83 | end 84 | end 85 | --------------------------------------------------------------------------------