All posts by Burdette Lamar

Gem markdown_helper Has CLI

I’ve added a proper command-line interface to gem markdown_helper.

Advertisements

MarkdownHelper Updated

I have updated the markdown_helper gem.

Features:

  • File inclusion
  • mage path resolution (new)

The image path resolution replaces relative image paths with absolute image URLs.

  • This matters because in the documentation for a gem (on RubyDoc.info), YARD formatting changes some file structures, which breaks relative links to images.
  • The resolution to absolute URLs avoids that breakage.

More Help with Markdown?

The markdown_helper gem I’ve put up does (so far) one thing:

  • Supports file inclusion.

I have in mind two additional features:

  • Support for relative links for images (see below for why this matters).
  • Support slideshow-style markdown pages (pages linked by next/prev navigation links).

Query: What else would be useful?

About relative links for images: they work fine in GitHub markdown, but when the project is formed into a gem, the links are broken in the gem’s documentation. That’s because on RubyDoc.info, YARD has rearranged some files and folders.

The workaround is to substitute absolute links to the files in raw.githubusercontent.com. This would be very inconvenient, not to say tedious and possibly error-prone.

What I want to add to the helper is a method that replaces the relative links with absolute ones automatically. That way, we have the convenience of relative links on GitHub, and correct (absolute) links on RubyDoc.

My GitHub Markdown Tips

 

I posted earlier about Richard Kim’s blog post that has some great tips for building an effective README.md page on GitHub.

A few of my own:

    • It’s not just README.md:
      • You can have any number of markdown pages.
      • They can be in any directories.
      • They can have filenames other than README.md.
      • The only ‘requirement’ is that for GH to render a markdown page properly, it must have the .md file extension.
    • You can link to a page with a normal GitHub URL:
      • https://github.com/user/project/blob/branch/file.md.
      • This lands readers at the top of the page, where they see various project information. (The actual markdown text will be farther down the page.)
    • You can link to a title in the markdown on a page with an extended URL:
      • https://github.com/user/project/blob/branch/file.md#title.
      • This lands the browser (Firefox at least) exactly at the title, not at the top of the page. (Get the exact URL from title’s link icon.)
      • The target title can be any title on the page (not just the main one, identified with a single #.)
    • This is especially useful for linking among markdown pages, so that the reader lands in the markdown text, instead of at the top of the page.
    • I’ve done this with my project’s Tester Tour, where each page in the tour has navigation links, forward and backward.
    • I have a MarkdownHelper class that I use to:
      • Build the tour by adding the navigation links.
      • Include external files by inlining them.
      • Add text highlighting if the file is .rb or .xml. (This can be extended to any language known to GitHub).
      • Query: Should this class be made into a Ruby gem?

     

    • Linking from markdown to an HTML file:
      • If you link in the usual way, the HTML will not be rendered: https://github.com/user/project/blob/branch/file.html
      • If you link in a special way, the HTML will be rendered: https://htmlpreview.github.io/?https://github.com/user/project/file.html
      • I would illustrate, but from here opening either type of link causes the HTML to be rendered. The difference is seen only in GitHub markdown.
      • But you can see it work via the link at the foot of https://github.com/BurdetteLamar/RubyTest/blob/master/examples/changes_report/ChangesReport.md.