Login About Gallery
Bear TOC
Accepts
Files
COMMENT
‎Bear TOC v. 2.3 2024-07-15 at 10:42 EDT Makes TOC in Bear Notes: - Input identifier from Bear - Adds result TOC to Bear note - or Paste TOC manually - Option to include note title in TOC - Create as bullet or numbered lists - Optional with Wiki links to headings
TEXT
‎### _Table of Contents_
VARIABLES
‎Set variable ‎TocHeading ‎to ‎Text
NUMBER
‎4
VARIABLES
‎Set variable ‎Depth ‎to ‎Number
TEXT
‎Include note title = true
VARIABLES
‎Set variable ‎NoteTitleInToc ‎to ‎Text
VARIABLES
‎Set variable ‎note_id ‎to ‎Shortcut Input
TEXT
‎Match ‎^[0-9A-F\-]+$ ‎in ‎note_id
Case Sensitive
SCRIPTING
‎Count ‎Items ‎in ‎Matches
SCRIPTING
‎If ‎Count ‎is ‎0
SCRIPTING
‎Show alert ‎Informational Message
Title
‎optional
Show Cancel Button
SCRIPTING
‎Exit shortcut with ‎Result
SCRIPTING
‎Otherwise
SCRIPTING
‎End If
BEAR
‎ Under Construction
VARIABLES
‎Set variable ‎MdText ‎to ‎Note
VARIABLES
‎Set variable ‎noteTitle ‎to ‎Note
SCRIPTING
‎Choose from Menu
SCRIPTING
‎Bullet TOC
NUMBER
VARIABLES
‎Set variable ‎MakeTocLinks ‎to ‎Number
TEXT
‎-
SCRIPTING
‎Numbered TOC
NUMBER
VARIABLES
‎Set variable ‎MakeTocLinks ‎to ‎Number
TEXT
‎1.
SCRIPTING
‎Bullet TOC with links
NUMBER
‎1.0
VARIABLES
‎Set variable ‎MakeTocLinks ‎to ‎Number
TEXT
‎-
SCRIPTING
‎Numbered TOC with links
NUMBER
‎1.0
VARIABLES
‎Set variable ‎MakeTocLinks ‎to ‎Number
TEXT
‎1.
SCRIPTING
‎Quit Shortcut
SCRIPTING
‎Exit shortcut with ‎Result
SCRIPTING
‎End Menu
VARIABLES
‎Set variable ‎ListTag ‎to ‎Menu Result
COMMENT
‎First make plain TOC without links:
SCRIPTING
‎If ‎NoteTitleInToc ‎contains ‎Include note title = true
TEXT
‎Split ‎MdText ‎by ‎New Lines
SCRIPTING
‎Get ‎First Item ‎from ‎Split Text
VARIABLES
‎Set variable ‎TocList ‎to ‎Item from List
SCRIPTING
‎Otherwise
SCRIPTING
‎End If
TEXT
‎Match ‎\n(#{1, ‎Depth ‎} .+?)\n ‎in ‎MdText
Case Sensitive
TEXT
‎Get ‎Group At Index ‎1 ‎in ‎Matches
VARIABLES
‎Add ‎Text ‎to ‎TocList
NUMBER
‎6.0
VARIABLES
‎Set variable ‎TopMost ‎to ‎Number
SCRIPTING
‎Repeat with each item in ‎TocList
DOCUMENTS
‎Replace ‎^(#{1,6}) .+ ‎with ‎$1 ‎in ‎Repeat Item
Case Sensitive
Regular Expression
SCRIPTING
‎Count ‎Characters ‎in ‎Updated Text
SCRIPTING
‎If ‎Count ‎is less than or equal to ‎TopMost
VARIABLES
‎Set variable ‎TopMost ‎to ‎Count
SCRIPTING
‎Otherwise
SCRIPTING
‎End If
SCRIPTING
‎End Repeat
SCRIPTING
‎Get ‎First Item ‎from ‎TocList
DOCUMENTS
‎Replace ‎^(#+) .+ ‎with ‎$1 ‎in ‎Item from List
Case Sensitive
Regular Expression
SCRIPTING
‎Count ‎Characters ‎in ‎Updated Text
SCRIPTING
‎If ‎Count ‎is ‎TopMost
VARIABLES
‎Set variable ‎TocStartLevel ‎to ‎Count
SCRIPTING
‎Otherwise
NUMBER
‎1.0
VARIABLES
‎Set variable ‎TocStartLevel ‎to ‎Number
SCRIPTING
‎End If
TEXT
‎Combine ‎TocList ‎with ‎New Lines
VARIABLES
‎Set variable ‎toc ‎to ‎Combined Text
SCRIPTING
‎If ‎MakeTocLinks ‎is ‎1
COMMENT
‎Add wiki style tags: [[/title]]
DOCUMENTS
‎Replace ‎(#+?) (.+) ‎with ‎$1 [[/$2|$2]] ‎in ‎toc
Case Sensitive
Regular Expression
VARIABLES
‎Set variable ‎toc ‎to ‎Updated Text
SCRIPTING
‎Otherwise
SCRIPTING
‎End If
DOCUMENTS
‎Replace ‎#{ ‎TocStartLevel ‎}(#*) ‎with ‎$1 ‎ListTag ‎in ‎toc
Case Sensitive
Regular Expression
DOCUMENTS
‎Replace ‎# ‎with ‎in ‎Updated Text
Case Sensitive
Regular Expression
DOCUMENTS
‎Replace ‎<!-- {"fold":true} --> ‎with ‎World ‎in ‎Updated Text
Case Sensitive
Regular Expression
DOCUMENTS
‎Replace ‎[*~=`]+(\b.*?\b[,.?!]?)[*~=`]+|\_+(\S.+?)\_+ ‎with ‎$1$2 ‎in ‎Updated Text
Case Sensitive
Regular Expression
TEXT
‎Updated Text ‎TocHeading
VARIABLES
‎Set variable ‎toc ‎to ‎Text
SCRIPTING
‎Choose from Menu
SCRIPTING
‎Add it to beginning of Note - Only use this if Title is H1!
VARIABLES
‎Get ‎toc
BEAR
‎Add to Bear Note
Attach
Text
File
Mode
Append
Prepend
Title
‎optional
Note Identifier
‎[{'class': 'magic', 'value': 'note_id', 'glyph': 'assets/cat/Variable.svg', 'UUID': ''}]
Return to Shortcuts
SCRIPTING
‎Paste TOC into note manually
SHARING
‎Copy ‎toc ‎to clipboard
Local Only
Expire At
‎Today at 3 pm
BEAR
‎Open ‎Note Title
Note Identifier
‎[{'class': 'magic', 'value': 'note_id', 'glyph': 'assets/cat/Variable.svg', 'UUID': ''}]
NOTIFICATIONS
‎Show notification ‎Input
‎Options Under Construction
SCRIPTING
‎Quit Shortcut
SCRIPTING
‎Exit shortcut with ‎Result
SCRIPTING
‎End Menu
SCRIPTING
‎Exit shortcut with ‎Result

Showcuts

Magic Vars

Screenshot

Submitted Anonymously 7 months ago

Visit iCloud (iOS)

Copy iCloud Link

Scan QR Code

0