Skip to main content

detect_inline

Function detect_inline 

pub fn detect_inline(before_caret: &str) -> Option<InlineMatch>
Expand description

The span the last character of before_caret completes, if any.

before_caret is the block’s text from its start to the caret, including the closing delimiter just typed.

The rules keep a stray delimiter from ever eating text:

  • The closing delimiter is the whole run of the typed character ending at the caret, exactly as wide as its kind: one `, two ~, one * or _ for italic, two for bold. *** or ``` is left alone.
  • The opening delimiter is the nearest run of the same character to the left, exactly as wide as the closing one.
  • The content is not empty, holds no delimiter character of its kind, and neither starts nor ends with whitespace, so 2 * 3 * 4 stays as typed.
  • An _ opener never follows a letter or digit, so snake_case_name stays as typed.