~/bend-docscommunity

linkify.bend checks

raw source on the hub · import 0x2a08fdaf2b3aa16ae55ed9f5bb4a08ba/linkify.bend as Linkify

bible-linkify surface (pure Bend): protect-aware Markdown walker + plain matcher

5 imports
import Base
import ./route.bend as Route
import ./protect.bend as Prot
import ./parse.bend as P
import ./ref_token.bend as Tok

Types

type LinkOpts source · line 12 · raw

Data

Linkify options (baseUrl / src / rewriteExisting), matching bible-linkify.

type TvPh source · line 38 · raw

Data

Peek trailing " (ESV)" after a match — does not consume; code or "".

type SigPh source · line 220 · raw

Data

--- Passage signal ---

type TrPh source · line 258 · raw

Data

--- Trim wrappers: drop lead wrappers, reverse, drop lead (ex-trail), reverse ---

type TcPh source · line 306 · raw

Data

type VisCan source · line 398 · raw

Data

type CandGate source · line 401 · raw

Data

type TwPh source · line 437 · raw

Data

type ExPh source · line 474 · raw

Data

--- Urlish ---

type NaPh source · line 551 · raw

Data

type PlPh source · line 606 · raw

Data

--- Plain linkify ---

type LpGate source · line 823 · raw

Data

type FullHit2 source · line 826 · raw

Data

type MlPh source · line 898 · raw

Data

--- Extract label from [label](url); "" if image or malformed ---

type RwEq source · line 1025 · raw

Data

type RwPick source · line 1050 · raw

Data

type MdWalk source · line 1088 · raw

Data

--- Markdown walker ---

Definitions

def char1 source · line 8 · raw

@+c:Char -> String

def default_opts source · line 15 · raw

LinkOpts

def opts_base source · line 18 · raw

@+base:String -> @+src:String -> @rewrite:Bool -> LinkOpts

def linkify_parts source · line 21 · raw

@+visible:String -> @+canonical:String -> String

def linkify_parts_qv source · line 24 · raw

@+visible:String -> @+canonical:String -> @+translation:String -> String

def linkify_parts_opts source · line 27 · raw

@+visible:String -> @+canonical:String -> @+translation:String -> @+opts:LinkOpts -> String

def tv_letter_ok source · line 50 · raw

@+letters:Nat -> Bool

def tv_digit_ok source · line 53 · raw

@+digits:Nat -> Bool

def peek_translation_go source · line 56 · raw

@fuel:Nat -> @ph:TvPh -> @rest:String -> String

def peek_translation source · line 159 · raw

@+suffix:String -> String

def is_newline source · line 166 · raw

@+c:Char -> Bool

def is_alnum source · line 171 · raw

@+c:Char -> Bool

def is_wrapper_lead source · line 174 · raw

@+c:Char -> Bool

def is_wrapper_trail source · line 189 · raw

@+c:Char -> Bool

def has_signal_go source · line 224 · raw

@fuel:Nat -> @ph:SigPh -> @rest:String -> Bool

def has_passage_signal source · line 254 · raw

@+s:String -> Bool

def is_wrapper_either source · line 262 · raw

@+c:Char -> Bool

def trim_pass_go source · line 265 · raw

@fuel:Nat -> @ph:TrPh -> @rest:String -> String

def trim_pass source · line 288 · raw

@+s:String -> String

def trim_wrappers source · line 291 · raw

@+s:String -> String

def is_colon_dot_dash source · line 295 · raw

@+c:Char -> Bool

--- Candidate take ---

def is_cand_char source · line 300 · raw

@+c:Char -> Bool

def pick_sp source · line 317 · raw

@has_d:Bool -> @+n:Nat -> TcPh

def take_cand_go source · line 324 · raw

@fuel:Nat -> @ph:TcPh -> @+rest:String -> @acc:String -> String

def take_candidate source · line 394 · raw

@+s:String -> String

def cand_pick source · line 405 · raw

@empty:Bool -> @+visible:String -> @+canonical:String -> CandGate

def cand_from source · line 412 · raw

@+visible:String -> @+canonical:String -> CandGate

def try_parse_visible_gated source · line 415 · raw

@g:CandGate -> Maybe<&2, VisCan>

def try_parse_visible source · line 422 · raw

@+visible:String -> Maybe<&2, VisCan>

def drop_last_rev source · line 427 · raw

@rev:String -> String

def drop_last source · line 434 · raw

@s:String -> String

def try_windows_go source · line 443 · raw

