Question: unexpected Heading title type #6

Open
opened 2024-08-02 16:13:58 +00:00 by lyz · 2 comments
Collaborator

I see that the title attribute of Heading has a type Text instead a string.

Is there any reason behind this? It's preventing me from doing:

if "test 1" in org_file.headlines[0].title
  ...

With the next error Operator "in" not supported for types "Literal['test 1']" and "Text".

Would it be possible to change the line to:

self.title = parse_content_block([RawLine(linenum=start_line, line=title)]).get_text()
I see that the `title` attribute of `Heading` [has a type `Text`](https://code.codigoparallevar.com/kenkeiras/org-rw/src/branch/develop/org_rw/org_rw.py#L327) instead a string. Is there any reason behind this? It's preventing me from doing: ```python if "test 1" in org_file.headlines[0].title ... ``` With the next error `Operator "in" not supported for types "Literal['test 1']" and "Text"`. Would it be possible to change the line to: ```python self.title = parse_content_block([RawLine(linenum=start_line, line=title)]).get_text() ```
Author
Collaborator

if it breaks stuff I can use org_file.headlines[0].title.get_text() but is the ergonomics of the class I expected

if it breaks stuff I can use `org_file.headlines[0].title.get_text()` but is the ergonomics of the class I expected
Owner

Let me implement the in operator for the Text class (though I'm not sure how to handle some parts, but I'll try to work it out).

It's not returning a string because it can contain Links or other kinds of markup that can be useful to handle.

Let me implement the `in` operator for the Text class (though I'm not sure how to handle some parts, but I'll try to work it out). It's not returning a string because it can contain Links or other kinds of markup that can be useful to handle.
kenkeiras self-assigned this 2024-08-22 18:33:30 +00:00
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: kenkeiras/org-rw#6
No description provided.