Skip to content

Commit

Permalink
introduced comments and script to generate a basic version of a beame…
Browse files Browse the repository at this point in the history
…r using a simple template in the class MicBeamer.

Added a sample for slides. 
Change the visit method to return the contents.
  • Loading branch information
Ducasse committed Apr 22, 2022
1 parent 7926974 commit 64d4fca
Show file tree
Hide file tree
Showing 3 changed files with 133 additions and 8 deletions.
123 changes: 115 additions & 8 deletions src/Microdown-BeamerExporter/MicBeamerWriter.class.st
Original file line number Diff line number Diff line change
@@ -1,25 +1,132 @@
"
I export mainly slides in Beamer LaTeX. Note that I do not generate the full beamer but the body of the slides. The beamer template can be for example the one of Pillar/presentation.
```
| doc dict aFileReference output|
doc := Microdown parse: MicMicrodownSnippetFactory new oneSlide.
dict := Dictionary new.
dict at: 'content' put: (MicBeamerWriter new visit: doc).
dict at: 'title' put: 'ZeCrazy slides'.
output := (MustacheTemplate
on: '/Users/ducasse/.pillar/build/archetypes/presentation/support/templates/beamer/presentation.template' asFileReference readStream contents)
value: dict.
aFileReference := FileSystem workingDirectory / 'MyCoolPresentation.tex'.
aFileReference ensureDelete.
aFileReference parent ensureCreateDirectory.
aFileReference writeStreamDo: [ :stream |
stream nextPutAll: output ]
```
```
| doc dict aFileReference output|
doc := Microdown parse: MicMicrodownSnippetFactory new oneSlide.
dict := Dictionary new.
dict at: 'content' put: (MicBeamerWriter new visit: doc).
dict at: 'title' put: 'ZeCrazy slides'.
output := (MustacheTemplate on: MicBeamerWriter basicTemplateForTest) value: dict.
aFileReference := FileSystem workingDirectory / 'MyCoolPresentation.tex'.
aFileReference ensureDelete.
aFileReference parent ensureCreateDirectory.
aFileReference writeStreamDo: [ :stream |
stream nextPutAll: output ]
```
### How to load mustache
```
Metacello new
baseline: 'Mustache';
repository: 'github://noha/mustache:v1.0/repository';
load
```
"
Class {
#name : #MicBeamerWriter,
#superclass : #MicLaTeXWriter,
#category : #'Microdown-BeamerExporter'
}

{ #category : #'as yet unclassified' }
{ #category : #'basic ressources' }
MicBeamerWriter class >> basicTemplateForTest [

^ '% -*- mode: latex; -*- mustache tags: {{=« »=}} «! the ''&'' below prevents HTML escaping. »
\documentclass{beamer}
\usepackage[frenchb]{babel}
\usepackage[T1]{fontenc}
\usepackage{pgfpages}
\usepackage{listings}
\usepackage{color}
\definecolor{codegreen}{rgb}{0,0.6,0}
\definecolor{codegray}{rgb}{0.5,0.5,0.5}
\definecolor{codepurple}{rgb}{0.58,0,0.82}
\definecolor{backcolour}{rgb}{0.95,0.95,0.92}
\lstdefinestyle{mystyle}{
backgroundcolor=\color{backcolour},
numberstyle=\tiny\color{codegreen},
breaklines=true,
captionpos=b,
tabsize=2,
basicstyle=\ttfamily\scriptsize
}
\lstset{style=mystyle}
\usetheme{Warsaw}
\setbeamercolor{structure}{fg=red!90!black}
\title{«& title»}
\subtitle{«& subtitle»}
\author{«& author»}
\institute{«& complement»}
\date{«& date»}
\addtobeamertemplate{navigation symbols}{}{%
\usebeamerfont{footline}%
\usebeamercolor[fg]{footline}%
\hspace{1em}%
\insertframenumber/\inserttotalframenumber
}
\setbeamercolor{footline}{fg=blue}
\setbeamerfont{footline}{series=\bfseries}
\setbeamertemplate{headline}{}
\begin{document}
\frame[plain]{\titlepage}
\frame[plain]{\tableofcontents}
«& content»
\end{document}'
]

{ #category : #helpers }
MicBeamerWriter >> createFrametitle: aTitle [
canvas command
name: 'frametitle';
parameter: aTitle
]

{ #category : #'as yet unclassified' }
{ #category : #helpers }
MicBeamerWriter >> createLinkToLabelWithAlias: anInternalLink [
canvas command
name: 'hyperlink';
parameter: [ canvas raw: anInternalLink anchor ];
parameter: [ canvas raw: anInternalLink alias ]
]

{ #category : #'as yet unclassified' }
{ #category : #helpers }
MicBeamerWriter >> sectionOptionFrom: level To: depth On: parameters [
parameters
add:
Expand All @@ -38,7 +145,7 @@ MicBeamerWriter >> sectionOptionFrom: level To: depth On: parameters [
ifFalse: [ 'subsubsectionstyle=hide/hide/hide' ])
]

{ #category : #'as yet unclassified' }
{ #category : #visiting }
MicBeamerWriter >> visitCode: aCodeBlock [
| env |
env := (aCodeBlock hasCaption and: [ aCodeBlock hasLabel ])
Expand Down Expand Up @@ -69,7 +176,7 @@ MicBeamerWriter >> visitCode: aCodeBlock [
env with: [ canvas nextPutAllLines: aCodeBlock body. canvas newLine ]
]

{ #category : #'as yet unclassified' }
{ #category : #visiting }
MicBeamerWriter >> visitColumn: aColumn [
canvas environment
name: 'column';
Expand All @@ -81,7 +188,7 @@ MicBeamerWriter >> visitColumn: aColumn [
canvas newLine
]

{ #category : #'as yet unclassified' }
{ #category : #visiting }
MicBeamerWriter >> visitColumns: aColumns [
canvas environment
name: 'columns';
Expand All @@ -90,14 +197,14 @@ MicBeamerWriter >> visitColumns: aColumns [
canvas newLine
]

{ #category : #'as yet unclassified' }
{ #category : #visiting }
MicBeamerWriter >> visitFigure: aFigure [
canvas environment
name: 'center';
with: [ self includeGraphicsFor: aFigure ]
]

{ #category : #'as yet unclassified' }
{ #category : #visiting }
MicBeamerWriter >> visitSlide: aSlide [
canvas newLine.
canvas environment
Expand Down
7 changes: 7 additions & 0 deletions src/Microdown-LaTeXExporter/MicDocumentWriter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ MicDocumentWriter >> usedNewLine [
^ canvas stream usedNewLine
]

{ #category : #writing }
MicDocumentWriter >> visit: aMicElement [

aMicElement accept: self.
^ self contents
]

{ #category : #writing }
MicDocumentWriter >> writeRawDuring: aBlock [
[
Expand Down
11 changes: 11 additions & 0 deletions src/Microdown-Tests/MicMicroDownSnippetFactory.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,17 @@ MicMicrodownSnippetFactory >> newlineSample [
^ Smalltalk os lineEnding
]

{ #category : #sample }
MicMicrodownSnippetFactory >> oneSlide [

^ '<!slide|title=This is a cool title&tag=nh5p
- a list of bullet
- bullet 2
- bullet 3
!>'
]

{ #category : #list }
MicMicrodownSnippetFactory >> orderedListEmptySample [
^ '
Expand Down

0 comments on commit 64d4fca

Please sign in to comment.