# # Includes external code. # Supports including named regions from a sample file. # # Usage: # # {% include_external filename %} # # or: # # {% include_external filename region-name %} # # Where regions are delimited by start and end tags like this: # # // [START region-name] # // [END region-name] # # /* [START region-name] */ # /* [END region-name] */ # # HTML-style comments are also supported: # # # # # Regions may overlap. Region start and end tags are always omitted from the # included content. # # When a region is selected, the region is de-indented as if the first # non-whitespace character in the start tag is column 0. # # module Jekyll class IncludeExternal < Liquid::Tag def initialize(tag_name, param_string, tokens) params = param_string.split(" ").map(&:strip) @filename = params[0] @inregion = true if (params.length > 1) @region = params[1] @inregion = false end @output = [] begin startpattern = /^\s*(?:\/\/|\/\*|