all repos — hastyscribe @ 669a56eb5d1018a4e3c224312e6676e6dc249439

A professional markdown compiler.

Fixed compile errors with Nim 1.4.0.
h3rald h3rald@h3rald.com
Sun, 25 Oct 2020 16:58:25 +0100
commit

669a56eb5d1018a4e3c224312e6676e6dc249439

parent

892c1bfdf5131a624e93ea847a05a1e8d67e52e8

4 files changed, 9 insertions(+), 26 deletions(-)

jump to
M hastyscribe.nimblehastyscribe.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.nimsrc/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.nimsrc/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.nimsrc/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: