Fixed compile errors with Nim 1.4.0.
h3rald h3rald@h3rald.com
Sun, 25 Oct 2020 16:58:25 +0100
4 files changed,
9 insertions(+),
26 deletions(-)
M
hastyscribe.nimble
→
hastyscribe.nimble
@@ -20,7 +20,7 @@ bin = @["hastyscribe"]
srcDir = "src" installExt = @["nim", "json", "a", "css", "png", "svg", "woff", "c", "h", "in"] -requires "nim >= 0.19.0" +requires "nim >= 1.4.0" before install: exec "nifty install"
M
src/hastyscribe.nim
→
src/hastyscribe.nim
@@ -429,8 +429,10 @@ # Date parsing and validation
var timeinfo: DateTime = local(getTime()) - if parse_date(metadata.date, timeinfo) == false: - discard parse_date(getDateStr(), timeinfo) + try: + timeinfo = parse(metadata.date, "yyyy-MM-dd") + except: + timeinfo = parse(getDateStr(), "yyyy-MM-dd") hs.document = """<!doctype html> <html lang="en">@@ -490,7 +492,7 @@
when isMainModule: let usage = " HastyScribe v" & pkgVersion & " - Self-contained Markdown Compiler" & """ - (c) 2013-2018 Fabio Cevasco + (c) 2013-2020 Fabio Cevasco Usage: hastyscribe <markdown_file_or_glob> [options]
M
src/hastyscribepkg/config.nim
→
src/hastyscribepkg/config.nim
@@ -1,4 +1,4 @@
const - pkgVersion* = "1.12.1" + pkgVersion* = "1.12.2" pkgAuthor* = "Fabio Cevasco" pkgDescription* = "Self-contained markdown compiler generating self-contained HTML documents"
M
src/hastyscribepkg/utils.nim
→
src/hastyscribepkg/utils.nim
@@ -2,30 +2,11 @@ import
base64, os, strutils, - sequtils, - pegs, - times + pegs import consts -proc parse_date*(date: string, timeinfo: var DateTime): bool = - var parts = date.split('-').map(proc(i:string): int = - try: - i.parseInt - except: - 0 - ) - if parts.len < 3: - return false - try: - timeinfo = DateTime(year: parts[0], month: Month(parts[1]), monthday: parts[2]) - # Fix invalid dates (e.g. Feb 31st -> Mar 3rd) - timeinfo = local(timeinfo.toTime); - return true - except: - return false - proc style_tag*(css: string): string = result = "<style>$1</style>" % [css]@@ -34,7 +15,7 @@ let enc_contents = contents.encode
return "data:image/$format;base64,$enc_contents" % ["format", format, "enc_contents", enc_contents] proc encode_image_file*(file, format: string): string = - if (file.existsFile): + if (file.fileExists): let contents = file.readFile return encode_image(contents, format) else: