You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by dc...@apache.org on 2020/10/30 10:39:23 UTC

[thrift-website] 07/08: Handle snippets with Jekyll plugin

This is an automated email from the ASF dual-hosted git repository.

dcelasun pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/thrift-website.git

commit 38bff77488b1460e7be95e4c2ba849820f1e3cd2
Author: Christopher Tubbs <ct...@apache.org>
AuthorDate: Thu Oct 29 15:53:41 2020 -0400

    Handle snippets with Jekyll plugin
---
 _config.yml                    |  3 +-
 _plugins/remote_snippets.rb    | 74 ++++++++++++++++++++++++++++++++++++++++
 docs/HowToContribute.md        |  2 +-
 docs/Languages.md              |  3 +-
 docs/coding_standards.md       |  2 +-
 docs/committers/HowToCommit.md |  2 +-
 docs/idl.md                    |  2 +-
 docs/install/centos.md         |  2 +-
 docs/install/debian.md         |  2 +-
 docs/install/os_x.md           |  2 +-
 docs/install/windows.md        |  2 +-
 index.md                       |  8 ++---
 lib/c_glib.md                  |  2 +-
 lib/cl.md                      |  2 +-
 lib/cpp.md                     |  2 +-
 lib/csharp.md                  |  1 -
 lib/d.md                       |  2 +-
 lib/delphi.md                  |  2 +-
 lib/erl.md                     |  2 +-
 lib/go.md                      |  2 +-
 lib/haxe.md                    |  2 +-
 lib/hs.md                      |  2 +-
 lib/java.md                    |  2 +-
 lib/js.md                      |  2 +-
 lib/netstd.md                  |  2 +-
 lib/nodejs.md                  |  2 +-
 lib/ocaml.md                   |  2 +-
 lib/perl.md                    |  2 +-
 lib/php.md                     |  2 +-
 lib/py.md                      |  2 +-
 lib/rb.md                      |  2 +-
 lib/st.md                      |  2 +-
 perllib/path.pm                | 77 ------------------------------------------
 test/ThriftTest.thrift         |  2 +-
 test/index.md                  |  2 +-
 test/keys.md                   |  2 +-
 tutorial/as3.md                |  4 +--
 tutorial/c_glib.md             |  4 +--
 tutorial/cpp.md                |  6 ++--
 tutorial/csharp.md             |  4 ---
 tutorial/d.md                  |  4 +--
 tutorial/dart.md               |  6 ++--
 tutorial/delphi.md             |  4 +--
 tutorial/go.md                 |  6 ++--
 tutorial/haxe.md               |  4 +--
 tutorial/hs.md                 |  4 +--
 tutorial/java.md               |  6 ++--
 tutorial/netstd.md             |  4 +--
 tutorial/nodejs.md             |  4 +--
 tutorial/ocaml.md              |  4 +--
 tutorial/perl.md               |  4 +--
 tutorial/php.md                |  4 +--
 tutorial/py.md                 |  4 +--
 tutorial/rb.md                 |  4 +--
 54 files changed, 149 insertions(+), 157 deletions(-)

diff --git a/_config.yml b/_config.yml
index ab19b00..7d37b92 100644
--- a/_config.yml
+++ b/_config.yml
@@ -19,7 +19,7 @@
 
 # Basic site settings
 safe: false
-title: Apache Thrift™
+title: Apache Thrift
 email: dev@thrift.apache.org
 description: >-
   The Apache Thrift software framework, for scalable cross-language services
@@ -38,6 +38,7 @@ defaults:
 
 # Additional variables to power specific pages
 git_repo: "https://github.com/apache/thrift"
+gitbox_url: "https://gitbox.apache.org/repos/asf?p=thrift.git"
 release_url: "https://www.apache.org/dist/thrift"
 mirror_url: "http://www.apache.org/dyn/closer.cgi?path="
 jira_url: "http://issues.apache.org/jira/browse/THRIFT"
