mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-23 02:05:57 +01:00
readme: make local file links work relative to out/
Thanks to awesome help at: https://github.com/asciidoctor/asciidoctor/issues/3324
This commit is contained in:
20
asciidoctor/extract-link-targets
Executable file
20
asciidoctor/extract-link-targets
Executable file
@@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
# https://github.com/cirosantilli/linux-kernel-module-cheat#asciidoctor-extract-links
|
||||
|
||||
require 'asciidoctor'
|
||||
require 'asciidoctor/extensions'
|
||||
|
||||
class Main < Asciidoctor::Extensions::InlineMacroProcessor
|
||||
use_dsl
|
||||
named :link
|
||||
def process parent, target, attrs
|
||||
puts target
|
||||
end
|
||||
end
|
||||
|
||||
Asciidoctor::Extensions.register do
|
||||
inline_macro Main
|
||||
end
|
||||
|
||||
(Asciidoctor.load_file(ARGV[0])).convert
|
||||
31
asciidoctor/link-target-up.rb
Normal file
31
asciidoctor/link-target-up.rb
Normal file
@@ -0,0 +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
|
||||
|
||||
require 'asciidoctor'
|
||||
require 'asciidoctor/extensions'
|
||||
|
||||
class Main < Asciidoctor::Extensions::InlineMacroProcessor
|
||||
use_dsl
|
||||
named :link
|
||||
ExternalLinkRegex = /^https?:\/\//
|
||||
def process parent, target, attrs
|
||||
text = attrs[1]
|
||||
if text.nil? || text.empty?
|
||||
text = target
|
||||
end
|
||||
if !ExternalLinkRegex.match?(target)
|
||||
target = File.join('..', target)
|
||||
end
|
||||
create_anchor parent, text, type: :link, target: target
|
||||
end
|
||||
end
|
||||
|
||||
Asciidoctor::Extensions.register do
|
||||
inline_macro Main
|
||||
end
|
||||
|
||||
#(Asciidoctor.load_file(ARGV[0])).convert
|
||||
Reference in New Issue
Block a user