diff --git a/lib/scripture_extract.ex b/lib/scripture_extract.ex index 19deab7..56189b0 100644 --- a/lib/scripture_extract.ex +++ b/lib/scripture_extract.ex @@ -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) @@ -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 @@ -159,7 +166,10 @@ 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 @@ -167,7 +177,7 @@ defmodule ScriptureExtract do 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