@fuel:Nat -> @ph:TwPh -> Maybe<&2, VisCan>

def try_windows source · line 470 · raw

@+raw:String -> Maybe<&2, VisCan>

def expand_token_left source · line 478 · raw

@fuel:Nat -> @ph:ExPh -> @+left_rev:String -> @acc:String -> String

def expand_token_right source · line 501 · raw

@fuel:Nat -> @ph:ExPh -> @+right:String -> @acc:String -> String

def token_around source · line 524 · raw

@+prefix_rev:String -> @+matched:String -> @+suffix:String -> String

def is_urlish_token source · line 533 · raw

@+tok:String -> Bool

def is_book_num source · line 542 · raw

@+c:Char -> Bool

def looks_like_ref_start source · line 548 · raw

@+c:Char -> Bool

def not_alnum_next_go source · line 554 · raw

@ph:NaPh -> Bool

def not_alnum_next source · line 563 · raw

@next_suffix:String -> Bool

def standalone_from_prev source · line 570 · raw

@prev_alnum:Bool -> @+next_suffix:String -> Bool

def standalone_ok source · line 577 · raw

@+prev_rev:String -> @+next_suffix:String -> Bool

def try_ref_at_parsed source · line 585 · raw

@+raw:String -> @m:Maybe<&2, VisCan> -> Maybe<&2, VisCan>

Prefer REFERENCE_TOKEN-shaped match; fall back to candidate-window shrink.

def try_ref_at_tok_empty source · line 592 · raw

@empty:Bool -> @+raw:String -> @+tok:String -> Maybe<&2, VisCan>

def try_ref_at_tok source · line 599 · raw

@+raw:String -> @+tok:String -> Maybe<&2, VisCan>

def try_ref_at source · line 602 · raw

@+raw:String -> Maybe<&2, VisCan>

def pick_pl_ref source · line 620 · raw

@at_start:Bool -> PlPh

def pick_pl source · line 627 · raw

@is_ref:Bool -> @at_start:Bool -> PlPh

def linkify_plain_go source · line 654 · raw

@fuel:Nat -> @ph:PlPh -> @+rest:String -> @+prev_rev:String -> @out:String -> @+opts:LinkOpts -> String

def classify_rest source · line 831 · raw

@exact:Bool -> @+visible:String -> @+canonical:String -> @+rest:String -> FullHit2

def classify_hit source · line 838 · raw

@m:Maybe<&2, VisCan> -> @+text:String -> FullHit2

def linkify_plain_from_hit source · line 852 · raw

@h:FullHit2 -> @+text:String -> @+opts:LinkOpts -> String

def linkify_plain_gated source · line 878 · raw

@g:LpGate -> @+text:String -> @+opts:LinkOpts -> String

def linkify_plain_opts source · line 891 · raw

@+text:String -> @+opts:LinkOpts -> String

def linkify_plain source · line 894 · raw

@+text:String -> String

def md_label_go source · line 909 · raw

@fuel:Nat -> @ph:MlPh -> @rest:String -> String

def md_extract_label source · line 1018 · raw

@+token:String -> String

def rewrite_from_eq source · line 1028 · raw

@g:RwEq -> @+opts:LinkOpts -> String

def rewrite_from_parse source · line 1037 · raw

@+label:String -> @m:Maybe<&2, VisCan> -> @+opts:LinkOpts -> String

def maybe_rewrite_pick_go source · line 1053 · raw

@g:RwPick -> String

def maybe_rewrite_pick source · line 1062 · raw

@+token:String -> @+repl:String -> String

def is_md_protect source · line 1075 · raw

@+rest:String -> @+plen:Nat -> Bool

def want_rewrite_md source · line 1078 · raw

@+opts:LinkOpts -> @+rest:String -> @+plen:Nat -> Bool

def linkify_md_go source · line 1097 · raw

@fuel:Nat -> @ph:MdWalk -> @+rest:String -> @plain:String -> @out:String -> @+opts:LinkOpts -> String

def linkify_markdown_opts source · line 1216 · raw

@+source:String -> @+opts:LinkOpts -> String

def linkify_markdown source · line 1226 · raw

@+source:String -> String

def linkify_markdown_src source · line 1229 · raw

@+source:String -> @+src:String -> String

def linkify_markdown_rewrite source · line 1232 · raw

@+source:String -> String

def opts_cli source · line 1235 · raw

@+src:String -> @rewrite:Bool -> LinkOpts

def linkify_markdown_cli source · line 1238 · raw

@+source:String -> @+src:String -> @rewrite:Bool -> String