Skip to content

Commit

Permalink
Merge pull request #10 from mbStavola/new-look
Browse files Browse the repository at this point in the history
Refactor to be more scope oriented
  • Loading branch information
mbStavola authored Nov 17, 2020
2 parents 45a705f + 15bfd8f commit db70eed
Show file tree
Hide file tree
Showing 9 changed files with 742 additions and 512 deletions.
14 changes: 11 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
slydes

# Created by https://www.toptal.com/developers/gitignore/api/go,intellij+all
# Edit at https://www.toptal.com/developers/gitignore?templates=go,intellij+all
# Created by https://www.toptal.com/developers/gitignore/api/go,intellij+all,vscode
# Edit at https://www.toptal.com/developers/gitignore?templates=go,intellij+all,vscode

### Go ###
# Binaries for programs and plugins
Expand Down Expand Up @@ -113,4 +113,12 @@ modules.xml
# Sonarlint plugin
.idea/sonarlint

# End of https://www.toptal.com/developers/gitignore/api/go,intellij+all
### vscode ###
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace

# End of https://www.toptal.com/developers/gitignore/api/go,intellij+all,vscode
139 changes: 81 additions & 58 deletions SLY.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,35 +32,10 @@ let variable1 = "hello";
let variable2 = variable1;
```

Variables are global and are not scoped to slides or blocks.
Variables are scoped to the slides or blocks that defined them and you may refer to variables from the enclosing scope(s).

Variables may be shadowed by redeclaring them.

## Attribute Declaration

Sly allows you to control specific characteristics of the current slide using an attribute declaration.

```
@attributeName = "value";
```

As you can see, the syntax is very similar to variable declaration, but preceded with an @ symbol.

There is also a fixed set of attributes which you can define. They are as follows:

- backgroundColor
- the background color of the slide. Can be either the name of a color (ex: "black") or a color literal.
- font
- the font of a text block. Must be a string value.
- fontColor
- the font color of a text block. Can be either the name of a color (ex: "black") or a color literal.
- fontSize
- the font size of a text block. Must be an integer value.
- justify
- the justification for a text block. Accepted values are "left", "center", or "right".

Slide level attributes will be inherited by following slides. Block level attributes will be inherited by later blocks, but are reset between slides.

## Data Types

Sly supports some very (very) basic data types.
Expand All @@ -84,74 +59,122 @@ In the future we may support these types as well:
- booleans
- multiline strings

## Text
## Slide Scopes

The Text declaration is what you use to actually write the content for your slides.
These signify the start of a new slide.

```
---This is my first line of text---
---
This is my
Second line of text
---
slide exampleSlide {
let foo = "red";
self.backgroundColor = foo;
block title {
---Hello!---
}
}
```

This can be multi-line or single-line, up to you!
You may define variables and blocks.

## Slide Scopes
Sly allows you to control specific characteristics of the current slide using an attribute declaration. Currently, slides support the following attributes:

- backgroundColor
- the background color of the slide. Can be either the name of a color (ex: "black") or a color literal.

These signify the start of a new slide. A title slide is assumed, so you only need to use this from your second slide onwards.
Sly also supports a limited form of inheritance for slides, where the child slide will copy all the attributes defined on the parent slide.

```
[Name of my slide]
slide foo {
self.backgroundColor = "red";
}
---Hello!---
slide bar : foo {
# The background color of this slide will start off as red
}
```

The text between the square brackets is not currently used by Slydes; scope title text is purely for organizational purposes.
A slide scope must be defined at the top level.

## Block Scopes

This represents a unique, styled section of text.

```
[Starting Slide]
block foo {
---Boo!---
}
```

The block must end with *exactly* one text declaration.

The text declaration can be multi-line or single-line, up to you!

```
block foo {
---
This is my
Second line of text
---
}
```

Blocks also have attributes. The following attributes are currently supported:

- font
- the font of a text block. Must be a string value.
- fontColor
- the font color of a text block. Can be either the name of a color (ex: "black") or a color literal.
- fontSize
- the font size of a text block. Must be an integer value.
- justify
- the justification for a text block. Accepted values are "left", "center", or "right".

Like slide scopes, you can use inheritance to copy styles between blocks in the same scope.

```
block foo {
self.font = "Fira Code";
self.fontColor = "red";
---Hello!---
}
block bar : foo {
self.fontColor = "blue";
[[My Text]]
---
Boo!
---
---Boo!---
}
```

Like slide scopes, the title text not used in processing.
A block scope must be defined within a slide scope.

## Macros

To cut down on repetition, Sly provides macro functionality.

```
green = (0, 255, 0);
let green = (0, 255, 0);
$themeMacro = {
foo = "hello";
@font = "Fira Code";
macro themeMacro {
let foo = "hello";
self.font = "Fira Code";
# Can refer to outside variables
@fontColor = green;
self.fontColor = green;
# Variables only need to be instantiated
# by the time the macro is called, not when
# it is defined
@fontSize = defaultFontSize;
};
self.fontSize = defaultFontSize;
}
[Example Section]
defaultFontSize = 14;
slide example {
let defaultFontSize = 14;
# Will expand to the statement block originally
# defined in the macro
$themeMacro()
# Will expand to the statement block originally
# defined in the macro
$themeMacro();
}
```

Macros are very basic in Sly. When called they simply expand to the statement block originally provided.
Expand Down
148 changes: 75 additions & 73 deletions examples/basic.sly
Original file line number Diff line number Diff line change
Expand Up @@ -13,64 +13,61 @@ let coolGray = (26, 83, 92);
mut paleGreen = (247, 255, 247);
let tealBlue = (78, 205, 196);

# Set the default styles for the rest
# of the presentation
@backgroundColor = coolGray;

$titleStyle = {
@font = "Fira Code";
@fontSize = 42;
@fontColor = tealBlue;
@justify = "center";
};

$contentStyle = {
@justify = "left";
@font = "Times New Roman";
@fontSize = 32;
@fontColor = paleGreen;
};

$titleStyle();

---
Welcome!

This is an example of Slydes
---

[First Slide]
$titleStyle();

---
These are my thoughts
---

[[Body - Point 1]]
$contentStyle();

---
- This is my first point
---

[[Body - Point 2]]

---
- This is my second point
---

[Second Slide]
$titleStyle();

---
How about this?
---

[[Body 1]]
@justify = "right";
@font = "Times New Roman";
@fontSize = 38;
@fontColor = paleGreen;
macro titleStyle() {
self.font = "Fira Code";
self.fontSize = 42;
self.fontColor = tealBlue;
self.justify = "center";
}

macro contentStyle() {
self.justify = "left";
self.font = "Times New Roman";
self.fontSize = 32;
self.fontColor = paleGreen;
}

slide intro {
self.backgroundColor = coolGray;

block title {
$titleStyle();

---
Welcome!

This is an example of Slydes
---
}
}

slide firstSlide : intro {
block title {
$titleStyle();
---These are my thoughts---
}

block pointOne {
$contentStyle();
--- - This is my first point ---
}

block pointTwo : pointOne {
--- - This is my second point ---
}
}

slide secondSlide : intro {
block title {
$titleStyle();
---How about this?---
}

block body1 {
$contentStyle();

self.justify = "right";
self.fontSize = 38;

---

Expand All @@ -79,23 +76,28 @@ How about this?


I'm boldly making my point---

[[Body 2]]
@justify = "center";

---With some style---

[[Body 3]]
@justify = "left";

---What do you think?---

[Conclusion]
$titleStyle();

}

block body2 : body1 {
self.fontColor = "red";
self.justify = "center";
---With some style---
}

block body3 : body2 {
self.justify = "left";
---What do you think?---
}
}

slide conclusion : intro {
block title {
$titleStyle();
---



We're through
---
---
}
}
3 changes: 0 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,9 @@ func main() {

switch *output {
case "noop":
break
case "html":
if err := html.Render(show); err != nil {
fmt.Print(err)
}

break
}
}
Loading

0 comments on commit db70eed

Please sign in to comment.