Skip to content

Commit d2ddec4

Browse files
committedNov 11, 2019
Adds initial files.
0 parents  commit d2ddec4

16 files changed

+3757
-0
lines changed
 

‎.gitignore

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
*stack-work*
2+
*cabal*sandbox*
3+
*dist*
4+
*tmp*
5+
*blend1
6+
*blend2
7+
*blend3
8+
*blend4
9+
*blend5

‎LICENSE

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
BSD 3-Clause License
2+
3+
Copyright (c) 2019, David Lettier
4+
All rights reserved.
5+
6+
Redistribution and use in source and binary forms, with or without
7+
modification, are permitted provided that the following conditions are met:
8+
9+
* Redistributions of source code must retain the above copyright notice, this
10+
list of conditions and the following disclaimer.
11+
12+
* Redistributions in binary form must reproduce the above copyright notice,
13+
this list of conditions and the following disclaimer in the documentation
14+
and/or other materials provided with the distribution.
15+
16+
* Neither the name of the copyright holder nor the names of its
17+
contributors may be used to endorse or promote products derived from
18+
this software without specific prior written permission.
19+
20+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

‎README.md

+1,577
Large diffs are not rendered by default.

‎Setup.hs

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import Distribution.Simple
2+
main = defaultMain

‎docs/_build-docs.sh

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env bash
2+
3+
SCRIPT_PATH="$(cd "$(dirname "$0")"; pwd -P)"
4+
MAIN_TITLE="Parsing With Haskell Parser Combinators"
5+
DESCRIPTION="Need to parse something? Never heard of a parser combinator? \
6+
Looking to learn some Haskell? \
7+
Awesome! This is everything you'll need to get up and parsing with Haskell parser combinators. \
8+
From here you can try tackling esoteric data serialization formats, compiler front ends, domain specific languages—you name it!"
9+
REPO_URL="https://github.com/lettier/parsing-with-haskell-parser-combinators"
10+
AUTHOR="David Lettier"
11+
CSS="style.css"
12+
13+
$PANDOC \
14+
-f gfm \
15+
-t html5 \
16+
--highlight-style=breezedark \
17+
--template=$SCRIPT_PATH/_template.html5 \
18+
$SCRIPT_PATH/../README.md \
19+
--metadata pagetitle="$MAIN_TITLE" \
20+
--metadata author-meta="$AUTHOR" \
21+
--metadata description="$DESCRIPTION" \
22+
--metadata css=$CSS \
23+
-o "$SCRIPT_PATH/index.html"

