summaryrefslogtreecommitdiff
path: root/src/syntax/node.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2021-01-30 15:24:11 +0100
committerLaurenz <laurmaedje@gmail.com>2021-01-30 15:24:11 +0100
commit67047047e82c564d7701c3505c85db6e34223763 (patch)
tree1ea60584f34e54718927ce23414209a59f33588d /src/syntax/node.rs
parentfe7ea53800e3b646e3c51c1f10a1e95a06334c7f (diff)
Interpret two backticks as single-backtick block ✅
Diffstat (limited to 'src/syntax/node.rs')
-rw-r--r--src/syntax/node.rs53
1 files changed, 25 insertions, 28 deletions
diff --git a/src/syntax/node.rs b/src/syntax/node.rs
index d45e5952..f7625036 100644
--- a/src/syntax/node.rs
+++ b/src/syntax/node.rs
@@ -66,11 +66,11 @@ impl Pretty for NodeHeading {
/// A raw block with optional syntax highlighting: `` `raw` ``.
///
-/// Raw blocks start with an arbitrary number of backticks and end with the same
-/// number of backticks. If you want to include a sequence of backticks in a raw
-/// block, simply surround the block with more backticks.
+/// Raw blocks start with 1 or 3+ backticks and end with the same number of
+/// backticks. If you want to include a sequence of backticks in a raw block,
+/// simply surround the block with more backticks.
///
-/// When using at least two backticks, an optional language tag may follow
+/// When using at least three backticks, an optional language tag may follow
/// directly after the backticks. This tag defines which language to
/// syntax-highlight the text in. Apart from the language tag and some
/// whitespace trimming discussed below, everything inside a raw block is
@@ -82,22 +82,21 @@ impl Pretty for NodeHeading {
/// `raw`
/// ```
/// - An optional language tag may follow directly at the start when the block
-/// is surrounded by at least two backticks.
-/// ```typst
-/// ``rust println!("hello!")``;
-/// ```
-/// - Blocks can span multiple lines. Two backticks suffice to be able to
-/// specify the language tag, but three are fine, too.
-/// ```typst
-/// ``rust
+/// is surrounded by at least three backticks.
+/// ````typst
+/// ```rust println!("hello!")```;
+/// ````
+/// - Blocks can span multiple lines.
+/// ````typst
+/// ```rust
/// loop {
/// find_yak().shave();
/// }
-/// ``
/// ```
-/// - Start with a space to omit the language tag (the space will be trimmed
-/// from the output) and use more backticks to allow backticks in the raw
-/// text.
+/// ````
+/// - Start with a space to omit the language tag (the space will be trimmed
+/// from the output) and use more backticks to allow backticks in the raw
+/// text.
/// `````typst
/// ```` This contains ```backticks``` and has no leading & trailing spaces. ````
/// `````
@@ -107,24 +106,22 @@ impl Pretty for NodeHeading {
/// given, a few things would become problematic or even impossible:
/// - Typical multiline code blocks (like in the example above) would have an
/// additional newline before and after the code.
-/// - Raw text wrapped in more than one backtick could not exist without
-/// leading whitespace since the first word would be interpreted as a
-/// language tag.
+/// - The first word of text wrapped in more than three backticks would always
+/// be interpreted as a language tag which means that text without leading
+/// space would be impossible.
/// - A single backtick without surrounding spaces could not exist as raw text
/// since it would be interpreted as belonging to the opening or closing
/// backticks.
///
-/// To fix these problems, we trim text in multi-backtick blocks as follows:
-/// - We trim a single space or a sequence of whitespace followed by a newline
-/// at the start.
-/// - We trim a single space or a newline followed by a sequence of whitespace
-/// at the end.
+/// To fix these problems, we trim blocks with 3+ backticks as follows:
+/// - A single space or a sequence of whitespace followed by a newline at the start.
+/// - A single space or a newline followed by a sequence of whitespace at the end.
///
/// With these rules, a single raw backtick can be produced by the sequence
-/// ``` `` ` `` ```, ``` `` unhighlighted text `` ``` has no surrounding
-/// spaces and multiline code blocks don't have extra empty lines. Note that
-/// you can always force leading or trailing whitespace simply by adding more
-/// spaces.
+/// ```` ``` ` ``` ````, ```` ``` unhighlighted text ``` ```` has no
+/// surrounding spaces and multiline code blocks don't have extra empty lines.
+/// Note that you can always force leading or trailing whitespace simply by
+/// adding more spaces.
#[derive(Debug, Clone, PartialEq)]
pub struct NodeRaw {
/// An optional identifier specifying the language to syntax-highlight in.