1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-12-04 15:58:05 +00:00

Revamp markdown plugin (#6528)

* Rename markdown to markdown-legacy

* Change how default renderWikiTextPragma value is displayed

To prevent out-of-sync, dynamically display the default value of
renderWikiTextPragma from the shadow tiddler instead of hard coding
the text in the "usage.tid".

* Repackage remarkable-based markdown plugin as markdown-legacy

- Rename plugin title to $:/plugins/tiddlywiki/markdown-legacy

- Add support for "text/markdown" MIME type and set that as the default
  when creating new markdown tiddlers

* Create new markdown plugin

* add support to text/markdown MIME type

* remove linkify and linkNewWindow config options

- linkify feature should be controlled by "extlink" TW parser rule;
  enabling markdown's linkify option will interfere with parsing

- remove the possibility to open external links in the same tab/window
  to match TW's behavior

* Ignore latex-parser wikirule in rednerWikiTextPragma

* Prevent camel-case link text from generating a link

* Update editions/markdowndemo

* Produce better parse tree

* Improve markdown/tiddlywiki integration

- widget block should not interrupt paragraph
- ignore tw-syntax links inside markdown-syntax links
- remove repeated renderWikiTextPragma parsing
- more efficient findNextMatch when examining tw rules

* Update user docs

* Replace includes() with indexOf() for legacy browsers
This commit is contained in:
cdruan
2023-01-14 01:49:04 -08:00
committed by GitHub
parent b5134951e5
commit 0c328a1696
84 changed files with 2443 additions and 359 deletions

View File

@@ -0,0 +1,15 @@
title: $:/plugins/tiddlywiki/markdown-legacy/EditorToolbar/bold
list-after: $:/core/ui/EditorToolbar/bold
tags: $:/tags/EditorToolbar
icon: $:/core/images/bold
caption: {{$:/language/Buttons/Bold/Caption}} (Markdown)
description: {{$:/language/Buttons/Bold/Hint}}
condition: [<targetTiddler>type[text/x-markdown]] [<targetTiddler>type[text/markdown]]
shortcuts: ((bold))
<$action-sendmessage
$message="tm-edit-text-operation"
$param="wrap-selection"
prefix="**"
suffix="**"
/>

View File

@@ -0,0 +1,15 @@
title: $:/plugins/tiddlywiki/markdown-legacy/EditorToolbar/heading-1
list-after: $:/core/ui/EditorToolbar/heading-1
tags: $:/tags/EditorToolbar
icon: $:/core/images/heading-1
caption: {{$:/language/Buttons/Heading1/Caption}} (Markdown)
description: {{$:/language/Buttons/Heading1/Hint}}
condition: [<targetTiddler>type[text/x-markdown]] [<targetTiddler>type[text/markdown]]
shortcuts: ((heading-1))
<$action-sendmessage
$message="tm-edit-text-operation"
$param="prefix-lines"
character="#"
count="1"
/>

View File

@@ -0,0 +1,15 @@
title: $:/plugins/tiddlywiki/markdown-legacy/EditorToolbar/heading-2
list-after: $:/core/ui/EditorToolbar/heading-2
tags: $:/tags/EditorToolbar
icon: $:/core/images/heading-2
caption: {{$:/language/Buttons/Heading2/Caption}} (Markdown)
description: {{$:/language/Buttons/Heading2/Hint}}
condition: [<targetTiddler>type[text/x-markdown]] [<targetTiddler>type[text/markdown]]
shortcuts: ((heading-2))
<$action-sendmessage
$message="tm-edit-text-operation"
$param="prefix-lines"
character="#"
count="2"
/>

View File

@@ -0,0 +1,15 @@
title: $:/plugins/tiddlywiki/markdown-legacy/EditorToolbar/heading-3
list-after: $:/core/ui/EditorToolbar/heading-3
tags: $:/tags/EditorToolbar
icon: $:/core/images/heading-3
caption: {{$:/language/Buttons/Heading3/Caption}} (Markdown)
description: {{$:/language/Buttons/Heading3/Hint}}
condition: [<targetTiddler>type[text/x-markdown]] [<targetTiddler>type[text/markdown]]
shortcuts: ((heading-3))
<$action-sendmessage
$message="tm-edit-text-operation"
$param="prefix-lines"
character="#"
count="3"
/>

View File

@@ -0,0 +1,15 @@
title: $:/plugins/tiddlywiki/markdown-legacy/EditorToolbar/heading-4
list-after: $:/core/ui/EditorToolbar/heading-4
tags: $:/tags/EditorToolbar
icon: $:/core/images/heading-4
caption: {{$:/language/Buttons/Heading4/Caption}} (Markdown)
description: {{$:/language/Buttons/Heading4/Hint}}
condition: [<targetTiddler>type[text/x-markdown]] [<targetTiddler>type[text/markdown]]
shortcuts: ((heading-4))
<$action-sendmessage
$message="tm-edit-text-operation"
$param="prefix-lines"
character="#"
count="4"
/>

View File

@@ -0,0 +1,15 @@
title: $:/plugins/tiddlywiki/markdown-legacy/EditorToolbar/heading-5
list-after: $:/core/ui/EditorToolbar/heading-5
tags: $:/tags/EditorToolbar
icon: $:/core/images/heading-5
caption: {{$:/language/Buttons/Heading5/Caption}} (Markdown)
description: {{$:/language/Buttons/Heading5/Hint}}
condition: [<targetTiddler>type[text/x-markdown]] [<targetTiddler>type[text/markdown]]
shortcuts: ((heading-5))
<$action-sendmessage
$message="tm-edit-text-operation"
$param="prefix-lines"
character="#"
count="5"
/>

View File

@@ -0,0 +1,15 @@
title: $:/plugins/tiddlywiki/markdown-legacy/EditorToolbar/heading-6
list-after: $:/core/ui/EditorToolbar/heading-6
tags: $:/tags/EditorToolbar
icon: $:/core/images/heading-6
caption: {{$:/language/Buttons/Heading6/Caption}} (Markdown)
description: {{$:/language/Buttons/Heading6/Hint}}
condition: [<targetTiddler>type[text/x-markdown]] [<targetTiddler>type[text/markdown]]
shortcuts: ((heading-6))
<$action-sendmessage
$message="tm-edit-text-operation"
$param="prefix-lines"
character="#"
count="6"
/>

View File

@@ -0,0 +1,15 @@
title: $:/plugins/tiddlywiki/markdown-legacy/EditorToolbar/italic
list-after: $:/core/ui/EditorToolbar/italic
tags: $:/tags/EditorToolbar
icon: $:/core/images/italic
caption: {{$:/language/Buttons/Italic/Caption}} (Markdown)
description: {{$:/language/Buttons/Italic/Hint}}
condition: [<targetTiddler>type[text/x-markdown]] [<targetTiddler>type[text/markdown]]
shortcuts: ((italic))
<$action-sendmessage
$message="tm-edit-text-operation"
$param="wrap-selection"
prefix="*"
suffix="*"
/>

View File

@@ -0,0 +1,73 @@
title: $:/plugins/tiddlywiki/markdown-legacy/EditorToolbar/link-dropdown
\define lingo-base() $:/language/Buttons/Link/
\define add-link-actions()
\whitespace trim
<$action-sendmessage $message="tm-edit-text-operation" $param="make-markdown-link" text={{$(linkTiddler)$}} />
<$action-deletetiddler $filter="[<dropdown-state>] [<searchTiddler>] [<linkTiddler>] [<storeTitle>] [<searchListState>]"/>
\end
\define get-focus-selector() [data-tiddler-title="$(cssEscapedTitle)$"] .tc-create-wikitext-link input
\define cancel-search-actions-inner()
<$set name="userInput" value={{{ [<storeTitle>get[text]] }}}><$list filter="[<searchTiddler>get[text]!match<userInput>]" emptyMessage="<$action-deletetiddler $filter='[<searchTiddler>] [<linkTiddler>] [<storeTitle>] [<searchListState>]'/>"><$action-setfield $tiddler=<<searchTiddler>> text=<<userInput>>/><$action-setfield $tiddler=<<refreshTitle>> text="yes"/></$list></$set>
\end
\define cancel-search-actions() <$list filter="[<storeTitle>!has[text]] +[<searchTiddler>!has[text]]" emptyMessage="<<cancel-search-actions-inner>>"><$action-sendmessage $message="tm-edit-text-operation" $param="focus-editor"/></$list>
\define external-link()
\whitespace trim
<$button class="tc-btn-invisible" style="width: auto; display: inline-block; background-colour: inherit;" actions=<<add-link-actions>>>
{{$:/core/images/chevron-right}}
</$button>
\end
\define set-next-input-tab(beforeafter:"after") <$macrocall $name="change-input-tab" stateTitle="$:/state/tab/search-results/sidebar" tag="$:/tags/SearchResults" beforeafter="$beforeafter$" defaultState={{$:/config/SearchResults/Default}} actions="<$action-setfield $tiddler='$:/state/search/currentTab' text=<<nextTab>>/>"/>
\define body(config-title)
\whitespace trim
''<<lingo Hint>>''
<$vars searchTiddler="""$config-title$/search""" linkTiddler="""$config-title$/link""" linktext="" searchListState=<<qualify "$:/temp/link-search/selected-item">> refreshTitle=<<qualify "$:/temp/link-search/refresh">> storeTitle=<<qualify "$:/temp/link-search/input">>>
<$vars linkTiddler=<<searchTiddler>>>
<$keyboard key="((input-tab-right))" actions=<<set-next-input-tab>>>
<$keyboard key="((input-tab-left))" actions=<<set-next-input-tab "before">> class="tc-create-wikitext-link">
<$macrocall $name="keyboard-driven-input" tiddler=<<searchTiddler>> storeTitle=<<storeTitle>>
selectionStateTitle=<<searchListState>> refreshTitle=<<refreshTitle>> type="search" filterMinLength="1"
tag="input" focus="true" class="tc-popup-handle" inputCancelActions=<<cancel-search-actions>>
inputAcceptActions=<<add-link-actions>> placeholder={{$:/language/Search/Search}} default=""
configTiddlerFilter="[[$:/state/search/currentTab]!is[missing]get[text]] ~[{$:/config/SearchResults/Default}]" />
</$keyboard>
</$keyboard>
&#32;
<$reveal tag="span" state=<<storeTitle>> type="nomatch" text="">
<<external-link>>
&#32;
<$button class="tc-btn-invisible" style="width: auto; display: inline-block; background-colour: inherit;">
<<cancel-search-actions>><$set name="cssEscapedTitle" value={{{ [<storyTiddler>escapecss[]] }}}><$action-sendmessage $message="tm-focus-selector" $param=<<get-focus-selector>>/></$set>
{{$:/core/images/close-button}}
</$button>
</$reveal>
</$vars>
<$reveal tag="div" state=<<storeTitle>> type="nomatch" text="">
<$linkcatcher actions=<<add-link-actions>> to=<<linkTiddler>>>
<$vars userInput={{{ [<storeTitle>get[text]] }}} configTiddler={{{ [[$:/state/search/currentTab]!is[missing]get[text]] ~[{$:/config/SearchResults/Default}] }}}>
{{$:/core/ui/SearchResults}}
</$vars>
</$linkcatcher>
</$reveal>
</$vars>
\end
<$macrocall $name="body" config-title=<<qualify "$:/state/Link/">>/>

View File

@@ -0,0 +1,11 @@
title: $:/plugins/tiddlywiki/markdown-legacy/EditorToolbar/link
list-after: $:/core/ui/EditorToolbar/link
tags: $:/tags/EditorToolbar
icon: $:/core/images/link
caption: {{$:/language/Buttons/Link/Caption}}
description: {{$:/language/Buttons/Link/Hint}}
condition: [<targetTiddler>type[text/x-markdown]] [<targetTiddler>type[text/markdown]]
button-classes: tc-text-editor-toolbar-item-start-group
shortcuts: ((link))
dropdown: $:/plugins/tiddlywiki/markdown-legacy/EditorToolbar/link-dropdown

View File

@@ -0,0 +1,15 @@
caption: {{$:/language/Buttons/Linkify/Caption}} (Markdown)
condition: [<targetTiddler>type[text/x-markdown]] [<targetTiddler>type[text/markdown]]
description: {{$:/language/Buttons/Linkify/Hint}}
icon: $:/plugins/tiddlywiki/markdown-legacy/images/markdown-linkify
list-after: $:/core/ui/EditorToolbar/linkify
shortcuts: ((linkify))
title: $:/plugins/tiddlywiki/markdown-legacy/EditorToolbar/linkify
tags: $:/tags/EditorToolbar
<$action-sendmessage
$message="tm-edit-text-operation"
$param="wrap-selection"
prefix="["
suffix="]()"
/>

View File

@@ -0,0 +1,15 @@
title: $:/plugins/tiddlywiki/markdown-legacy/EditorToolbar/list-bullet
list-after: $:/core/ui/EditorToolbar/list-bullet
tags: $:/tags/EditorToolbar
icon: $:/core/images/list-bullet
caption: {{$:/language/Buttons/ListBullet/Caption}} (Markdown)
description: {{$:/language/Buttons/ListBullet/Hint}}
condition: [<targetTiddler>type[text/x-markdown]] [<targetTiddler>type[text/markdown]]
shortcuts: ((list-bullet))
<$action-sendmessage
$message="tm-edit-text-operation"
$param="prefix-lines"
character="*"
count="1"
/>

View File

@@ -0,0 +1,15 @@
title: $:/plugins/tiddlywiki/markdown-legacy/EditorToolbar/list-number
list-after: $:/core/ui/EditorToolbar/list-number
tags: $:/tags/EditorToolbar
icon: $:/core/images/list-number
caption: {{$:/language/Buttons/ListNumber/Caption}} (Markdown)
description: {{$:/language/Buttons/ListNumber/Hint}}
condition: [<targetTiddler>type[text/x-markdown]] [<targetTiddler>type[text/markdown]]
shortcuts: ((list-number))
<$action-sendmessage
$message="tm-edit-text-operation"
$param="prefix-lines"
character="1."
count="1"
/>

View File

@@ -0,0 +1,17 @@
title: $:/plugins/tiddlywiki/markdown-legacy/EditorToolbar/mono-block
list-after: $:/core/ui/EditorToolbar/mono-block
tags: $:/tags/EditorToolbar
icon: $:/core/images/mono-block
caption: {{$:/language/Buttons/MonoBlock/Caption}} (Markdown)
description: {{$:/language/Buttons/MonoBlock/Hint}}
condition: [<targetTiddler>type[text/x-markdown]] [<targetTiddler>type[text/markdown]]
button-classes: tc-text-editor-toolbar-item-start-group
shortcuts: ((mono-block))
<$action-sendmessage
$message="tm-edit-text-operation"
$param="wrap-lines"
prefix="
```"
suffix="```"
/>

View File

@@ -0,0 +1,15 @@
title: $:/plugins/tiddlywiki/markdown-legacy/EditorToolbar/mono-line
list-after: $:/core/ui/EditorToolbar/mono-line
tags: $:/tags/EditorToolbar
icon: $:/core/images/mono-line
caption: {{$:/language/Buttons/MonoLine/Caption}} (Markdown)
description: {{$:/language/Buttons/MonoLine/Hint}}
condition: [<targetTiddler>type[text/x-markdown]] [<targetTiddler>type[text/markdown]]
shortcuts: ((mono-line))
<$action-sendmessage
$message="tm-edit-text-operation"
$param="wrap-selection"
prefix="`"
suffix="`"
/>

View File

@@ -0,0 +1,15 @@
title: $:/plugins/tiddlywiki/markdown-legacy/EditorToolbar/quote
list-after: $:/core/ui/EditorToolbar/quote
tags: $:/tags/EditorToolbar
icon: $:/core/images/quote
caption: {{$:/language/Buttons/Quote/Caption}} (Markdown)
description: {{$:/language/Buttons/Quote/Hint}}
condition: [<targetTiddler>type[text/x-markdown]] [<targetTiddler>type[text/markdown]]
shortcuts: ((quote))
<$action-sendmessage
$message="tm-edit-text-operation"
$param="prefix-lines"
character=">"
count="1"
/>