INNER CODE UNIT · Python
add_code_block
sangrokjung/claude-forge · scripts/md-to-docx/convert.py:335
def add_code_block(doc: Document, code: str, language: str = ''):
"""코드 블록 - 둥근 느낌의 회색 배경"""
table = doc.add_table(rows=1, cols=1)
table.alignment = WD_TABLE_ALIGNMENT.CENTER
cell = table.cell(0, 0)
set_cell_shading(cell, CODE_BG)
set_cell_margins(cell, top=80, bottom=80, left=160, right=120)
set_cell_borders(
cell,
top=(4, BORDER_COLOR, 'single'),
bottom=(4, BORDER_COLOR, 'single'),
left=(4, BORDER_COLOR, 'single'),
right=(4, BORDER_COLOR, 'single'),
)
p = cell.paragraphs[0]
p.paragraph_format.space_before = Pt(0)