Skip to content

Need a link remover script #182

@carols10cents

Description

@carols10cents

This is related to #169 and #127. This issue is for the mechanics of removing links, but not for deciding which things should be links and which shouldn't.

Problem

We link to terms and resources pretty frequently in the online version of the book, because there's not much cost/risk with linking on the web-- it doesn't take up any more space than just text, there's not a lot of cognitive overhead to read past it if you're not interested, and if a link should break, it's a pretty easy fix that can be made available quickly.

Print, on the other hand, means we have to work the URL into the prose, you'd have to read past the entire URL if you're not interested, and we should consider the likelihood of a link breaking when considering whether to print a URL. The bar should be higher to get a URL in print.

Solution

I would like some way of annotating a link in the src/*.md files such that:

  • when we do mdbook build, the HTML generated has the link and the annotation is invisible
  • when we run this currently-imaginary script, that script would see the annotation and remove the link markdown, leaving only the link text.

The script should be written in Rust.

The script should read from stdin and write to stdout-- I'm imagining running this with xargs and incorporating this into the concatenation script for delivering to nostarch, so the output will probably go in a temporary file, but this script shouldn't have to worry about that.

Example

I'm open to other ideas for what we use for the annotation, but this is one thing that should work: say the markdown contains:

Lorem Ipsum [the ‘prelude’][prelude]<!-- ignore --> dolor sit [amet](http://lipsum.com/)<!-- ignore -->.

[prelude]: ../std/prelude/index.html

Vestibulum elit turpis, 

The output of this script should be:

Lorem Ipsum the ‘prelude’ dolor sit amet.

Vestibulum elit turpis, 

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions