fix(styles): refuse a number format Hancom numbers in plain digits - #183
Conversation
Colours, border and column-line widths, the character width ratio and
border types were written as given. Hancom rejects none of them; it
reads them as something else.
- A colour was written as "#" plus whatever it was given, upper cased,
or as given. Hancom reads a colour attribute as one hexadecimal number,
so "#abc" showed as #000ABC (not CSS's #AABBCC), "red" as black and
"#12345" as #012345. hwpx.oxml.color gains rgb_color (six hexadecimal
digits, the "#" may be left out, either case, written as upper case
#RRGGBB) and normalize_color (the same, plus "none" and empty as
before). Every colour argument goes through them: styles.ensure_run
(color, highlight, underline_color, shadow), cell shading, border fills
and their gradient colours, memo shapes, shape lines and fills, column
separators and body_patch's restyle_text. Anything else raises
HwpxValueError (style-color-invalid).
- Hancom keeps a border or column-line width only when it is one of the
hc:LineWidth strings exactly ("0.1 mm" .. "5.0 mm") and draws anything
else, "1 mm" and "0.12mm" included, as 0.1 mm. hwpx.oxml.utils gains
LINE_WIDTHS and normalize_line_width ("1 mm", "1mm" and 1 are "1.0 mm");
border fills, paragraph borders and column separators use it, and a
width off the list raises HwpxValueError (style-line-width-invalid).
- Hancom keeps a character width ratio in one byte, so ensure_run's
ratio of 256 to 400 came out as ratio - 256 (300 was drawn at 44 %).
The ratio now goes up to 255.
- Hancom draws a border of a type it does not know as no border, and
THICK_3D, THICK_3D_REVERSE_LIGHTING, SLIM_3D and
SLIM_3D_REVERSE_LIGHTING are not its spellings. Border fills now write
them as Hancom's THICK3D, THICKREV3D, 3D and REV3D, and take those
spellings as well.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Number formats were written upper cased, whatever they were: list formats (apply_list_format's number_format, ensure_numbering's level format), note number formats (set_footnote_auto_num_format / set_endnote_auto_num_format type) and, past their short names, page number formats (set_page_number's format_type). Hancom does not reject a number format it does not know; it numbers in plain digits, so number_format="decimal" or "roman" came out as 1. 2. 3. hwpx.oxml.numbering_kinds gains NUMBER_FORMATS (hc:NumberType2: DIGIT, ROMAN_SMALL, ROMAN_CAPITAL, LATIN_SMALL, CIRCLED_DIGIT, HANGUL_SYLLABLE, DECAGON_CIRCLE, SYMBOL and the rest, 19 in all), NUMBER_FORMAT_ALIASES (the short names set_page_number already took - roman, roman_lower, alpha, alpha_lower, number, ... - plus hangul) and number_format(). Numbering definitions, note number formats and page numbers go through it; any other format raises HwpxValueError (style-number-format-invalid). A test that expected number_format="roman" to be written as "ROMAN" now expects ROMAN_CAPITAL. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
airmang
left a comment
There was a problem hiding this comment.
코드 리뷰: 머지 전에 고쳐야 할 문제가 있습니다.
검토한 커밋은 9bf6658입니다. main 0760ba9에는 충돌 없이 합쳐지고, #179·#182와 합쳐도 CHANGELOG만 충돌합니다.
거부되는 쪽 번호 모양을 받으면 꼬리말이 반쯤 바뀐 채 남습니다
oxml/section_story.py#L588 · #L622
set_page_number가 꼬리말을 다시 채우는 도중에 add_page_number_field의 번호 모양 검사가 값을 거부합니다. 그 전에 set_content()가 clear_content()로 hp:secPr 쪽 꼬리말을 이미 비워 두었습니다. 그래서 거부된 뒤에도 꼬리말은 바뀐 채로 남고, 한/글이 읽는 hp:ctrl 사본에는 옛 내용이 남습니다.
from hwpx.document import HwpxDocument
doc = HwpxDocument.new()
doc.page.set_footer(text="기존 꼬리말")
doc.page.set_page_number(format_type="decimal", prefix="- ")
# HwpxValueError: unsupported number format 'DECIMAL'- 이 PR:
get_footer().text는'- '이고, 저장한 XML의 ctrl 사본에는기존 꼬리말이 남습니다.
번호 모양 검사를 내용을 바꾸기 전에 끝내 주세요. #182의 set_content 색 검사도 같은 문제라서, 한 번에 고치면 좋겠습니다.
Generated by Claude Code
…e does Use the same alias table (_BORDER_LINE_TYPE_ALIASES) and the same calls as #151, which maps the earlier 3-D line names too, so the two changes do not conflict. Behaviour is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
보류 (PR 처리 담당 리뷰). #182를 포함하고, 자체 문제가 있습니다. 목록·개요 머리( |
set_content cleared a header or footer before the new runs' colours were checked, so a refused colour left the hp:secPr copy empty while the copy Hancom reads kept the old text. Colours are now checked before anything is cleared, and a value refused later on (a page number format, an unknown content type) puts the old content back. set_columns changed colCount, the type and the column line before checking the separator width and colour; they are now checked first, so a refused value leaves the columns as they were. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
set_page_number refills the footer through set_content, which (from fix/color-values) now puts the old content back when a value is refused; this pins it for the number format check. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
리뷰 고맙습니다. #182를 고친 커밋(
|
|
계속 보류 (PR 처리 담당 재리뷰,
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…st becomes the nearest Hancom writes hatch, border, line and shadow colours as #AARRGGBB, so a colour read from a document is taken and written back unchanged instead of refused. A border or column-line width that is not one of Hancom's widths is written as the nearest listed width (the thicker one when it lies halfway) instead of refused; only a value that is not a positive width in millimetres is refused. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…mbers NumberType2 List and outline heads and page numbers take the fifteen hc:NumberType1 formats; footnote and endnote numbers take the nineteen hc:NumberType2 formats, which add DECAGON_CIRCLE, DECAGON_CIRCLE_HANJA, SYMBOL and USER_CHAR (NOTE_NUMBER_FORMATS). A note-only format given for a list or a page number is refused and the message says it is for notes only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tests/fixtures/hancom_saved/border_3d.hwpx is a table Hancom made and saved (author, version and dates removed) with its four 3D cell borders. The names this library writes for the old 3D spellings are the ones in that file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
근거 파일 출처 확인 요청 (PR 처리 담당). 한/글이 저장한 파일을 넣어 주셔서 고맙습니다. 머지 전에 이 파일들을 저장한 프로그램을 확인하고 싶습니다. 저장소의 다른 한/글 산출물과 모양이 달라서입니다.
줄 배치 캐시와
출처가 한/글(또는 한컴의 다른 프로그램)로 확인되면, 이 파일을 근거로 리뷰를 이어 가겠습니다. |
|
보류 사유를 고쳤습니다(
|
|
리뷰 통과 (PR 처리 담당). 한/글이 저장한 파일을 근거로 받습니다.
main에 #165·#172·#182·#183·#184를 함께 얹은 상태에서 core 4,047개가 통과했습니다. python-hwpx-automation은 #165에 기대는 테스트 둘을 python-hwpx-automation#123으로 옛·새 동작 모두에서 통과하게 고쳤습니다. 머지 순서는 #184 → #182 → #183 → #172 → #165입니다. |
# Conflicts: # docs/error-codes.md # src/hwpx/errors.py # src/hwpx/oxml/section_format.py
|
다시 열었습니다 (PR 처리 담당). #182를 머지하면서 제 머지 스크립트가 이 PR의 기준 브랜치( |
요약
번호 형식을 대문자로만 바꿔 쓰던 것을 고칩니다.
styles.apply_list_format의number_format,styles.ensure_numbering레벨의format), 각주·미주(구역 설정의set_footnote_auto_num_format·set_endnote_auto_num_format의type), 쪽 번호(page.set_page_number의format_type, 짧은 이름 밖의 값)가 받은 값을 대문자로만 바꿔 씁니다.number_format="decimal"(DECIMAL),"roman"(ROMAN),"upper-alpha"가 모두1. 2. 3.이 되었습니다.hc:NumberType2의 19개입니다(DIGIT,ROMAN_SMALL→i. ii.,ROMAN_CAPITAL,LATIN_SMALL,CIRCLED_DIGIT,HANGUL_SYLLABLE→가. 나.,DECAGON_CIRCLE→갑. 을.,SYMBOL등).set_page_number가 먼저 받던 짧은 이름(roman→ROMAN_CAPITAL,roman_lower→ROMAN_SMALL,alpha→LATIN_CAPITAL,alpha_lower→LATIN_SMALL,number→DIGIT등)에hangul→HANGUL_SYLLABLE을 더해 받습니다. 그 밖의 값은HwpxValueError(style-number-format-invalid)입니다.변경
src/hwpx/oxml/numbering_kinds.py:NUMBER_FORMATS(19개),NUMBER_FORMAT_ALIASES,number_format(). 번호·개요 번호 정의를 만들기 전에 각 레벨의 형식을 한/글 표기로 바꿔 둡니다.src/hwpx/oxml/section_format.py: 각주·미주 번호 형식도number_format()을 거칩니다.src/hwpx/oxml/section_story.py: 쪽 번호의 별칭 표를number_format()으로 옮겼습니다(page·page/total은 그대로 숫자).src/hwpx/errors.py: 새 코드style-number-format-invalid.docs/error-codes.md를 다시 만들었습니다.tests/test_number_formats.py: 새 테스트 17개.ensure_numbering의 번호·개요 레벨 검사, 각주 번호 형식 검사·기록, 쪽 번호 형식 검사.tests/test_existing_document_format_editing.py:number_format="roman"이ROMAN으로 쓰인다고 기대하던 테스트를ROMAN_CAPITAL로 고쳤습니다.CHANGELOG.md: 고침 항목 1개검증
scripts/check_typing_generics_scope.py,scripts/error_code_census.py --check,scripts/check_public_hygiene.py통과.🤖 Generated with Claude Code