-
Notifications
You must be signed in to change notification settings - Fork 0
/
round2.py
141 lines (120 loc) · 3.96 KB
/
round2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
import os
# File Paths
input_questions = 'questions.txt'
input_answers = 'answers.txt'
output_file = 'main1.html'
# The main html stuff
html_content = """
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>Enquesta-Round 1-Pounce and Bounce</title>
<link rel="stylesheet" href="dist/reset.css">
<link rel="stylesheet" href="dist/reveal.css">
<link rel="stylesheet" href="dist/theme/black.css">
<!-- Theme used for syntax highlighted code -->
<link rel="stylesheet" href="plugin/highlight/monokai.css">
<style>
.image-container {
display: flex;
justify-content: center;
align-items: center;
width: 100%;
height: 100%;
overflow: hidden;
}
.image-container img {
max-width: 100%;
max-height: 100%;
object-fit: contain;
box-sizing: border-box;
}
</style>
</head>
<body>
<div class="reveal">
<div class="slides">
"""
#Reading Questions
z1 = -1
questions = ["" for _ in range(18)]
with open(input_questions, 'r') as file:
lines1 = file.readlines()
for i in range(len(lines1)):
if (lines1[i].startswith('-')):
z1 += 1
questions[z1] += lines1[i]
#Reading Answers
z2 = -1
answers = ["" for _ in range(18)]
with open(input_answers, 'r') as file:
lines2 = file.readlines()
for i in range(len(lines2)):
if (lines2[i].startswith('-')):
z2 += 1
answers[z2] += lines2[i]
#Reading images
questions_with_images = -1
images = []
n_images = []
for i in range(0, len(questions)-1):
if questions[i][len(questions[i]) - 3] == '#':
questions_with_images += 1
images.append(i)
n_images.append(int(questions[i][len(questions[i]) - 2]))
print(images)
print(n_images)
#Adding Questions, Answers, Images
for i in range(len(questions)):
html_content += '<section>'
html_content += '<section><h4>Question ' +str(i+1)+'</h4><p class="r-fit-text">'+questions[i]+'<p></section>\n'
if i in images:
html_content += '<section data-background="images/image'+str(i)+'-0.png" data-background-size="contain">\n'
html_content += '</section>\n'
html_content += '<section data-background="memes/meme0.png"></section\n>'
html_content += '<section>' + answers[i] + '</section>\n'
html_content += '</section>\n'
# Closing html tags
html_content += """
</div>
</div>
<script src="dist/reveal.js"></script>
<script src="plugin/notes/notes.js"></script>
<script src="plugin/markdown/markdown.js"></script>
<script src="plugin/highlight/highlight.js"></script>
<script>
// More info about initialization & config:
// - https://revealjs.com/initialization/
// - https://revealjs.com/config/
Reveal.initialize({
hash: true,
// Learn about plugins: https://revealjs.com/plugins/
plugins: [ RevealMarkdown, RevealHighlight, RevealNotes ]
});
document.addEventListener('DOMContentLoaded', () => {
function updateImageSize() {
const imageContainer = document.querySelector('.image-container');
const image = imageContainer.querySelector('img');
const containerWidth = imageContainer.offsetWidth;
const containerHeight = imageContainer.offsetHeight;
// Ensure image fits within the container
if (image.naturalWidth > containerWidth || image.naturalHeight > containerHeight) {
image.style.maxWidth = `${containerWidth}px`;
image.style.maxHeight = `${containerHeight}px`;
} else {
image.style.maxWidth = '100%';
image.style.maxHeight = '100%';
}
}
updateImageSize();
window.addEventListener('resize', updateImageSize);
});
</script>
</body>
</html>
"""
# Adding html content to file
with open(output_file, 'w') as file:
file.write(html_content)