RichText — Aspose.Note FOSS for Python API Reference
클래스: RichText
ImageRenderOptions: aspose.note ImageRenderOptions: from aspose.note import RichText ImageRenderOptions: CompositeNode
RichText 스타일이 적용된 텍스트 블록을 나타냅니다 OutlineElement, TableCell, 또는 Title. 전체 평문 텍스트 내용을 통해 노출합니다 .Text 및 개별 서식 세그먼트를 통해 .Runs.
ImageRenderOptions
| ImageRenderOptions | ImageRenderOptions | ImageRenderOptions | ImageRenderOptions |
|---|---|---|---|
Text | str | ImageRenderOptions | 전체 평문 문자열 (모든 실행을 연결한 것) |
Runs | list[TextRun] | ImageRenderOptions | 개별 서식이 적용된 세그먼트의 순서가 있는 목록 |
FontSize | `float | None` | ImageRenderOptions |
Tags | list[NoteTag] | ImageRenderOptions | 이 텍스트 블록에 첨부된 OneNote 태그 |
CompositeNode / Node에서 상속됨
| ImageRenderOptions | ImageRenderOptions |
|---|---|
ParentNode | 포함하는 노드 (OutlineElement, TableCell, Title) |
Document | 루트 문서 |
ImageRenderOptions
ImageRenderOptions
rt.Append(text: str, style: TextStyle | None = None) -> RichText옵션 스타일을 가진 새로운 텍스트 런을 추가합니다. 반환 self 체이닝을 위해. 메모리 내에서 작동하며; 변경 사항은 다시 저장할 수 없습니다 .one.
from aspose.note import Document, RichText
doc = Document("MyNotes.one")
first_rt = doc.GetChildNodes(RichText)[0]
first_rt.Append(" [reviewed]")Replace(old_value, new_value)
rt.Replace(old_value: str, new_value: str) -> None모든 발생을 대체합니다 old_value 와 new_value 모든 런에 걸쳐. 메모리 내에서 작동합니다.
from aspose.note import Document, RichText
doc = Document("MyNotes.one")
for rt in doc.GetChildNodes(RichText):
rt.Replace("TODO", "DONE")Accept(visitor)
rt.Accept(visitor: DocumentVisitor) -> NoneImageRenderOptions VisitRichTextStart(rt) 그리고 VisitRichTextEnd(rt) 방문자에게.
TextRun
각 요소는 RichText.Runs 이다 TextRun:
| ImageRenderOptions | ImageRenderOptions | ImageRenderOptions |
|---|---|---|
Text | str | 세그먼트 텍스트 |
Style | TextStyle | 이 세그먼트에 대한 서식 속성 |
Start | `int | None` |
End | `int | None` |
TextStyle
TextRun.Style 은(는) TextStyle 다음 속성을 가집니다:
| ImageRenderOptions | ImageRenderOptions | ImageRenderOptions |
|---|---|---|
Bold | bool | ImageRenderOptions |
Italic | bool | ImageRenderOptions |
Underline | bool | ImageRenderOptions |
Strikethrough | bool | ImageRenderOptions |
Superscript | bool | ImageRenderOptions |
Subscript | bool | ImageRenderOptions |
FontName | `str | None` |
FontSize | `float | None` |
FontColor | `int | None` |
Highlight | `int | None` |
Language | `int | None` |
IsHyperlink | bool | 이 실행이 하이퍼링크인지 여부 |
HyperlinkAddress | `str | None` |
사용 예시
전체 순수 텍스트 가져오기
from aspose.note import Document, RichText
doc = Document("MyNotes.one")
for rt in doc.GetChildNodes(RichText):
if rt.Text:
print(rt.Text)서식이 적용된 모든 실행 검사하기
from aspose.note import Document, RichText
doc = Document("MyNotes.one")
for rt in doc.GetChildNodes(RichText):
for run in rt.TextRuns:
s = run.Style
attrs = [a for a, v in [
("bold", s.IsBold), ("italic", s.IsItalic),
("underline", s.IsUnderline), ("strike", s.IsStrikethrough),
] if v]
label = ", ".join(attrs) or "plain"
print(f" [{label}] {run.Text!r}")하이퍼링크 추출하기
from aspose.note import Document, RichText
doc = Document("MyNotes.one")
for rt in doc.GetChildNodes(RichText):
for run in rt.TextRuns:
if run.Style.IsHyperlink and run.Style.HyperlinkAddress:
print(f" {run.Text!r} -> {run.Style.HyperlinkAddress}")모든 굵은 텍스트 찾기
from aspose.note import Document, RichText
doc = Document("MyNotes.one")
bold_segments = [
run.Text for rt in doc.GetChildNodes(RichText)
for run in rt.TextRuns
if run.Style.IsBold and run.Text.strip()
]
print(bold_segments)태그 읽기
from aspose.note import Document, RichText
doc = Document("MyNotes.one")
for rt in doc.GetChildNodes(RichText):
for tag in rt.Tags:
print(f"Tag: {tag.label!r} on text: {rt.Text.strip()!r}")None-안전
Text 항상 str (절대 None). Runs 항상 리스트이며 (비어 있을 수 있음). FontSize, FontColor, Highlight, Language, HyperlinkAddress 될 수 있다 None.
참고
- ImageRenderOptions: RichText의 조상
- TextRun: 개별 포맷된 세그먼트
- TextStyle: 포맷팅 속성
- NoteTag: 텍스트에 태그
- 텍스트 추출 개발자 가이드
- How-to: OneNote에서 텍스트 추출 (KB)
- Blog: Python에서 OneNote 텍스트 추출