‎docs/_template.html5

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<!DOCTYPE html>
2+
<html xmlns="http://www.w3.org/1999/xhtml" lang="$lang$" xml:lang="$lang$"$if(dir)$ dir="$dir$"$endif$>
3+
<head>
4+
<meta charset="utf-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
6+
<meta name="description" content="$description$" />
7+
<meta property="og:title" content="$if(title-prefix)$$title-prefix$ – $endif$$pagetitle$" />
8+
<meta property="og:description" content="$description$" />
9+
<meta property="og:image" content="https://i.imgur.com/kw2kYzf.jpg" />
10+
<meta name="twitter:title" content="$if(title-prefix)$$title-prefix$ – $endif$$pagetitle$" />
11+
<meta name="twitter:description" content="$description$" />
12+
<meta name="twitter:image" content="https://i.imgur.com/kw2kYzf.jpg" />
13+
<meta name="twitter:card" content="summary_large_image" />
14+
$for(author-meta)$
15+
<meta name="author" content="$author-meta$" />
16+
$endfor$
17+
$if(date-meta)$
18+
<meta name="dcterms.date" content="$date-meta$" />
19+
$endif$
20+
$if(keywords)$
21+
<meta name="keywords" content="$for(keywords)$$keywords$$sep$, $endfor$" />
22+
$endif$
23+
<title>$if(title-prefix)$$title-prefix$ – $endif$$pagetitle$</title>
24+
<style>
25+
code{white-space: pre-wrap;}
26+
span.smallcaps{font-variant: small-caps;}
27+
span.underline{text-decoration: underline;}
28+
div.column{display: inline-block; vertical-align: top; width: 50%;}
29+
$if(quotes)$
30+
q { quotes: "“" "”" "‘" "’"; }
31+
$endif$
32+
</style>
33+
$if(highlighting-css)$
34+
<style>
35+
$highlighting-css$
36+
</style>
37+
$endif$
38+
$if(math)$
39+
$math$
40+
$endif$
41+
<!--[if lt IE 9]>
42+
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
43+
<![endif]-->
44+
$for(header-includes)$
45+
$header-includes$
46+
$endfor$
47+
$for(css)$
48+
<link rel="stylesheet" href="$css$" />
49+
$endfor$
50+
</head>
51+
<body>
52+
$for(include-before)$
53+
$include-before$
54+
$endfor$
55+
$if(title)$
56+
<header id="title-block-header">
57+
<h1 class="title">$title$</h1>
58+
$if(subtitle)$
59+
<p class="subtitle">$subtitle$</p>
60+
$endif$
61+
$for(author)$
62+
<p class="author">$author$</p>
63+
$endfor$
64+
$if(date)$
65+
<p class="date">$date$</p>
66+
$endif$
67+
</header>
68+
$endif$
69+
$if(toc)$
70+
<nav id="$idprefix$TOC" role="doc-toc">
71+
$table-of-contents$
72+
</nav>
73+
$endif$
74+
$body$
75+
$for(include-after)$
76+
$include-after$
77+
$endfor$
78+
</body>
79+
</html>

‎docs/index.html

+1,064
Large diffs are not rendered by default.

‎docs/style.css

