% % subroutine of pmhanguljamo.sty %. v0.3.2 (2020/02/05) %. v0.3.3 (2020/03/09) %. v0.3.4 (2020/03/15) % \seq_new:N \l_textjm_seq \NewDocumentEnvironment { jamotext } { +b } { \seq_set_split:Nnn \l_textjm_seq {\par} { #1 } \seq_indexed_map_inline:Nn \l_textjm_seq { \jamoword { ##2 } \int_compare:nT { ##1 < \seq_count:N \l_textjm_seq } { \par } } }{} \tl_new:N \l_tmpz_tl \NewDocumentCommand \jamoword { m } { \seq_set_split:Nnn \l_tmpa_seq { ~ } { #1 } \seq_indexed_map_inline:Nn \l_tmpa_seq { \tl_set:Nn \l_tmpz_tl { ##2 } \exp_args:No \str_if_in:nnT { \l_tmpz_tl } { - } { \regex_replace_all:nnN { \- } { \/\- } \l_tmpz_tl } \exp_args:No \str_if_in:nnT { \l_tmpz_tl } { . } { \regex_replace_all:nnN { \. } { \/\. } \l_tmpz_tl } \exp_args:No \str_if_in:nnT { \l_tmpz_tl } { , } { \regex_replace_all:nnN { \, } { \/\, } \l_tmpz_tl } \exp_args:No \str_if_in:nnT { \l_tmpz_tl } { ! } { \regex_replace_all:nnN { \! } { \/\! } \l_tmpz_tl } \exp_args:No \str_if_in:nnT { \l_tmpz_tl } { ? } { \regex_replace_all:nnN { \? } { \/\? } \l_tmpz_tl } \exp_args:No \str_if_in:nnT { \l_tmpz_tl } { : } { \regex_replace_all:nnN { \: } { \/\: } \l_tmpz_tl } \exp_args:No \str_if_in:nnT { \l_tmpz_tl } { ; } { \regex_replace_all:nnN { \; } { \/\; } \l_tmpz_tl } \exp_args:No \str_if_in:nnTF { \l_tmpz_tl } { / } { \exp_args:NNno \seq_set_split:Nnn \l_tmpb_seq { / } { \l_tmpz_tl } \seq_map_function:NN \l_tmpb_seq \rrk_fn_outer:n } { \exp_args:No \rrk_a_word:n { \l_tmpz_tl } } \int_compare:nT { \seq_count:N \l_tmpa_seq > ##1 } { \space } } } \cs_new:Npn \rrk_fn_outer:n #1 { \rrk_a_word:n { #1 } } \cs_new_nopar:Npn \rrk_a_word:n #1 { \seq_gclear:N \g_outsyl_tl \regex_match:nnTF { [a-zA-Z0 ] } { #1 } { \exp_args:NNnx \seq_set_split:Nnn \g_tmpa_seq {} { \str_lowercase:f { #1 } } \int_step_inline:nn { 9 } { \seq_put_right:Nn \g_tmpa_seq { 0 } } \cho_fn: \seq_use:Nn \g_outsyl_tl { } } { #1 } } \cs_new:Npn \insert_out:n #1 { \seq_put_right:Nn \g_outsyl_tl { #1 } } \cs_new:Npn \prepare_three_tk: { \seq_pop_left:NN \g_tmpa_seq \l_tmpa_tl \seq_pop_left:NN \g_tmpa_seq \l_tmpb_tl \seq_pop_left:NN \g_tmpa_seq \l_tmpc_tl } \cs_new:Npn \cho_fn: { \prepare_three_tk: \str_case_e:nn { \l_tmpa_tl } { % Zero 자음 { @ } { \insert_out:n { ᄋ } \restore_c: \restore_b: \restore_a: } { a } { \insert_out:n { ᄋ } \restore_c: \restore_b: \restore_a: } { e } { \insert_out:n { ᄋ } \restore_c: \restore_b: \restore_a: } { i } { \insert_out:n { ᄋ } \restore_c: \restore_b: \restore_a: } { o } { \insert_out:n { ᄋ } \restore_c: \restore_b: \restore_a: } { u } { \insert_out:n { ᄋ } \restore_c: \restore_b: \restore_a: } { w } { \insert_out:n { ᄋ } \restore_c: \restore_b: \restore_a: } { y } { \insert_out:n { ᄋ } \restore_c: \restore_b: \restore_a: } { g } { \insert_out:n { ᄀ } \restore_c: \restore_b: } { n } { \insert_out:n { ᄂ } \restore_c: \restore_b: } { d } { \insert_out:n { ᄃ } \restore_c: \restore_b: } { l } { \insert_out:n { ᄅ } \restore_c: \restore_b: } { r } { \insert_out:n { ᄅ } \restore_c: \restore_b: } { m } { \insert_out:n { ᄆ } \restore_c: \restore_b: } { b } { \insert_out:n { ᄇ } \restore_c: \restore_b: } { c } { \insert_out:n { ᄎ } \restore_c: } { h } { \insert_out:n { ᄒ } \restore_c: \restore_b: } { x } { \insert_out:n { ᄋ } \restore_c: \restore_b: } { s } { \exp_args:No \str_if_eq:nnTF { \l_tmpb_tl } { s } { \insert_out:n { ᄊ } \restore_c: } { \insert_out:n { ᄉ } \restore_c: \restore_b: } } { j } { \exp_args:No \str_if_eq:nnTF { \l_tmpb_tl } { j } { \insert_out:n { ᄍ } \restore_c: } { \insert_out:n { ᄌ } \restore_c: \restore_b: } } { k } { \exp_args:No \str_if_eq:nnTF { \l_tmpb_tl } { k } { \insert_out:n { ᄁ } \restore_c: } { \insert_out:n { ᄏ } \restore_c: \restore_b: } } { t } { \exp_args:No \str_if_eq:nnTF { \l_tmpb_tl } { t } { \insert_out:n { ᄄ } \restore_c: } { \insert_out:n { ᄐ } \restore_c: \restore_b: } } { p } { \exp_args:No \str_if_eq:nnTF { \l_tmpb_tl } { p } { \insert_out:n { ᄈ } \restore_c: } { \insert_out:n { ᄑ } \restore_c: \restore_b: } } { - } { \exp_args:Nno \str_if_in:nnTF { aeiouwy@ } { \l_tmpb_tl } { \insert_out:n { ᄋ } \restore_c: \restore_b: } { \insert_out:n { } \restore_c: \restore_b: \cho_fn: } } } \jung_fn: } \cs_new:Npn \jung_fn: { \prepare_three_tk: \exp_args:No \str_if_eq:nnTF { \l_tmpa_tl } { 0 } { \scan_stop: } { \str_case_e:nn { \l_tmpa_tl } { { i } { \insert_out:n { ᅵ } \restore_c: \restore_b: } { o } { \exp_args:No \str_if_eq:nnTF { \l_tmpb_tl } { e } { \insert_out:n { ᅬ } \restore_c: } { \insert_out:n { ᅩ } \restore_c: \restore_b: } } { u } { \exp_args:No \str_if_eq:nnTF { \l_tmpb_tl } { i } { \insert_out:n { ᅴ } \restore_c: } { \insert_out:n { ᅮ } \restore_c: \restore_b: } } { a } { \exp_args:No \str_if_eq:nnTF { \l_tmpb_tl } { e } { \insert_out:n { ᅢ } \restore_c: } { \insert_out:n { ᅡ } \restore_c: \restore_b: } } { e } { \str_case_e:nnF { \l_tmpb_tl } { { o } { \insert_out:n { ᅥ } \restore_c: } { u } { \insert_out:n { ᅳ } \restore_c: } } { \insert_out:n { ᅦ } \restore_c: \restore_b: } } { @ } { \str_case_e:nnF { \l_tmpb_tl } { { @ } { \insert_out:n { ᆢ } \restore_c: } { i } { \insert_out:n { ᆡ } \restore_c: } } { \insert_out:n { ᆞ } \restore_c: \restore_b: } } { y } { \str_case_e:nn { \l_tmpb_tl } { { o } { \insert_out:n { ᅭ } \restore_c: } { u } { \insert_out:n { ᅲ } \restore_c: } { a } { \exp_args:No \str_if_eq:nnTF { \l_tmpc_tl } { e } { \insert_out:n { ᅤ } } { \insert_out:n { ᅣ } \restore_c: } } { e } { \exp_args:No \str_if_eq:nnTF { \l_tmpc_tl } { o } { \insert_out:n { ᅧ } } { \insert_out:n { ᅨ } \restore_c: } } } } { w } { \str_case_e:nn { \l_tmpb_tl } { { o } { \insert_out:n { ᅯ } \restore_c: } { i } { \insert_out:n { ᅱ } \restore_c: } { e } { \insert_out:n { ᅰ } \restore_c: } { a } { \exp_args:No \str_if_eq:nnTF { \l_tmpc_tl } { e } { \insert_out:n { ᅫ } } { \insert_out:n { ᅪ } \restore_c: } } } } } \jong_fn: } } \cs_new:Npn \prepare_five_tk: { \seq_pop_left:NN \g_tmpa_seq \l_tmpa_tl \seq_pop_left:NN \g_tmpa_seq \l_tmpb_tl \seq_pop_left:NN \g_tmpa_seq \l_tmpc_tl \seq_pop_left:NN \g_tmpa_seq \l_tmpd_tl \seq_pop_left:NN \g_tmpa_seq \l_tmpe_tl } \cs_new:Npn \jong_fn: { \prepare_five_tk: \exp_args:No \str_if_eq:nnTF { \l_tmpb_tl } { 0 } { \exp_args:Nx \insert_jong:n { \l_tmpa_tl } } { \exp_args:Nno \str_if_in:nnTF { aeiouwy@ } { \l_tmpb_tl } { \restore_e: \restore_d: \restore_c: \restore_b: \restore_a: \cho_fn: } { \exp_args:Nno \str_if_in:nnTF { aeiouwy@ } { \l_tmpc_tl } { \restore_e: \restore_d: \restore_c: \restore_b: \restore_a: \take_jong_two: } { \exp_args:Nno \str_if_in:nnTF { aeiouwy@ } { \l_tmpd_tl } { \restore_e: \restore_d: \restore_c: \restore_b: \restore_a: \take_jong_three: } { \exp_args:Nno \str_if_in:nnTF { aeiouwy@ } { \l_tmpe_tl } { \exp_args:Nx \insert_jong:n { \l_tmpa_tl \l_tmpb_tl } % \exp_args:Nx \insert_out:n { \l_tmpc_tl \l_tmpd_tl } \restore_e: \restore_d: \restore_c: \cho_fn: } { \restore_e: \restore_d: \restore_c: \restore_b: \restore_a: \take_jong_four: } } } } } } \cs_new:Npn \take_jong_four: { \prepare_five_tk: \exp_args:No \str_if_eq:nnTF { \l_tmpa_tl } { 0 } { \scan_stop: } { \exp_args:Nx \insert_jong:n { \tl_use:N \l_tmpa_tl \tl_use:N \l_tmpb_tl } \restore_e: \restore_d: \restore_c: \cho_fn: } } \cs_new:Npn \insert_jong:n #1 { \str_case:nn { #1 } { { kk } { \insert_out:n { ᆩ } } { gs } { \insert_out:n { ᆪ } } { g } { \insert_out:n { ᆨ } } { nj } { \insert_out:n { ᆬ } } { nh } { \insert_out:n { ᆭ } } { n } { \insert_out:n { ᆫ } } { d } { \insert_out:n { ᆮ } } { lg } { \insert_out:n { ᆰ } } { lm } { \insert_out:n { ᆱ } } { lb } { \insert_out:n { ᆲ } } { ls } { \insert_out:n { ᆳ } } { lt } { \insert_out:n { ᆴ } } { lp } { \insert_out:n { ᆵ } } { lh } { \insert_out:n { ᆶ } } { l } { \insert_out:n { ᆯ } } { m } { \insert_out:n { ᆷ } } { bs } { \insert_out:n { ᆹ } } { b } { \insert_out:n { ᆸ } } { ss } { \insert_out:n { ᆻ } } { s } { \insert_out:n { ᆺ } } { ng } { \insert_out:n { ᆼ } } { j } { \insert_out:n { ᆽ } } { ch } { \insert_out:n { ᆾ } } { k } { \insert_out:n { ᆿ } } { t } { \insert_out:n { ᇀ } } { p } { \insert_out:n { ᇁ } } { h } { \insert_out:n { ᇂ } } { / } { \insert_out:n { 0 } } } } \cs_new:Npn \take_jong_three: { \prepare_three_tk: \exp_args:No \str_if_eq:nnTF { \l_tmpa_tl } { 0 } { \scan_stop: } { %% XX- \exp_args:No \str_if_eq:nnTF { \l_tmpc_tl } { - } { \exp_args:Nx \insert_jong:n { \l_tmpa_tl \l_tmpb_tl } \restore_c: } { \exp_args:No \str_if_eq:nnTF { \l_tmpb_tl } { - } { \exp_args:Nx \insert_jong:n { \l_tmpa_tl } \restore_c: \restore_b: } { \check_jong_sub: } } \cho_fn: } } \cs_new:Npn \check_jong_sub: { \exp_args:Noo \str_if_eq:nnTF { \l_tmpb_tl } { \l_tmpc_tl } { \exp_args:Noo \str_if_eq:nnTF { \l_tmpa_tl } { \l_tmpb_tl } %%% sss { \exp_args:Nx \insert_jong:n { \l_tmpa_tl \l_tmpb_tl } %% ss-s \restore_c: } { \bool_if:nTF { \exp_args:Noo \str_if_eq_p:nn { \l_tmpb_tl } { \l_tmpc_tl } %%% X-ss && \exp_args:Noo \str_if_eq_p:nn { \l_tmpb_tl } { s } } { \exp_args:Nx \insert_jong:n { \l_tmpa_tl } \restore_c: \restore_b: } { \exp_args:Nno \str_if_in:nnTF { tpkj } { \l_tmpb_tl } { \exp_args:Nx \insert_jong:n { \l_tmpa_tl } \restore_c: \restore_b: } { \check_jong_sub_last: } } } } { \str_if_eq:eeTF { \l_tmpa_tl } { k } { \str_if_eq:eeTF { \l_tmpb_tl } { k } %% kk-g { \exp_args:Nx \insert_jong:n { \l_tmpa_tl \l_tmpb_tl } \restore_c: } { \exp_args:Nx \insert_jong:n { \l_tmpa_tl } \restore_c: \restore_b: } } { \exp_args:No \str_if_eq:nnTF { \l_tmpa_tl } { c } %%% chX { \exp_args:Nx \insert_jong:n { \l_tmpa_tl \l_tmpb_tl } \restore_c: } { \exp_args:No \str_if_eq:nnTF { \l_tmpb_tl } { c } %%% Xch { \exp_args:Nx \insert_jong:n { \l_tmpa_tl } \restore_c: \restore_b: } { \check_jong_sub_last: } } } } } \cs_new:Npn \check_jong_sub_last: { \str_case_e:nnTF { \l_tmpa_tl } { { n } { \str_case_e:nn { \l_tmpb_tl } { { j } { } { g } { } { h } { } } } { g } { \str_case_e:nn { \l_tmpb_tl } { { s } { } } } { l } { \str_case_e:nn { \l_tmpb_tl } { { g } { } { m } { } { b } { } { s } { } { t } { } { p } { } { h } { } } } { b } { \str_case_e:nn { \l_tmpb_tl } { { s } { } } } { s } { \str_case_e:nn { \l_tmpb_tl } { { s } { } } } } { \exp_args:Nx \insert_jong:n { \l_tmpa_tl \l_tmpb_tl } \restore_c: } { \exp_args:Nx \insert_jong:n { \l_tmpa_tl } \restore_c: \restore_b: } } \cs_new:Npn \take_jong_two: { \prepare_three_tk: \exp_args:No \str_if_eq:nnTF { \l_tmpa_tl } { 0 } { \scan_stop: } { \exp_args:Noo \str_if_eq:nnTF { \l_tmpa_tl } { \l_tmpb_tl } { \exp_args:Nno \str_if_in:nnTF { tpkj } { \l_tmpa_tl } { \restore_c: \restore_b: \restore_a: } { \exp_args:No \str_if_eq:nnTF { \l_tmpa_tl } { c } { \restore_c: \restore_b: \restore_a: } { \exp_args:Nx \insert_jong:n { \l_tmpa_tl } \restore_c: \restore_b: } } } { \exp_args:No \str_if_eq:nnTF { \l_tmpa_tl } { c } { \restore_c: \restore_b: \restore_a: } { \exp_args:Nx \insert_jong:n { \l_tmpa_tl } \restore_c: \restore_b: } } } \cho_fn: } \cs_new:Npn \restore_c: { \exp_args:NNx \seq_put_left:Nn \g_tmpa_seq { \tl_use:N \l_tmpc_tl } } \cs_new:Npn \restore_b: { \exp_args:NNx \seq_put_left:Nn \g_tmpa_seq { \tl_use:N \l_tmpb_tl } } \cs_new:Npn \restore_a: { \exp_args:NNx \seq_put_left:Nn \g_tmpa_seq { \tl_use:N \l_tmpa_tl } } \cs_new:Npn \restore_d: { \exp_args:NNx \seq_put_left:Nn \g_tmpa_seq { \tl_use:N \l_tmpd_tl } } \cs_new:Npn \restore_e: { \exp_args:NNx \seq_put_left:Nn \g_tmpa_seq { \tl_use:N \l_tmpe_tl } } \cs_new:Npn \restore_five: { \restore_e: \restore_d: \restore_c: \restore_b: \restore_a: } \endinput %% end of file pmhanguljamo-rrk.tex