Better line match to avoid cutting off verses that contain line breaks.
This commit is contained in:
		@@ -1,6 +1,6 @@
 | 
				
			|||||||
# Package
 | 
					# Package
 | 
				
			||||||
 | 
					
 | 
				
			||||||
version       = "0.2.1"
 | 
					version       = "0.2.2"
 | 
				
			||||||
author        = "Jonathan Bernard"
 | 
					author        = "Jonathan Bernard"
 | 
				
			||||||
description   = "Simple Nim CLI wrapper around the ESV API (api.esv.org)"
 | 
					description   = "Simple Nim CLI wrapper around the ESV API (api.esv.org)"
 | 
				
			||||||
license       = "MIT"
 | 
					license       = "MIT"
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -7,15 +7,15 @@ import std/[httpclient, json, logging, os, re, strutils, uri, wordwrap]
 | 
				
			|||||||
import cliutils, docopt, zero_functional
 | 
					import cliutils, docopt, zero_functional
 | 
				
			||||||
 | 
					
 | 
				
			||||||
proc formatMarkdown(raw: string): string =
 | 
					proc formatMarkdown(raw: string): string =
 | 
				
			||||||
  let rawLines = raw.splitLines --> map(it.strip)
 | 
					  let rawLines = raw.splitLines
 | 
				
			||||||
  let wrapped = (rawLines -->
 | 
					  let wrapped = (raw.splitLines -->
 | 
				
			||||||
    filter(not isEmptyOrWhitespace(it.strip) and match(it, re"^\[\d+\].*")).
 | 
					    filter(match(it, re"^\s+(\[\d+\]|\w).*")).
 | 
				
			||||||
    map(it.multiReplace([(re"\((\d+)\)", ""), (re"\[(\d+)\]", "**$1**")])).
 | 
					    map(it.strip.multiReplace([(re"\((\d+)\)", ""), (re"\[(\d+)\]", "**$1**")])).
 | 
				
			||||||
    map(wrapWords(it, maxLineWidth = 74, newLine = "\p"))).
 | 
					    map(wrapWords(it, maxLineWidth = 74, newLine = "\p"))).
 | 
				
			||||||
    join("\p")
 | 
					    join("\p")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  result = (wrapped.splitLines --> map("> " & it)).join("\p") &
 | 
					  result = (wrapped.splitLines --> map("> " & it)).join("\p") &
 | 
				
			||||||
    "\p>\p> -- *" & rawLines[0] & " (ESV)*"
 | 
					    "\p>\p> -- *" & rawLines[0].strip & " (ESV)*"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
when isMainModule:
 | 
					when isMainModule:
 | 
				
			||||||
  const USAGE = """Usage:
 | 
					  const USAGE = """Usage:
 | 
				
			||||||
@@ -44,7 +44,7 @@ Options:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  try:
 | 
					  try:
 | 
				
			||||||
    # Parse arguments
 | 
					    # Parse arguments
 | 
				
			||||||
    let args = docopt(USAGE, version = "0.2.1")
 | 
					    let args = docopt(USAGE, version = "0.2.2")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if args["--debug"]:
 | 
					    if args["--debug"]:
 | 
				
			||||||
      consoleLogger.levelThreshold = lvlDebug
 | 
					      consoleLogger.levelThreshold = lvlDebug
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user