mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-23 02:05:57 +01:00
readme: setup github pages to overcome 512k limit
This commit is contained in:
19
asciidoctor/link-target-github.rb
Normal file
19
asciidoctor/link-target-github.rb
Normal file
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env ruby
|
||||
#
|
||||
# https://github.com/cirosantilli/linux-kernel-module-cheat#asciidoctor-link-target-up-rb
|
||||
|
||||
require 'asciidoctor'
|
||||
require 'asciidoctor/extensions'
|
||||
|
||||
require_relative 'link-target-up.rb'
|
||||
|
||||
class LinkTargetGitHub < LinkTargetUp
|
||||
named :link
|
||||
def target_base
|
||||
'https://github.com/cirosantilli/linux-kernel-module-cheat/blob/master/'
|
||||
end
|
||||
end
|
||||
|
||||
Asciidoctor::Extensions.register do
|
||||
inline_macro LinkTargetGitHub
|
||||
end
|
||||
@@ -1,29 +1,31 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
=begin
|
||||
README.html links break because we place that output file in out/
|
||||
This extension hacks local link targets to the right path.
|
||||
=end
|
||||
# https://github.com/cirosantilli/linux-kernel-module-cheat#asciidoctor-link-target-up-rb
|
||||
|
||||
require 'asciidoctor'
|
||||
require 'asciidoctor/extensions'
|
||||
|
||||
class Main < Asciidoctor::Extensions::InlineMacroProcessor
|
||||
class LinkTargetUp < Asciidoctor::Extensions::InlineMacroProcessor
|
||||
use_dsl
|
||||
named :link
|
||||
ExternalLinkRegex = /^https?:\/\//
|
||||
|
||||
def target_base
|
||||
'..'
|
||||
end
|
||||
|
||||
def process parent, target, attrs
|
||||
text = attrs[1]
|
||||
if text.nil? || text.empty?
|
||||
text = target
|
||||
end
|
||||
if !ExternalLinkRegex.match?(target)
|
||||
target = File.join('..', target)
|
||||
target = File.join(target_base, target)
|
||||
end
|
||||
create_anchor parent, text, type: :link, target: target
|
||||
end
|
||||
end
|
||||
|
||||
Asciidoctor::Extensions.register do
|
||||
inline_macro Main
|
||||
inline_macro LinkTargetUp
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user