Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ jobs:
- uses: actions/checkout@v5
- uses: changepacks/action@main
id: changepacks
with:
token: ${{ secrets.GITHUB_TOKEN }}
outputs:
changepacks: ${{ steps.changepacks.outputs.changepacks }}
release_assets_urls: ${{ steps.changepacks.outputs.release_assets_urls }}
Expand Down
41 changes: 40 additions & 1 deletion libs/braillify/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,10 @@ impl Encoder {
if !(i > 0 && ['.', ','].contains(&word_chars[i - 1])) {
// 제40항 숫자는 수표 ⠼을 앞세워 다음과 같이 적는다.
result.push(60);
// 제61항 작은따옴표(')가 숫자 앞에 올 때는 수표와 작은따옴표를 함께 사용
if i > 0 && (word_chars[i - 1] == '\'' || word_chars[i - 1] == '\u{2019}') {
result.push(4); // ⠄
}
}
is_number = true;
}
Expand Down Expand Up @@ -496,6 +500,17 @@ impl Encoder {
}
result.push(7);
*skip_count = count - 1;
} else if (c == '\'' || c == '\u{2019}') && i + 1 < word_len && word_chars[i + 1].is_ascii_digit() {
// 제61항 작은따옴표(')가 숫자 앞에 올 때는 숫자 처리에서 함께 처리하므로 건너뛴다
continue;
} else if c == '*' {
// 제60항 별표(*)는 앞뒤를 한 칸씩 띄어 쓴다
// 별표가 단독 단어이고 이전 단어가 있을 때만 앞에 공백 추가
if i == 0 && word_len == 1 && !prev_word.is_empty() {
result.push(0);
}
result.extend(symbol_shortcut::encode_char_symbol_shortcut(c)?);
// 별표 뒤의 공백은 단어 사이 공백으로 자동 처리됨
} else {
result.extend(symbol_shortcut::encode_char_symbol_shortcut(c)?);
}
Expand Down Expand Up @@ -611,6 +626,20 @@ impl Encoder {
}

result.push(0);
} else {
// word_shortcut을 사용한 경우가 아닐 때만 별표 확인
let word_chars = word.chars().collect::<Vec<char>>();
let word_len = word_chars.len();
// 제60항 별표(*)는 앞뒤를 한 칸씩 띄어 쓴다
// 별표가 마지막 단어의 마지막 글자이고, 다음 단어가 없을 때 뒤에 공백 추가
if remaining_words.is_empty() && word_len > 0 {
// 마지막 단어인 경우, 별표로 끝나는지 확인
if let Some(last_char) = word_chars.last() {
if *last_char == '*' {
result.push(0); // 별표 뒤에 공백 추가
}
}
}
}

// Update state for next iteration
Expand Down Expand Up @@ -642,6 +671,15 @@ pub fn encode(text: &str) -> Result<Vec<u8>, String> {
let mut result = Vec::new();
encoder.encode(text, &mut result)?;
encoder.finish(&mut result)?;

// 제60항 별표(*)는 앞뒤를 한 칸씩 띄어 쓴다
// 별표가 단독 단어로 포함된 텍스트의 마지막에 공백 추가
let words: Vec<&str> = text.split(' ').filter(|word| !word.is_empty()).collect();
let has_asterisk_as_word = words.iter().any(|w| *w == "*");
if has_asterisk_as_word {
result.push(0); // 별표가 단독 단어로 포함된 텍스트의 마지막에 공백 추가
}

Ok(result)
}

Expand Down Expand Up @@ -969,7 +1007,8 @@ mod test {
);
let record = result.expect(&error);
let input = &record[0];
let expected = record[2].replace(" ", "⠀");
// 테스트 케이스 파일의 숫자 코드에서 앞뒤 공백 제거 후 비교
let expected = record[2].trim().replace(" ", "⠀");
match encode(input) {
Ok(actual) => {
let braille_expected = actual
Expand Down
3 changes: 2 additions & 1 deletion libs/braillify/src/symbol_shortcut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ static SHORTCUT_MAP: phf::Map<char, &'static [u8]> = phf_map! {
// '×' => &[decode_unicode('⠸'),decode_unicode('⠭'), decode_unicode('⠇')],
'△' => &[decode_unicode('⠸'),decode_unicode('⠬'), decode_unicode('⠇')],
'□' => &[decode_unicode('⠸'),decode_unicode('⠶'), decode_unicode('⠇')],
'ː' => &[decode_unicode('⠰'), decode_unicode('⠂')],
'ː' => &[decode_unicode('⠠'), decode_unicode('⠄')],
'〃' => &[decode_unicode('⠴'), decode_unicode('⠴')],
};

static ENGLISH_SYMBOL_MAP: phf::Map<char, &'static [u8]> = phf_map! {
Expand Down
2 changes: 1 addition & 1 deletion test_cases/rule_60.csv
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* 야애: 들에 낀 안개,"""9`>-r""1`i!n`,@q`<3@r", 16200283623162010462903283103518823,⠐⠔⠀⠜⠤⠗⠐⠂⠀⠊⠮⠝⠀⠠⠈⠟⠀⠣⠒⠈⠗⠀
* 야애: 들에 낀 안개,"""9`>-r""1`i!n`,@q`<3@r",162002836231620104629032831035188230,⠐⠔⠀⠜⠤⠗⠐⠂⠀⠊⠮⠝⠀⠠⠈⠟⠀⠣⠒⠈⠗⠀
Loading