Skip to content

Commit

Permalink
Fix relative links from README in rustdoc (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
not-my-profile committed Aug 11, 2023
1 parent 7d42ef7 commit ee5130b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
12 changes: 9 additions & 3 deletions README.md
Expand Up @@ -48,7 +48,7 @@ test suite](https://github.com/html5lib/html5lib-tests/tree/master/tokenizer). S
* `html5gum` doesn't implement the DOM, and unfortunately in the HTML spec,
constructing the DOM ("tree construction") influences how tokenization is
done. For an example of which problems this causes see [this example
code](./examples/tokenize_with_state_switches.rs).
code][examples/tokenize_with_state_switches.rs].
* `html5gum` **does not** generally qualify as a browser-grade HTML *parser* as
per the WHATWG spec. This can change in the future, see [issue
21](https://github.com/untitaker/html5gum/issues/21).
Expand All @@ -69,7 +69,7 @@ This allows you to:
you, you can implement the respective trait methods as noop and therefore
avoid any overhead creating plaintext tokens.

See [the `custom_emitter` example](./examples/custom_emitter.rs) for how this
See [the `custom_emitter` example][examples/custom_emitter.rs] for how this
looks like in practice.

## Other features
Expand Down Expand Up @@ -109,4 +109,10 @@ Why is this library called `html5gum`?

## License

Licensed under the MIT license, see [`./LICENSE`](./LICENSE).
Licensed under the MIT license, see [`./LICENSE`][LICENSE].


<!-- These link destinations are defined like this so that src/lib.rs can override them. -->
[LICENSE]: ./LICENSE
[examples/tokenize_with_state_switches.rs]: ./examples/tokenize_with_state_switches.rs
[examples/custom_emitter.rs]: ./examples/custom_emitter.rs
16 changes: 16 additions & 0 deletions src/lib.rs
@@ -1,7 +1,13 @@
#![warn(missing_docs)]
// This is an HTML parser. HTML can be untrusted input from the internet.
#![forbid(unsafe_code)]
//
// Relative links in the README.md don't work in rustdoc, so we have to override them.
#![doc = concat!("[LICENSE]: ", blob_url_prefix!(), "LICENSE")]
#![doc = concat!("[examples/tokenize_with_state_switches.rs]: ", blob_url_prefix!(), "examples/tokenize_with_state_switches.rs")]
#![doc = concat!("[examples/custom_emitter.rs]: ", blob_url_prefix!(), "examples/custom_emitter.rs")]
#![doc = include_str!("../README.md")]
//
#![warn(clippy::all)]
#![warn(
absolute_paths_not_starting_with_crate,
Expand All @@ -16,6 +22,16 @@
#![allow(clippy::module_name_repetitions)]
#![allow(clippy::missing_errors_doc)]

macro_rules! blob_url_prefix {
() => {
concat!(
"https://github.com/untitaker/html5gum/blob/",
env!("CARGO_PKG_VERSION"),
"/"
)
};
}

mod arrayvec;
mod char_validator;
mod emitter;
Expand Down

0 comments on commit ee5130b

Please sign in to comment.