From 93d0b7c6465f4ffe220b3ddada729746b11eb6ce Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Tue, 16 Aug 2022 13:04:38 +0200 Subject: Update some last docs, bnf grammars --- src/construct/label_end.rs | 46 +++++++++++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 17 deletions(-) (limited to 'src/construct/label_end.rs') diff --git a/src/construct/label_end.rs b/src/construct/label_end.rs index 4752639..5e31444 100644 --- a/src/construct/label_end.rs +++ b/src/construct/label_end.rs @@ -1,11 +1,14 @@ -//! Label end is a construct that occurs in the [text][] content type. +//! Label end occurs in the [text][] content type. //! -//! It forms with the following BNF: +//! ## Grammar +//! +//! Label end forms with the following BNF +//! (see [construct][crate::construct] for character groups): //! //! ```bnf -//! label_end ::= ']' [ resource | reference_full | reference_collapsed ] +//! label_end ::= ']' [resource | reference_full | reference_collapsed] //! -//! resource ::= '(' [ whitespace ] destination [ whitespace title ] [ whitespace ] ')' +//! resource ::= '(' [space_or_tab_eol] destination [space_or_tab_eol title] [space_or_tab_eol] ')' //! reference_full ::= '[' label ']' //! reference_collapsed ::= '[' ']' //! @@ -14,15 +17,7 @@ //! ``` //! //! See [`destination`][destination], [`label`][label], and [`title`][title] -//! for grammar, notes, and recommendations. -//! -//! Label end does not, on its own, relate to anything in HTML. -//! When matched with a [label start (link)][label_start_link], they together -//! relate to the `` element in HTML. -//! See [*§ 4.5.1 The `a` element*][html-a] in the HTML spec for more info. -//! It can also match with [label start (image)][label_start_image], in which -//! case they form an `` element. -//! See [*§ 4.8.3 The `img` element*][html-img] in the HTML spec for more info. +//! for grammar, notes, and recommendations on each part. //! //! In the case of a resource, the destination and title are given directly //! with the label end. @@ -49,7 +44,7 @@ //! //! When the resource or reference matches, the destination forms the `href` //! attribute in case of a [label start (link)][label_start_link], and an -//! `src` attribute otherwise. +//! `src` attribute in case of a [label start (image)][label_start_image]. //! The title is formed, optionally, on either `` or ``. //! //! For info on how to encode characters in URLs, see @@ -94,12 +89,29 @@ //!

a [b c d](#) e

//! ``` //! -//! This limiation is imposed because links in links is invalid according to +//! This limitation is imposed because links in links is invalid according to //! HTML. //! Technically though, in markdown it is still possible to construct them by //! using an [autolink][] in a link. //! You definitely should not do that. //! +//! ## HTML +//! +//! Label end does not, on its own, relate to anything in HTML. +//! When matched with a [label start (link)][label_start_link], they together +//! relate to the `` element in HTML. +//! See [*§ 4.5.1 The `a` element*][html_a] in the HTML spec for more info. +//! It can also match with [label start (image)][label_start_image], in which +//! case they form an `` element. +//! See [*§ 4.8.3 The `img` element*][html_img] in the HTML spec for more info. +//! +//! ## Recommendation +//! +//! It is recommended to use labels instead of [autolinks][autolink]. +//! Labels allow more characters in URLs, and allow relative URLs and `www.` +//! URLs. +//! They also allow for descriptive text to explain the URL in prose. +//! //! ## Tokens //! //! * [`Data`][Name::Data] @@ -143,8 +155,8 @@ //! [autolink]: crate::construct::autolink //! [sanitize_uri]: crate::util::sanitize_uri::sanitize_uri //! [normalize_identifier]: crate::util::normalize_identifier::normalize_identifier -//! [html-a]: https://html.spec.whatwg.org/multipage/text-level-semantics.html#the-a-element -//! [html-img]: https://html.spec.whatwg.org/multipage/embedded-content.html#the-img-element +//! [html_a]: https://html.spec.whatwg.org/multipage/text-level-semantics.html#the-a-element +//! [html_img]: https://html.spec.whatwg.org/multipage/embedded-content.html#the-img-element use crate::constant::RESOURCE_DESTINATION_BALANCE_MAX; use crate::construct::partial_space_or_tab_eol::space_or_tab_eol; -- cgit