Skip to content
This repository has been archived by the owner on Sep 4, 2023. It is now read-only.

Commit

Permalink
Merge branch 'links'
Browse files Browse the repository at this point in the history
  • Loading branch information
Gambhiro committed Nov 17, 2019
2 parents a174112 + 5db6acf commit bb97d7c
Show file tree
Hide file tree
Showing 33 changed files with 2,683 additions and 439 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "simsapa_dictionary"
version = "0.1.0"
version = "0.2.0-alpha.1"
authors = ["Gambhiro <gambhiro.bhikkhu.85@gmail.com>"]
edition = "2018"
license = "MIT"
Expand Down
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ ndped-example.md
book_id = "NcpedDictionarySimsapa"
created_date_human = ""
created_date_opf = ""
is_epub = true
is_mobi = false
```

--- DICTIONARY WORD ENTRIES ---
Expand Down Expand Up @@ -162,7 +160,7 @@ SUBCOMMANDS:
Process a Markdown file and generate an EPUB or MOBI dictionary.
USAGE:
simsapa_dictionary markdown_to_ebook [FLAGS] [OPTIONS] --ebook_format <FORMAT>
simsapa_dictionary markdown_to_ebook [FLAGS] [OPTIONS] --output_format <FORMAT>
FLAGS:
--dont_remove_generated_files Turns off the removal of the generated OPF, HTML, etc. files used to create the
Expand All @@ -176,7 +174,7 @@ FLAGS:
OPTIONS:
--dict_label <LABEL> Use this dict_label property, instead of the one defined in the Markdown file.
--ebook_format <FORMAT> Either EPUB or MOBI. [default: EPUB] [possible values: EPUB, Epub, epub, MOBI,
--output_format <FORMAT> Either EPUB or MOBI. [default: EPUB] [possible values: EPUB, Epub, epub, MOBI,
Mobi, mobi]
--kindlegen_path <PATH> The KindleGen tool must be available either (a) in the current folder with this
tool, (b) in the system PATH, (c) declared with this option.
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: "0.1.0.{branch}.{build}"
version: "0.2.0-alpha.1.{branch}.{build}"

image: Visual Studio 2019

Expand Down
27 changes: 5 additions & 22 deletions assets/OEBPS/entries-epub.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,15 @@

{{#each group.dict_words}}
<h4>{{#if ../meta.word_prefix}}{{../meta.word_prefix}} {{/if}}{{word_header.word}}</h4>
{{grammar_phonetic_transliteration word_header ../meta.use_velthuis ~}}
{{#if word_header.dict_label ~}}
<p>[{{word_header.dict_label}}]</p>
{{/if ~}}
{{#if word_header.summary ~}}
<p>{{word_header.summary}}</p>
{{/if ~}}
{{grammar_phonetic_transliteration word_header ../meta.add_velthuis ~}}

{{word_list "Also written as:" word_header.also_written_as ~}}
{{markdown definition_md}}

{{#if word_header.synonyms}}
<p>Synonyms:</p>
<ul>
{{#each word_header.synonyms}}
<li>{{this}}</li>
{{/each}}
</ul>
{{/if}}

{{#if word_header.antonyms}}
<p>Antonyms:</p>
<ul>
{{#each word_header.antonyms}}
<li>{{this}}</li>
{{/each}}
</ul>
{{/if}}
{{word_list "Synonyms:" word_header.synonyms ~}}
{{word_list "Antonyms:" word_header.antonyms ~}}
{{word_list "See also:" word_header.see_also ~}}

{{/each}}
26 changes: 7 additions & 19 deletions assets/OEBPS/entries-mobi.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,14 @@
{{! Spaces and newlines in <idx:entry> are significant for dictionary entry search}}

{{#each group.dict_words}}
<idx:entry><idx:orth><h4>{{word_header.word}}</h4>{{grammar_phonetic_transliteration word_header ../meta.use_velthuis ~}}<p>{{#if word_header.dict_label}} <i>{{word_header.dict_label}}</i>{{/if}}{{#if word_header.summary}} <i>{{word_header.summary}}</i>{{/if}}{{#if word_header.inflections}}</p><idx:infl>{{#each word_header.inflections}} <idx:iform value="{{this}}"/>{{/each}}</idx:infl>{{/if}}</idx:orth></idx:entry>
<idx:entry><idx:orth><h4>{{word_header.word}}</h4><p>{{#if word_header.dict_label}} <i>{{word_header.dict_label}}</i>{{/if}}{{#if word_header.summary}} <i>{{word_header.summary}}</i>{{/if}}{{#if word_header.inflections}}</p><idx:infl>{{#each word_header.inflections}} <idx:iform value="{{this}}"/>{{/each}}</idx:infl>{{/if}}</idx:orth></idx:entry>

{{markdown definition_md}}

{{#if word_header.synonyms}}
<p>Synonyms:</p>
<ul>
{{#each word_header.synonyms}}
<li>{{this}}</li>
{{/each}}
</ul>
{{/if}}
{{grammar_phonetic_transliteration word_header ../meta.add_velthuis ~}}

{{#if word_header.antonyms}}
<p>Antonyms:</p>
<ul>
{{#each word_header.antonyms}}
<li>{{this}}</li>
{{/each}}
</ul>
{{/if}}
{{word_list "Also written as:" word_header.also_written_as ~}}
{{markdown definition_md}}
{{word_list "Synonyms:" word_header.synonyms ~}}
{{word_list "Antonyms:" word_header.antonyms ~}}
{{word_list "See also:" word_header.see_also ~}}

{{/each}}
9 changes: 5 additions & 4 deletions assets/OEBPS/package.opf
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<meta name="cover" content="item_cover"></meta>

{{#if meta.is_mobi ~}}
{{#if (eq output_format "Mobi") ~}}
<x-metadata>
<output encoding="utf-8"></output>
<EmbeddedCover>{{meta.cover_path}}</EmbeddedCover>
Expand All @@ -27,7 +27,7 @@
<manifest>
<item id="htmltoc" href="htmltoc.xhtml" media-type="application/xhtml+xml" properties="nav"/>

{{#if meta.is_epub ~}}
{{#if (eq output_format "Epub") ~}}
<item id="cover_page" href="cover.xhtml" media-type="application/xhtml+xml" properties="svg"/>
{{/if ~}}

Expand All @@ -48,9 +48,10 @@
</manifest>

<spine toc="ncx">
{{#if meta.is_epub ~}}
{{#if (eq output_format "Epub") ~}}
<itemref idref="cover_page"/>
{{else}}
{{/if ~}}
{{#if (eq output_format "Mobi") ~}}
<itemref idref="item_cover"/>
{{/if ~}}

Expand Down
2 changes: 1 addition & 1 deletion assets/simsapa_md_to_epub.bat
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ SET DEST_FILE=%SRC_NAME%.epub
simsapa_dictionary.exe markdown_to_ebook ^
--source_path "%~1" ^
--dict_label "" ^
--ebook_format epub ^
--output_format epub ^
--output_path "%DEST_FILE%"

Exit /b
Expand Down
2 changes: 1 addition & 1 deletion assets/simsapa_md_to_epub.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ DEST_FILE="$SRC_NAME.epub"
simsapa_dictionary markdown_to_ebook \
--source_path "$1" \
--dict_label "" \
--ebook_format epub \
--output_format epub \
--output_path "$DEST_FILE"

2 changes: 1 addition & 1 deletion assets/simsapa_md_to_mobi.bat
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ SET DEST_FILE=%SRC_NAME%.mobi
simsapa_dictionary.exe markdown_to_ebook ^
--source_path "%~1" ^
--dict_label "" ^
--ebook_format mobi ^
--output_format mobi ^
--output_path "%DEST_FILE%" ^
--mobi_compression 0 ^
--kindlegen_path kindlegen.exe
Expand Down
2 changes: 1 addition & 1 deletion assets/simsapa_md_to_mobi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ DEST_FILE="$SRC_NAME.mobi"
simsapa_dictionary markdown_to_ebook \
--source_path "$1" \
--dict_label "" \
--ebook_format mobi \
--output_format mobi \
--output_path "$DEST_FILE" \
--mobi_compression 0

6 changes: 5 additions & 1 deletion assets/stardict_textual.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@

<definition type="h">
<![CDATA[
{{grammar_phonetic_transliteration word_header ../meta.use_velthuis ~}}
{{#if word_header.dict_label ~}}
<p>[{{word_header.dict_label}}]</p>
{{/if ~}}
{{grammar_phonetic_transliteration word_header ../meta.add_velthuis ~}}
{{word_list "Also written as:" word_header.also_written_as ~}}
{{markdown definition_md ~}}
{{word_list "Synonyms:" word_header.synonyms ~}}
{{word_list "Antonyms:" word_header.antonyms ~}}
Expand Down
64 changes: 56 additions & 8 deletions scripts/build_dicts_for_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,89 @@
SRC_DIR=../simsapa-dictionary-data
OUT_DIR=../simsapa-dictionary_releases/new-release

if [ -z "$OUT_DIR" ]; then
rm -r "$OUT_DIR"
fi

mkdir -p "$OUT_DIR"

PROJ_ROOT=$(pwd)

KINDLEGEN_PATH="$HOME/lib/kindlegen/kindlegen"

# === Combined ===
STARDICT_TEXT2BIN="/usr/lib/stardict-tools/stardict-text2bin"

# === Individual ===

for i in dhammika dppn ncped nyana pts; do
cd "$PROJ_ROOT"

cargo run -- markdown_to_ebook \
--source_path "$SRC_DIR/$i.md" \
--dict_label "" \
--ebook_format mobi \
--output_format mobi \
--output_path "$OUT_DIR/$i.mobi" \
--mobi_compression 0 \
--kindlegen_path "$KINDLEGEN_PATH"

cargo run -- markdown_to_ebook \
--source_path "$SRC_DIR/$i.md" \
--dict_label "" \
--ebook_format epub \
--output_format epub \
--output_path "$OUT_DIR/$i.epub"

# TODO epubcheck

stardict_out="$OUT_DIR/$i-stardict"
mkdir -p "$stardict_out"

cargo run -- markdown_to_stardict_xml \
--source_path "$SRC_DIR/$i.md" \
--output_path "$stardict_out/$i.xml"

cd "$stardict_out"
$STARDICT_TEXT2BIN "$i.xml" "$i.ifo"
rm "$i.xml"
cd ..
zip -r "$i-stardict.zip" "$i-stardict"
rm "$i-stardict" -r

done

# === Combined ===

cd "$PROJ_ROOT"

name="combined-dictionary"

cargo run -- markdown_to_ebook \
--source_paths_list ./scripts/combined_dict_md_paths.txt \
--title "Combined Pali - English Dictionary" \
--ebook_format mobi \
--output_path "$OUT_DIR/combined-dictionary.mobi" \
--source_paths_list ./scripts/combined_dict_md_paths.txt \
--output_format mobi \
--output_path "$OUT_DIR/$name.mobi" \
--mobi_compression 0 \
--kindlegen_path "$KINDLEGEN_PATH"

cargo run -- markdown_to_ebook \
--title "Combined Pali - English Dictionary" \
--source_paths_list ./scripts/combined_dict_md_paths.txt \
--output_format epub \
--output_path "$OUT_DIR/$name.epub"

# TODO epubcheck

stardict_out="$OUT_DIR/$name-stardict"
mkdir -p "$stardict_out"

cargo run -- markdown_to_stardict_xml \
--title "Combined Pali - English Dictionary" \
--ebook_format epub \
--output_path "$OUT_DIR/combined-dictionary.epub"
--source_paths_list ./scripts/combined_dict_md_paths.txt \
--output_path "$stardict_out/$name.xml"

cd "$stardict_out"
$STARDICT_TEXT2BIN "$name.xml" "$name.ifo"
rm "$name.xml"
cd ..
zip -r "$name-stardict.zip" "$name-stardict"
rm "$name-stardict" -r

2 changes: 1 addition & 1 deletion scripts/combined_to_mobi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
cargo run -- markdown_to_ebook \
--source_paths_list ./scripts/combined_dict_md_paths.txt \
--title "Combined Pali - English Dictionary" \
--ebook_format mobi \
--output_format mobi \
--output_path ../simsapa-dictionary_releases/combined-dictionary.mobi \
--mobi_compression 0 \
--dont_remove_generated_files \
Expand Down
60 changes: 51 additions & 9 deletions scripts/json_to_md.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,67 @@

#RUST_LOG=sources_to_markdown=info cargo run --bin sources_to_markdown 2>&1 | tee sources_to_markdown.log

SC_ROOT="$HOME/src/suttacentral-2018-09-03/sc-data/dictionaries/en"
SC_ROOT="$HOME/src/suttacentral-2019-11-15/sc-data/dictionaries/en"
OUT_DIR="../simsapa-dictionary-data"

# === Dhammika ===

cargo run -- suttacentral_json_to_markdown \
--title "Dhammika Pali - English Dictionary" \
--dict_label Dhammika \
--json_path "$SC_ROOT/dhammika.json" \
--output_path "$OUT_DIR/dhammika.md"

cargo run -- suttacentral_json_to_markdown \
--title "Dhammika Pali - English Dictionary" \
--dict_label Dhammika \
--dont_process \
--json_path "$SC_ROOT/dhammika.json" \
--output_path "$OUT_DIR/dhammika.md" \
--dict_label Dhammika
--output_path "$OUT_DIR/dhammika_unprocessed.md"

# === DPPN ===

cargo run -- suttacentral_json_to_markdown \
--title "Dictionary of Pali Proper Names (DPPN)" \
--dict_label DPPN \
--json_path "$SC_ROOT/dppn.json" \
--output_path "$OUT_DIR/dppn.md"

cargo run -- suttacentral_json_to_markdown \
--title "Dictionary of Pali Proper Names (DPPN)" \
--dict_label DPPN \
--dont_process \
--json_path "$SC_ROOT/dppn.json" \
--output_path "$OUT_DIR/dppn.md" \
--dict_label DPPN
--output_path "$OUT_DIR/dppn_unprocessed.md"

# === NCPED ===

cargo run -- suttacentral_json_to_markdown \
--title "New Concise Pali - English Dictionary (NCPED)" \
--dict_label NCPED \
--json_path "$SC_ROOT/ncped.json" \
--output_path "$OUT_DIR/ncped.md"

cargo run -- suttacentral_json_to_markdown \
--title "New Concise Pali - English Dictionary (NCPED)" \
--dict_label NCPED \
--dont_process \
--json_path "$SC_ROOT/ncped.json" \
--output_path "$OUT_DIR/ncped.md" \
--dict_label NCPED
--output_path "$OUT_DIR/ncped_unprocessed.md"

# === PTS ===

cargo run -- suttacentral_json_to_markdown \
--title "Pali Text Society Pali - English Dictionary (PTS)" \
--dict_label PTS \
--dont_remove_see_also \
--json_path "$SC_ROOT/pts.json" \
--output_path "$OUT_DIR/pts.md"

cargo run -- suttacentral_json_to_markdown \
--title "Pali Text Society Pali - English Dictionary (PTS)" \
--dict_label PTS \
--dont_process \
--dont_remove_see_also \
--json_path "$SC_ROOT/pts.json" \
--output_path "$OUT_DIR/pts.md" \
--dict_label PTS
--output_path "$OUT_DIR/pts_unprocessed.md"
12 changes: 12 additions & 0 deletions scripts/ncped_json_to_md.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

#RUST_LOG=sources_to_markdown=info cargo run --bin sources_to_markdown 2>&1 | tee sources_to_markdown.log

SC_ROOT="$HOME/src/suttacentral-2019-11-15/sc-data/dictionaries/en"
OUT_DIR="../simsapa-dictionary-data"

cargo run -- suttacentral_json_to_markdown \
--json_path "$SC_ROOT/ncped.json" \
--output_path "$OUT_DIR/ncped.md" \
--dict_label NCPED

Loading

0 comments on commit bb97d7c

Please sign in to comment.