Module: YARD::RelativeMarkdownLinks
- Defined in:
- lib/yard/relative_markdown_links.rb,
lib/yard/relative_markdown_links/version.rb
Overview
A YARD plugin to convert relative links between Markdown files.
GitHub and YARD render Markdown files differently. In particular, relative
links in Markdown files that work in GitHub don't work in YARD. For example,
if you have [hello](docs/FOO.md) in your README, YARD renders it as
<a href="docs/FOO.md">hello</a>, creating a broken link in your docs.
With this plugin enabled, you'll get <a href="file.FOO.html">hello</a>
instead, which correctly links through to the rendered HTML file.
This plugin also properly handles files in subdirectories. For example,
if docs/index.md links to getting-started.md, the plugin resolves
the link relative to the current file's directory, finding
docs/getting-started.md in YARD's file list.
Constant Summary collapse
- ANCHOR_TAG_PATTERN =
%r{<a\b(?<attributes>[^>]*)>(?<content>.*?)</a>}im
- HREF_ATTRIBUTE_PATTERN =
/ \bhref \s*=\s* (?: "(?<double>[^"]*)" | '(?<single>[^']*)' | (?<bare>[^\s"'=<>`]+) ) /imx
- RDOC_FILENAME_PATTERN =
%r{\A(?<dirname>(?:[^/#]*/)*+)(?<basename>[^/#]+)\.(?<ext>rb|rdoc|md)\z}i- VERSION =
'0.3.0'
Instance Method Summary collapse
-
#resolve_links(text) ⇒ String
Resolves relative links from Markdown files.
Instance Method Details
#resolve_links(text) ⇒ String
Resolves relative links from Markdown files.
41 42 43 44 45 |
# File 'lib/yard/relative_markdown_links.rb', line 41 def resolve_links(text) return super unless .files super(rewrite_anchor_links(text)) end |