diff --git a/_plugins/remote_snippets.rb b/_plugins/remote_snippets.rb
new file mode 100644
index 0000000..a374c72
--- /dev/null
+++ b/_plugins/remote_snippets.rb
@@ -0,0 +1,74 @@
+require 'rouge'
+require 'open-uri'
+require 'uri'
+
+class RemoteSnippet < Liquid::Tag
+  def initialize(tag_name, text, tokens)
+    super
+    args = text.strip.split(' ', 3)
+    @path = args[0]
+    if args.length() > 2
+      @type = args[1]
+      @range = args[2]
+    elsif args.length() > 1
+      @type = args[1]
+      @range = "all"
+    else
+      @type = "text"
+      @range = "all"
+    end
+  end
+
+  def openLink(url)
+    begin
+      URI.open(url)
+    rescue OpenURI::HTTPError
+      $stderr.print "Failed to download #{url}"
+      raise
+    end
+  end
+
+  def render(context)
+    title = context.registers[:site].config['title']
+    prefix = context.registers[:site].config['gitbox_url']
+    url = "#{prefix};a=blob_plain;hb=HEAD;f=#{@path}"
+    pretty_url = "#{prefix};a=blob;hb=HEAD;f=#{@path}"
+    content = ""
+    if @range == "all"
+      openLink(url) {|f| content = f.read }
+    else
+      rangenums = @range.split(",", 2)
+      first = 0
+      second = 0
+      if rangenums.length() == 2
+        first = Integer(rangenums[0])
+        second = Integer(rangenums[1]) - first
+        openLink(url) {|f| content = f.each_line.drop(first).take(second).join() }
+      else
+        first = Integer(rangenums[0])
+        openLink(url) {|f| content = f.each_line.drop(first).join() }
+      end
+    end
+    snippet_type = "snippet"
+    content = ""
+    if @type == "direct"
+      content = Kramdown::Document.new(content).to_html
+      snippet_type = "page"
+    else
+      content = content.force_encoding("utf-8")
+      formatter = Rouge::Formatters::HTMLLegacy.new
+      lexer = Rouge::Lexer.find_fancy(@type, content)
+      content = formatter.format(lexer.lex(content))
+    end
+    #content = CGI::escapeHTML(content)
+    return """
+#{content}
+<p class=\"snippet_footer\">This #{snippet_type} was generated by #{title}'s <strong>source tree docs</strong>:
+<a href=\"#{pretty_url}\">#{@path}</a>
+</p>
+      """
+  end
+end
+
+Liquid::Template.register_tag('remote_snippet', RemoteSnippet)
+
diff --git a/docs/HowToContribute.md b/docs/HowToContribute.md
index fc902e9..412f852 100644
--- a/docs/HowToContribute.md
+++ b/docs/HowToContribute.md
@@ -3,4 +3,4 @@ title: "How To Contribute"
 isdoc: true
 ---
 
