Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

hyperlink manpage references against index

  • Loading branch information...
commit 4a6eed9adb244a1d6fa9dd26bc504ed685ffd444 1 parent 1ad5b5d
@rtomayko authored
View
21 lib/ronn/document.rb
@@ -306,6 +306,7 @@ def process_html!
html_filter_inject_name_section
html_filter_heading_anchors
html_filter_annotate_bare_links
+ html_filter_manual_references
@html
end
@@ -430,5 +431,25 @@ def html_filter_annotate_bare_links
end
end
end
+
+ # Convert text of the form "name(section)" to a hyperlink. The URL is
+ # obtaiend from the index.
+ def html_filter_manual_reference_links
+ return if index.nil?
+ @html.search('text()').each do |node|
+ next if !node.content.include?(')')
+ next if %w[pre code h1 h2 h3].include?(node.parent.name)
+ next if child_of?(node, 'a')
+ node.swap(
+ node.content.gsub(/([0-9A-Za-z_:.+=@~-]+\(\d+\w*\))/) {
+ if ref = index[$1]
+ "<a class='man-ref' href='#{ref.url}'>#{$1}</a>"
+ else
+ "<b class='man-ref'>#{$1}</b>"
+ end
+ }
+ )
+ end
+ end
end
end
View
11 lib/ronn/roff.rb
@@ -29,17 +29,6 @@ def previous(node)
end
end
- def child_of?(node, tag)
- while node
- if node.name && node.name.downcase == tag
- return true
- else
- node = node.parent
- end
- end
- false
- end
-
def title_heading(name, section, tagline, manual, version, date)
comment "generated with Ronn/v#{Ronn.version}"
comment "http://github.com/rtomayko/ronn/tree/#{Ronn.revision}"
View
4 lib/ronn/template/man.css
@@ -68,10 +68,14 @@ body#manpage { margin:0 }
text-decoration:none;
}
+/* LINKS */
+
.mp a, .mp a:link, .mp a:hover,
.mp a code, .mp a pre, .mp a tt,
.mp a kbd, .mp a samp { color:#0000ff }
+.mp b.man-ref { font-weight:normal;color:#434241 }
+
/* PREFORMATTED BLOCKS */
.mp pre { padding:0 4ex }
View
8 lib/ronn/utils.rb
@@ -43,5 +43,13 @@ def empty_element?(name)
def html_element?(name)
HTML.include?(name)
end
+
+ def child_of?(node, tag)
+ while node
+ return true if node.name && node.name.downcase == tag
+ node = node.parent
+ end
+ false
+ end
end
end
View
2  man/index.txt
Git LFS file not shown
View
2  test/markdown_syntax.html
@@ -951,7 +951,7 @@ <h2 id="AUTHOR">AUTHOR</h2>
<h2 id="SEE-ALSO">SEE ALSO</h2>
-<p>ronn(5)<br />
+<p><b class="man-ref">ronn(5)</b><br />
<a href="http://daringfireball.net/projects/markdown/" data-bare-link="true">http://daringfireball.net/projects/markdown/</a></p>
</div>
View
2  test/markdown_syntax.roff
@@ -1461,7 +1461,7 @@ Markdown was created by John Gruber\.
Manual page by Ryan Tomayko\. It\'s pretty much a direct copy of the Markdown Syntax Reference \fIhttp://daringfireball\.net/projects/markdown/syntax\fR, also by John Gruber\.
.
.SH "SEE ALSO"
-ronn(5)
+\fBronn(5)\fR
.
.br
\fIhttp://daringfireball\.net/projects/markdown/\fR
Please sign in to comment.
Something went wrong with that request. Please try again.