Skip to content

Commit

Permalink
Merge pull request #3 from digitalbias/merge-request-1
Browse files Browse the repository at this point in the history
tags added for major volumes
  • Loading branch information
digitalbias authored May 13, 2022
2 parents 8fd73b9 + fc0ef4e commit ae84d74
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions lib/scripture_extract.ex
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ defmodule ScriptureExtract do
end
###############################################################

def write_to_volume_index(output_dir, result, chapter_number = 1, book_number = 1) do
def write_to_volume_index(output_dir, result, _chapter_number = 1, _book_number = 1) do
volume_title = get_result_value(:volume_title, result)
book_title = get_result_value(:book_title, result)

Expand Down Expand Up @@ -122,21 +122,28 @@ defmodule ScriptureExtract do
book_title = get_result_value(:book_title, result)

subtitle = get_book_subtitle(book_id)
volume_title = get_result_value(:volume_title, result)
subtag = String.downcase(String.replace(volume_title, " ", "-"), :ascii)
tag = "#scriptures/#{subtag}"

contents = "# #{book_title}\n"
contents = write_book_subtitle(contents, subtitle)
contents = write_book_subtitle(contents, subtitle, tag)
IO.binwrite(file, contents)
end

def write_book_header(_, _, _) do end

def write_book_subtitle(contents, "") do
def write_book_subtitle(contents, "", "") do
"#{contents}\n"
end

def write_book_subtitle(contents, subtitle) do
def write_book_subtitle(contents, subtitle, "") do
"#{contents}## #{subtitle}\n\n"
end

def write_book_subtitle(contents, subtitle, tag) do
"#{contents}## #{subtitle}\n#{tag}\n\n"
end

###############################################################
def extract_chapter(output_dir, result) do
Expand All @@ -159,15 +166,18 @@ defmodule ScriptureExtract do
book_title = get_result_value(:book_title, result)
chapter_number = get_result_value(:chapter_number, result)

IO.binwrite(file, "# #{book_title} #{chapter_number}\n\n")
volume_title = get_result_value(:volume_title, result)
subtag = String.downcase(String.replace(volume_title, " ", "-"), :ascii)

IO.binwrite(file, "# #{book_title} #{chapter_number}\n#scriptures/#{subtag}\n\n")
end

def write_chapter_header(_, _, _) do end

def extract_verse(result) do
verse_number = get_result_value(:verse_number, result)
scripture_text = get_result_value(:scripture_text, result)
"#{verse_number} #{scripture_text}\n\n"
"#{verse_number} #{scripture_text} ^#{verse_number}\n\n"
end

defp get_result_value(:book_id, [_, book_id, _, _, _, _, _, _, _]) do
Expand Down

0 comments on commit ae84d74

Please sign in to comment.