-[snippet:path=CONTRIBUTING.md]
+{% remote_snippet CONTRIBUTING.md direct %}
diff --git a/docs/Languages.md b/docs/Languages.md
index d217e9d..d703225 100644
--- a/docs/Languages.md
+++ b/docs/Languages.md
@@ -5,5 +5,4 @@ isdoc: true
 
 [This page on GitHub](https://github.com/apache/thrift/blob/master/LANGUAGES.md)
 
-[snippet:path=LANGUAGES.md]
-
+{% remote_snippet LANGUAGES.md direct %}
diff --git a/docs/coding_standards.md b/docs/coding_standards.md
index 9cf9f7a..ac0d14b 100644
--- a/docs/coding_standards.md
+++ b/docs/coding_standards.md
@@ -3,4 +3,4 @@ title: "Coding standards"
 isdoc: true
 ---
 
-[snippet:path=doc/coding_standards.md]
+{% remote_snippet doc/coding_standards.md direct %}
diff --git a/docs/committers/HowToCommit.md b/docs/committers/HowToCommit.md
index 02fc352..b052861 100644
--- a/docs/committers/HowToCommit.md
+++ b/docs/committers/HowToCommit.md
@@ -2,4 +2,4 @@
 title: "How To Commit"
 ---
 
-[snippet:path=doc/committers.md]
+{% remote_snippet doc/committers.md direct %}
diff --git a/docs/idl.md b/docs/idl.md
index 06dd803..373d12f 100644
--- a/docs/idl.md
+++ b/docs/idl.md
@@ -3,4 +3,4 @@ title: "Interface Description Language (IDL)"
 isdoc: true
 ---
 
-[snippet:path=doc/specs/idl.md]
+{% remote_snippet doc/specs/idl.md direct %}
diff --git a/docs/install/centos.md b/docs/install/centos.md
index 16c157e..4862423 100644
--- a/docs/install/centos.md
+++ b/docs/install/centos.md
@@ -3,4 +3,4 @@ title: "Centos 6.5 Install"
 isinstall: true
 ---
 
-[snippet:path=doc/install/centos.md]
+{% remote_snippet doc/install/centos.md direct %}
diff --git a/docs/install/debian.md b/docs/install/debian.md
index 3df529b..3ffeb78 100644
--- a/docs/install/debian.md
+++ b/docs/install/debian.md
@@ -3,4 +3,4 @@ title: Debian/Ubuntu install
 isinstall: true
 ---
 
-[snippet:path=doc/install/debian.md]
+{% remote_snippet doc/install/debian.md direct %}
diff --git a/docs/install/os_x.md b/docs/install/os_x.md
index b7e0320..a6e4c5b 100644
--- a/docs/install/os_x.md
+++ b/docs/install/os_x.md
@@ -3,4 +3,4 @@ title: "OS X Install"
 isinstall: true
 ---
 
-[snippet:path=doc/install/os_x.md]
+{% remote_snippet doc/install/os_x.md direct %}
diff --git a/docs/install/windows.md b/docs/install/windows.md
index 8534185..8f16753 100644
--- a/docs/install/windows.md
+++ b/docs/install/windows.md
@@ -3,4 +3,4 @@ title: "Windows Install"
 isinstall: true
 ---
 
-[snippet:path=doc/install/windows.md]
+{% remote_snippet doc/install/windows.md direct %}
diff --git a/index.md b/index.md
index 652d7cc..df4651d 100644
--- a/index.md
+++ b/index.md
@@ -69,17 +69,17 @@ title: Home
   </ul>
   <div class="tab-content">
     <div class="tab-pane active" id="1">
-      [snippet:path=tutorial/tutorial.thrift:lang=text:lines=125,147]
+      {% remote_snippet tutorial/tutorial.thrift text 123,150 %}
     </div>
     <div class="tab-pane" id="2">
-      [snippet:path=tutorial/py/PythonClient.py:lang=python:lines=36,55]
+      {% remote_snippet tutorial/py/PythonClient.py py 35,55 %}
     </div>
     <div class="tab-pane" id="3">
     Initialize the Server:
-      [snippet:path=tutorial/java/src/JavaServer.java:lang=java:lines:65,76]
+      {% remote_snippet tutorial/java/src/JavaServer.java java 64,76 %}
 
     The CalculatorHandler:
-      [snippet:path=tutorial/java/src/CalculatorHandler.java:lang=java:lines:28,91]
+      {% remote_snippet tutorial/java/src/CalculatorHandler.java java 27,91 %}
     </div>
   </div>
 </div>
diff --git a/lib/c_glib.md b/lib/c_glib.md
index 7e31289..108c0c4 100644
--- a/lib/c_glib.md
+++ b/lib/c_glib.md
@@ -3,4 +3,4 @@ title: C GLib
 islib: true
 ---
 
-[snippet:path=lib/c_glib/README.md:lines=22]
+{% remote_snippet lib/c_glib/README.md direct 21 %}
diff --git a/lib/cl.md b/lib/cl.md
index 1d205a6..f3a5392 100644
--- a/lib/cl.md
+++ b/lib/cl.md
@@ -3,4 +3,4 @@ title: Common Lisp Library README
 islib: true
 ---
 
-[snippet:path=lib/cl/README.md:lines=22]
+{% remote_snippet lib/cl/README.md direct 21 %}
diff --git a/lib/cpp.md b/lib/cpp.md
index 4df8225..059b789 100644
--- a/lib/cpp.md
+++ b/lib/cpp.md
@@ -3,4 +3,4 @@ title: C++ library
 islib: true
 ---
 
-[snippet:path=lib/cpp/README.md:lines=22]
+{% remote_snippet lib/cpp/README.md direct 21 %}
diff --git a/lib/csharp.md b/lib/csharp.md
index be2feb0..35ae50e 100644
--- a/lib/csharp.md
+++ b/lib/csharp.md
@@ -3,4 +3,3 @@ title: C# library
 islib: true
 ---
 
-[snippet:path=lib/csharp/README.md:lines=22]
diff --git a/lib/d.md b/lib/d.md
index 95df3f2..b567ee3 100644
--- a/lib/d.md
+++ b/lib/d.md
@@ -3,4 +3,4 @@ title: D library
 islib: true
 ---
 
-[snippet:path=lib/d/README.md:lines=23]
+{% remote_snippet lib/d/README.md direct 22 %}
diff --git a/lib/delphi.md b/lib/delphi.md
index 42c9e2c..4557ac3 100644
--- a/lib/delphi.md
+++ b/lib/delphi.md
@@ -3,4 +3,4 @@ title: Delphi library
 islib: true
 ---
 
-[snippet:path=lib/delphi/README.md:lines=22]
+{% remote_snippet lib/delphi/README.md direct 21 %}
diff --git a/lib/erl.md b/lib/erl.md
index d0799b2..3c0a677 100644
--- a/lib/erl.md
+++ b/lib/erl.md
@@ -3,4 +3,4 @@ title: Erlang library
 islib: true
 ---
 
-[snippet:path=lib/erl/README.md:lines=22]
+{% remote_snippet lib/erl/README.md direct 21 %}
diff --git a/lib/go.md b/lib/go.md
index d5f10cb..a7c9e26 100644
--- a/lib/go.md
+++ b/lib/go.md
@@ -3,4 +3,4 @@ title: Go library
 islib: true
 ---
 
-[snippet:path=lib/go/README.md:lines=23]
+{% remote_snippet lib/go/README.md direct 22 %}
diff --git a/lib/haxe.md b/lib/haxe.md
index a12e81d..d5e147b 100644
--- a/lib/haxe.md
+++ b/lib/haxe.md
@@ -3,4 +3,4 @@ title: Haxe library
 islib: true
 ---
 
-[snippet:path=lib/haxe/README.md:lines=22]
+{% remote_snippet lib/haxe/README.md direct 21 %}
diff --git a/lib/hs.md b/lib/hs.md
index 77a7456..9e40577 100644
--- a/lib/hs.md
+++ b/lib/hs.md
@@ -3,4 +3,4 @@ title: Haskell library
 islib: true
 ---
 
-[snippet:path=lib/hs/README.md:lines=22]
+{% remote_snippet lib/hs/README.md direct 21 %}
diff --git a/lib/java.md b/lib/java.md
index 01924d9..be4bda1 100644
--- a/lib/java.md
+++ b/lib/java.md
@@ -3,4 +3,4 @@ title: Java library
 islib: true
 ---
 
-[snippet:path=lib/java/README.md:lines=22]
+{% remote_snippet lib/java/README.md direct 21 %}
diff --git a/lib/js.md b/lib/js.md
index afe4408..30abcd7 100644
--- a/lib/js.md
+++ b/lib/js.md
@@ -3,4 +3,4 @@ title: JavaScript library
 islib: true
 ---
 
-[snippet:path=lib/js/README.md:lines=25]
+{% remote_snippet lib/js/README.md direct 24 %}
diff --git a/lib/netstd.md b/lib/netstd.md
index 435b5d6..183344e 100644
--- a/lib/netstd.md
+++ b/lib/netstd.md
@@ -3,4 +3,4 @@ title: .NET Standard library
 islib: true
 ---
 
-[snippet:path=lib/netstd/README.md]
+{% remote_snippet lib/netstd/README.md direct 0 %}
diff --git a/lib/nodejs.md b/lib/nodejs.md
index e590273..89d5956 100644
--- a/lib/nodejs.md
+++ b/lib/nodejs.md
@@ -3,4 +3,4 @@ title: node.js library
 islib: true
 ---
 
-[snippet:path=lib/nodejs/README.md:lines=23]
+{% remote_snippet lib/nodejs/README.md direct 22 %}
diff --git a/lib/ocaml.md b/lib/ocaml.md
index cd929fe..d3169f4 100644
--- a/lib/ocaml.md
+++ b/lib/ocaml.md
@@ -3,4 +3,4 @@ title: OCaml library
 islib: true
 ---
 
-[snippet:path=lib/ocaml/README.md:lines=23]
+{% remote_snippet lib/ocaml/README.md direct 22 %}
diff --git a/lib/perl.md b/lib/perl.md
index 59d1a31..6443108 100644
--- a/lib/perl.md
+++ b/lib/perl.md
@@ -3,4 +3,4 @@ title: Perl library
 islib: true
 ---
 
-[snippet:path=lib/perl/README.md:lines=22]
+{% remote_snippet lib/perl/README.md direct 32 %}
diff --git a/lib/php.md b/lib/php.md
index 89a43fe..a8c10b1 100644
--- a/lib/php.md
+++ b/lib/php.md
@@ -3,4 +3,4 @@ title: PHP library
 islib: true
 ---
 
-[snippet:path=lib/php/README.md:lines=22]
+{% remote_snippet lib/php/README.md direct 21 %}
diff --git a/lib/py.md b/lib/py.md
index 750b8ea..9bca861 100644
--- a/lib/py.md
+++ b/lib/py.md
@@ -3,4 +3,4 @@ title: Python library
 islib: true
 ---
 
-[snippet:path=lib/py/README.md:lines=22]
+{% remote_snippet lib/py/README.md direct 21 %}
diff --git a/lib/rb.md b/lib/rb.md
index 90b1836..5d74647 100644
--- a/lib/rb.md
+++ b/lib/rb.md
@@ -3,4 +3,4 @@ title: Ruby library
 islib: true
 ---
 
-[snippet:path=lib/rb/README.md:lines=22]
+{% remote_snippet lib/rb/README.md direct 21 %}
diff --git a/lib/st.md b/lib/st.md
index 9eb970b..1cdfd71 100644
--- a/lib/st.md
+++ b/lib/st.md
@@ -3,4 +3,4 @@ title: SmallTalk library
 islib: true
 ---
 
-[snippet:path=lib/st/README.md:lines=28]
+{% remote_snippet lib/st/README.md direct 27 %}
diff --git a/perllib/path.pm b/perllib/path.pm
deleted file mode 100644
index 4f8c8c5..0000000
--- a/perllib/path.pm
+++ /dev/null
@@ -1,77 +0,0 @@
-package path;
-
-use ASF::Util qw/walk_content_tree Load/;
-use strict;
-use warnings;
-
-my $thrift_snippet_footer = <<'EOT'; # '$snippet' string magically refers to current snippet obj
-<p class='snippet_footer'>
-  This snippet was generated by {{ site.title }}'s <strong>source tree docs</strong>:
-  <a href="{{ $snippet.pretty_uri }}"</a>{{ $snippet.path }}</a>
-</p>
-EOT
-
-my %thrift_args = (
-    conf          => Load(join "", <DATA>), # make YAML __DATA__ below available in conf argument
-    preprocess    => 1,                     # enable template preprocessing of .md files
-    repo          => 'gitbox/thrift.git',   # set snippet default git repo (on gitbox)...
-    template      => 'default.html',        # set common template argument (mainly for .md files)
-    snippet_footer=> $thrift_snippet_footer,# append this string to each generated snipppet block
-    quick_deps    => 1,                     # short-circuit deps processing to headers only
-);
-
-my $thrift_page_footer = $thrift_snippet_footer;
-$thrift_page_footer =~ s/ snippet / page /; # full page 'snippets'
-
-# order matters here: first match wins...  see http://www.apache.org/dev/cmsref#core-logic
-
-our @patterns = (
-    [qr!^/sitemap\.html$!,     sitemap => { %thrift_args, # %thrift_args as overrideable defaults
-        headers   => { title => "Sitemap" },
-        nest      => 1,
-    }],
-    [qr!^/index\.html$!,       snippet => { %thrift_args,
-        view      => 'news_page',
-        headers   => { title => "Home" },
-    }],
-    [qr!/index\.html$!,        sitemap => { %thrift_args }],
-    [qr!^/(lib|test)/!,        snippet => { %thrift_args,
-        view           => [qw/reconstruct trim_local_links single_narrative/],
-        snippet_footer => $thrift_page_footer, # override: these are full pages not snippets
-    }],
-    [qr/\.md(?:text)?$/,       snippet => { %thrift_args,
-        view      => 'single_narrative',
-    }],
-);
-
-our %dependencies; # for /sitemap.html and /**/index.html pages whose title + url listings
-                   # depend on the other files in the relevant content/ subdirectories.  We run
-                   # the views for those files in offline mode for performance, since the titles
-                   # and urls required do not depend on code snippet contents which take time to
-                   # fetch.  We could do slightly better if we weren't interested in the actual
-                   # build-generated output of those dependent files, which we aren't, but
-                   # coding that up as a special case of the standard sitemap view isn't worth
-                   # the trouble.
-                   # Now watch me bother anyway just to see... ok done with 'quick_deps' support.
-                   # Yay it's about a second faster on a full site build for thrift- go team!
-
-walk_content_tree {
-    if (/\.md(?:text)?$/ or m!/index\.html$! or m!^/test/!) {
-        # basically grep s/^content//, glob("content/**/*.{md,mdtext}"),
-        #                              glob("content/**/index.html"),
-        #                              glob("content/test/**/*");
-        # if perl's glob was as smart as zsh's glob
-        push @{$dependencies{"/sitemap.html"}}, $_;
-    }
-    if (s!/index\.html$!!) {
-        $dependencies{"$_/index.html"} = [
-            grep s/^content//, glob("content$_/*.{md,mdtext}"),
-                               glob("content$_/*/index.html")
-        ];
-    }
-};
-
-delete $dependencies{"/index.html"}; # the home page really doesn't depend on anything else
-
-1;
-
diff --git a/test/ThriftTest.thrift b/test/ThriftTest.thrift
index e804a1c..41fc775 100644
--- a/test/ThriftTest.thrift
+++ b/test/ThriftTest.thrift
@@ -2,4 +2,4 @@
 title: ThriftTest
 ---
 
-[snippet:path=test/ThriftTest.thrift:lang=text:numbers=1]
+{% remote_snippet test/ThriftTest.thrift text %}
diff --git a/test/index.md b/test/index.md
index 370b0c6..323e673 100644
--- a/test/index.md
+++ b/test/index.md
@@ -2,4 +2,4 @@
 title: Test Suite
 ---
 
-[snippet:path=test/README.md]
+{% remote_snippet test/README.md direct %}
diff --git a/test/keys.md b/test/keys.md
index 40a8b46..6ed8caf 100644
--- a/test/keys.md
+++ b/test/keys.md
@@ -2,4 +2,4 @@
 title: Keys
 ---
 
-[snippet:path=test/keys/README.md]
+{% remote_snippet test/keys/README.md direct %}
diff --git a/tutorial/as3.md b/tutorial/as3.md
index 62eafc3..4285b3c 100644
--- a/tutorial/as3.md
+++ b/tutorial/as3.md
@@ -11,7 +11,7 @@ tutorial: true
 ### Client
 To initialize client you can use code similar to:
 
-  [snippet:path=tutorial/as3/src/CalculatorUI.as:lang=java:lines=42,48]
+{% remote_snippet tutorial/as3/src/CalculatorUI.as java 41,49 %}
 
 ### Server
 The example client above can be tested against a java tutorial server.
@@ -34,7 +34,7 @@ Also, you can find a simple python/perl server script to serve this file there.
 crossdomain.xml from any port. So, you can start your RPC servers on ports 9090 and 9091, and serve polisy file from
 port 9092. To tell flash about this, you can use code from tutorial file:
 
-  [snippet:path=tutorial/as3/src/CalculatorUI.as:lang=java:lines=35,37]
+{% remote_snippet tutorial/as3/src/CalculatorUI.as java 34,37 %}
 
 Example of crossdomain file, to allow connect to ports 9090 and 9091 from any server:
 
diff --git a/tutorial/c_glib.md b/tutorial/c_glib.md
index 22faa07..a69f34b 100644
--- a/tutorial/c_glib.md
+++ b/tutorial/c_glib.md
@@ -7,8 +7,8 @@ tutorial: true
 
 ### Client
 
-[snippet:path=tutorial/c_glib/c_glib_client.c:lang=c:lines=20,190]
+{% remote_snippet tutorial/c_glib/c_glib_client.c c 19,190 %}
 
 ### Server
 
-[snippet:path=tutorial/c_glib/c_glib_server.c:lang=c:lines=20,527]
+{% remote_snippet tutorial/c_glib/c_glib_server.c c 19,527 %}
diff --git a/tutorial/cpp.md b/tutorial/cpp.md
index 1e18f7a..daa988c 100644
--- a/tutorial/cpp.md
+++ b/tutorial/cpp.md
@@ -9,14 +9,14 @@ tutorial: true
 
 ### Client
 
-[snippet:path=tutorial/cpp/CppClient.cpp:lang=cpp:lines=20,82]
+{% remote_snippet tutorial/cpp/CppClient.cpp cpp 19,82 %}
 
 ### Server
 
-[snippet:path=tutorial/cpp/CppServer.cpp:lang=cpp:lines=20,152]
+{% remote_snippet tutorial/cpp/CppServer.cpp cpp 19,152 %}
 
 ## Additional Information
 
 ### Example ThreadPool Server
 
-[snippet:path=tutorial/cpp/CppServer.cpp:lang=cpp:lines=119,131]
+{% remote_snippet tutorial/cpp/CppServer.cpp cpp 118,131 %}
diff --git a/tutorial/csharp.md b/tutorial/csharp.md
index 6efa89d..146f927 100644
--- a/tutorial/csharp.md
+++ b/tutorial/csharp.md
@@ -10,11 +10,7 @@ tutorial: true
 
 ### Client
 
-[snippet:path=tutorial/csharp/CsharpClient/CsharpClient.cs:lang=cpp:lines=20,92]
-
 ### Server
 
-[snippet:path=tutorial/csharp/CsharpServer/CsharpServer.cs:lang=cpp:lines=20,129]
-
 ## Additional Information
 
diff --git a/tutorial/d.md b/tutorial/d.md
index 3f2b774..304f7a6 100644
--- a/tutorial/d.md
+++ b/tutorial/d.md
@@ -10,11 +10,11 @@ tutorial: true
 
 ### Client
 
-[snippet:path=tutorial/d/server.d:lang=cpp:lines=19,111]
+{% remote_snippet tutorial/d/client.d cpp 18,64 %}
 
 ### Server
 
-[snippet:path=tutorial/d/client.d:lang=cpp:lines=19,64]
+{% remote_snippet tutorial/d/server.d cpp 18,111 %}
 
 ## Additional Information
 
diff --git a/tutorial/dart.md b/tutorial/dart.md
index c893ca5..da9ff5b 100644
--- a/tutorial/dart.md
+++ b/tutorial/dart.md
@@ -11,15 +11,15 @@ TBD
 
 ### Client
 
-[snippet:path=tutorial/dart/client/web/client.dart:lang=cpp:lines=18,279]
+{% remote_snippet tutorial/dart/client/web/client.dart cpp 17,279 %}
 
 ### Client web page
 
-[snippet:path=tutorial/dart/client/web/index.html:lang=html:lines=19,37]
+{% remote_snippet tutorial/dart/client/web/index.html html 18,37 %}
 
 ### Server
 
-[snippet:path=tutorial/dart/server/bin/main.dart:lang=cpp:lines=18,164]
+{% remote_snippet tutorial/dart/server/bin/main.dart cpp 17,164 %}
 
 ## Additional Information
 
diff --git a/tutorial/delphi.md b/tutorial/delphi.md
index cb8cb40..7af6933 100644
--- a/tutorial/delphi.md
+++ b/tutorial/delphi.md
@@ -10,11 +10,11 @@ tutorial: true
 
 ### Client
 
-[snippet:path=tutorial/delphi/DelphiClient/DelphiClient.dpr:lang=pascal:lines=19,114]
+{% remote_snippet tutorial/delphi/DelphiClient/DelphiClient.dpr pascal 18,114 %}
 
 ### Server
 
-[snippet:path=tutorial/delphi/DelphiServer/DelphiServer.dpr:lang=pascal:lines=19,173]
+{% remote_snippet tutorial/delphi/DelphiServer/DelphiServer.dpr pascal 18,173 %}
 
 ## Additional Information
 
diff --git a/tutorial/go.md b/tutorial/go.md
index 0b53337..892190c 100644
--- a/tutorial/go.md
+++ b/tutorial/go.md
@@ -15,17 +15,17 @@ To use a specific version of the library, either clone the repository for that v
 
 ### Client
 
-[snippet:path=tutorial/go/src/client.go:lang=cpp:lines=22,99]
+{% remote_snippet tutorial/go/src/client.go cpp 21,99 %}
 
 
 ### Server
 
-[snippet:path=tutorial/go/src/server.go:lang=cpp:lines=22,54]
+{% remote_snippet tutorial/go/src/server.go cpp 21,54 %}
 
 
 ### Server Handler
 
-[snippet:path=tutorial/go/src/handler.go:lang=cpp:lines=22,200]
+{% remote_snippet tutorial/go/src/handler.go cpp 21,200 %}
 
 
 ## Additional Information
diff --git a/tutorial/haxe.md b/tutorial/haxe.md
index d74e4ad..b207510 100644
--- a/tutorial/haxe.md
+++ b/tutorial/haxe.md
@@ -12,7 +12,7 @@ tutorial: true
 For this tutorial, we put both the server and the client main code into one single program.
 Depending on the arguments passed, it runs as a server or as a client program.
 
-[snippet:path=tutorial/haxe/src/Main.hx:lines=20,332]
+{% remote_snippet tutorial/haxe/src/Main.hx text 19,332 %}
 
 Were done with the client, but need some more for the server: A service handler implementaion.
 
@@ -20,7 +20,7 @@ Were done with the client, but need some more for the server: A service handler
 As the name suggests, the service handler implements the Thrift service on the server side.
 The code to achieve this is as follows:
 
-[snippet:path=tutorial/haxe/src/CalculatorHandler.hx:lines=20,102]
+{% remote_snippet tutorial/haxe/src/CalculatorHandler.hx text 19,102 %}
 
 ### Additional Information
 
diff --git a/tutorial/hs.md b/tutorial/hs.md
index 9958a8e..566d484 100644
--- a/tutorial/hs.md
+++ b/tutorial/hs.md
@@ -10,10 +10,10 @@ tutorial: true
 
 ### Client
 
-[snippet:path=tutorial/hs/HaskellClient.hs:lang=cpp:lines=20,73]
+{% remote_snippet tutorial/hs/HaskellClient.hs cpp 19,73 %}
 
 ### Server
 
-[snippet:path=tutorial/hs/HaskellServer.hs:lang=cpp:lines=20,102]
+{% remote_snippet tutorial/hs/HaskellServer.hs cpp 19,102 %}
 
 ## Additional Information
diff --git a/tutorial/java.md b/tutorial/java.md
index b2f7fc2..fbf770c 100644
--- a/tutorial/java.md
+++ b/tutorial/java.md
@@ -10,14 +10,14 @@ tutorial: true
 
 ### Client
 
-[snippet:path=tutorial/java/src/JavaClient.java:lang=java]
+{% remote_snippet tutorial/java/src/JavaClient.java java %}
 
 ### CalculatorHandler
 
-[snippet:path=tutorial/java/src/CalculatorHandler.java:lang=java]
+{% remote_snippet tutorial/java/src/CalculatorHandler.java java %}
 
 ### Server
 
-[snippet:path=tutorial/java/src/JavaServer.java:lang=java]
+{% remote_snippet tutorial/java/src/JavaServer.java java %}
 
 ## Additional Information
diff --git a/tutorial/netstd.md b/tutorial/netstd.md
index f90c3f6..b9cb805 100644
--- a/tutorial/netstd.md
+++ b/tutorial/netstd.md
@@ -10,11 +10,11 @@ tutorial: true
 
 ### Client
 
-[snippet:path=tutorial/netstd/Client/Program.cs:lang=cpp:lines=18,356]
+{% remote_snippet tutorial/netstd/Client/Program.cs cpp 17,356 %}
 
 ### Server
 
-[snippet:path=tutorial/netstd/Server/Program.cs:lang=cpp:lines=18,430]
+{% remote_snippet tutorial/netstd/Server/Program.cs cpp 17,430 %}
 
 ## Additional Information
 
diff --git a/tutorial/nodejs.md b/tutorial/nodejs.md
index a489cb1..b839af4 100644
--- a/tutorial/nodejs.md
+++ b/tutorial/nodejs.md
@@ -10,10 +10,10 @@ tutorial: true
 
 ### Client
 
-[snippet:path=tutorial/nodejs/NodeClient.js:lang=javascript:lines=20]
+{% remote_snippet tutorial/nodejs/NodeClient.js js 20 %}
 
 ### Server
 
-[snippet:path=tutorial/nodejs/NodeServer.js:lang=javascript:lines=20]
+{% remote_snippet tutorial/nodejs/NodeServer.js js 20 %}
 
 ## Additional Information
diff --git a/tutorial/ocaml.md b/tutorial/ocaml.md
index 4c46ef1..c39bb08 100644
--- a/tutorial/ocaml.md
+++ b/tutorial/ocaml.md
@@ -10,10 +10,10 @@ tutorial: true
 
 ### Client
 
-[snippet:path=tutorial/ocaml/CalcClient.ml:lang=cpp:lines=20,74]
+{% remote_snippet tutorial/ocaml/CalcClient.ml cpp 19,74 %}
 
 ### Server
 
-[snippet:path=tutorial/ocaml/CalcServer.ml:lang=cpp:lines=20,89]
+{% remote_snippet tutorial/ocaml/CalcServer.ml cpp 19,89 %}
 
 ## Additional Information
diff --git a/tutorial/perl.md b/tutorial/perl.md
index 7e92cb4..bfbdb61 100644
--- a/tutorial/perl.md
+++ b/tutorial/perl.md
@@ -10,10 +10,10 @@ tutorial: true
 
 ### Client
 
-[snippet:path=tutorial/perl/PerlClient.pl:lang=ruby:lines=20,79]
+{% remote_snippet tutorial/perl/PerlClient.pl perl 19,79 %}
 
 ### Server
 
-[snippet:path=tutorial/perl/PerlServer.pl:lang=ruby:lines=20,85]
+{% remote_snippet tutorial/perl/PerlServer.pl perl 19,85 %}
 
 ## Additional Information
diff --git a/tutorial/php.md b/tutorial/php.md
index f423dd2..7bdaa77 100644
--- a/tutorial/php.md
+++ b/tutorial/php.md
@@ -10,10 +10,10 @@ tutorial: true
 
 ### Client
 
-[snippet:path=tutorial/php/PhpClient.php:lang=php:lines=2,91]
+{% remote_snippet tutorial/php/PhpClient.php php 1,91 %}
 
 ### Server
 
-[snippet:path=tutorial/php/PhpServer.php:lang=php:lines=2,130]
+{% remote_snippet tutorial/php/PhpServer.php php 1,130 %}
 
 ## Additional Information
diff --git a/tutorial/py.md b/tutorial/py.md
index fe527d1..cef4b4d 100644
--- a/tutorial/py.md
+++ b/tutorial/py.md
@@ -10,10 +10,10 @@ tutorial: true
 
 ### Client
 
-[snippet:path=tutorial/py/PythonClient.py:lang=python:lines=22,83]
+{% remote_snippet tutorial/py/PythonClient.py py 21,83 %}
 
 ### Server
 
-[snippet:path=tutorial/py/PythonServer.py:lang=python:lines=22,97]
+{% remote_snippet tutorial/py/PythonServer.py py 21,97 %}
 
 ## Additional Information
diff --git a/tutorial/rb.md b/tutorial/rb.md
index 3406567..47ab184 100644
--- a/tutorial/rb.md
+++ b/tutorial/rb.md
@@ -9,10 +9,10 @@ tutorial: true
 
 ### Client
 
-[snippet:path=tutorial/rb/RubyClient.rb:lang=ruby:lines=22,75]
+{% remote_snippet tutorial/rb/RubyClient.rb ruby 21,75 %}
 
 ### Server
 
-[snippet:path=tutorial/rb/RubyServer.rb:lang=ruby:lines=22,95]
+{% remote_snippet tutorial/rb/RubyServer.rb ruby 21,95 %}
 
 ## Additional Information