From d37970ccd647b89a790c0944611f3e3be1f05eaf Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Sat, 10 Oct 2020 19:29:58 -0300 Subject: Use Jekyll to output slides HTML files --- _plugins/add-anchor-to-code-block-line-numbers.rb | 2 +- _plugins/add-anchor-to-header-from-header-id.rb | 2 +- _plugins/add-link-to-plaintext-code-block.rb | 2 +- _plugins/generate-pastebin-plaintext-alternate.rb | 14 ++++++++------ _plugins/noop-converter.rb | 18 ++++++++++++++++++ 5 files changed, 29 insertions(+), 9 deletions(-) create mode 100644 _plugins/noop-converter.rb (limited to '_plugins') diff --git a/_plugins/add-anchor-to-code-block-line-numbers.rb b/_plugins/add-anchor-to-code-block-line-numbers.rb index ef9f579..ec6f0a8 100644 --- a/_plugins/add-anchor-to-code-block-line-numbers.rb +++ b/_plugins/add-anchor-to-code-block-line-numbers.rb @@ -1,7 +1,7 @@ PREFIX = '
'
 POSTFIX = '
' Jekyll::Hooks.register [:documents, :pages], :post_render do |doc| - if doc.output_ext == ".html" + if doc.output_ext == ".html" && doc.type != :slides code_block_counter = 1 doc.output = doc.output.gsub(/
[\n0-9]+<\/pre>/) do |match|
       line_numbers = match
diff --git a/_plugins/add-anchor-to-header-from-header-id.rb b/_plugins/add-anchor-to-header-from-header-id.rb
index d0df4d6..33e3ad7 100644
--- a/_plugins/add-anchor-to-header-from-header-id.rb
+++ b/_plugins/add-anchor-to-header-from-header-id.rb
@@ -1,5 +1,5 @@
 Jekyll::Hooks.register [:documents, :pages], :post_render do |doc|
-  if doc.output_ext == ".html"
+  if doc.output_ext == ".html" && doc.type != :slides
     doc.output =
       doc.output.gsub(
         /(.*?)<\/h[1-6]>/,
diff --git a/_plugins/add-link-to-plaintext-code-block.rb b/_plugins/add-link-to-plaintext-code-block.rb
index 04fbdea..4c15d33 100644
--- a/_plugins/add-link-to-plaintext-code-block.rb
+++ b/_plugins/add-link-to-plaintext-code-block.rb
@@ -1,5 +1,5 @@
 Jekyll::Hooks.register :documents, :post_render do |doc|
-  if doc.output_ext == ".html"
+  if doc.output_ext == ".html" && doc.type != :slides
     code_block_counter = 1
     doc.output = doc.output.gsub(/(<\/code><\/pre><\/div><\/div>)/) do |match|
       res = match +
diff --git a/_plugins/generate-pastebin-plaintext-alternate.rb b/_plugins/generate-pastebin-plaintext-alternate.rb
index d85cacf..110a943 100644
--- a/_plugins/generate-pastebin-plaintext-alternate.rb
+++ b/_plugins/generate-pastebin-plaintext-alternate.rb
@@ -9,12 +9,13 @@ module Jekyll
       site.collections.each do |collection|
         _collection_name, collection_documents = collection
         collection_documents.docs.each do |document|
-          n = 1
-          Renderer
-            .new(site, document)                       # create a renderer for the document
-            .run                                       # generate the HTML string
-            .scan(CODE_BLOCK)                          # match all occurrences of regexp
-            .each do |code_block|                      # iterate on each match
+          if document.type != :slides
+            n = 1
+            Renderer
+              .new(site, document)                       # create a renderer for the document
+              .run                                       # generate the HTML string
+              .scan(CODE_BLOCK)                          # match all occurrences of regexp
+              .each do |code_block|                      # iterate on each match
               unhighlighted_code = code_block[0]       # regexp only defines 1 match (only 1 parens)
                                      .gsub(/(.*?)<\/span>/m, '\1')
               content = CGI.unescapeHTML unhighlighted_code
@@ -23,6 +24,7 @@ module Jekyll
               plain.content = content
               site.pages << plain
               n += 1
+            end
           end
         end
       end
diff --git a/_plugins/noop-converter.rb b/_plugins/noop-converter.rb
new file mode 100644
index 0000000..118d103
--- /dev/null
+++ b/_plugins/noop-converter.rb
@@ -0,0 +1,18 @@
+module Jekyll
+  class NoOpConverter < Converter
+    safe true
+    priority :high
+
+    def matches(ext)
+      ext == '.slides'
+    end
+
+    def output_ext(ext)
+      ".html"
+    end
+
+    def convert(content)
+      content
+    end
+  end
+end
-- 
cgit v1.2.3