Skip to content

Instantly share code, notes, and snippets.

@jasonm
Created September 2, 2011 18:36
Show Gist options
  • Save jasonm/1189434 to your computer and use it in GitHub Desktop.
Save jasonm/1189434 to your computer and use it in GitHub Desktop.
diff --git a/source-highlight-filter.conf b/source-highlight-filter.conf
index 0022c9b..aa73b04 100644
--- a/source-highlight-filter.conf
+++ b/source-highlight-filter.conf
@@ -94,19 +94,19 @@ template::[source-filter-style]
delimiter=(^source~{4,}$)|(^\^{4,}$)
template=source-highlight-block
presubs=none
-posattrs=language,src_numbered,src_tab
+posattrs=language,src_numbered,src_tab,src_start,src_end
ifndef::basebackend-docbook[]
postsubs=callouts
# GNU Source Highlight filter.
-filter=source-highlight -f {basebackend-xhtml11?xhtml}{basebackend-html4?html} -s {language} {src_numbered?--line-number} {src_tab?--tab={src_tab}}
+filter=source-highlight -f {basebackend-xhtml11?xhtml}{basebackend-html4?html} -s {language} {src_numbered?--line-number} {src_tab?--tab={src_tab}} {src_start?--line-range={src_start}-{src_end}}
endif::basebackend-docbook[]
ifdef::basebackend-docbook[]
postsubs=specialcharacters,callouts
# In the case of DocBook just pass the listing through and let the DocBook
# toolchain handle it.
-filter=
+filter=sed {src_start?-n {src_start},{src_end}p}
endif::basebackend-docbook[]
#
[language=ruby,src_start=3,src_end=10]
source~~~~
#
# Useful Ruby base class extensions.
#
class Array
# Execute a block passing it corresponding items in
# +self+ and +other_array+.
# If self has less items than other_array it is repeated.
def cycle(other_array) # :yields: item, other_item
other_array.each_with_index do |item, index|
yield(self[index % self.length], item)
end
end
end
if $0 == __FILE__
# Array#cycle test
# true => 0
# false => 1
# true => 2
# false => 3
# true => 4
puts 'Array#cycle test'
[true, false].cycle([0, 1, 2, 3, 4]) do |a, b|
puts "#{a.inspect} => #{b.inspect}"
end
end
source~~~~
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment