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
Otherwise
End If
Under Construction
VARIABLES
Set variable
MdText
to
Note
VARIABLES
Set variable
noteTitle
to
Note
SCRIPTING
Choose from Menu
Bullet TOC
NUMBER
VARIABLES
Set variable
MakeTocLinks
to
Number
TEXT
-
Numbered TOC
NUMBER
VARIABLES
Set variable
MakeTocLinks
to
Number
TEXT
1.
Bullet TOC with links
NUMBER
1.0
VARIABLES
Set variable
MakeTocLinks
to
Number
TEXT
-
Numbered TOC with links
NUMBER
1.0
VARIABLES
Set variable
MakeTocLinks
to
Number
TEXT
1.
Quit Shortcut
SCRIPTING
Exit shortcut with
Result
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
Otherwise
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
Otherwise
End If
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
Otherwise
NUMBER
1.0
VARIABLES
Set variable
TocStartLevel
to
Number
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
Otherwise
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
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
note_id
Return to Shortcuts
Paste TOC into note manually
SHARING
Copy
toc
to clipboard
Local Only
Expire At
Today at 3 pm
BEAR
Open
Note Title
Note Identifier
note_id
NOTIFICATIONS
Show notification
Input
Options Under Construction
Quit Shortcut
SCRIPTING
Exit shortcut with
Result
End Menu
SCRIPTING
Exit shortcut with
Result

Showcuts

Magic Vars

Screenshot

Submitted Anonymously 4 days ago

Visit iCloud (iOS)

Copy iCloud Link

Scan QR Code

0