script Test
div Container
pre Script
module ShowdownModule
variable Markup
a Link
load plugin `showdown`
attach Container to `ec-container`
put `# Hello, Markdown!` cat newline
cat `This is a test of ~mono:{embedded}~ markup styles` cat newline
cat `including ~link:hyperlinks~ and ~darkred:styles~` cat newline
cat `This is a link to ~link:something else~`
into Markup
attach Script to `ec-showdown`
run the content of Script with Container and Markup and Link as ShowdownModule
trigger ShowdownModule
stop
script Showdown
import div Container and variable Markup and a Link
callback DecoratorCallback
variable Payload
variable P
variable Function
variable Data
variable LinkCount
variable Index
load showdown
on trigger
begin
put 0 into LinkCount
set the content of Container to showdown decode Markup with DecoratorCallback
set the elements of Link to LinkCount
put 0 into Index
while Index is less than LinkCount
begin
index Link to Index
attach Link to `ec-link-` cat Index
add 1 to Index
end
on click Link alert the content of Link
end
on DecoratorCallback go to Decorate
set ready
stop
Decorate:
put the payload of DecoratorCallback into Payload
put the position of `:` in Payload into P
put left P of Payload into Function
add 1 to P
put from P of Payload into Data
put `` into Payload
set property `content` of Payload to Data
if Function is `mono`
begin
set property `type` of Payload to `span`
set property `styles` of Payload to `color:#800;font-family:mono`
end
else if Function is `link`
begin
set property `type` of Payload to `link`
set property `id` of Payload to `ec-link-` cat LinkCount
add 1 to LinkCount
end
else if Function is `darkred`
begin
set property `type` of Payload to `span`
set property `styles` of Payload to `color:#800`
end
set the payload of DecoratorCallback to Payload
stop