Merging fixes in image 0.8.690 to integrate into new versions.
This commit is contained in:
parent
e8c73c7563
commit
fb433bfaef
@ -11,13 +11,13 @@ Class {
|
||||
'title',
|
||||
'text',
|
||||
'modified',
|
||||
'mofier',
|
||||
'created',
|
||||
'creator',
|
||||
'tags',
|
||||
'type',
|
||||
'list',
|
||||
'caption'
|
||||
'caption',
|
||||
'modifier'
|
||||
],
|
||||
#category : #'TiddlyWiki-Model'
|
||||
}
|
||||
@ -32,6 +32,11 @@ Tiddler >> asDictionary [
|
||||
yourself.
|
||||
]
|
||||
|
||||
{ #category : #converting }
|
||||
Tiddler >> asJson [
|
||||
^ STONJSON toStringPretty: self asDictionary
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
Tiddler >> caption [
|
||||
|
||||
@ -101,6 +106,20 @@ Tiddler >> list: anObject [
|
||||
list := anObject
|
||||
]
|
||||
|
||||
{ #category : #utilities }
|
||||
Tiddler >> markdownLinksAsWikiText [
|
||||
"I'm useful to convert _internal_ links between formats, as is a common pattern
|
||||
found when migrating content from Markdown to TiddlyWiki's WikiText.
|
||||
I DON'T work on external links. A better regex could be used for that.
|
||||
See:
|
||||
- https://davidwells.io/snippets/regex-match-markdown-links
|
||||
- http://blog.michaelperrin.fr/2019/02/04/advanced-regular-expressions/"
|
||||
| markdownLinks |
|
||||
markdownLinks := (self text splitOn: Character space) select: [:each | each matchesRegex: '\[(.+)\)'].
|
||||
markdownLinks ifEmpty: [^ self].
|
||||
^ markdownLinks
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
Tiddler >> modified [
|
||||
|
||||
@ -114,15 +133,22 @@ Tiddler >> modified: anObject [
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
Tiddler >> mofier [
|
||||
Tiddler >> modifier [
|
||||
|
||||
^ mofier
|
||||
^ modifier
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
Tiddler >> mofier: anObject [
|
||||
Tiddler >> modifier: anObject [
|
||||
|
||||
mofier := anObject
|
||||
modifier := anObject
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
Tiddler >> printOn: aStream [
|
||||
super printOn: aStream.
|
||||
aStream
|
||||
nextPutAll: '( ', self title, ' )'
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
|
45
repository/TiddlyWiki/WikiText.class.st
Normal file
45
repository/TiddlyWiki/WikiText.class.st
Normal file
@ -0,0 +1,45 @@
|
||||
Class {
|
||||
#name : #WikiText,
|
||||
#superclass : #Object,
|
||||
#instVars : [
|
||||
'content'
|
||||
],
|
||||
#category : #'TiddlyWiki-Model'
|
||||
}
|
||||
|
||||
{ #category : #accessing }
|
||||
WikiText >> content [
|
||||
^ content
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
WikiText >> content: aString [
|
||||
content := aString
|
||||
]
|
||||
|
||||
{ #category : #conversions }
|
||||
WikiText >> converMarkdownBold [
|
||||
self content: (self content copyReplaceAll: '**' with: '''''').
|
||||
]
|
||||
|
||||
{ #category : #conversions }
|
||||
WikiText >> convertMarkdownBold [
|
||||
self content: (self content copyReplaceAll: '**' with: '''''').
|
||||
^ self.
|
||||
]
|
||||
|
||||
{ #category : #conversions }
|
||||
WikiText >> convertMarkdownLinks [
|
||||
| markdownLinks markdownLinksRegex |
|
||||
markdownLinksRegex := '\[([\w|\s]+)\]\((\S+)\)'.
|
||||
"For the explanation of the Regex details see: http://scottradcliff.com/how-to-parse-urls-in-markdown.html"
|
||||
markdownLinks := self content regex: markdownLinksRegex matchesCollect: [:link | link ].
|
||||
markdownLinks ifEmpty: [ ^ self ].
|
||||
markdownLinks do: [:markdownLink | | linkText closingLinkIndex newContent |
|
||||
closingLinkIndex := markdownLink indexOf: $].
|
||||
linkText := markdownLink copyFrom: 2 to: closingLinkIndex.
|
||||
newContent := self content copyReplaceAll: markdownLink with: '[[', linkText, ']'.
|
||||
self content: newContent.
|
||||
].
|
||||
^ self
|
||||
]
|
Loading…
Reference in New Issue
Block a user