+332
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,332 @@
1+
html {
2+
font-size: 100%;
3+
overflow-y: scroll;
4+
-webkit-text-size-adjust: 100%;
5+
-ms-text-size-adjust: 100%;
6+
}
7+
8+
body {
9+
color: #444;
10+
font-family: Helvetica, Arial, sans-serif;
11+
font-size: 20px;
12+
line-height: 2;
13+
padding: 1em;
14+
margin: auto;
15+
max-width: 887px;
16+
background: #fefefe;
17+
}
18+
19+
a {
20+
color: #059;
21+
text-decoration: none;
22+
}
23+
24+
a:visited {
25+
color: #048;
26+
}
27+
28+
a:hover {
29+
color: #06a;
30+
}
31+
32+
a:active {
33+
color: #06a;
34+
}
35+
36+
a:focus {
37+
outline: thin dotted;
38+
}
39+
40+
*::-moz-selection {
41+
background: rgba(0, 200, 255, 0.3);
42+
color: #111;
43+
}
44+
45+
*::selection {
46+
background: rgba(0, 200, 255, 0.3);
47+
color: #111;
48+
}
49+
50+
a::-moz-selection {
51+
background: rgba(0, 200, 255, 0.3);
52+
color: #048;
53+
}
54+
55+
a::selection {
56+
background: rgba(0, 200, 255, 0.3);
57+
color: #048;
58+
}
59+
60+
a > span.emoji {
61+
font-size: 30px;
62+
margin-left: 5px;
63+
}
64+
65+
p {
66+
margin: 1em 0;
67+
}
68+
69+
img {
70+
max-width: 100%;
71+
}
72+
73+
h1, h2, h3, h4, h5, h6 {
74+
color: #111;
75+
line-height: 125%;
76+
margin-top: 1em;
77+
font-weight: lighter;
78+
font-family: 'Roboto Condensed', Helvetica, Arial, sans-serif;
79+
}
80+
81+
h4, h5, h6 {
82+
font-weight: bold;
83+
}
84+
85+
h1 {
86+
font-size: 2.5em;
87+
}
88+
89+
h2 {
90+
font-size: 2em;
91+
}
92+
93+
h3 {
94+
font-size: 1.5em;
95+
}
96+
97+
h4 {
98+
font-size: 1.2em;
99+
}
100+
101+
h5 {
102+
font-size: 1em;
103+
}
104+
105+
h6 {
106+
font-size: 0.9em;
107+
}
108+
109+
blockquote {
110+
color: #666666;
111+
margin: 0;
112+
padding-left: 3em;
113+
border-left: 0.5em #EEE solid;
114+
}
115+
116+
hr {
117+
display: block;
118+
height: 2px;
119+
border: 0;
120+
border-top: 1px solid #aaa;
121+
border-bottom: 1px solid #eee;
122+
margin: 1em 0;
123+
padding: 0;
124+
}
125+
126+
pre, code, kbd, samp {
127+
font-family: monospace;
128+
font-size: 14px;
129+
}
130+
131+
pre {
132+
white-space: pre;
133+
white-space: pre-wrap;
134+
word-wrap: break-word;
135+
padding: 15px;
136+
}
137+
138+
b, strong {
139+
font-weight: bold;
140+
}
141+
142+
p > code {
143+
font-weight: bold;
144+
}
145+
146+
dfn {
147+
font-style: italic;
148+
}
149+
150+
ins {
151+
background: #ff9;
152+
color: #000;
153+
text-decoration: none;
154+
}
155+
156+
mark {
157+
background: #ff0;
158+
color: #000;
159+
font-style: italic;
160+
font-weight: bold;
161+
}
162+
163+
sub, sup {
164+
font-size: 75%;
165+
line-height: 0;
166+
position: relative;
167+
vertical-align: baseline;
168+
}
169+
170+
sup {
171+
top: -0.5em;
172+
}
173+
174+
sub {
175+
bottom: -0.25em;
176+
}
177+
178+
ul, ol {
179+
margin: 1em 0;
180+
padding: 0 0 0 2em;
181+
}
182+
183+
li p:last-child {
184+
margin-bottom: 0;
185+
}
186+
187+
ul ul, ol ol {
188+
margin: .3em 0;
189+
}
190+
191+
dl {
192+
margin-bottom: 1em;
193+
}
194+
195+
dt {
196+
font-weight: bold;
197+
margin-bottom: .8em;
198+
}
199+
200+
dd {
201+
margin: 0 0 .8em 2em;
202+
}
203+
204+
dd:last-child {
205+
margin-bottom: 0;
206+
}
207+
208+
img {
209+
border: 0;
210+
-ms-interpolation-mode: bicubic;
211+
vertical-align: middle;
212+
}
213+
214+
figure {
215+
display: block;
216+
text-align: center;
217+
margin: 1em 0;
218+
}
219+
220+
figure img {
221+
border: none;
222+
margin: 0 auto;
223+
}
224+
225+
figcaption {
226+
font-size: 0.8em;
227+
font-style: italic;
228+
margin: 0 0 .8em;
229+
}
230+
231+
table {
232+
margin-bottom: 2em;
233+
border-bottom: 1px solid #ddd;
234+
border-right: 1px solid #ddd;
235+
border-spacing: 0;
236+
border-collapse: collapse;
237+
}
238+
239+
table th {
240+
padding: .2em 1em;
241+
background-color: #eee;
242+
border-top: 1px solid #ddd;
243+
border-left: 1px solid #ddd;
244+
}
245+
246+
table td {
247+
padding: .2em 1em;
248+
border-top: 1px solid #ddd;
249+
border-left: 1px solid #ddd;
250+
vertical-align: top;
251+
}
252+
253+
kbd {
254+
border: 1px solid #999;
255+
padding: 5px;
256+
border-radius: 2px;
257+
background-color: #555;
258+
color: #eee;
259+
white-space: nowrap;
260+
}
261+
262+
.author {
263+
font-size: 1.2em;
264+
text-align: center;
265+
}
266+
267+
@media print {
268+
* {
269+
background: transparent !important;
270+
color: black !important;
271+
filter: none !important;
272+
-ms-filter: none !important;
273+
}
274+
275+
body {
276+
font-size: 12pt;
277+
max-width: 100%;
278+
}
279+
280+
a, a:visited {
281+
text-decoration: underline;
282+
}
283+
284+
hr {
285+
height: 1px;
286+
border: 0;
287+
border-bottom: 1px solid black;
288+
}
289+
290+
a[href]:after {
291+
content: " (" attr(href) ")";
292+
}
293+
294+
abbr[title]:after {
295+
content: " (" attr(title) ")";
296+
}
297+
298+
.ir a:after, a[href^="javascript:"]:after, a[href^="#"]:after {
299+
content: "";
300+
}
301+
302+
pre, blockquote {
303+
border: 1px solid #999;
304+
padding-right: 1em;
305+
page-break-inside: avoid;
306+
}
307+
308+
tr, img {
309+
page-break-inside: avoid;
310+
}
311+
312+
img {
313+
max-width: 100% !important;
314+
}
315+
316+
@page :left {
317+
margin: 15mm 20mm 15mm 10mm;
318+
}
319+
320+
@page :right {
321+
margin: 15mm 10mm 15mm 20mm;
322+
}
323+
324+
p, h2, h3 {
325+
orphans: 3;
326+
widows: 3;
327+
}
328+
329+
h2, h3 {
330+
page-break-after: avoid;
331+
}
332+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: parsing-with-haskell-parser-combinators
2+
version: 0.0.0.0
3+
homepage: https://github.com/lettier/parsing-with-haskell-parser-combinators
4+
author: David Lettier
5+
copyright: 2019 David Lettier
6+
license: BSD3
7+
build-type: Simple
8+
cabal-version: >= 1.10
9+
extra-source-files: README.md
10+
11+
source-repository head
12+
type: git
13+
location: https://github.com/lettier/parsing-with-haskell-parser-combinators
14+
15+
executable version-number-parser
16+
main-is: src/version-number-parser.hs
17+
build-depends:
18+
base >=4.7 && <5
19+
ghc-options: -threaded -rtsopts -with-rtsopts=-N
20+
default-language: Haskell2010
21+
22+
executable srt-file-parser
23+
main-is: src/srt-file-parser.hs
24+
build-depends:
25+
base >=4.7 && <5
26+
ghc-options: -threaded -rtsopts -with-rtsopts=-N
27+
default-language: Haskell2010

‎src/srt-file-parser.hs

+476
Large diffs are not rendered by default.

‎src/version-number-parser.hs

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
{-
2+
Version Number Parser
3+
(C) 2019 David Lettier
4+
lettier.com
5+
-}
6+
7+
import Control.Monad
8+
import Text.ParserCombinators.ReadP
9+
import Data.Char
10+
import Data.Maybe
11+
12+
main
13+
:: IO ()
14+
main
15+
= do
16+
putStrLn "What is the version output file path?"
17+
filePath <- getLine
18+
text <- readFile filePath
19+
let result =
20+
case readP_to_S (parseVersionNumber []) text of
21+
[] -> []
22+
r@(_:_) -> map readInt $ fst $ last r
23+
putStrLn ""
24+
print result
25+
26+
parseVersionNumber
27+
:: [String]
28+
-> ReadP [String]
29+
parseVersionNumber
30+
nums
31+
= do
32+
_ <- parseNotNumber
33+
num <- parseNumber
34+
let nums' = nums ++ [num]
35+
parseSeparator nums' parseVersionNumber
36+
37+
parseSeparator
38+
:: [String]
39+
-> ([String] -> ReadP [String])
40+
-> ReadP [String]
41+
parseSeparator
42+
nums
43+
f
44+
= do
45+
next <- look
46+
case next of
47+
"" -> return nums
48+
(c:_) ->
49+
case c of
50+
'.' -> f nums
51+
'-' -> if length nums == 1 then f [] else f nums
52+
_ -> if length nums == 1 then f [] else return nums
53+
54+
parseNotNumber
55+
:: ReadP String
56+
parseNotNumber
57+
=
58+
munch (not . isNumber)
59+
60+
parseNumber
61+
:: ReadP String
62+
parseNumber
63+
=
64+
munch1 isNumber
65+
66+
readInt
67+
:: String
68+
-> Int
69+
readInt
70+
=
71+
read

‎stack.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
resolver: lts-13.27
2+
packages:
3+
- .

‎stack.yaml.lock

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# This file was autogenerated by Stack.
2+
# You should not edit this file by hand.
3+
# For more information, please see the documentation at:
4+
# https://docs.haskellstack.org/en/stable/lock_files
5+
6+
packages: []
7+
snapshots:
8+
- completed:
9+
size: 500539
10+
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/13/27.yaml
11+
sha256: 690db832392afe55733b4c7023fd29b1b1c660ee42f1fb505b86b07394ca994e
12+
original: lts-13.27
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
         ▄▄▄▄▄▄▄▄                                                                             
3+
    ▄▄████   ▀▀███▄                                                                         
4+
      ████▀   ▄    ▀███           ▄    ▐██▌   ▄███▄                                          
5+
  ▄   ▐███   ████   ▀███      ▄███▀▀██       ███                                             
6+
 ▐█▌   ██   ▐███     ████    ███        ▐██ █████▌ ▄█████ ▐██▌  ██▌  ██▄██▌ ██▄██▌ ██▌   ███ 
7+
 ███   ▐▌   ███      ▐███▌   ███  ████▌ ▐██   ██▌  ███     ▐██▌  ██▌  ███▀   ███▀   ▐██  ███  
8+
 ████      ███▀  ▐█   ███▌   ███    ██▌ ▐██   ██▌  ███     ▐██▌  ██▌  ██▌    ██▌     ██▌▐██   
9+
 ▐███▄    ▐██▌   ██    ██     ███▄▄▄██▌ ▐██   ██▌   ███▄▄█ ███▄███▌  ██▌    ██▌      ████▌   
10+
  ▀███   ▀███   ▐███   ▀        ▀▀▀▀▀    ▀▀   ▀▀      ▀▀▀    ▀▀▀   ▀▀     ▀▀        ███    
11+
    ███▄   ▀    ████▌                                                                ███▀     
12+
      ▀███▄▄   █████▀                                                                         
13+
          ▀▀▀▀▀▀▀                                                                             
14+
15+
16+
Gifcurry 6.0.0.0
17+
(C) 2016 David Lettier
18+
https://lettier.com
19+
20+
Wanna help out Gifcurry? Star it on GitHub! ☺ Thanks for helping out—you rock!
21+
https://github.com/lettier/gifcurry/stargazers
22+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Version: ImageMagick 2018-10-24 6.9.10-14 Q16 x86_64 https://imagemagick.org
2+
Copyright: © 1999-2018 ImageMagick Studio LLC
3+
License: https://imagemagick.org/script/license.php
4+
Features: Cipher DPC HDRI Modules OpenCL OpenMP

‎test-input/subtitles.srt

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
2+
3+
4+
1
5+
01:00:12,000 --> 01:00:15,000
6+
This is a subtitle.
7+
8+
9+
10+
11+
2
12+
1:02:18,010 --> 01:05:10,010
13+
This is some subtitle
14+
text that spans multiple lines.
15+
It includes formatting
16+
like <b>bold</b>, <i>italic</i>,
17+
<u>underline</u>, < font color="#010101" color="#333" >
18+
font > color</font>, and << even <b><i><u>
19+
nested tags over multiple
20+
</u></i> lines</b><u>.
21+
22+
3
23+
03:23:11,010 --> 03:55:17.110 X1:123 X2:223 Y1:50 Y2:101
24+
This subtitle specifies a text box
25+
using X1, X2, Y1, and Y2.
26+
27+

0 commit comments

Comments
 (0)
Please sign in to comment.